CPS-1016 Merge 2 'query' end points in NCMP



CPS-1016: Merge 2 'query' end points in NCMP Closed



Assumptions/Decisions


Issue

Notes/Jira

Decision

Issue

Notes/Jira

Decision

1

1

There are 2 separate query objects defined in OpenAPI



Combine them into one 'Conditions' has the better structure but 'cmHandleQueryRestParameters' is a better  name

2

Exact format of  'legacy' Conditions unclear and maybe not generic enough

Study demo: https://lf-onap.atlassian.net/wiki/download/attachments/16450241/CPS644.mkv?version=1&modificationDate=1636566033000&api=v2



3

Definition of 'Conditions' is not Generic enough

$ref: '#/components/schemas/ModuleNamesAsJsonArray

Should be something like '#/components/ConditionParametersNameValuePairs 



4

Agree backward incompatibility

Discuss with stakeholders





Implementation Proposal


Merge 2 'query' end points in one

Layer

Proposed Changes

Layer

Proposed Changes

1

REST Layer

  1. openapi.yaml

    1. change /v1/data/ch/searches to  /v1/ch/id-searches

  2. ncmp.yaml

    1. change queryCmHandles method to executeCmHandleIdSearch

    2. Use the CmHandleQueryRestParameters schema to both of them

  3. components.yaml

    1. merge Conditions schema to CmHandleQueryRestParameters schema

    2. delete Conditions schema

2

Controller Layer

  1. NetworkCmProxyController

    1. Update controller methods to use the new schema

    2. Both component method call separated service method

    3. Rename queryCmHandles method to executeCmHandleIdSearch

3

Service Layer

  1. NetworkCmProxyDataService

    1. Create new method for query cmHandles

    2. Keep queryCmHandles method and rename it to queryCmHandleIds

    3. Both method should be calling separate methods in CpsDataService

    4. Validation logic should be moved to an separated method and call it from both method

  2. CpsDataService

    1. Update queryCmHandles method return type to Set<CmHandles>

    2. Use separate methods to CmHandlesId search to just return a collection of CmHandleIds (extract from DataNode Objects) 

  3. CpsAdminPersistenceService

    1. Update queryCmHandles will always return complet DataNode object(s). No updates can be done

4

Persistence Layer

  1. ModuleReferenceQuery

    1. Update queryCmHandles method return type to Set<CmHandles>

    2. Update queryCmHandles method to handle both filtering parameters

    3. Create to separete method for CmHandlesId searches with new filtering parameters (use the original queryCmHandles method code)

New Rest Request Input Format

Assumed Current Request Format:
See Issue #3, it need to be confirmed

{ "conditions": [ { "name": "hasAllModules", "conditionParameters": [ {"moduleName": "module1"} ,{ "moduleName": "module2" } } } ] }



Action 1: Rename query new top element name

After 'Merge' it should also support (public Properties conditions like so

{ "cmHandleQueryRestParameters": [ { "name": "hasAllModules", "conditionParameters": [ {"moduleName": "module1"} ,{ "moduleName": "module2" } ] } ] }



Action 2: Support (public' Properties condition using the same format

{ "cmHandleQueryRestParameters": [ { "name": "hasAllProperties", "conditionParameters": [ {"Colour": "Green"} ,{ "Size": "Small" } ] } ] }

Action 2:  Verify combinations of conditions are supported (AND is assumed)

Test

  • update existing tests to the new endpoint (groovy and CSIT)

  • create new tests for new filtering scenarios (combine the two existing filter) in CSIT tests



References