diff options
author | shrikantawachar <shrikant.awachar@amdocs.com> | 2018-12-17 12:26:43 +0530 |
---|---|---|
committer | shrikantawachar <shrikant.awachar@amdocs.com> | 2018-12-19 15:08:44 +0530 |
commit | b6e7850484ba61df259e38fd6b59e94c2a7de5b6 (patch) | |
tree | b235bafe42063bea899602c54d8f437c26227c77 /catalog-model/src/main/java/org | |
parent | e7cdba9c8a87f6dfd4823214ca64016e69b45a16 (diff) |
API for get all interface lifecycle types
API for get all interface lifecycle types
Change-Id: I64471c98ff9626ac53562a075a34f506c2e263ab
Issue-ID: SDC-1999
Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'catalog-model/src/main/java/org')
2 files changed, 39 insertions, 1 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java index fd9addd0ec..06622ebba6 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java @@ -50,4 +50,6 @@ public interface IInterfaceLifecycleOperation { public Either<InterfaceDefinition, StorageOperationStatus> getInterface(String interfaceId); public String getShortInterfaceName(InterfaceDataDefinition interfaceDefinition); + + Either<Map<String, InterfaceDefinition>,StorageOperationStatus> getAllInterfaceLifecycleTypes(); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java index 3482a25bc4..c842e5b59d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java @@ -47,8 +47,8 @@ import java.util.*; import java.util.Map.Entry; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.stream.Collectors; @Component("interface-operation") public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation { @@ -891,4 +891,40 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation return createInterfaceType(interf, false); } + @Override + public Either<Map<String, InterfaceDefinition>, StorageOperationStatus> getAllInterfaceLifecycleTypes() { + + Either<List<InterfaceData>, TitanOperationStatus> allInterfaceLifecycleTypes = + titanGenericDao.getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(), InterfaceData.class); + if (allInterfaceLifecycleTypes.isRight()) { + return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus + (allInterfaceLifecycleTypes.right().value())); + } + + Map<String, InterfaceDefinition> interfaceTypes = new HashMap<>(); + List<InterfaceData> interfaceDataList = allInterfaceLifecycleTypes.left().value(); + List<InterfaceDefinition> interfaceDefinitions = interfaceDataList.stream() + .map(this::convertInterfaceDataToInterfaceDefinition) + .filter(interfaceDefinition -> interfaceDefinition.getUniqueId().equalsIgnoreCase((interfaceDefinition.getType()))) + .collect(Collectors.toList()); + + for (InterfaceDefinition interfaceDefinition : interfaceDefinitions) { + + Either<List<ImmutablePair<OperationData, GraphEdge>>, TitanOperationStatus> + childrenNodes = titanGenericDao.getChildrenNodes(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), + interfaceDefinition.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, NodeTypeEnum.InterfaceOperation, OperationData.class); + if(childrenNodes.isRight()) { + return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(childrenNodes.right().value())); + } + + Map<String, OperationDataDefinition> operationsDataDefinitionMap = new HashMap<>(); + for(ImmutablePair<OperationData, GraphEdge> operation : childrenNodes.left().value()) { + OperationData operationData = operation.getLeft(); + operationsDataDefinitionMap.put(operationData.getUniqueId(), operationData.getOperationDataDefinition()); + } + interfaceDefinition.setOperations(operationsDataDefinitionMap); + interfaceTypes.put(interfaceDefinition.getUniqueId(), interfaceDefinition); + } + return Either.left(interfaceTypes); + } } |