summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main
diff options
context:
space:
mode:
authorsourabh_sourabh <sourabh.sourabh@est.tech>2022-12-15 17:16:04 +0000
committersourabh_sourabh <sourabh.sourabh@est.tech>2022-12-16 11:52:26 +0000
commitfd226778aec35a6ca28b1788aa9150863cb4f63c (patch)
tree9b62cbf8c6dd1cde4b72d1f5d551ad9e29ecd410 /cps-ncmp-service/src/main
parenteb56f6192d3cccaad1f43df1a4898a3d9d1e8819 (diff)
Use public exposed interface of CPS service instead of spi
- Used public interface of cps service to get data node or anchor names. Issue-ID: CPS-1427 Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech> Change-Id: I2a891dd5f8955977295f32005e49543886eac88c Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java14
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java19
3 files changed, 12 insertions, 33 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java
index a8fc6d7057..b67ae0c19e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java
@@ -49,7 +49,6 @@ import org.onap.cps.ncmp.api.inventory.enums.PropertyType;
import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.spi.exceptions.DataValidationException;
-import org.onap.cps.spi.model.Anchor;
import org.onap.cps.spi.model.ConditionProperties;
import org.onap.cps.spi.model.DataNode;
import org.springframework.stereotype.Service;
@@ -105,7 +104,8 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
if (moduleNamesForQuery.isEmpty()) {
return combinedQueryResult.keySet();
}
- final Set<String> moduleNameQueryResult = getNamesOfAnchorsWithGivenModules(moduleNamesForQuery);
+ final Set<String> moduleNameQueryResult =
+ new HashSet<>(inventoryPersistence.getCmHandleIdsWithGivenModules(moduleNamesForQuery));
if (combinedQueryResult == NO_QUERY_TO_EXECUTE) {
return moduleNameQueryResult;
@@ -209,7 +209,8 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
if (moduleNamesForQuery.isEmpty()) {
return previousQueryResult;
}
- final Collection<String> cmHandleIdsByModuleName = getNamesOfAnchorsWithGivenModules(moduleNamesForQuery);
+ final Collection<String> cmHandleIdsByModuleName =
+ inventoryPersistence.getCmHandleIdsWithGivenModules(moduleNamesForQuery);
if (cmHandleIdsByModuleName.isEmpty()) {
return Collections.emptyMap();
}
@@ -260,11 +261,6 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
return cmHandleQueries.combineCmHandleQueries(cpsPathQueryResult, propertiesQueryResult);
}
- private Set<String> getNamesOfAnchorsWithGivenModules(final Collection<String> moduleNamesForQuery) {
- final Collection<Anchor> anchors = inventoryPersistence.queryAnchors(moduleNamesForQuery);
- return anchors.parallelStream().map(Anchor::getName).collect(Collectors.toSet());
- }
-
private Collection<String> getModuleNamesForQuery(final List<ConditionProperties> conditionProperties) {
final List<String> result = new ArrayList<>();
getConditions(conditionProperties, CmHandleQueryConditions.HAS_ALL_MODULES.getConditionName())
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java
index b29825e7c0..6d006d9e2a 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.Map;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.spi.FetchDescendantsOption;
-import org.onap.cps.spi.model.Anchor;
import org.onap.cps.spi.model.DataNode;
import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.spi.model.ModuleReference;
@@ -132,19 +131,12 @@ public interface InventoryPersistence {
DataNode getCmHandleDataNode(String cmHandleId);
/**
- * Query anchors via module names.
+ * get CM handles that has given module names.
*
* @param moduleNamesForQuery module names
- * @return Collection of anchors
+ * @return Collection of CM handle Ids
*/
- Collection<Anchor> queryAnchors(Collection<String> moduleNamesForQuery);
-
- /**
- * Method to get all anchors.
- *
- * @return Collection of anchors
- */
- Collection<Anchor> getAnchors();
+ Collection<String> getCmHandleIdsWithGivenModules(Collection<String> moduleNamesForQuery);
/**
* Replaces list content by removing all existing elements and inserting the given new elements as data nodes.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java
index adba198408..5b0b5eafde 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImpl.java
@@ -34,15 +34,13 @@ import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
-import org.onap.cps.spi.CpsAdminPersistenceService;
-import org.onap.cps.spi.CpsDataPersistenceService;
import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.exceptions.SchemaSetNotFoundException;
-import org.onap.cps.spi.model.Anchor;
import org.onap.cps.spi.model.DataNode;
import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.spi.model.ModuleReference;
@@ -69,9 +67,7 @@ public class InventoryPersistenceImpl implements InventoryPersistence {
private final CpsModuleService cpsModuleService;
- private final CpsDataPersistenceService cpsDataPersistenceService;
-
- private final CpsAdminPersistenceService cpsAdminPersistenceService;
+ private final CpsAdminService cpsAdminService;
private final CpsValidator cpsValidator;
@@ -161,7 +157,7 @@ public class InventoryPersistenceImpl implements InventoryPersistence {
@Override
public DataNode getDataNode(final String xpath, final FetchDescendantsOption fetchDescendantsOption) {
- return cpsDataPersistenceService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
+ return cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
xpath, fetchDescendantsOption);
}
@@ -171,13 +167,8 @@ public class InventoryPersistenceImpl implements InventoryPersistence {
}
@Override
- public Collection<Anchor> queryAnchors(final Collection<String> moduleNamesForQuery) {
- return cpsAdminPersistenceService.queryAnchors(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
- }
-
- @Override
- public Collection<Anchor> getAnchors() {
- return cpsAdminPersistenceService.getAnchors(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME);
+ public Collection<String> getCmHandleIdsWithGivenModules(final Collection<String> moduleNamesForQuery) {
+ return cpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
}
@Override