X-Git-Url: https://gerrit.onap.org/r/gitweb?p=cps.git;a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2FNetworkCmProxyDataServiceImpl.java;h=e624953f54d7192eb83b490232b34f4e7d1cfe98;hp=f498e5d4fbbee95f7374b85c834026937d964674;hb=006c7dca01d6d04ce122eadc06707a5b0b70d76c;hpb=3a13b2e965569304822fe4d56838a4fee4e7ad44 diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index f498e5d4f..e624953f5 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -34,7 +34,6 @@ import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED; import com.google.common.base.Strings; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -48,10 +47,10 @@ import org.onap.cps.api.CpsModuleService; import org.onap.cps.ncmp.api.NetworkCmProxyDataService; import org.onap.cps.ncmp.api.impl.exception.HttpClientRequestException; import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations; -import org.onap.cps.ncmp.api.impl.operations.DmiModelOperations; import org.onap.cps.ncmp.api.impl.operations.DmiOperations; import org.onap.cps.ncmp.api.impl.operations.YangModelCmHandleRetriever; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; +import org.onap.cps.ncmp.api.inventory.sync.ModuleSyncService; import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters; import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse; import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError; @@ -79,8 +78,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private final DmiDataOperations dmiDataOperations; - private final DmiModelOperations dmiModelOperations; - private final CpsModuleService cpsModuleService; private final CpsAdminService cpsAdminService; @@ -89,6 +86,8 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private final YangModelCmHandleRetriever yangModelCmHandleRetriever; + private final ModuleSyncService moduleSyncService; + @Override public DmiPluginRegistrationResponse updateDmiRegistrationAndSyncModule( final DmiPluginRegistration dmiPluginRegistration) { @@ -223,8 +222,10 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } protected void syncModulesAndCreateAnchor(final YangModelCmHandle yangModelCmHandle) { - syncAndCreateSchemaSet(yangModelCmHandle); - createAnchor(yangModelCmHandle); + final String schemaSetName = moduleSyncService.syncAndCreateSchemaSet(yangModelCmHandle); + final String anchorName = yangModelCmHandle.getId(); + cpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, schemaSetName, + anchorName); } protected List parseAndRemoveCmHandlesInDmiRegistration( @@ -267,35 +268,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } } - private void syncAndCreateSchemaSet(final YangModelCmHandle yangModelCmHandle) { - final Collection moduleReferencesFromCmHandle = - dmiModelOperations.getModuleReferences(yangModelCmHandle); - - final Collection identifiedNewModuleReferencesFromCmHandle = cpsModuleService - .identifyNewModuleReferences(moduleReferencesFromCmHandle); - - final Collection existingModuleReferencesFromCmHandle = - moduleReferencesFromCmHandle.stream().filter(moduleReferenceFromCmHandle -> - !identifiedNewModuleReferencesFromCmHandle.contains(moduleReferenceFromCmHandle) - ).collect(Collectors.toList()); - - final Map newModuleNameToContentMap; - if (identifiedNewModuleReferencesFromCmHandle.isEmpty()) { - newModuleNameToContentMap = new HashMap<>(); - } else { - newModuleNameToContentMap = dmiModelOperations.getNewYangResourcesFromDmi(yangModelCmHandle, - identifiedNewModuleReferencesFromCmHandle); - } - cpsModuleService - .createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, yangModelCmHandle.getId(), - newModuleNameToContentMap, existingModuleReferencesFromCmHandle); - } - - private void createAnchor(final YangModelCmHandle yangModelCmHandle) { - cpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, yangModelCmHandle.getId(), - yangModelCmHandle.getId()); - } - private Object getResourceDataResponse(final String cmHandleId, final String resourceIdentifier, final DmiOperations.DataStoreEnum dataStore,