summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-09-01 17:12:28 +0100
committeraditya puthuparambil <aditya.puthuparambil@bell.ca>2021-09-06 14:06:16 +0000
commitd0422226b45f752086c9920bdead753c644d9289 (patch)
tree219118e284927589ad69dc4ded6d520e76e77530 /cps-service/src/main/java/org
parentc27465347d10b573e7a211c0b11b7c8a6fd792c0 (diff)
P1 - Get module name and revision persistence layer
Rename ModuleReference to ExtendedModuleReference Create new ModuleReference class (moduleName and revision) Update existing sync model flow to use new module reference class Create native query to get module name and revision Issue-ID: CPS-485 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: I0d0da7742ceef3a68e83a5dd4852091e6adf138b
Diffstat (limited to 'cps-service/src/main/java/org')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java8
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java11
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java22
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java42
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java10
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java8
9 files changed, 81 insertions, 28 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 5c40331d74..218a236f1b 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
@@ -21,6 +21,7 @@
package org.onap.cps.api;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -51,12 +52,12 @@ public interface CpsModuleService {
* @param dataspaceName Dataspace name
* @param schemaSetName schema set name
* @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content
- * @param existingModuleReferences List of YANG resources module references of the modules
+ * @param moduleReferences List of YANG resources module references of the modules
* needed for this handle that are already in CPS
*/
void createSchemaSetFromModules(@NonNull String dataspaceName, @NonNull String schemaSetName,
@NonNull Map<String, String> newYangResourcesModuleNameToContentMap,
- @NonNull List<ModuleReference> existingModuleReferences);
+ @NonNull List<ModuleReference> moduleReferences);
/**
* Read schema set in the given dataspace.
@@ -82,7 +83,8 @@ public interface CpsModuleService {
/**
* Retrieve all modules and revisions known by CPS for all Yang Resources.
*
+ * @param dataspaceName dataspace name
* @return a list of ModuleReference objects
*/
- List<ModuleReference> getAllYangResourcesModuleReferences();
+ Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName);
}
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 0597d380a5..17ad78cbe8 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
@@ -21,6 +21,7 @@
package org.onap.cps.api.impl;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.onap.cps.api.CpsModuleService;
@@ -53,9 +54,9 @@ public class CpsModuleServiceImpl implements CpsModuleService {
@Override
public void createSchemaSetFromModules(final String dataspaceName, final String schemaSetName,
final Map<String, String> newYangResourcesModuleNameToContentMap,
- final List<ModuleReference> existingModuleReferences) {
+ final List<ModuleReference> moduleReferences) {
cpsModulePersistenceService.storeSchemaSetFromModules(dataspaceName, schemaSetName,
- newYangResourcesModuleNameToContentMap, existingModuleReferences);
+ newYangResourcesModuleNameToContentMap, moduleReferences);
}
@@ -64,7 +65,7 @@ public class CpsModuleServiceImpl implements CpsModuleService {
final var yangTextSchemaSourceSet = yangTextSchemaSourceSetCache
.get(dataspaceName, schemaSetName);
return SchemaSet.builder().name(schemaSetName).dataspaceName(dataspaceName)
- .moduleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
+ .extendedModuleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
}
@Override
@@ -74,8 +75,8 @@ public class CpsModuleServiceImpl implements CpsModuleService {
}
@Override
- public List<ModuleReference> getAllYangResourcesModuleReferences() {
- return cpsModulePersistenceService.getAllYangResourcesModuleReferences();
+ public Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName) {
+ return cpsModulePersistenceService.getAllYangResourceModuleReferences(dataspaceName);
}
}
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 7ad109d815..4f46c0dacb 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
@@ -21,6 +21,7 @@
package org.onap.cps.spi;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -48,11 +49,11 @@ public interface CpsModulePersistenceService {
* @param dataspaceName Dataspace name
* @param schemaSetName Schema set name
* @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content
- * @param moduleReferenceList List of YANG resources module references
+ * @param moduleReferences List of YANG resources module references
*/
void storeSchemaSetFromModules(@NonNull String dataspaceName, @NonNull String schemaSetName,
@NonNull Map<String, String> newYangResourcesModuleNameToContentMap,
- @NonNull List<ModuleReference> moduleReferenceList);
+ @NonNull List<ModuleReference> moduleReferences);
/**
* Deletes Schema Set.
@@ -89,9 +90,20 @@ public interface CpsModulePersistenceService {
@NonNull String anchorName);
/**
- * Returns all YANG resources module references.
+ * Returns all YANG resources module references for the given dataspace name.
*
- * @return List of all YANG resources module information in the database
+ * @param dataspaceName dataspace name
+ * @return Collection of all YANG resources module information in the database
+ */
+ Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName);
+
+ /**
+ * Get all YANG resource module references for the given anchor name and dataspace name.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @return a collection of module names and revisions
*/
- List<ModuleReference> getAllYangResourcesModuleReferences();
+ Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName,
+ final String anchorName);
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
index 5773bc45c9..8e9dff873a 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
@@ -38,7 +38,7 @@ public class DataNode {
private String dataspace;
private String schemaSetName;
private String anchorName;
- private ModuleReference moduleReference;
+ private ExtendedModuleReference extendedModuleReference;
private String xpath;
private Map<String, Object> leaves = Collections.emptyMap();
private Collection<String> xpathsChildren;
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java b/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java
new file mode 100644
index 0000000000..5e9c8d0cd7
--- /dev/null
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright 2020-2021 Pantheon.tech
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.spi.model;
+
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class ExtendedModuleReference implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String namespace;
+ private String revision;
+
+}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
index f9aa2b5904..9b73f8ff0f 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
@@ -1,7 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * Modifications Copyright 2020-2021 Pantheon.tech
+ * Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,10 +32,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class ModuleReference implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String name;
- private String namespace;
+ private static final long serialVersionUID = -1761408847591042599L;
+ private String moduleName;
private String revision;
-
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
index caf7800d9b..4df7893e2c 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
@@ -35,5 +35,5 @@ public class SchemaSet implements Serializable {
private static final long serialVersionUID = 1464791260718603291L;
private String name;
private String dataspaceName;
- private List<ModuleReference> moduleReferences;
+ private List<ExtendedModuleReference> extendedModuleReferences;
}
diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
index 32ee324c54..2c9d374b14 100644
--- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
+++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
@@ -21,7 +21,7 @@ package org.onap.cps.yang;
import java.util.List;
import org.checkerframework.checker.nullness.qual.NonNull;
-import org.onap.cps.spi.model.ModuleReference;
+import org.onap.cps.spi.model.ExtendedModuleReference;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
@@ -35,7 +35,7 @@ public interface YangTextSchemaSourceSet {
* @return list of ModuleRef
*/
@NonNull
- List<ModuleReference> getModuleReferences();
+ List<ExtendedModuleReference> getModuleReferences();
/**
* Return SchemaContext for given YangSchema.
diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
index 3a65369dc7..5cbfd6222d 100644
--- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
import lombok.NoArgsConstructor;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.ModelValidationException;
-import org.onap.cps.spi.model.ModuleReference;
+import org.onap.cps.spi.model.ExtendedModuleReference;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -88,14 +88,14 @@ public final class YangTextSchemaSourceSetBuilder {
}
@Override
- public List<ModuleReference> getModuleReferences() {
+ public List<ExtendedModuleReference> getModuleReferences() {
return schemaContext.getModules().stream()
.map(YangTextSchemaSourceSetImpl::toModuleReference)
.collect(Collectors.toList());
}
- private static ModuleReference toModuleReference(final Module module) {
- return ModuleReference.builder()
+ private static ExtendedModuleReference toModuleReference(final Module module) {
+ return ExtendedModuleReference.builder()
.name(module.getName())
.namespace(module.getQNameModule().getNamespace().toString())
.revision(module.getRevision().map(Revision::toString).orElse(null))