Merge "Update Model to allow Persisting of alternateId"
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / CpsModulePersistenceService.java
index 4306df7..aaca2ee 100755 (executable)
@@ -1,7 +1,8 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2020-2022 Nordix Foundation
+ *  Copyright (C) 2020-2023 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.
@@ -23,7 +24,9 @@ package org.onap.cps.spi;
 
 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.
@@ -40,15 +43,36 @@ public interface CpsModulePersistenceService {
     void storeSchemaSet(String dataspaceName, String schemaSetName, Map<String, String> yangResourcesNameToContentMap);
 
     /**
-     * Stores a schema set from new modules and existing modules.
+     * Stores a new schema set from new modules and existing modules.
      *
-     * @param dataspaceName                          Dataspace name
-     * @param schemaSetName                          Schema set name
+     * @param dataspaceName             Dataspace name
+     * @param schemaSetName             Schema set name
      * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
-     * @param moduleReferences                       List of YANG resources module references
+     * @param allModuleReferences       All YANG resources module references
      */
     void storeSchemaSetFromModules(String dataspaceName, String schemaSetName,
-        Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> moduleReferences);
+        Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> allModuleReferences);
+
+    /**
+     * Update an existing schema set from new modules and existing modules.
+     *
+     * @param dataspaceName             Dataspace name
+     * @param schemaSetName             Schema set name
+     * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
+     * @param allModuleReferences       All YANG resources module references
+     */
+    void updateSchemaSetFromModules(final String dataspaceName, final String schemaSetName,
+                                    final Map<String, String> newModuleNameToContentMap,
+                                    final 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.
@@ -59,22 +83,21 @@ public interface CpsModulePersistenceService {
     void deleteSchemaSet(String dataspaceName, String schemaSetName);
 
     /**
-     * Returns YANG resources per specific dataspace / schemaSetName.
+     * Deletes Schema Sets.
      *
-     * @param dataspaceName dataspace name
-     * @param schemaSetName schema set name
-     * @return YANG resources (files) map where key is a name and value is content
+     * @param dataspaceName  dataspace name
+     * @param schemaSetNames schema set names
      */
-    Map<String, String> getYangSchemaResources(String dataspaceName, String schemaSetName);
+    void deleteSchemaSets(String dataspaceName, Collection<String> schemaSetNames);
 
     /**
-     * Returns YANG resources per specific dataspace / anchorName.
+     * Returns YANG resources per specific dataspace / schemaSetName.
      *
      * @param dataspaceName dataspace name
-     * @param anchorName    anchor name
+     * @param schemaSetName schema set name
      * @return YANG resources (files) map where key is a name and value is content
      */
-    Map<String, String> getYangSchemaSetResources(String dataspaceName, String anchorName);
+    Map<String, String> getYangSchemaResources(String dataspaceName, String schemaSetName);
 
     /**
      * Returns YANG resources module references for the given dataspace name.
@@ -89,10 +112,19 @@ public interface CpsModulePersistenceService {
      *
      * @param dataspaceName dataspace name
      * @param anchorName    anchor name
-     * @return a collection of module names and revisions
+     * @return a collection of module reference (moduleName and revision)
      */
     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName);
 
+    /**
+     * Get YANG resource definitions for the given anchor name and dataspace name.
+     *
+     * @param dataspaceName dataspace name
+     * @param anchorName    anchor name
+     * @return a collection of module definitions (moduleName, revision and yang resource content)
+     */
+    Collection<ModuleDefinition> getYangResourceDefinitions(String dataspaceName, String anchorName);
+
     /**
      * Remove unused Yang Resource Modules.
      */
@@ -100,9 +132,11 @@ public interface CpsModulePersistenceService {
 
     /**
      * Identify new module references from those returned by a node compared to what is in CPS already.
+     * The system will ignore the namespace of all module references.
      *
      * @param moduleReferencesToCheck the module references ot check
-     * @returns Collection of {@link ModuleReference} of previously unknown module references
+     * @returns Collection of {@link ModuleReference} (namespace will be always blank)
+     *
      */
     Collection<ModuleReference> identifyNewModuleReferences(
         Collection<ModuleReference> moduleReferencesToCheck);