Added oparent to sdc main
[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
21 package org.openecomp.sdc.be.model.operations.api;
22
23
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;
28
29 import java.util.function.Function;
30
31 public interface DerivedFromOperation {
32
33     /**
34      *
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
39      */
40     Either<GraphRelation, StorageOperationStatus> addDerivedFromRelation(String parentUniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
41     
42     /**
43      *
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
48      */
49     <T extends GraphNode> Either<T, StorageOperationStatus> getDerivedFromChild(String uniqueId, NodeTypeEnum nodeType, Class<T> clazz);
50
51     /**
52      *
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.
57      */
58     StorageOperationStatus removeDerivedFromRelation(String uniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
59     
60     
61     /**
62      * Checks whether childCandidateType is derived from parentCandidateType
63      */
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);
67
68     /**
69      * Checks whether replacement of oldTypeParent hold in DERIVED FROM with newTypeParent is legal
70      */
71     public <T extends GraphNode> StorageOperationStatus isUpdateParentAllowed(String oldTypeParent, String newTypeParent, String childType,
72                                                                                NodeTypeEnum capabilitytype, Class<T> clazz,
73                                                                                Function<T, String> typeProvider);        
74 }