diff options
author | shrek2000 <orenkle@amdocs.com> | 2018-04-24 16:46:33 +0300 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-04-25 14:22:16 +0000 |
commit | d71a8de8c7b688eabb250e524dc4f6000b3233b6 (patch) | |
tree | 38c550f0f78084cd19c79e997f5a5ece37751bd5 /catalog-model/src | |
parent | ad3c41b5693b4f0b2a151e9c3221551e24f8264d (diff) |
Delete workflow artifact and add artifact to CSAR
Added delete artifact codes, add artifact to CSAR and refactored operation Business logic.
Change-Id: Iaad3f26795633076d1362bfd33631acc9fcf7aa1
Issue-ID: SDC-1060
Signed-off-by: shrek2000 <orenkle@amdocs.com>
Diffstat (limited to 'catalog-model/src')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java index cbd612d024..4782851e26 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.jsontitan.operations; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,13 +41,16 @@ 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.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.HeatParameterDefinition; +import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; @@ -88,7 +92,7 @@ public class ArtifactsOperations extends BaseOperation { } - public Either<ArtifactDefinition, StorageOperationStatus> updateArifactOnResource(ArtifactDefinition artifactInfo, String id, String artifactId, NodeTypeEnum type, String instanceId) { + public Either<ArtifactDefinition, StorageOperationStatus> updateArtifactOnResource(ArtifactDefinition artifactInfo, String id, String artifactId, NodeTypeEnum type, String instanceId) { Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(id, artifactInfo, type, artifactId, instanceId, true, false); if (status.isRight()) { @@ -141,6 +145,10 @@ public class ArtifactsOperations extends BaseOperation { if (foundArtifact == null) { foundArtifact = getArtifactByLabelAndId(parentId, id, EdgeLabelEnum.SERVICE_API_ARTIFACTS); } + if (foundArtifact == null) { + foundArtifact = findInterfaceArtifact(parentId, id); + + } if (foundArtifact == null) { result = Either.right(StorageOperationStatus.NOT_FOUND); @@ -151,6 +159,47 @@ public class ArtifactsOperations extends BaseOperation { return Either.left(artifactDefResult); } + private ArtifactDataDefinition findInterfaceArtifact(String parentId, String id) { + Either<Map<String, InterfaceDefinition>, TitanOperationStatus> dataFromGraph = getDataFromGraph(parentId, EdgeLabelEnum.INTERFACE_ARTIFACTS); + if (dataFromGraph.isRight()){ + log.debug("failed to fetch interfaces {} for tosca element with id {}, error {}", id, parentId ,dataFromGraph.right().value()); + return null; + } + + Map<String, InterfaceDefinition> interfaceDefinitionMap = dataFromGraph.left().value(); + if(interfaceDefinitionMap == null) { + return null; + } + Collection<InterfaceDefinition> interfaces = interfaceDefinitionMap.values(); + if (interfaces == null){ + return null; + } + for (InterfaceDataDefinition interfaceDataDefinition : interfaces){ + Map<String, OperationDataDefinition> operationsMap = interfaceDataDefinition.getOperations(); + if (operationsMap == null) { + return null; + } + ArtifactDataDefinition implementationArtifact = getArtifactDataDefinition(id, operationsMap); + if (implementationArtifact != null) + return implementationArtifact; + } + return null; + } + + private ArtifactDataDefinition getArtifactDataDefinition(String id, + Map<String, OperationDataDefinition> operationsMap) { + for(OperationDataDefinition operationDataDefinition : operationsMap.values()){ + ArtifactDataDefinition implementationArtifact = operationDataDefinition.getImplementation(); + if(implementationArtifact != null){ + String uniqueId = implementationArtifact.getUniqueId(); + if (id.equals(uniqueId)) { + return implementationArtifact; + } + } + } + return null; + } + public Either<ArtifactDefinition, StorageOperationStatus> removeArifactFromResource(String id, String artifactId, NodeTypeEnum type, boolean deleteMandatoryArtifact) { Either<ArtifactDefinition, StorageOperationStatus> status = removeArtifactOnGraph(id, artifactId, type, deleteMandatoryArtifact); @@ -336,7 +385,7 @@ public class ArtifactsOperations extends BaseOperation { if (envList != null && !envList.isEmpty()) { envList.forEach(a -> { a.setGeneratedFromId(newArtifactId); - updateArifactOnResource(a, id, a.getUniqueId(), type, instanceId); + updateArtifactOnResource(a, id, a.getUniqueId(), type, instanceId); }); @@ -345,7 +394,7 @@ public class ArtifactsOperations extends BaseOperation { } public Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvPlaceholder(ArtifactDefinition artifactInfo, String parentId, NodeTypeEnum type) { - return updateArifactOnResource(artifactInfo, parentId, artifactInfo.getUniqueId(), type, null); + return updateArtifactOnResource(artifactInfo, parentId, artifactInfo.getUniqueId(), type, null); } // public Either<List<HeatParameterDefinition>, StorageOperationStatus> getHeatParamsForEnv(ArtifactDefinition heatEnvArtifact, String parentId) { |