From f0811d5711a03c3b4b3e02ecdce4a2cd0f7f7a35 Mon Sep 17 00:00:00 2001 From: priyanshu Date: Tue, 7 Aug 2018 19:22:05 +0530 Subject: Interface operations Bug Fix modify operation bug fix Change-Id: I510b19013a050b02bf3b1c959a1340a1ce1b3566 Issue-ID: SDC-1535 Signed-off-by: priyanshu --- .../jsontitan/operations/InterfaceOperation.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java index 04562534a8..3b1b6e506c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/InterfaceOperation.java @@ -30,6 +30,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; @@ -115,9 +116,10 @@ public class InterfaceOperation extends BaseOperation { return Either.right(statusRes); } GraphVertex interfaceVertex = getToscaElementInt.left().value(); - if (!isUpdateAction) { + if (!isUpdateAction) initNewOperation(operation); - } + else + operation.setImplementation(getArtifactImplFromOperation(operation, interfaceDef)); statusRes = performUpdateToscaAction(isUpdateAction, interfaceVertex, Arrays.asList(operation), EdgeLabelEnum.INTERFACE_OPERATION, VertexTypeEnum.INTERFACE_OPERATION); @@ -214,15 +216,24 @@ public class InterfaceOperation extends BaseOperation { } } - private void initNewOperation(Operation operation){ + private ArtifactDefinition createNewArtifactDefForOperation(){ ArtifactDefinition artifactDefinition = new ArtifactDefinition(); String artifactUUID = UUID.randomUUID().toString(); artifactDefinition.setArtifactUUID(artifactUUID); artifactDefinition.setUniqueId(artifactUUID); artifactDefinition.setArtifactType(ArtifactTypeEnum.PLAN.getType()); artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.LIFE_CYCLE); - operation.setImplementation(artifactDefinition); + return artifactDefinition; + } + + private ArtifactDataDefinition getArtifactImplFromOperation(Operation operation, InterfaceDefinition interfaceDef){ + Either operationData = getInterfaceOperation(interfaceDef, operation.getUniqueId()); + return operationData.isLeft()? operationData.left().value().getImplementation() : createNewArtifactDefForOperation(); + } + + private void initNewOperation(Operation operation){ operation.setUniqueId(UUID.randomUUID().toString()); + operation.setImplementation(createNewArtifactDefForOperation()); } private InterfaceDefinition getUpdatedInterfaceDef(InterfaceDefinition interfaceDef, Operation operation, String operationId){ -- cgit 1.2.3-korg