2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022-2023 Nordix Foundation
4 * Modifications Copyright (C) 2023 TechMahindra Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.cps.ncmp.api.inventory;
24 import java.util.Collection;
26 import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
27 import org.onap.cps.spi.FetchDescendantsOption;
28 import org.onap.cps.spi.model.DataNode;
29 import org.onap.cps.spi.model.ModuleDefinition;
30 import org.onap.cps.spi.model.ModuleReference;
32 public interface InventoryPersistence {
35 * Get the Cm Handle Composite State from the data node.
37 * @param cmHandleId cm handle id
38 * @return the cm handle composite state
40 CompositeState getCmHandleState(String cmHandleId);
43 * Save the cm handles state.
45 * @param cmHandleId cm handle id
46 * @param compositeState composite state
48 void saveCmHandleState(String cmHandleId, CompositeState compositeState);
51 * Save all cm handles states in batch.
53 * @param cmHandleStatePerCmHandleId contains cm handle id and updated state
55 void saveCmHandleStateBatch(Map<String, CompositeState> cmHandleStatePerCmHandleId);
58 * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
60 * @param cmHandleId the id of the cm handle
61 * @return yang model cm handle
63 YangModelCmHandle getYangModelCmHandle(String cmHandleId);
66 * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
68 * @param cmHandleIds a list of the ids of the cm handles
69 * @return collection of yang model cm handles
71 Collection<YangModelCmHandle> getYangModelCmHandles(Collection<String> cmHandleIds);
74 * Method to return module definitions by cmHandleId.
76 * @param cmHandleId cm handle ID
77 * @return a collection of module definitions (moduleName, revision and yang resource content)
79 Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(String cmHandleId);
82 * Method to return module references by cmHandleId.
84 * @param cmHandleId cm handle ID
85 * @return a collection of module references (moduleName and revision)
87 Collection<ModuleReference> getYangResourcesModuleReferences(String cmHandleId);
90 * Method to save cmHandle.
92 * @param yangModelCmHandle cmHandle represented as Yang Model
94 void saveCmHandle(YangModelCmHandle yangModelCmHandle);
97 * Method to save batch of cm handles.
99 * @param yangModelCmHandles cm handle represented as Yang Models
101 void saveCmHandleBatch(Collection<YangModelCmHandle> yangModelCmHandles);
104 * Method to delete a list or a list element.
106 * @param listElementXpath list element xPath
108 void deleteListOrListElement(String listElementXpath);
111 * Method to delete a schema set.
113 * @param schemaSetName schema set name
115 void deleteSchemaSetWithCascade(String schemaSetName);
118 * Method to delete multiple schema sets.
120 * @param schemaSetNames schema set names
122 void deleteSchemaSetsWithCascade(Collection<String> schemaSetNames);
125 * Get data node via xpath.
130 Collection<DataNode> getDataNode(String xpath);
133 * Get data node via xpath.
136 * @param fetchDescendantsOption fetch descendants option
139 Collection<DataNode> getDataNode(String xpath, FetchDescendantsOption fetchDescendantsOption);
142 * Get collection of data nodes via xpaths.
144 * @param xpaths collection of xpaths
145 * @return collection of data nodes
147 Collection<DataNode> getDataNodes(Collection<String> xpaths);
150 * Get collection of data nodes via xpaths.
152 * @param xpaths collection of xpaths
153 * @param fetchDescendantsOption fetch descendants option
154 * @return collection of data nodes
156 Collection<DataNode> getDataNodes(Collection<String> xpaths, FetchDescendantsOption fetchDescendantsOption);
159 * Get data node of given cm handle.
161 * @param cmHandleId cmHandle ID
164 Collection<DataNode> getCmHandleDataNode(String cmHandleId);
167 * Get collection of data nodes of given cm handles.
169 * @param cmHandleIds collection of cmHandle IDs
170 * @return collection of data nodes
172 Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds);
175 * get CM handles that has given module names.
177 * @param moduleNamesForQuery module names
178 * @return Collection of CM handle Ids
180 Collection<String> getCmHandleIdsWithGivenModules(Collection<String> moduleNamesForQuery);
183 * Replaces list content by removing all existing elements and inserting the given new elements as data nodes.
185 * @param parentNodeXpath parent node xpath
186 * @param dataNodes datanodes representing the updated data
188 void replaceListContent(String parentNodeXpath, Collection<DataNode> dataNodes);
193 * @param dataNodeXpath data node xpath
195 void deleteDataNode(String dataNodeXpath);
198 * Deletes multiple data nodes.
200 * @param dataNodeXpaths data node xpaths
202 void deleteDataNodes(Collection<String> dataNodeXpaths);