Reformat catalog-model
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / operations / api / DerivedFromOperation.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.openecomp.sdc.be.model.operations.api;
21
22 import fj.data.Either;
23 import java.util.function.Function;
24 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
25 import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
27
28 public interface DerivedFromOperation {
29
30     /**
31      * @param parentUniqueId      the unique id of the object which is the parent of the derived from object
32      * @param derivedFromUniqueId the unique id of the derived from object
33      * @param nodeType            the type of the derived from and its parent objects
34      * @return the status of the operation
35      */
36     Either<GraphRelation, StorageOperationStatus> addDerivedFromRelation(String parentUniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
37
38     /**
39      * @param uniqueId the id of the entity of which to fetch its derived from object
40      * @param nodeType the type of the derived from object
41      * @param clazz    the class which represent the derived from object
42      * @return the derived from object or error status of operation failed
43      */
44     <T extends GraphNode> Either<T, StorageOperationStatus> getDerivedFromChild(String uniqueId, NodeTypeEnum nodeType, Class<T> clazz);
45
46     /**
47      * @param uniqueId            the id of the entity of which to remove its derived from object
48      * @param derivedFromUniqueId the unique id of the derived from object
49      * @param nodeType            the type of the derived from and its parent objects
50      * @return the status of the remove operation. if no derived from relation exists the operation is successful.
51      */
52     StorageOperationStatus removeDerivedFromRelation(String uniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
53
54     /**
55      * Checks whether childCandidateType is derived from parentCandidateType
56      */
57     public <T extends GraphNode> Either<Boolean, StorageOperationStatus> isTypeDerivedFrom(String childCandidateType, String parentCandidateType,
58                                                                                            String currentChildType, NodeTypeEnum capabilitytype,
59                                                                                            Class<T> clazz, Function<T, String> typeProvider);
60
61     /**
62      * Checks whether replacement of oldTypeParent hold in DERIVED FROM with newTypeParent is legal
63      */
64     public <T extends GraphNode> StorageOperationStatus isUpdateParentAllowed(String oldTypeParent, String newTypeParent, String childType,
65                                                                               NodeTypeEnum capabilitytype, Class<T> clazz,
66                                                                               Function<T, String> typeProvider);
67 }