Versions Compared

Key

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

...

A dataspace must be defined

CPS service provides a method to create a dataspace

  • createDataspace method in the CpsAdminService

This method takes one parameter, dataspaceName. The value for this parameter is going to be based on the cm handle id received from NCMP.A dataspace is already defined as part of CPS-352, the dataspace we are using is NCMP-Admin

A schemaset must be created in the defined dataspace

...

  • schemasetName : The value for this parameter is going to be based on the cm handle id received from id provided from NCMP
  • dataspaceName : The value for this parameter is going to be based on the cm handle id received from NCMP NCMP-Admin
  • yangResourcesNameToContentMap : The value for this parameter will be discussed in more details below.

...

From NCMP we have a map of new yang resources and also a list of ModuleReference objects needed to create a full schema set.

...

Note: This list is a list of ModuleReferences for the yang resources that are already stored in the yang_resources table in the DB that the node requires.

Approach 1

We now have to retrieve yang resources using the list of ModuleReferences. To do this the following needs to happen.

...

Code Block
languagejava
themeMidnight
titleYangResourcesMap
// We have the list of yang resources retrieved from the db, exisitingYangResources
exisitingYangResourcesexisitingYangResourcesForTheGivenCmHandle
allYangResourcesModuleNameToContentMap = exisitingYangResourcesForTheGivenCmHandle.forEach(yangResource -> newYangResourcesModuleNameToContentMap.put(yangResource.getModuleName(), yangResource.getContent()));

Now the allYangResourcesModuleNameToContentMap Map is a complete map that contains the new and existing resources for the cm handle and can now be passed as a parameter to the createSchemaSet method in the CpsModuleService.

The method will now create a new schema set and we can now use this to create the anchor.

Approach 2

In this approach, instead of retrieving the yang resource we will do something different.

We will call the createSchemaSet method and pass the newYangResourcesModuleNameToContentMap  and create the schema set. We will then update the schema_set_yang_resources table. To do this, the following needs to happen.

  1.  Create a new method in the YangResourceRepository interface to retrieve the ids of the yang resources using the moduleName and revision got from the list of ModuleReferences.
  2. Then we will need to create a new repository, SchemaSetYangResourcesRepository, this interface will have one method, insertSchemaSetIdYangResourceId(Integer SchemaId, List<Long> yangResourceIds)
  3. This method will then be used to create a relation between the schemaSetId and the YangResourceId

Now we can create the anchor.

Create an Anchor using the schemaset created above

CPS service provides a method to create an anchor.

  • createAnchor method in the CpsAdminService

This method takes three parameters:

  • dataspaceName : NCMP-Admin
  • schemasetName 
  • anchorName

The value for schemasetName and anchorName is going to be based on the cm handle id provided from NCMP. 

Decisions