Merge "use separated get methods for every cmHandle instead of one "get all" query"
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / CpsModulePersistenceService.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020-2022 Nordix Foundation
4  *  Modifications Copyright (C) 2020-2022 Bell Canada.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 package org.onap.cps.spi;
23
24 import java.util.Collection;
25 import java.util.Map;
26 import org.onap.cps.spi.model.ModuleDefinition;
27 import org.onap.cps.spi.model.ModuleReference;
28
29 /**
30  * Service to manage modules.
31  */
32 public interface CpsModulePersistenceService {
33
34     /**
35      * Stores Schema Set.
36      *
37      * @param dataspaceName                 dataspace name
38      * @param schemaSetName                 schema set name
39      * @param yangResourcesNameToContentMap YANG resources (files) map where key is a name and value is content
40      */
41     void storeSchemaSet(String dataspaceName, String schemaSetName, Map<String, String> yangResourcesNameToContentMap);
42
43     /**
44      * Stores a schema set from new modules and existing modules.
45      *
46      * @param dataspaceName                          Dataspace name
47      * @param schemaSetName                          Schema set name
48      * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
49      * @param moduleReferences                       List of YANG resources module references
50      */
51     void storeSchemaSetFromModules(String dataspaceName, String schemaSetName,
52         Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> moduleReferences);
53
54     /**
55      * Deletes Schema Set.
56      *
57      * @param dataspaceName dataspace name
58      * @param schemaSetName schema set name
59      */
60     void deleteSchemaSet(String dataspaceName, String schemaSetName);
61
62     /**
63      * Returns YANG resources per specific dataspace / schemaSetName.
64      *
65      * @param dataspaceName dataspace name
66      * @param schemaSetName schema set name
67      * @return YANG resources (files) map where key is a name and value is content
68      */
69     Map<String, String> getYangSchemaResources(String dataspaceName, String schemaSetName);
70
71     /**
72      * Returns YANG resources per specific dataspace / anchorName.
73      *
74      * @param dataspaceName dataspace name
75      * @param anchorName    anchor name
76      * @return YANG resources (files) map where key is a name and value is content
77      */
78     Map<String, String> getYangSchemaSetResources(String dataspaceName, String anchorName);
79
80     /**
81      * Returns YANG resources module references for the given dataspace name.
82      *
83      * @param dataspaceName dataspace name
84      * @return Collection of all YANG resources module information in the database
85      */
86     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
87
88     /**
89      * Get YANG resource module references for the given anchor name and dataspace name.
90      *
91      * @param dataspaceName dataspace name
92      * @param anchorName    anchor name
93      * @return a collection of module reference (moduleName and revision)
94      */
95     Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName);
96
97     /**
98      * Get YANG resource definitions for the given anchor name and dataspace name.
99      *
100      * @param dataspaceName dataspace name
101      * @param anchorName    anchor name
102      * @return a collection of module definitions (moduleName, revision and yang resource content)
103      */
104     Collection<ModuleDefinition> getYangResourceDefinitions(String dataspaceName, String anchorName);
105
106     /**
107      * Remove unused Yang Resource Modules.
108      */
109     void deleteUnusedYangResourceModules();
110
111     /**
112      * Identify new module references from those returned by a node compared to what is in CPS already.
113      * The system will ignore the namespace of all module references.
114      *
115      * @param moduleReferencesToCheck the module references ot check
116      * @returns Collection of {@link ModuleReference} (namespace will be always blank)
117      *
118      */
119     Collection<ModuleReference> identifyNewModuleReferences(
120         Collection<ModuleReference> moduleReferencesToCheck);
121
122 }