2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022-2024 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.impl.inventory;
24 import java.util.Collection;
25 import java.util.List;
27 import org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence;
28 import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
29 import org.onap.cps.spi.model.DataNode;
30 import org.onap.cps.spi.model.ModuleDefinition;
31 import org.onap.cps.spi.model.ModuleReference;
33 public interface InventoryPersistence extends NcmpPersistence {
36 * Get the Cm Handle Composite State from the data node.
38 * @param cmHandleId cm handle id
39 * @return the cm handle composite state
41 CompositeState getCmHandleState(String cmHandleId);
44 * Save the cm handles state.
46 * @param cmHandleId cm handle id
47 * @param compositeState composite state
49 void saveCmHandleState(String cmHandleId, CompositeState compositeState);
52 * Save all cm handles states in batch.
54 * @param cmHandleStatePerCmHandleId contains cm handle id and updated state
56 void saveCmHandleStateBatch(Map<String, CompositeState> cmHandleStatePerCmHandleId);
59 * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
61 * @param cmHandleId the id of the cm handle
62 * @return yang model cm handle
64 YangModelCmHandle getYangModelCmHandle(String cmHandleId);
67 * This method retrieves DMI service name, DMI properties and the state for a given cm handle.
69 * @param cmHandleIds a list of the ids of the cm handles
70 * @return collection of yang model cm handles
72 Collection<YangModelCmHandle> getYangModelCmHandles(Collection<String> cmHandleIds);
75 * Method to return module definitions by cmHandleId.
77 * @param cmHandleId cm handle ID
78 * @return a collection of module definitions (moduleName, revision and yang resource content)
80 Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(String cmHandleId);
83 * Method to return module definitions for the given parameters.
85 * @param cmHandleId cm-handle identifier
86 * @param moduleName module name
87 * @param moduleRevision the revision of the module
88 * @return list of module definitions (module name, revision, yang resource content)
90 Collection<ModuleDefinition> getModuleDefinitionsByCmHandleAndModule(String cmHandleId,
92 String moduleRevision);
95 * Method to return module references by cmHandleId.
97 * @param cmHandleId cm handle ID
98 * @return a collection of module references (moduleName and revision)
100 Collection<ModuleReference> getYangResourcesModuleReferences(String cmHandleId);
103 * Method to save cmHandle.
105 * @param yangModelCmHandle cmHandle represented as Yang Model
107 void saveCmHandle(YangModelCmHandle yangModelCmHandle);
110 * Method to save batch of cm handles.
112 * @param yangModelCmHandles cm handle represented as Yang Models
114 void saveCmHandleBatch(List<YangModelCmHandle> yangModelCmHandles);
117 * Get data node with the given cm handle id.
119 * @param cmHandleId cmHandle ID
122 Collection<DataNode> getCmHandleDataNodeByCmHandleId(String cmHandleId);
125 * Get data node with the given alternate id.
127 * @param alternateId alternate ID
130 DataNode getCmHandleDataNodeByAlternateId(String alternateId);
133 * Get collection of data nodes of given cm handles.
135 * @param cmHandleIds collection of cmHandle IDs
136 * @return collection of data nodes
138 Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds);
141 * get CM handles that has given module names.
143 * @param moduleNamesForQuery module names
144 * @return Collection of CM handle Ids
146 Collection<String> getCmHandleIdsWithGivenModules(Collection<String> moduleNamesForQuery);