aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2020-09-17 15:11:30 +0100
committerS�bastien Determe <sebastien.determe@intl.att.com>2020-10-23 14:49:33 +0000
commita5a46f26d043b70cd9a44fed05b0e8ba184318fb (patch)
tree97582d3263a48658f8a84367684e1eb40ba4624e /catalog-model
parent9714961d2950d00ae66be01e20c1ebb8552a82e9 (diff)
Fix for substitution filter properties
Issue-ID: SDC-3325 Change-Id: If26bf895a0a2f914fb9c2b36e53466df9b7999fe Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java77
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java12
5 files changed, 37 insertions, 68 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
index ba73e77e05..8f58a3c4d2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
@@ -87,6 +87,7 @@ public abstract class Component implements PropertiesOwner {
private Map<String, SubstitutionFilterDataDefinition> substitutionFilterComponents;
private Map<String, InterfaceDefinition> interfaces;
private List<DataTypeDefinition> dataTypes;
+ private SubstitutionFilterDataDefinition substitutionFilter;
public Component(ComponentMetadataDefinition componentMetadataDefinition) {
this.componentMetadataDefinition = componentMetadataDefinition;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java
index 5b99f99bd2..fd4feeb035 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java
@@ -47,7 +47,6 @@ public class ComponentInstance extends ComponentInstanceDataDefinition implement
private Map<String, Object> interfaces;
private List<PropertyDefinition> properties;
private CINodeFilterDataDefinition nodeFilter;
- private SubstitutionFilterDataDefinition substitutionFilter;
private List<InputDefinition> inputs;
public ComponentInstance() {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
index f1785c76f8..505b8e6c7c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
@@ -50,7 +50,6 @@ public class ComponentParametersView {
private boolean ignoreServicePath = true;
private boolean ignorePolicies = false;
private boolean ignoreNodeFilterRequirements = false;
- private boolean ignoreSubstitutionFilterRequirements = false;
private boolean ignoreNodeFilter = false;
private boolean ignoreSubstitutionFilter = false;
private boolean ignoreDataType = false;
@@ -157,7 +156,6 @@ public class ComponentParametersView {
this.setIgnoreNodeFilter(false);
break;
case SUBSTITUTION_FILTER:
- this.setIgnoreSubstitutionFilterRequirements(false);
this.setIgnoreSubstitutionFilter(false);
break;
case COMPONENT_INSTANCES_INTERFACES:
@@ -223,9 +221,6 @@ public class ComponentParametersView {
if (ignoreNodeFilterRequirements){
component.setNodeFilterComponents(null);
}
- if (ignoreSubstitutionFilterRequirements){
- component.setSubstitutionFilterComponents(null);
- }
if (ignoreInterfaces && ignoreInterfaceInstances &&
componentType == ComponentTypeEnum.RESOURCE) {
component.setInterfaces(null);
@@ -268,14 +263,6 @@ public class ComponentParametersView {
this.ignoreNodeFilterRequirements = ignoreNodeFilter;
}
- public boolean isIgnoreSubstitutionFilterRequirements() {
- return ignoreSubstitutionFilterRequirements;
- }
-
- public void setIgnoreSubstitutionFilterRequirements(boolean ignoreSubstitutionFilterRequirements) {
- this.ignoreSubstitutionFilterRequirements = ignoreSubstitutionFilterRequirements;
- }
-
public void disableAll() {
ignoreUsers = true;
ignoreGroups = true;
@@ -299,7 +286,6 @@ public class ComponentParametersView {
ignoreCapabiltyProperties = true;
ignoreServicePath = true;
ignoreNodeFilterRequirements = true;
- ignoreSubstitutionFilterRequirements = true;
ignoreNodeFilter = true;
ignoreSubstitutionFilter = true;
ignoreDataType = true;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java
index 9007e20998..0062e2eaa7 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
import com.google.common.collect.ImmutableList;
import fj.data.Either;
import java.util.List;
+import java.util.Objects;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
@@ -44,78 +45,70 @@ public class SubstitutionFilterOperation extends BaseOperation {
private static final Logger LOGGER = Logger.getLogger(SubstitutionFilterOperation.class);
public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> createSubstitutionFilter(
- final String componentId, final String componentInstanceId) {
+ final String componentId) {
- return addOrUpdateSubstitutionFilter(false, componentId, componentInstanceId,
- new SubstitutionFilterDataDefinition());
+ return addOrUpdateSubstitutionFilter(false, componentId, new SubstitutionFilterDataDefinition());
}
public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> deleteConstraint(
- final String serviceId, final String componentInstanceId,
- final SubstitutionFilterDataDefinition substitutionFilterDataDefinition, final int propertyIndex) {
+ final String serviceId, final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
+ final int propertyIndex) {
final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> properties =
- substitutionFilterDataDefinition.getProperties();
+ substitutionFilterDataDefinition.getProperties();
properties.getListToscaDataDefinition().remove(propertyIndex);
substitutionFilterDataDefinition.setProperties(properties);
- return addOrUpdateSubstitutionFilter(true, serviceId, componentInstanceId, substitutionFilterDataDefinition);
+
+ return addOrUpdateSubstitutionFilter(true, serviceId, substitutionFilterDataDefinition);
}
- public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> addNewProperty(
- final String componentId, final String componentInstanceId,
- final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
- final RequirementSubstitutionFilterPropertyDataDefinition requirementSubstitutionFilterPropertyDataDefinition) {
+ public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> addPropertyFilter(
+ final String componentId, final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
+ final RequirementSubstitutionFilterPropertyDataDefinition substitutionFilterPropertyDataDefinition) {
- ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> properties =
- substitutionFilterDataDefinition.getProperties();
- if (properties == null) {
- properties = new ListDataDefinition<>();
- substitutionFilterDataDefinition.setProperties(properties);
- }
- properties.getListToscaDataDefinition().add(requirementSubstitutionFilterPropertyDataDefinition);
- substitutionFilterDataDefinition.setProperties(properties);
- return addOrUpdateSubstitutionFilter(true, componentId, componentInstanceId, substitutionFilterDataDefinition);
+ final SubstitutionFilterDataDefinition substitutionFilterDataDefinition1 =
+ Objects.requireNonNullElseGet(substitutionFilterDataDefinition, SubstitutionFilterDataDefinition::new);
+ final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> properties =
+ Objects.requireNonNullElseGet(substitutionFilterDataDefinition1.getProperties(), ListDataDefinition::new);
+ properties.getListToscaDataDefinition().add(substitutionFilterPropertyDataDefinition);
+ substitutionFilterDataDefinition1.setProperties(properties);
+ return addOrUpdateSubstitutionFilter(true, componentId, substitutionFilterDataDefinition1);
}
- public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> updateSubstitutionFilter(
- final String serviceId, final String componentInstanceId,
- final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
- final List<RequirementSubstitutionFilterPropertyDataDefinition> requirementSubstitutionFilterPropertyDataDefinitions) {
+ public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> updateProperties(
+ final String componentId, final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
+ final List<RequirementSubstitutionFilterPropertyDataDefinition> requirementSubstitutionFilterPropertyDataDefinition) {
final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> properties =
substitutionFilterDataDefinition.getProperties();
properties.getListToscaDataDefinition().clear();
- properties.getListToscaDataDefinition().addAll(requirementSubstitutionFilterPropertyDataDefinitions);
+ properties.getListToscaDataDefinition().addAll(requirementSubstitutionFilterPropertyDataDefinition);
substitutionFilterDataDefinition.setProperties(properties);
- return addOrUpdateSubstitutionFilter(true, serviceId, componentInstanceId,
- substitutionFilterDataDefinition);
+ return addOrUpdateSubstitutionFilter(true, componentId, substitutionFilterDataDefinition);
}
private Either<SubstitutionFilterDataDefinition, StorageOperationStatus> addOrUpdateSubstitutionFilter(
- final boolean isUpdateAction, final String componentId, final String componentInstanceId,
+ final boolean isUpdateAction, final String componentId,
final SubstitutionFilterDataDefinition substitutionFilterDataDefinition) {
- StorageOperationStatus statusRes;
- Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
-
- getToscaElementRes = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
- if (getToscaElementRes.isRight()) {
- final JanusGraphOperationStatus status = getToscaElementRes.right().value();
+ final Either<GraphVertex, JanusGraphOperationStatus> toscaElementEither =
+ janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ if (toscaElementEither.isRight()) {
+ final JanusGraphOperationStatus status = toscaElementEither.right().value();
CommonUtility.addRecordToLog(LOGGER, CommonUtility.LogLevelEnum.DEBUG,
"Failed to get tosca element {} upon adding the properties. Status is {}. ", componentId, status);
- statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
- return Either.right(statusRes);
+ return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
- final GraphVertex serviceVertex = getToscaElementRes.left().value();
- substitutionFilterDataDefinition.setID(componentInstanceId);
- statusRes = performUpdateToscaAction(isUpdateAction, serviceVertex,
+ final GraphVertex serviceVertex = toscaElementEither.left().value();
+ substitutionFilterDataDefinition.setID(componentId);
+ final StorageOperationStatus operationStatus = performUpdateToscaAction(isUpdateAction, serviceVertex,
ImmutableList.of(substitutionFilterDataDefinition));
- if (!statusRes.equals(StorageOperationStatus.OK)) {
+ if (!StorageOperationStatus.OK.equals(operationStatus)) {
janusGraphDao.rollback();
LOGGER.error(EcompErrorSeverity.ERROR, EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR,
" Failed to perform tosca update for substitution filter in service {} , component instance {}. status is {}",
- componentId, componentInstanceId, statusRes);
- return Either.right(statusRes);
+ componentId, "componentInstanceId", operationStatus);
+ return Either.right(operationStatus);
}
janusGraphDao.commit();
return Either.left(substitutionFilterDataDefinition);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
index 839ae27a19..4d2480f6af 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
@@ -909,14 +909,9 @@ public class ModelConverter {
final Component component) {
final Map<String, SubstitutionFilterDataDefinition> filters = topologyTemplate
.getSubstitutionFilterDataDefinitionMap();
- final Map<String, SubstitutionFilterDataDefinition> copy;
if (MapUtils.isNotEmpty(filters)) {
- copy = filters.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> new SubstitutionFilterDataDefinition(e.getValue())));
- } else {
- copy = new HashMap<>();
+ component.setSubstitutionFilter(filters.get(component.getUniqueId()));
}
- component.setSubstitutionFilterComponents(copy);
}
private static void convertServiceApiArtifacts(TopologyTemplate topologyTemplate, Service service) {
@@ -1361,8 +1356,6 @@ public class ModelConverter {
List<ComponentInstance> componentInstances = new ArrayList<>();
ComponentInstance currComponentInstance;
Map<String, CINodeFilterDataDefinition> nodeFilterComponents = topologyTemplate.getNodeFilterComponents();
- Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap = topologyTemplate
- .getSubstitutionFilterDataDefinitionMap();
for (Map.Entry<String, ComponentInstanceDataDefinition> entry : topologyTemplate.getComponentInstances().entrySet()) {
String key = entry.getKey();
@@ -1375,9 +1368,6 @@ public class ModelConverter {
if(MapUtils.isNotEmpty(nodeFilterComponents) && nodeFilterComponents.containsKey(key)){
currComponentInstance.setNodeFilter(nodeFilterComponents.get(key));
}
- if(MapUtils.isNotEmpty(substitutionFilterDataDefinitionMap) && substitutionFilterDataDefinitionMap.containsKey(key)) {
- currComponentInstance.setSubstitutionFilter(substitutionFilterDataDefinitionMap.get(key));
- }
if(topologyTemplate.getInstProperties() != null && topologyTemplate.getInstProperties().containsKey(key) && topologyTemplate.getInstProperties().get(key) != null ){
List<PropertyDefinition> instanceProps = topologyTemplate.getInstProperties().get(key).getMapToscaDataDefinition().entrySet().stream().map(e -> new PropertyDefinition(e.getValue())).collect(Collectors.toList());
currComponentInstance.setProperties(instanceProps);