2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022-2023 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.ncmp.api.inventory;
23 import java.util.Collection;
25 import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
26 import org.onap.cps.spi.FetchDescendantsOption;
27 import org.onap.cps.spi.model.DataNode;
28 import org.onap.cps.spi.model.ModuleDefinition;
29 import org.onap.cps.spi.model.ModuleReference;
31 public interface InventoryPersistence {
34 * Get the Cm Handle Composite State from the data node.
36 * @param cmHandleId cm handle id
37 * @return the cm handle composite state
39 CompositeState getCmHandleState(String cmHandleId);
42 * Save the cm handles state.
44 * @param cmHandleId cm handle id
45 * @param compositeState composite state
47 void saveCmHandleState(String cmHandleId, CompositeState compositeState);
50 * Save all cm handles states in batch.
52 * @param cmHandleStatePerCmHandleId contains cm handle id and updated state
54 void saveCmHandleStateBatch(Map<String, CompositeState> cmHandleStatePerCmHandleId);
57 * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
59 * @param cmHandleId the id of the cm handle
60 * @return yang model cm handle
62 YangModelCmHandle getYangModelCmHandle(String cmHandleId);
65 * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
67 * @param cmHandleIds a list of the ids of the cm handles
68 * @return collection of yang model cm handles
70 Collection<YangModelCmHandle> getYangModelCmHandles(Collection<String> cmHandleIds);
73 * Method to return module definitions by cmHandleId.
75 * @param cmHandleId cm handle ID
76 * @return a collection of module definitions (moduleName, revision and yang resource content)
78 Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(String cmHandleId);
81 * Method to return module references by cmHandleId.
83 * @param cmHandleId cm handle ID
84 * @return a collection of module references (moduleName and revision)
86 Collection<ModuleReference> getYangResourcesModuleReferences(String cmHandleId);
89 * Method to save cmHandle.
91 * @param yangModelCmHandle cmHandle represented as Yang Model
93 void saveCmHandle(YangModelCmHandle yangModelCmHandle);
96 * Method to save batch of cm handles.
98 * @param yangModelCmHandles cm handle represented as Yang Models
100 void saveCmHandleBatch(Collection<YangModelCmHandle> yangModelCmHandles);
103 * Method to delete a list or a list element.
105 * @param listElementXpath list element xPath
107 void deleteListOrListElement(String listElementXpath);
110 * Method to delete a schema set.
112 * @param schemaSetName schema set name
114 void deleteSchemaSetWithCascade(String schemaSetName);
117 * Get data node via xpath.
122 DataNode getDataNode(String xpath);
125 * Get data node via xpath.
128 * @param fetchDescendantsOption fetch descendants option
131 DataNode getDataNode(String xpath, FetchDescendantsOption fetchDescendantsOption);
134 * Get collection of data nodes via xpaths.
136 * @param xpaths collection of xpaths
137 * @return collection of data nodes
139 Collection<DataNode> getDataNodes(Collection<String> xpaths);
142 * Get collection of data nodes via xpaths.
144 * @param xpaths collection of xpaths
145 * @param fetchDescendantsOption fetch descendants option
146 * @return collection of data nodes
148 Collection<DataNode> getDataNodes(Collection<String> xpaths, FetchDescendantsOption fetchDescendantsOption);
151 * Get data node of given cm handle.
153 * @param cmHandleId cmHandle ID
156 DataNode getCmHandleDataNode(String cmHandleId);
159 * Get collection of data nodes of given cm handles.
161 * @param cmHandleIds collection of cmHandle IDs
162 * @return collection of data nodes
164 Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds);
167 * get CM handles that has given module names.
169 * @param moduleNamesForQuery module names
170 * @return Collection of CM handle Ids
172 Collection<String> getCmHandleIdsWithGivenModules(Collection<String> moduleNamesForQuery);
175 * Replaces list content by removing all existing elements and inserting the given new elements as data nodes.
177 * @param parentNodeXpath parent node xpath
178 * @param dataNodes datanodes representing the updated data
180 void replaceListContent(String parentNodeXpath, Collection<DataNode> dataNodes);
185 * @param dataNodeXpath data node xpath
187 void deleteDataNode(String dataNodeXpath);
190 * Deletes multiple data nodes.
192 * @param dataNodeXpaths data node xpaths
194 void deleteDataNodes(Collection<String> dataNodeXpaths);