summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service/src/main/java/org')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java9
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java16
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java10
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/exceptions/SchemaSetNotFoundException.java1
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java14
5 files changed, 49 insertions, 1 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
index 6b17e820c..b1f90d686 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2022 Nordix Foundation
* Modifications Copyright (C) 2020-2021 Pantheon.tech
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,6 +67,14 @@ public interface CpsModuleService {
SchemaSet getSchemaSet(String dataspaceName, String schemaSetName);
/**
+ * Retrieve all schema sets in the given dataspace.
+ *
+ * @param dataspaceName dataspace name
+ * @return all SchemaSets
+ */
+ Collection<SchemaSet> getSchemaSets(String dataspaceName);
+
+ /**
* Deletes Schema Set.
*
* @param dataspaceName dataspace name
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
index b4890f4a7..a04dd2af5 100644
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2022 Nordix Foundation
* Modifications Copyright (C) 2020-2021 Pantheon.tech
* Modifications Copyright (C) 2022 Bell Canada
+ * Modifications Copyright (C) 2022 TechMahindra Ltd
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +36,7 @@ import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.spi.model.ModuleReference;
import org.onap.cps.spi.model.SchemaSet;
import org.onap.cps.spi.utils.CpsValidator;
+import org.onap.cps.yang.YangTextSchemaSourceSet;
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -78,6 +80,15 @@ public class CpsModuleServiceImpl implements CpsModuleService {
}
@Override
+ public Collection<SchemaSet> getSchemaSets(final String dataspaceName) {
+ cpsValidator.validateNameCharacters(dataspaceName);
+ final Collection<SchemaSet> schemaSets =
+ cpsModulePersistenceService.getSchemaSetsByDataspaceName(dataspaceName);
+ schemaSets.forEach(schemaSet -> setModuleReferences(schemaSet, dataspaceName));
+ return schemaSets;
+ }
+
+ @Override
@Transactional
public void deleteSchemaSet(final String dataspaceName, final String schemaSetName,
final CascadeDeleteAllowed cascadeDeleteAllowed) {
@@ -124,4 +135,9 @@ public class CpsModuleServiceImpl implements CpsModuleService {
return CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED == cascadeDeleteAllowed;
}
+ private void setModuleReferences(final SchemaSet schemaSet, final String dataspaceName) {
+ final YangTextSchemaSourceSet yangTextSchemaSourceSet = yangTextSchemaSourceSetCache
+ .get(dataspaceName, schemaSet.getName());
+ schemaSet.setModuleReferences(yangTextSchemaSourceSet.getModuleReferences());
+ }
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
index aaf6b38af..f5dc8ac3a 100755
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2022 Nordix Foundation
* Modifications Copyright (C) 2020-2022 Bell Canada.
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ import java.util.Collection;
import java.util.Map;
import org.onap.cps.spi.model.ModuleDefinition;
import org.onap.cps.spi.model.ModuleReference;
+import org.onap.cps.spi.model.SchemaSet;
/**
* Service to manage modules.
@@ -52,6 +54,14 @@ public interface CpsModulePersistenceService {
Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> allModuleReferences);
/**
+ * Get all schema sets for a given dataspace.
+ *
+ * @param dataspaceName dataspace name.
+ * @return List of schema sets
+ */
+ Collection<SchemaSet> getSchemaSetsByDataspaceName(String dataspaceName);
+
+ /**
* Deletes Schema Set.
*
* @param dataspaceName dataspace name
diff --git a/cps-service/src/main/java/org/onap/cps/spi/exceptions/SchemaSetNotFoundException.java b/cps-service/src/main/java/org/onap/cps/spi/exceptions/SchemaSetNotFoundException.java
index cf63f924f..218918fcb 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/exceptions/SchemaSetNotFoundException.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/exceptions/SchemaSetNotFoundException.java
@@ -38,4 +38,5 @@ public class SchemaSetNotFoundException extends CpsAdminException {
super("Schema Set not found.",
String.format("Schema Set with name %s was not found for dataspace %s.", schemaSetName, dataspaceName));
}
+
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
index db7ef3e22..1d8bac0dd 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
@@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
import org.onap.cps.spi.exceptions.DataValidationException;
import org.onap.cps.utils.YangUtils;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
@@ -174,7 +175,9 @@ public class DataNodeBuilder {
private static void addDataNodeFromNormalizedNode(final DataNode currentDataNode,
final NormalizedNode normalizedNode) {
- if (normalizedNode instanceof DataContainerNode) {
+ if (normalizedNode instanceof ChoiceNode) {
+ addChoiceNode(currentDataNode, (ChoiceNode) normalizedNode);
+ } else if (normalizedNode instanceof DataContainerNode) {
addYangContainer(currentDataNode, (DataContainerNode) normalizedNode);
} else if (normalizedNode instanceof MapNode) {
addDataNodeForEachListElement(currentDataNode, (MapNode) normalizedNode);
@@ -238,4 +241,13 @@ public class DataNodeBuilder {
return newChildDataNode;
}
+ private static void addChoiceNode(final DataNode currentDataNode, final ChoiceNode choiceNode) {
+
+ final Collection<DataContainerChild> normalizedChildNodes = choiceNode.body();
+ for (final NormalizedNode normalizedNode : normalizedChildNodes) {
+ addDataNodeFromNormalizedNode(currentDataNode, normalizedNode);
+ }
+ }
+
+
}