re base code
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / operations / api / DerivedFromOperation.java
1 package org.openecomp.sdc.be.model.operations.api;
2
3
4 import fj.data.Either;
5 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
6 import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
7 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
8
9 import java.util.function.Function;
10
11 public interface DerivedFromOperation {
12
13     /**
14      *
15      * @param parentUniqueId the unique id of the object which is the parent of the derived from object
16      * @param derivedFromUniqueId the unique id of the derived from object
17      * @param nodeType the type of the derived from and its parent objects
18      * @return the status of the operation
19      */
20     Either<GraphRelation, StorageOperationStatus> addDerivedFromRelation(String parentUniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
21     
22     /**
23      *
24      * @param uniqueId the id of the entity of which to fetch its derived from object
25      * @param nodeType the type of the derived from object
26      * @param clazz the class which represent the derived from object
27      * @return the derived from object or error status of operation failed
28      */
29     <T extends GraphNode> Either<T, StorageOperationStatus> getDerivedFromChild(String uniqueId, NodeTypeEnum nodeType, Class<T> clazz);
30
31     /**
32      *
33      * @param uniqueId the id of the entity of which to remove its derived from object
34      * @param derivedFromUniqueId the unique id of the derived from object
35      * @param nodeType the type of the derived from and its parent objects
36      * @return the status of the remove operation. if no derived from relation exists the operation is successful.
37      */
38     StorageOperationStatus removeDerivedFromRelation(String uniqueId, String derivedFromUniqueId, NodeTypeEnum nodeType);
39     
40     
41     /**
42      * Checks whether childCandidateType is derived from parentCandidateType
43      */
44     public <T extends GraphNode> Either<Boolean, StorageOperationStatus> isTypeDerivedFrom(String childCandidateType, String parentCandidateType, String currentChildType,
45                                                                                            NodeTypeEnum capabilitytype, Class<T> clazz,
46                                                                                            Function<T, String> typeProvider);
47
48     /**
49      * Checks whether replacement of oldTypeParent hold in DERIVED FROM with newTypeParent is legal
50      */
51     public <T extends GraphNode> StorageOperationStatus isUpdateParentAllowed(String oldTypeParent, String newTypeParent, String childType,
52                                                                                NodeTypeEnum capabilitytype, Class<T> clazz,
53                                                                                Function<T, String> typeProvider);        
54 }