summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java20
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java36
-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/ComponentParametersView.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java3
-rw-r--r--catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts5
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts2
-rw-r--r--catalog-ui/src/app/ng2/services/responses/component-generic-response.ts6
11 files changed, 69 insertions, 30 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
index 8439ffbefd..706f7a7304 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
@@ -50,7 +50,6 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.tosca.utils.NodeFilterConverter;
import org.openecomp.sdc.be.tosca.utils.SubstitutionFilterConverter;
-import org.openecomp.sdc.be.ui.model.UINodeFilter;
import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
import org.openecomp.sdc.be.ui.model.UiComponentMetadata;
import org.openecomp.sdc.be.ui.model.UiResourceDataTransfer;
@@ -177,10 +176,11 @@ public class UiComponentDataConverter {
}
private void setSubstitutionFilter(final UiComponentDataTransfer dataTransfer, final Component component) {
- if (component.getSubstitutionFilterComponents() == null) {
- dataTransfer.setSubstitutionFilter(null);
+ if (component.getSubstitutionFilter() == null) {
+ dataTransfer.setSubstitutionFilters(null);
} else {
- dataTransfer.setSubstitutionFilter(component.getSubstitutionFilterComponents());
+ final SubstitutionFilterConverter substitutionFilterConverter = new SubstitutionFilterConverter();
+ dataTransfer.setSubstitutionFilters(substitutionFilterConverter.convertToUi(component.getSubstitutionFilter()));
}
}
@@ -387,12 +387,10 @@ public class UiComponentDataConverter {
break;
case SUBSTITUTION_FILTER:
if (resource.getSubstitutionFilter() == null) {
- dataTransfer.setSubstitutionFilterForTopologyTemplate(null);
+ dataTransfer.setSubstitutionFilters(null);
} else {
final SubstitutionFilterConverter substitutionFilterConverter = new SubstitutionFilterConverter();
- final Map<String, UINodeFilter> filterUiMap = new HashMap<>();
- filterUiMap.put(resource.getUniqueId(), substitutionFilterConverter.convertToUi(resource.getSubstitutionFilter()));
- dataTransfer.setSubstitutionFilterForTopologyTemplate(filterUiMap);
+ dataTransfer.setSubstitutionFilters(substitutionFilterConverter.convertToUi(resource.getSubstitutionFilter()));
}
break;
case NODE_FILTER:
@@ -458,12 +456,10 @@ public class UiComponentDataConverter {
break;
case SUBSTITUTION_FILTER:
if (service.getSubstitutionFilter() == null) {
- dataTransfer.setSubstitutionFilterForTopologyTemplate(null);
+ dataTransfer.setSubstitutionFilters(null);
} else {
final SubstitutionFilterConverter substitutionFilterConverter = new SubstitutionFilterConverter();
- final Map<String, UINodeFilter> filterUiMap = new HashMap<>();
- filterUiMap.put(service.getUniqueId(), substitutionFilterConverter.convertToUi(service.getSubstitutionFilter()));
- dataTransfer.setSubstitutionFilterForTopologyTemplate(filterUiMap);
+ dataTransfer.setSubstitutionFilters(substitutionFilterConverter.convertToUi(service.getSubstitutionFilter()));
}
break;
default:
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java
index f163b51f66..9864cf456d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/UiComponentDataConverterTest.java
@@ -19,7 +19,10 @@
package org.openecomp.sdc.be.datamodel;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.hibernate.validator.internal.util.CollectionHelper.asSet;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -43,6 +46,8 @@ import org.openecomp.sdc.be.components.utils.ServiceBuilder;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetPolicyValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RequirementSubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.GroupDefinition;
@@ -53,6 +58,7 @@ import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.ui.model.UIConstraint;
import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
import org.openecomp.sdc.be.ui.model.UiComponentMetadata;
import org.openecomp.sdc.be.ui.model.UiServiceDataTransfer;
@@ -322,7 +328,7 @@ public class UiComponentDataConverterTest {
UiComponentDataTransfer uiComponentDataTransfer = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resource,
Collections.singletonList("substitutionFilter"));
- assertThat(uiComponentDataTransfer.getSubstitutionFilter()).isNull();
+ assertThat(uiComponentDataTransfer.getSubstitutionFilters()).isNull();
}
@Test
@@ -330,13 +336,39 @@ public class UiComponentDataConverterTest {
SubstitutionFilterDataDefinition substitutionFilter = new SubstitutionFilterDataDefinition();
substitutionFilter.setID(SUBSTITUTION_FILTER_UID);
+ final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> expectedPropertyFilters = new ListDataDefinition<>();
+ var filter1 = new RequirementSubstitutionFilterPropertyDataDefinition();
+ filter1.setName("filter1");
+ filter1.setConstraints(Collections.singletonList("constraint1: {equal: testvalue1}\n"));
+ expectedPropertyFilters.add(filter1);
+
+ var filter2 = new RequirementSubstitutionFilterPropertyDataDefinition();
+ filter2.setName("filter2");
+ filter2.setConstraints(Collections.singletonList("constraint2: {equal: testvalue2}\n"));
+ expectedPropertyFilters.add(filter2);
+
+ substitutionFilter.setProperties(expectedPropertyFilters);
+
Resource resource = new ResourceBuilder().build();
resource.setSubstitutionFilter(substitutionFilter);
UiComponentDataTransfer uiComponentDataTransfer = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resource,
Collections.singletonList("substitutionFilter"));
+ assertThat(uiComponentDataTransfer.getSubstitutionFilters()).isNotNull();
+
+ List<UIConstraint> propertyFilters = uiComponentDataTransfer.getSubstitutionFilters().getProperties();
+ assertFalse(propertyFilters.isEmpty());
+ assertEquals(propertyFilters.size(), substitutionFilter.getProperties().getListToscaDataDefinition().size());
+
+ verifyPropertyFilters(propertyFilters.get(0), "constraint1", "testvalue1", "static", "equal");
+ verifyPropertyFilters(propertyFilters.get(1), "constraint2", "testvalue2", "static", "equal");
+ }
- assertThat(uiComponentDataTransfer.getSubstitutionFilterForTopologyTemplate()).isNotEmpty();
+ private void verifyPropertyFilters(UIConstraint uiConstraint, String propertyName, String value, String sourceType, String operator){
+ assertEquals(propertyName, uiConstraint.getServicePropertyName());
+ assertEquals(value, uiConstraint.getValue());
+ assertEquals(sourceType, uiConstraint.getSourceType());
+ assertEquals(operator, uiConstraint.getConstraintOperator());
}
private Resource buildResourceWithGroups() {
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 05cf94a266..dee4088d04 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,7 +87,6 @@ public abstract class Component implements PropertiesOwner {
private String derivedFromGenericVersion;
private String toscaType;
private Map<String, CINodeFilterDataDefinition> nodeFilterComponents;
- private Map<String, SubstitutionFilterDataDefinition> substitutionFilterComponents;
private Map<String, InterfaceDefinition> interfaces;
private List<DataTypeDefinition> dataTypes;
private SubstitutionFilterDataDefinition substitutionFilter;
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 e55c454829..4b5533fe84 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
@@ -263,7 +263,7 @@ public class ComponentParametersView {
component.setNodeFilterComponents(null);
}
if (ignoreSubstitutionFilter) {
- component.setSubstitutionFilterComponents(null);
+ component.setSubstitutionFilter(null);
}
if (ignoreDataType) {
component.setDataTypes(null);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
index 348b849719..1438454389 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
@@ -77,7 +77,7 @@ public class TopologyTemplate extends ToscaElement {
private Map<String, MapInterfaceInstanceDataDefinition> instInterfaces;
private Map<String, MapInterfaceDataDefinition> componentInstInterfaces;
private Map<String, CINodeFilterDataDefinition> nodeFilterComponents;
- private Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap;
+ private SubstitutionFilterDataDefinition substitutionFilters;
//-----------------------------------------------------------------------
private Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs;
//Component Instances External References (instanceId -> ExternalRefsMap)
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
index 0ca76b5304..3827cc5999 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
@@ -88,6 +88,9 @@ import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
+import org.openecomp.sdc.common.log.elements.ErrorLogOptionalData;
+import org.openecomp.sdc.common.log.enums.EcompErrorSeverity;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -971,7 +974,16 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
final Either<Map<String, SubstitutionFilterDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
EdgeLabelEnum.SUBSTITUTION_FILTER_TEMPLATE);
if (result.isLeft()) {
- topologyTemplate.setSubstitutionFilterDataDefinitionMap(result.left().value());
+ final Map<String, SubstitutionFilterDataDefinition> filters = result.left().value();
+ if (MapUtils.isEmpty(filters)) {
+ return JanusGraphOperationStatus.OK;
+ }
+ if(filters.values().size() > 1) {
+ log.error(EcompLoggerErrorCode.DATA_ERROR, TopologyTemplateOperation.class.getName(),
+ (ErrorLogOptionalData) null, "Only a single substitution filter is expected, but got '{}'", filters.values().size());
+ return JanusGraphOperationStatus.GENERAL_ERROR;
+ }
+ topologyTemplate.setSubstitutionFilters(new SubstitutionFilterDataDefinition(filters.values().iterator().next()));
} else {
if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
return result.right().value();
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 8b0ef75e43..225a068aaf 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
@@ -902,10 +902,12 @@ public class ModelConverter {
}
private static void convertSubstitutionFiltersComponents(final TopologyTemplate topologyTemplate, final Component component) {
- final Map<String, SubstitutionFilterDataDefinition> filters = topologyTemplate.getSubstitutionFilterDataDefinitionMap();
- if (MapUtils.isNotEmpty(filters)) {
- component.setSubstitutionFilter(filters.get(component.getUniqueId()));
+ final SubstitutionFilterDataDefinition filters = topologyTemplate.getSubstitutionFilters();
+ if (filters == null){
+ component.setSubstitutionFilter(null);
+ return;
}
+ component.setSubstitutionFilter(new SubstitutionFilterDataDefinition(filters));
}
private static void convertServiceApiArtifacts(TopologyTemplate topologyTemplate, Service service) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
index 92149143e6..96c1613d5a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
@@ -73,9 +73,8 @@ public class UiComponentDataTransfer {
private List<GroupDefinition> groups;
private Map<String, InterfaceDefinition> interfaces;
private Map<String, CINodeFilterDataDefinition> nodeFilter;
- private Map<String, SubstitutionFilterDataDefinition> substitutionFilter;
+ private UINodeFilter substitutionFilters;
private Map<String, UINodeFilter> nodeFilterforNode;
- private Map<String, UINodeFilter> substitutionFilterForTopologyTemplate;
private List<PropertyDefinition> properties;
private List<AttributeDefinition> attributes;
private Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces;
diff --git a/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts b/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts
index aade8d8b73..e0754af549 100644
--- a/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts
+++ b/catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts
@@ -157,9 +157,8 @@ export class SubstitutionFilterComponent {
private loadSubstitutionFilter = (): void => {
this.topologyTemplateService.getSubstitutionFilterConstraints(this.compositeService.componentType, this.compositeService.uniqueId)
.subscribe((response) => {
- if (response.substitutionFilterForTopologyTemplate && response.substitutionFilterForTopologyTemplate[this.compositeService.uniqueId]) {
- this.constraintProperties = response.
- substitutionFilterForTopologyTemplate[this.compositeService.uniqueId].properties;
+ if(response.substitutionFilters) {
+ this.constraintProperties = response.substitutionFilters.properties;
}
});
}
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts
index 2b5648c27f..c4101ab2bc 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts
@@ -71,7 +71,7 @@ export class SubstitutionFilterTabComponent {
public loadConstraints = (): void => {
this.topologyTemplateService.getSubstitutionFilterConstraints(this.metaData.componentType, this.metaData.uniqueId).subscribe((response) => {
- this.componentInstancesConstraints = response.substitutionFilterForTopologyTemplate;
+ this.componentInstancesConstraints = response.substitutionFilters;
});
}
diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
index 784a3d0ac9..6011aabec8 100644
--- a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
+++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
@@ -58,7 +58,7 @@ export class ComponentGenericResponse implements Serializable<ComponentGenericR
public additionalInformation:any;
public derivedList:Array<any>;
public nodeFilterforNode: Array<any>;
- public substitutionFilterForTopologyTemplate: Array<any>;
+ public substitutionFilters: any;
public derivedFromGenericType;
public derivedFromGenericVersion;
@@ -129,8 +129,8 @@ export class ComponentGenericResponse implements Serializable<ComponentGenericR
if(response.nodeFilterforNode) {
this.nodeFilterforNode = response.nodeFilterforNode;
}
- if(response.substitutionFilterForTopologyTemplate) {
- this.substitutionFilterForTopologyTemplate = response.substitutionFilterForTopologyTemplate;
+ if(response.substitutionFilters) {
+ this.substitutionFilters = response.substitutionFilters;
}
if(response.derivedFromGenericType) {
this.derivedFromGenericType = response.derivedFromGenericType;