2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.model.operations.api;
24 import fj.data.Either;
25 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
26 import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
27 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
29 import java.util.function.Function;
31 public interface DerivedFromOperation {
35 * @param parentUniqueId the unique id of the object which is the parent of the derived from object
36 * @param derivedFromUniqueId the unique id of the derived from object
37 * @param nodeType the type of the derived from and its parent objects
38 * @return the status of the operation
40 Either<GraphRelation, StorageOperationStatus> addDerivedFromRelation(String parentUniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
44 * @param uniqueId the id of the entity of which to fetch its derived from object
45 * @param nodeType the type of the derived from object
46 * @param clazz the class which represent the derived from object
47 * @return the derived from object or error status of operation failed
49 <T extends GraphNode> Either<T, StorageOperationStatus> getDerivedFromChild(String uniqueId, NodeTypeEnum nodeType, Class<T> clazz);
53 * @param uniqueId the id of the entity of which to remove its derived from object
54 * @param derivedFromUniqueId the unique id of the derived from object
55 * @param nodeType the type of the derived from and its parent objects
56 * @return the status of the remove operation. if no derived from relation exists the operation is successful.
58 StorageOperationStatus removeDerivedFromRelation(String uniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
62 * Checks whether childCandidateType is derived from parentCandidateType
64 public <T extends GraphNode> Either<Boolean, StorageOperationStatus> isTypeDerivedFrom(String childCandidateType, String parentCandidateType, String currentChildType,
65 NodeTypeEnum capabilitytype, Class<T> clazz,
66 Function<T, String> typeProvider);
69 * Checks whether replacement of oldTypeParent hold in DERIVED FROM with newTypeParent is legal
71 public <T extends GraphNode> StorageOperationStatus isUpdateParentAllowed(String oldTypeParent, String newTypeParent, String childType,
72 NodeTypeEnum capabilitytype, Class<T> clazz,
73 Function<T, String> typeProvider);