diff options
Diffstat (limited to 'catalog-model/src/main')
3 files changed, 47 insertions, 28 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java index 1726c397ad..79360f6e10 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; import java.util.stream.Collectors; @@ -44,6 +45,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition; @@ -1338,32 +1340,49 @@ public abstract class BaseOperation { // return StorageOperationStatus.OK; // } - protected GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDataDefinition group, ComponentInstanceDataDefinition componentInstance) { - - String componentInstanceName = componentInstance.getName(); - Long creationDate = System.currentTimeMillis(); - GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition(); - String groupUid = group.getUniqueId(); - - groupInstance.setGroupUid(groupUid); - groupInstance.setType(group.getType()); - groupInstance.setCustomizationUUID(generateCustomizationUUID()); - groupInstance.setCreationTime(creationDate); - groupInstance.setModificationTime(creationDate); - groupInstance.setName(buildGroupInstanceName(componentInstanceName, group.getName())); - groupInstance.setGroupName(group.getName()); - groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName())); - groupInstance.setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName())); - groupInstance.setArtifacts(group.getArtifacts()); - groupInstance.setArtifactsUuid(group.getArtifactsUuid()); - groupInstance.setProperties(group.getProperties()); - convertPropertiesToInstanceProperties(groupInstance.getProperties()); - groupInstance.setInvariantUUID(group.getInvariantUUID()); - groupInstance.setGroupUUID(group.getGroupUUID()); - groupInstance.setVersion(group.getVersion()); - - return groupInstance; - } + protected GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDataDefinition group, ComponentInstanceDataDefinition componentInstance, Map<String, ArtifactDataDefinition> instDeplArtifMap) { + + String componentInstanceName = componentInstance.getName(); + Long creationDate = System.currentTimeMillis(); + GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition(); + String groupUid = group.getUniqueId(); + + groupInstance.setGroupUid(groupUid); + groupInstance.setType(group.getType()); + groupInstance.setCustomizationUUID(generateCustomizationUUID()); + groupInstance.setCreationTime(creationDate); + groupInstance.setModificationTime(creationDate); + groupInstance.setName(buildGroupInstanceName(componentInstanceName, group.getName())); + groupInstance.setGroupName(group.getName()); + groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName())); + groupInstance.setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName())); + groupInstance.setArtifacts(group.getArtifacts()); + +// List<String> fixedArtifactsUuid; +// List<String> artifactsUuid = group.getArtifactsUuid(); +// if (instDeplArtifMap != null) { +// fixedArtifactsUuid = new ArrayList<>(); +// artifactsUuid.forEach(u -> { +// Optional<ArtifactDataDefinition> findFirst = instDeplArtifMap.values().stream().filter(a -> u.equals(a.getUniqueId())).findFirst(); +// if (findFirst.isPresent()) { +// fixedArtifactsUuid.add(findFirst.get().getArtifactUUID()); +// } else { +// fixedArtifactsUuid.add(u); +// } +// }); +// } else { +// fixedArtifactsUuid = artifactsUuid; +// } + groupInstance.setArtifactsUuid(group.getArtifactsUuid()); + groupInstance.setProperties(group.getProperties()); + convertPropertiesToInstanceProperties(groupInstance.getProperties()); + groupInstance.setInvariantUUID(group.getInvariantUUID()); + groupInstance.setGroupUUID(group.getGroupUUID()); + groupInstance.setVersion(group.getVersion()); + + return groupInstance; + } + protected String buildGroupInstanceName(String instanceName, String groupName) { return ValidationUtils.normalizeComponentInstanceName(instanceName) + ".." + groupName; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java index b642410548..7ff42ae42e 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java @@ -793,7 +793,7 @@ public class NodeTemplateOperation extends BaseOperation { for (Map.Entry<String, List<ArtifactDefinition>> groupArtifacts : groupInstancesArtifacts.entrySet()) { Optional<GroupDefinition> groupOptional = groups.stream().filter(g -> g.getUniqueId().equals(groupArtifacts.getKey())).findFirst(); if (groupOptional.isPresent()) { - GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition((GroupDataDefinition)groupOptional.get(), (ComponentInstanceDataDefinition)componentInstance); + GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition((GroupDataDefinition) groupOptional.get(), (ComponentInstanceDataDefinition) componentInstance, null); groupInstance.setGroupInstanceArtifacts(groupArtifacts.getValue().stream().map(a -> a.getUniqueId()).collect(Collectors.toList())); groupInstance.setGroupInstanceArtifactsUuid(groupArtifacts.getValue().stream().map(a -> a.getArtifactUUID()).collect(Collectors.toList())); groupInstanceToCreate.put(groupInstance.getName(), groupInstance); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java index 51d122524c..f34975b073 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java @@ -1120,7 +1120,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation { Map<String, GroupInstanceDataDefinition> groupInstanceToCreate = new HashMap<>(); for(GroupDataDefinition group:filteredGroups){ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "create new groupInstance {} ", group.getName()); - GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(group, vfInst); + GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(group, vfInst, instDeplArtifMap); List<String> artifactsUid = new ArrayList<>(); List<String> artifactsId = new ArrayList<>(); for (ArtifactDataDefinition artifact : instDeplArtifMap.values()) { |