Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
// before
void replaceDataNodeTree(@NonNull String dataspaceName, @NonNull String anchorName, @NonNull DataNode dataNode);	

// after, alternative 1
void replaceDataNodeTree(@NonNull String dataspaceName, @NonNull String anchorName, @NonNull DataNode ... dataNode dataNodes);

// after, alternative 2
void replaceListDataNode(@NonNull String dataspaceName, @NonNull String anchorName, @NonNull Colection<DataNode> dataNodes);

Alt. 1. cons: despite usage of same methods the actual logic for processing single node significantly differs from the one 
which is required to process multiple data nodes, as result 

...

/dataspaces/{dataspaceName}/anchor/{anchorName}/list-node


Implementation Proposal

Create list-

...

node with one or more

...

elements

Implement the functionality to support multiple nodes addition using data fragment with list-node as a root element.

...

  • find parent node by parent node xpath (throw not found exception if absent)
  • add all provided elements to parent node
  • persist (throw already exists exception on unique constraint violation)

Jira
serverONAP JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-360

Delete list-node content (all existing elements)

...

  • uri:
    • (CPS) DELETE /dataspaces/{dataspaceName}/anchor/{anchorName}/list-node
    •  (NCMP) DELETE /cm-handle/{cmHandle}/list-node
  • parameters:
    • xpath - list node xpath (same as list-node element but with no key attribute definition)
      i.e. /root/parent/list-node
  • response 204 on success

Service layer

  • validate xpath referenced list-node element (?)

Persistence layer

...

REST layer (DataRestController.java)

  • Implement the method deleteListNodeElements(final String dataspaceName, final String anchorName, final String listNodeXpath)
  • Call cpsDataService.deleteListNodeData()
  • return 200

REST layer (cpsData.yml)

  • Add patch

REST layer (DataRestControllerSpec.groovy)

  • Ensure appropriate REST responses on invocation 

Service layer (CpsDataService.java)

  • Create new abstract method deleteNodeTree() 

Service layer (CpsDataServiceImpl.java)

  • Override abstract method deleteNodeTree()
  • Validate the xpath of the list-nodes String
  • call cpsDataPersistenceService.deleteListDataNodes()
  • notificationService.processDataUpdatedEvent(dataspaceName, anchorName)

Service layer (CpsDataServiceImplSpec.groovy)

  • delete list-node data fragment under existing node
  • delete list-node data fragment under non existing node

Persistence layer (CpsDataPersistenceService.java)

  • Create new abstract method deleteListDataNodes()

Persistence layer (CpsDataPersistenceServiceImpl.java)

  • Override abstract method deleteListDataNodes()
  • Use method getFragmentByXpath() to get the parentEntity of the List-Node
  • Use parentEntity and a method parameter String listNodeXpath as arguments for method removeListNodeDescendants()

Persistence layer (CpsDataPersistenceServiceSpec.groovy)

  • Delete list node content successfully
  • Error thrown when listNodeXpath does not exist

Jira
serverONAP JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-361

Replace list-node content

...

  • extract list-node xpath identifier from data nodes provided
  • find parent node by parent node xpath (throw not found exception if absent)
  • remove all children matching (starting with) list-node xpath identifier
  • add all provided elements to parent node
  • persist

Jira
serverONAP JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-362







Proposal