aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-06-29 19:30:00 +0300
committerMichael Lando <ml636r@att.com>2017-06-29 21:32:19 +0300
commited7e1c3dfe332abc67ed943717db2ee94406f95e (patch)
treee0f2f39596656456272900f59aadc3dff6c6e828 /catalog-model
parent68ccc45de18f41cddb79de33a245bceb3b063ffb (diff)
[SDC] rebase code
Change-Id: I456ec65a233d277e6bae35e140f2e3da5765bae6 Signed-off-by: Tal Gitelman <tg851x@intl.att.com> Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstanceProperty.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java84
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java16
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java13
6 files changed, 80 insertions, 54 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java
index 9347f326d1..abcac352cc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java
@@ -38,8 +38,6 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
*/
private String valueUniqueUid;
- private String inputId;
-
private List<String> path = null;
private List<PropertyRule> rules = null;
@@ -53,7 +51,7 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
public ComponentInstanceInput(PropertyDataDefinition curPropertyDef, String inputId, String value,
String valueUniqueUid) {
super(curPropertyDef);
- this.inputId = inputId;
+ setInputId(inputId);
setValue(value);
this.valueUniqueUid = valueUniqueUid;
}
@@ -68,7 +66,7 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
public ComponentInstanceInput(PropertyDataDefinition propertyDefinition) {
super(propertyDefinition);
if(propertyDefinition.getGetInputValues() != null && !propertyDefinition.getGetInputValues().isEmpty()){
- this.inputId = propertyDefinition.getGetInputValues().get(0).getInputId();
+ setInputId(propertyDefinition.getGetInputValues().get(0).getInputId());
}
}
@@ -88,14 +86,6 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
this.componentInstanceId = componentInstanceId;
}
- public String getInputId() {
- return inputId;
- }
-
- public void setInputId(String inputId) {
- this.inputId = inputId;
- }
-
public String getValueUniqueUid() {
return valueUniqueUid;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstanceProperty.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstanceProperty.java
index e1e51729e0..683a2f2428 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstanceProperty.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstanceProperty.java
@@ -48,6 +48,7 @@ public class GroupInstanceProperty extends GroupProperty {
public GroupInstanceProperty(PropertyDataDefinition propertyDataDefinition) {
super(propertyDataDefinition);
+ parentValue = getDefaultValue();
}
public String getParentValue() {
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 4d9ec8c2fe..224697246d 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
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -98,7 +99,7 @@ public class ArtifactsOperations extends BaseOperation {
ArtifactDataDefinition foundArtifact = null;
if (componentType != null && componentType == ComponentTypeEnum.RESOURCE_INSTANCE) {
foundArtifact = getInstanceArtifactByLabelAndId(parentId, id, containerId, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS);
- if ( foundArtifact == null ){
+ if (foundArtifact == null) {
foundArtifact = getInstanceArtifactByLabelAndId(parentId, id, containerId, EdgeLabelEnum.INSTANCE_ARTIFACTS);
}
}
@@ -217,14 +218,14 @@ public class ArtifactsOperations extends BaseOperation {
oldVesrion = "0";
String currentChecksum = artifactData.getArtifactChecksum();
-
- if ( isUpdate ){
+
+ if (isUpdate) {
ArtifactTypeEnum type = ArtifactTypeEnum.findType(artifactData.getArtifactType());
- switch ( type ){
- case HEAT_ENV:
- if ( edgeLabel == EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS ){
+ switch (type) {
+ case HEAT_ENV:
+ if (edgeLabel == EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS) {
generateUUID(artifactData, oldVesrion);
- }else{
+ } else {
updateVersionAndDate(artifactData, oldVesrion);
}
break;
@@ -243,7 +244,7 @@ public class ArtifactsOperations extends BaseOperation {
}
break;
}
- }else{
+ } else {
if (oldChecksum == null || oldChecksum.isEmpty()) {
if (currentChecksum != null) {
generateUUID(artifactData, oldVesrion);
@@ -287,7 +288,7 @@ public class ArtifactsOperations extends BaseOperation {
}
Map<String, ArtifactDefinition> artifacts = artifactsEither.left().value();
- List<ArtifactDefinition> envList = artifacts.values().stream().filter(a -> a.getGeneratedFromId()!= null && a.getGeneratedFromId().equals(artifactId)).collect(Collectors.toList());
+ List<ArtifactDefinition> envList = artifacts.values().stream().filter(a -> a.getGeneratedFromId() != null && a.getGeneratedFromId().equals(artifactId)).collect(Collectors.toList());
if (envList != null && !envList.isEmpty()) {
envList.forEach(a -> {
a.setGeneratedFromId(newArtifactId);
@@ -366,7 +367,7 @@ public class ArtifactsOperations extends BaseOperation {
Map<String, ArtifactDefinition> artMap = null;
Map<String, ArtifactDataDefinition> artifactDataMap = null;
-
+
if (edgeLabelEnum != EdgeLabelEnum.INSTANCE_ARTIFACTS) {
Either<Map<String, ArtifactDataDefinition>, TitanOperationStatus> resultEither = getDataFromGraph(parentId, edgeLabelEnum);
if (resultEither.isRight()) {
@@ -374,7 +375,7 @@ public class ArtifactsOperations extends BaseOperation {
return Either.right(resultEither.right().value());
}
artifactDataMap = resultEither.left().value();
- }else{
+ } else {
Either<Map<String, MapArtifactDataDefinition>, TitanOperationStatus> resultEither = getDataFromGraph(parentId, edgeLabelEnum);
if (resultEither.isRight()) {
log.debug("failed to fetch {} for tosca element with id {}, error {}", edgeLabelEnum, parentId, resultEither.right().value());
@@ -382,13 +383,13 @@ public class ArtifactsOperations extends BaseOperation {
}
Map<String, MapArtifactDataDefinition> mapArtifacts = resultEither.left().value();
MapArtifactDataDefinition artifactPerInstance = mapArtifacts.get(instanceId);
- if ( artifactPerInstance != null ){
+ if (artifactPerInstance != null) {
artifactDataMap = artifactPerInstance.getMapToscaDataDefinition();
}
}
if (artifactDataMap != null && !artifactDataMap.isEmpty()) {
artMap = artifactDataMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> convertArtifactDataToArtifactDefinition(null, e.getValue())));
- }else{
+ } else {
artMap = new HashMap<>();
}
return Either.left(artMap);
@@ -462,26 +463,28 @@ public class ArtifactsOperations extends BaseOperation {
uniqueId = UniqueIdBuilder.buildPropertyUniqueId(instanceId, artifactToUpdate.getArtifactLabel());
}
artifactToUpdate.setUniqueId(uniqueId);
-
+ artifactToUpdate.setEsId(uniqueId);
} else
artifactToUpdate.setUniqueId(artifactId);
- Map<String, ArtifactDataDefinition> artifacts = null;
+ Map<String, ArtifactDataDefinition> artifacts = new HashMap<>();
+ Map<String, MapArtifactDataDefinition> artifactInst = null;
if (edgeLabelEnum != EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS && edgeLabelEnum != EdgeLabelEnum.INSTANCE_ARTIFACTS) {
Either<Map<String, ArtifactDataDefinition>, TitanOperationStatus> artifactsEither = this.getDataFromGraph(componentId, edgeLabelEnum);
if (artifactsEither.isLeft() && artifactsEither.left().value() != null && !artifactsEither.left().value().isEmpty()) {
artifacts = artifactsEither.left().value();
- if (isNeedToClone) {
+ if (isNeedToClone && artifacts != null) {
artifacts.values().stream().forEach(a -> a.setDuplicated(Boolean.TRUE));
}
}
} else {
+
Either<Map<String, MapArtifactDataDefinition>, TitanOperationStatus> artifactsEither = this.getDataFromGraph(componentId, edgeLabelEnum);
if (artifactsEither.isLeft()) {
- Map<String, MapArtifactDataDefinition> artifactInst = artifactsEither.left().value();
- if (isNeedToClone) {
+ artifactInst = artifactsEither.left().value();
+ if (isNeedToClone && artifactInst != null) {
artifactInst.values().forEach(ma -> ma.getMapToscaDataDefinition().values().forEach(a -> a.setDuplicated(Boolean.TRUE)));
}
MapArtifactDataDefinition artifatcsOnInstance = artifactInst.get(instanceId);
@@ -496,6 +499,9 @@ public class ArtifactsOperations extends BaseOperation {
ArtifactDataDefinition oldArtifactData = artifacts.get(artifactInfo.getArtifactLabel());
oldChecksum = oldArtifactData.getArtifactChecksum();
oldVersion = oldArtifactData.getArtifactVersion();
+ //duplicated flag didn't receive from UI, take from DB
+ artifactToUpdate.setDuplicated(oldArtifactData.getDuplicated());
+
if (isNeedToClone)
artifactToUpdate.setDuplicated(Boolean.FALSE);
else {
@@ -503,11 +509,12 @@ public class ArtifactsOperations extends BaseOperation {
String id = type != NodeTypeEnum.ResourceInstance ? componentId : instanceId;
String uniqueId = UniqueIdBuilder.buildPropertyUniqueId(id, artifactToUpdate.getArtifactLabel());
artifactToUpdate.setUniqueId(uniqueId);
- artifactToUpdate.setDuplicated(Boolean.TRUE);
+ artifactToUpdate.setEsId(uniqueId);
+ artifactToUpdate.setDuplicated(Boolean.FALSE);
}
}
}
- updateUUID(artifactToUpdate, oldChecksum, oldVersion, isUpdate, edgeLabelEnum );
+ updateUUID(artifactToUpdate, oldChecksum, oldVersion, isUpdate, edgeLabelEnum);
if (artifactInfo.getPayloadData() == null) {
if (!artifactToUpdate.getMandatory() || artifactToUpdate.getEsId() != null) {
@@ -516,19 +523,44 @@ public class ArtifactsOperations extends BaseOperation {
} else {
if (artifactToUpdate.getEsId() == null) {
artifactToUpdate.setEsId(artifactToUpdate.getUniqueId());
-
}
}
- StorageOperationStatus status;
+ StorageOperationStatus status = StorageOperationStatus.OK;
if (edgeLabelEnum != EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS && edgeLabelEnum != EdgeLabelEnum.INSTANCE_ARTIFACTS) {
- status = updateToscaDataOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, artifactToUpdate, JsonPresentationFields.ARTIFACT_LABEL);
+ List<ArtifactDataDefinition> toscaDataList = new ArrayList<>();
+ toscaDataList.add(artifactToUpdate);
+
+ if (isNeedToClone && artifacts != null) {
+ artifacts.values().stream().filter(a -> !a.getArtifactLabel().equals(artifactToUpdate.getArtifactLabel())).forEach(a -> toscaDataList.add(a));
+ }
+ status = updateToscaDataOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataList, JsonPresentationFields.ARTIFACT_LABEL);
} else {
- List<String> pathKeys = new ArrayList<>();
- pathKeys.add(instanceId);
List<ArtifactDataDefinition> toscaDataList = new ArrayList<>();
toscaDataList.add(artifactToUpdate);
- status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataList, pathKeys, JsonPresentationFields.ARTIFACT_LABEL);
+ List<String> pathKeys = new ArrayList<>();
+ pathKeys.add(instanceId);
+ if (isNeedToClone) {
+ MapArtifactDataDefinition artifatcsOnInstance = artifactInst.get(instanceId);
+ if (artifatcsOnInstance != null) {
+ artifacts = artifatcsOnInstance.getMapToscaDataDefinition();
+ artifacts.put(artifactToUpdate.getArtifactLabel(), artifactToUpdate);
+ }
+
+ for ( Entry<String, MapArtifactDataDefinition> e : artifactInst.entrySet() ) {
+ List<ArtifactDataDefinition> toscaDataListPerInst = e.getValue().getMapToscaDataDefinition().values().stream().collect(Collectors.toList());
+ List<String> pathKeysPerInst = new ArrayList<>();
+ pathKeysPerInst.add(e.getKey());
+ status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataListPerInst, pathKeysPerInst, JsonPresentationFields.ARTIFACT_LABEL);
+ if ( status != StorageOperationStatus.OK) {
+ log.debug("Failed to update atifacts group for instance {} in component {} edge type {} error {}", instanceId, componentId, edgeLabelEnum, status);
+ res = Either.right(status);
+ break;
+ }
+ }
+ } else {
+ status = updateToscaDataDeepElementsOfToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, toscaDataList, pathKeys, JsonPresentationFields.ARTIFACT_LABEL);
+ }
}
if (status == StorageOperationStatus.OK)
res = Either.left(artifactToUpdate);
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 ed8846010b..407d711ed1 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
@@ -28,6 +28,7 @@ import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
@@ -1340,6 +1341,7 @@ public abstract class BaseOperation {
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());
@@ -1354,5 +1356,9 @@ public abstract class BaseOperation {
protected String generateCustomizationUUID() {
return UUID.randomUUID().toString();
}
+
+ protected void convertPropertiesToInstanceProperties(List<PropertyDataDefinition> properties){
+ properties.forEach(p -> p.convertPropertyDataToInstancePropertyData());
+ }
}
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 58ee914046..0bb5476f1d 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
@@ -602,18 +602,18 @@ public class NodeTemplateOperation extends BaseOperation {
public MapArtifactDataDefinition prepareInstDeploymentArtifactPerInstance(Map<String, ArtifactDataDefinition> deploymentArtifacts, String componentInstanceId, User user, String envType) {
if (deploymentArtifacts != null && envType.equals(HEAT_VF_ENV_NAME)) {
- Map<String, ArtifactDataDefinition> instDeploymentArtifacts = new HashMap<>();
+
deploymentArtifacts.entrySet().forEach(e -> {
ArtifactDataDefinition artifact = e.getValue();
String type = artifact.getArtifactType();
- if (!(type.equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_NET.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_VOL.getType()))) {
- instDeploymentArtifacts.put(e.getKey(), artifact);
+ if (type.equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_NET.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_VOL.getType())) {
+ //instDeploymentArtifacts.put(e.getKey(), artifact);
ArtifactDataDefinition artifactEnv = createArtifactPlaceHolderInfo(artifact, componentInstanceId, user, envType);
- instDeploymentArtifacts.put(artifactEnv.getArtifactLabel(), artifactEnv);
+ deploymentArtifacts.put(artifactEnv.getArtifactLabel(), artifactEnv);
}
});
- MapArtifactDataDefinition instArtifacts = new MapArtifactDataDefinition(instDeploymentArtifacts);
+ MapArtifactDataDefinition instArtifacts = new MapArtifactDataDefinition(deploymentArtifacts);
return instArtifacts;
}
return null;
@@ -820,12 +820,16 @@ public class NodeTemplateOperation extends BaseOperation {
ComponentInstanceDataDefinition dataDefinition = new ComponentInstanceDataDefinition(resourceInstance);
Long creationDate = resourceInstance.getCreationTime();
+ Long modificationTime;
if (creationDate == null) {
creationDate = System.currentTimeMillis();
+ modificationTime = creationDate;
+ } else {
+ modificationTime = System.currentTimeMillis();
}
dataDefinition.setComponentUid(ciOriginComponentUid);
dataDefinition.setCreationTime(creationDate);
- dataDefinition.setModificationTime(creationDate);
+ dataDefinition.setModificationTime(modificationTime);
if (StringUtils.isNotEmpty(instanceNewName)) {
dataDefinition.setName(instanceNewName);
resourceInstance.setName(instanceNewName);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index e078f8eb86..58b7d30252 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -1,14 +1,7 @@
package org.openecomp.sdc.be.model.jsontitan.operations;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
@@ -359,7 +352,7 @@ public class ToscaOperationFacade {
}
- public <T extends Component> Either<List<T>, StorageOperationStatus> getFollowed(String userId, Set<LifecycleStateEnum> lifecycleStates, Set<LifecycleStateEnum> lastStateStates, ComponentTypeEnum componentType) {
+ public <T extends Component> Either<Set<T>, StorageOperationStatus> getFollowed(String userId, Set<LifecycleStateEnum> lifecycleStates, Set<LifecycleStateEnum> lastStateStates, ComponentTypeEnum componentType) {
Either<List<ToscaElement>, StorageOperationStatus> followedResources;
if (componentType == ComponentTypeEnum.RESOURCE) {
followedResources = nodeTypeOperation.getFollowedComponent(userId, lifecycleStates, lastStateStates, componentType);
@@ -367,7 +360,7 @@ public class ToscaOperationFacade {
followedResources = topologyTemplateOperation.getFollowedComponent(userId, lifecycleStates, lastStateStates, componentType);
}
- List<T> components = new ArrayList<>();
+ Set<T> components = new HashSet<>();
if (followedResources.isRight() && followedResources.right().value() != StorageOperationStatus.NOT_FOUND) {
return Either.right(followedResources.right().value());
}