summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-07-04 14:45:53 +0100
committerMichael Morris <michael.morris@est.tech>2023-10-11 14:22:03 +0000
commit0d9d05e705a6fbc9c4370fdd3a8ad543d04f8210 (patch)
tree92031d3d2bd92288686fb4c156cbbe02e64389ab
parent98513d2be1f1c5f0fba48a972dea297b784aec68 (diff)
No properties found when trying to add a node filter to a VF
Issue-ID: SDC-4607 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I5df11e156f4bc20ff1d4f19b7af8dfe798631077
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java136
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidatorTest.java150
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts25
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts12
-rw-r--r--catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts7
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts4
6 files changed, 239 insertions, 95 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
index a0716fe4ce..f75abf73a1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.components.validation;
import com.google.gson.Gson;
@@ -30,16 +31,19 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
import org.openecomp.sdc.be.datatypes.enums.PropertySource;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
@@ -84,6 +88,28 @@ public class NodeFilterValidator {
this.filterConstraintValidator = filterConstraintValidator;
}
+ private static List<? extends ToscaPropertyData> getSelfPropertyFromGetFunction(final Component component,
+ final ToscaGetFunctionDataDefinition toscaGetFunction) {
+ switch (toscaGetFunction.getFunctionType()) {
+ case GET_INPUT:
+ if (component.getInputs() != null) {
+ return component.getInputs();
+ }
+ break;
+ case GET_PROPERTY:
+ if (component.getProperties() != null) {
+ return component.getProperties();
+ }
+ break;
+ case GET_ATTRIBUTE:
+ if (component.getAttributes() != null) {
+ return component.getAttributes();
+ }
+ break;
+ }
+ return List.of();
+ }
+
public Either<Boolean, ResponseFormat> validateComponentInstanceExist(final Component component, final String componentInstanceId) {
if (component == null || StringUtils.isEmpty(componentInstanceId)) {
LOGGER.error("Expecting a component and a component instance id, given was '{}' and '{}'", component, componentInstanceId);
@@ -148,23 +174,20 @@ public class NodeFilterValidator {
final List<ToscaGetFunctionDataDefinition> toscaGetFunctionList = filterConstraint.getAsListToscaGetFunction().orElse(null);
if (toscaGetFunctionList == null || toscaGetFunctionList.isEmpty() || !(filterConstraint.getValue() instanceof List)) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.TOSCA_FUNCTION_EXPECTED_ERROR));
- }
- else {
+ } else {
toscaGetFunctionDataDefinitionList = toscaGetFunctionList;
}
- }
- else{
+ } else {
toscaGetFunctionDataDefinitionList.add(toscaGetFunction);
}
Boolean allGood = true;
- for (ToscaGetFunctionDataDefinition _toscaGetFunction: toscaGetFunctionDataDefinitionList) {
+ for (ToscaGetFunctionDataDefinition _toscaGetFunction : toscaGetFunctionDataDefinitionList) {
final Optional<? extends ToscaPropertyData> sourceSelectedProperty =
findPropertyFromGetFunction(parentComponent, _toscaGetFunction);
if (sourceSelectedProperty.isPresent()) {
Optional<? extends PropertyDefinition> targetComponentInstanceProperty =
- getInstanceProperties(parentComponent, componentInstanceId, capabilityName,
- filterConstraint.getPropertyName());
+ getInstanceProperties(parentComponent, componentInstanceId, capabilityName, filterConstraint);
source = targetComponentInstanceProperty.isEmpty() ? TARGET : SOURCE;
if (targetComponentInstanceProperty.isPresent()) {
@@ -176,8 +199,7 @@ public class NodeFilterValidator {
break;
}
- }
- else {
+ } else {
allGood = false;
final String missingProperty =
SOURCE.equals(source) ? filterConstraint.getValue().toString() : filterConstraint.getPropertyName();
@@ -185,8 +207,7 @@ public class NodeFilterValidator {
componentsUtils.getResponseFormat(ActionStatus.FILTER_PROPERTY_NOT_FOUND, source, missingProperty);
break;
}
- }
- else {
+ } else {
allGood = false;
final String missingProperty =
SOURCE.equals(source) ? filterConstraint.getValue().toString() : filterConstraint.getPropertyName();
@@ -249,28 +270,6 @@ public class NodeFilterValidator {
return instanceProperties;
}
- private static List<? extends ToscaPropertyData> getSelfPropertyFromGetFunction(final Component component,
- final ToscaGetFunctionDataDefinition toscaGetFunction) {
- switch (toscaGetFunction.getFunctionType()) {
- case GET_INPUT:
- if (component.getInputs() != null) {
- return component.getInputs();
- }
- break;
- case GET_PROPERTY:
- if (component.getProperties() != null) {
- return component.getProperties();
- }
- break;
- case GET_ATTRIBUTE:
- if (component.getAttributes() != null) {
- return component.getAttributes();
- }
- break;
- }
- return List.of();
- }
-
private Optional<PropertyDefinition> findSubProperty(final List<String> propertyPath, final String parentPropertyType,
final Map<String, DataTypeDefinition> modelDataTypes) {
final DataTypeDefinition dataTypeDefinition = modelDataTypes.get(parentPropertyType);
@@ -288,11 +287,24 @@ public class NodeFilterValidator {
return findSubProperty(propertyPath.subList(1, propertyPath.size()), propertyDefinition.getType(), modelDataTypes);
}
- private Optional<ComponentInstanceProperty> getInstanceProperties(final Component parentComponent, final String componentInstanceId,
- final String capabilityName, final String propertyName) {
+ private Optional<? extends PropertyDefinition> getInstanceProperties(final Component parentComponent, final String componentInstanceId,
+ final String capabilityName, final FilterConstraintDto filterConstraint) {
if (StringUtils.isEmpty(capabilityName)) {
+ OriginTypeEnum componentInstanceType = getComponentInstanceOriginType(parentComponent, componentInstanceId);
+ if (componentInstanceType == null) {
+ return Optional.empty();
+ }
+ PropertyDefinition componentInstanceProperty =
+ getComponentInstanceProperty(componentInstanceType, parentComponent, componentInstanceId, filterConstraint);
+ if (componentInstanceProperty == null) {
+ throw new ByActionStatusComponentException(ActionStatus.SELECTED_PROPERTY_NOT_PRESENT, filterConstraint.getPropertyName());
+ }
+ if (componentInstanceProperty instanceof ComponentInstanceInput) {
+ return parentComponent.getComponentInstancesInputs().get(componentInstanceId).stream()
+ .filter(property -> filterConstraint.getPropertyName().equals(property.getName())).findFirst();
+ }
return parentComponent.getComponentInstancesProperties().get(componentInstanceId).stream()
- .filter(property -> propertyName.equals(property.getName())).findFirst();
+ .filter(property -> filterConstraint.getPropertyName().equals(property.getName())).findFirst();
} else {
final Optional<ComponentInstance> componentInstanceOptional = parentComponent.getComponentInstances().stream()
.filter(componentInstance -> componentInstance.getUniqueId().equals(componentInstanceId)).findAny();
@@ -300,7 +312,8 @@ public class NodeFilterValidator {
for (final List<CapabilityDefinition> listOfCaps : componentInstanceOptional.get().getCapabilities().values()) {
final Optional<CapabilityDefinition> capDef = listOfCaps.stream().filter(cap -> cap.getName().equals(capabilityName)).findAny();
if (capDef.isPresent()) {
- return capDef.get().getProperties().stream().filter(property -> propertyName.equals(property.getName())).findFirst();
+ return capDef.get().getProperties().stream().filter(property -> filterConstraint.getPropertyName().equals(property.getName()))
+ .findFirst();
}
}
}
@@ -322,8 +335,7 @@ public class NodeFilterValidator {
if (optValid.isPresent()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.TOSCA_FUNCTION_EXPECTED_ERROR));
}
- }
- else {
+ } else {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.TOSCA_FUNCTION_EXPECTED_ERROR));
}
}
@@ -414,9 +426,8 @@ public class NodeFilterValidator {
}
}
return null;
- }
- else {
- if (null != ((PropertyDefinition) sourcePropDefinition).getSchemaProperty()){
+ } else {
+ if (null != ((PropertyDefinition) sourcePropDefinition).getSchemaProperty()) {
if (((PropertyDefinition) sourcePropDefinition).getSchemaProperty().getType().equals(targetType)) {
if (TYPES_WITH_SCHEMA.contains(((PropertyDefinition) sourcePropDefinition).getSchemaProperty().getType())) {
final String sourceSchemaType = sourcePropDefinition.getSchemaType();
@@ -431,8 +442,7 @@ public class NodeFilterValidator {
}
}
}
- }
- else {
+ } else {
if (sourceType.equalsIgnoreCase("integer")) {
if (TYPES_WITH_SCHEMA.contains(sourceType)) {
final String sourceSchemaType = sourcePropDefinition.getSchemaType();
@@ -451,10 +461,12 @@ public class NodeFilterValidator {
private Either<Boolean, ResponseFormat> validateStaticValueAndOperator(final Component parentComponent, final String componentInstanceId,
final FilterConstraintDto filterConstraint) {
- final ComponentInstanceProperty componentInstanceProperty = parentComponent.getComponentInstancesProperties()
- .get(componentInstanceId).stream().filter(property -> filterConstraint.getPropertyName().equals(property.getName()))
- .findFirst()
- .orElse(null);
+ OriginTypeEnum componentInstanceType = getComponentInstanceOriginType(parentComponent, componentInstanceId);
+ if (componentInstanceType == null) {
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND, componentInstanceId));
+ }
+ PropertyDefinition componentInstanceProperty =
+ getComponentInstanceProperty(componentInstanceType, parentComponent, componentInstanceId, filterConstraint);
if (componentInstanceProperty == null) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.SELECTED_PROPERTY_NOT_PRESENT, filterConstraint.getPropertyName()));
}
@@ -474,6 +486,34 @@ public class NodeFilterValidator {
filterConstraint.getValue(), filterConstraint.getPropertyName());
}
+ private PropertyDefinition getComponentInstanceProperty(OriginTypeEnum componentInstanceType, Component parentComponent,
+ String componentInstanceId, FilterConstraintDto filterConstraint) {
+ if (isInput(componentInstanceType)) {
+ return parentComponent.getComponentInstancesInputs()
+ .get(componentInstanceId).stream().filter(input -> filterConstraint.getPropertyName().equals(input.getName()))
+ .findFirst()
+ .orElse(null);
+ }
+ return parentComponent.getComponentInstancesProperties()
+ .get(componentInstanceId).stream().filter(property -> filterConstraint.getPropertyName().equals(property.getName()))
+ .findFirst()
+ .orElse(null);
+ }
+
+ private OriginTypeEnum getComponentInstanceOriginType(Component parentComponent, String componentInstanceId) {
+ Optional<ComponentInstance> componentInstanceOptional = parentComponent.getComponentInstanceById(componentInstanceId);
+ if (componentInstanceOptional.isPresent()) {
+ ComponentInstance componentInstance = componentInstanceOptional.get();
+ return componentInstance.getOriginType();
+ }
+ return null;
+ }
+
+ private boolean isInput(OriginTypeEnum instanceType) {
+ return OriginTypeEnum.VF.equals(instanceType) || OriginTypeEnum.PNF.equals(instanceType) || OriginTypeEnum.CVFC.equals(instanceType) ||
+ OriginTypeEnum.CR.equals(instanceType);
+ }
+
private Either<Boolean, ResponseFormat> validateStaticSubstitutionFilter(final Component component,
final FilterConstraintDto filterConstraint) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidatorTest.java
index ef5f7a0a84..cf6bc72256 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidatorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/NodeFilterValidatorTest.java
@@ -34,12 +34,14 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
@@ -48,11 +50,13 @@ import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.datatypes.enums.FilterValueType;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
import org.openecomp.sdc.be.datatypes.enums.PropertySource;
import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -82,6 +86,33 @@ class NodeFilterValidatorTest {
private NodeFilterValidator nodeFilterValidator;
private FilterConstraintDto baseFilterConstraintDto;
+ protected static ToscaGetFunctionDataDefinition createToscaGetFunction(final String sourceName,
+ final PropertySource propertySource,
+ final ToscaGetFunctionType toscaGetFunctionType,
+ final List<String> propertyPathFromSource,
+ final List<Object> toscaIndexList) {
+ final var toscaGetFunction = new ToscaGetFunctionDataDefinition();
+ toscaGetFunction.setFunctionType(toscaGetFunctionType);
+ toscaGetFunction.setPropertyPathFromSource(propertyPathFromSource);
+ toscaGetFunction.setSourceName(sourceName);
+ toscaGetFunction.setPropertySource(propertySource);
+ toscaGetFunction.setPropertyName(propertyPathFromSource.get(0));
+ toscaGetFunction.setToscaIndexList(toscaIndexList);
+ return toscaGetFunction;
+ }
+
+ private static FilterConstraintDto buildFilterConstraintDto(final String propertyName, final FilterValueType valueType,
+ final ConstraintType constraintType,
+ final PropertyFilterTargetType targetType, Object value) {
+ final var filterConstraintDto = new FilterConstraintDto();
+ filterConstraintDto.setPropertyName(propertyName);
+ filterConstraintDto.setValueType(valueType);
+ filterConstraintDto.setOperator(constraintType);
+ filterConstraintDto.setTargetType(targetType);
+ filterConstraintDto.setValue(value);
+ return filterConstraintDto;
+ }
+
@BeforeEach
void setup() {
componentsUtils = Mockito.mock(ComponentsUtils.class);
@@ -106,9 +137,9 @@ class NodeFilterValidatorTest {
assertEquals(expectedResponse, either.right().value());
Service service = createService("booleanIncorrect");
- when(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND, service.getName(), INNER_SERVICE))
+ when(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND, service.getName(), "uniqueId"))
.thenReturn(expectedResponse);
- either = nodeFilterValidator.validateComponentInstanceExist(service, INNER_SERVICE);
+ either = nodeFilterValidator.validateComponentInstanceExist(service, "uniqueId");
assertTrue(either.isRight());
assertEquals(expectedResponse, either.right().value());
@@ -451,11 +482,8 @@ class NodeFilterValidatorTest {
PropertyFilterTargetType.PROPERTY,
toscaGetFunction
);
- final Either<Boolean, ResponseFormat> validationResult =
- nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto));
-
- assertTrue(validationResult.isRight());
- assertEquals(expectedResponse, validationResult.right().value());
+ Assertions.assertThrows(ComponentException.class,
+ () -> nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto)));
}
@Test
@@ -474,26 +502,8 @@ class NodeFilterValidatorTest {
final ResponseFormat expectedResponse = new ResponseFormat();
when(componentsUtils.getResponseFormat(ActionStatus.FILTER_PROPERTY_NOT_FOUND, "Target", PROPERTY_NAME))
.thenReturn(expectedResponse);
- Either<Boolean, ResponseFormat> either =
- nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto));
-
- assertTrue(either.isRight());
- assertEquals(expectedResponse, either.right().value());
- }
-
- protected static ToscaGetFunctionDataDefinition createToscaGetFunction(final String sourceName,
- final PropertySource propertySource,
- final ToscaGetFunctionType toscaGetFunctionType,
- final List<String> propertyPathFromSource,
- final List<Object> toscaIndexList) {
- final var toscaGetFunction = new ToscaGetFunctionDataDefinition();
- toscaGetFunction.setFunctionType(toscaGetFunctionType);
- toscaGetFunction.setPropertyPathFromSource(propertyPathFromSource);
- toscaGetFunction.setSourceName(sourceName);
- toscaGetFunction.setPropertySource(propertySource);
- toscaGetFunction.setPropertyName(propertyPathFromSource.get(0));
- toscaGetFunction.setToscaIndexList(toscaIndexList);
- return toscaGetFunction;
+ Assertions.assertThrows(ComponentException.class,
+ () -> nodeFilterValidator.validateFilter(service, COMPONENT1_ID, List.of(filterConstraintDto)));
}
@Test
@@ -528,6 +538,71 @@ class NodeFilterValidatorTest {
assertEquals(expectedResponse, either.right().value());
}
+ @Test
+ void testValidateNodeFilterForVfStaticValue() {
+ Service service = createService(ToscaPropertyType.INTEGER.getType());
+ addComponentInstanceToService(service, OriginTypeEnum.VF, "vfInstance", ToscaPropertyType.INTEGER.getType());
+ baseFilterConstraintDto.setValue(1);
+ Either<Boolean, ResponseFormat> validationResult =
+ nodeFilterValidator.validateFilter(service, "vfInstance", List.of(baseFilterConstraintDto));
+
+ assertTrue(validationResult.isLeft());
+ }
+
+ @Test
+ void testValidateNodeFilterForVfToscaGetProperty() {
+ Service service = createService(ToscaPropertyType.INTEGER.getType());
+ addComponentInstanceToService(service, OriginTypeEnum.VF, "vfInstance", ToscaPropertyType.INTEGER.getType());
+ final ToscaGetFunctionDataDefinition toscaGetFunction =
+ createToscaGetFunction(PARENT_SERVICE_ID, PropertySource.SELF, ToscaGetFunctionType.GET_PROPERTY, List.of(PROPERTY_NAME), null);
+ final var filterConstraintDto = buildFilterConstraintDto(
+ PROPERTY_NAME,
+ FilterValueType.GET_PROPERTY,
+ ConstraintType.EQUAL,
+ PropertyFilterTargetType.PROPERTY,
+ toscaGetFunction
+ );
+ Either<Boolean, ResponseFormat> validationResult =
+ nodeFilterValidator.validateFilter(service, "vfInstance", List.of(filterConstraintDto));
+
+ assertTrue(validationResult.isLeft());
+ }
+
+ private void addComponentInstanceToService(Service service, OriginTypeEnum originTypeEnum, String instanceName, String type) {
+ ComponentInstance componentInstance = new ComponentInstance();
+ componentInstance.setUniqueId(instanceName);
+ componentInstance.setName(instanceName);
+ componentInstance.setOriginType(originTypeEnum);
+
+ List<ComponentInstance> compInstances = new ArrayList<>();
+ service.getComponentInstances().forEach(compInstance -> compInstances.add(compInstance));
+ compInstances.add(componentInstance);
+ service.setComponentInstances(compInstances);
+
+ if (isInput(originTypeEnum)) {
+ ComponentInstanceInput componentInstanceInput = new ComponentInstanceInput();
+ componentInstanceInput.setName(PROPERTY_NAME);
+ componentInstanceInput.setType(type);
+ if (service.getComponentInstancesInputs() == null) {
+ service.setComponentInstancesInputs(new HashMap<>());
+ }
+ service.getComponentInstancesInputs().put(instanceName, Collections.singletonList(componentInstanceInput));
+ } else {
+ ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
+ componentInstanceProperty.setName(PROPERTY_NAME);
+ componentInstanceProperty.setType(type);
+ if (service.getComponentInstancesProperties() == null) {
+ service.setComponentInstancesProperties(new HashMap<>());
+ }
+ service.getComponentInstancesProperties().put(instanceName, Collections.singletonList(componentInstanceProperty));
+ }
+ }
+
+ private boolean isInput(OriginTypeEnum instanceType) {
+ return OriginTypeEnum.VF.equals(instanceType) || OriginTypeEnum.PNF.equals(instanceType) || OriginTypeEnum.CVFC.equals(instanceType) ||
+ OriginTypeEnum.CR.equals(instanceType);
+ }
+
private Service createService(String type) {
return createService(type, null);
}
@@ -551,12 +626,19 @@ class NodeFilterValidatorTest {
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setUniqueId(COMPONENT1_ID);
componentInstance.setName(COMPONENT1_ID);
+ componentInstance.setOriginType(OriginTypeEnum.VFC);
ComponentInstance componentInstance2 = new ComponentInstance();
componentInstance2.setUniqueId(COMPONENT2_ID);
componentInstance2.setName(COMPONENT2_ID);
+ componentInstance2.setOriginType(OriginTypeEnum.VFC);
+
+ ComponentInstance componentInstance3 = new ComponentInstance();
+ componentInstance3.setUniqueId(INNER_SERVICE);
+ componentInstance3.setName(INNER_SERVICE);
+ componentInstance3.setOriginType(OriginTypeEnum.ServiceProxy);
- service.setComponentInstances(Arrays.asList(componentInstance, componentInstance2));
+ service.setComponentInstances(Arrays.asList(componentInstance, componentInstance2, componentInstance3));
ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
componentInstanceProperty.setName(PROPERTY_NAME);
@@ -578,16 +660,4 @@ class NodeFilterValidatorTest {
return service;
}
- private static FilterConstraintDto buildFilterConstraintDto(final String propertyName, final FilterValueType valueType,
- final ConstraintType constraintType,
- final PropertyFilterTargetType targetType, Object value) {
- final var filterConstraintDto = new FilterConstraintDto();
- filterConstraintDto.setPropertyName(propertyName);
- filterConstraintDto.setValueType(valueType);
- filterConstraintDto.setOperator(constraintType);
- filterConstraintDto.setTargetType(targetType);
- filterConstraintDto.setValue(value);
- return filterConstraintDto;
- }
-
}
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts
index 7ca4604004..ace5a18f22 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/service-dependencies-tab/service-dependencies-tab.component.ts
@@ -26,13 +26,15 @@ import {
Component as TopologyTemplate,
FullComponentInstance,
PropertiesGroup,
- PropertyBEModel, PropertyModel,
+ PropertyBEModel, PropertyModel, ComponentInstance,
} from 'app/models';
+import {ResourceType} from "app/utils";
import {DEPENDENCY_EVENTS} from 'app/utils/constants';
import {ComponentMetadata} from '../../../../../../models/component-metadata';
import {ServiceInstanceObject} from '../../../../../../models/service-instance-properties-and-interfaces';
import {EventListenerService} from '../../../../../../services/event-listener-service';
import {TopologyTemplateService} from '../../../../../services/component-services/topology-template.service';
+import {ComponentInstanceServiceNg2} from '../../../../../services/component-instance-services/component-instance.service';
import {ComponentGenericResponse} from '../../../../../services/responses/component-generic-response';
import {WorkspaceService} from '../../../../workspace/workspace.service';
import {SelectedComponentType} from '../../../common/store/graph.actions';
@@ -63,6 +65,7 @@ export class ServiceDependenciesTabComponent implements OnInit {
constructor(private store: Store,
private topologyTemplateService: TopologyTemplateService,
+ private componentInstanceServiceNg2: ComponentInstanceServiceNg2,
private workspaceService: WorkspaceService,
private compositionService: CompositionService,
private eventListenerService: EventListenerService) {
@@ -98,10 +101,22 @@ export class ServiceDependenciesTabComponent implements OnInit {
}
private initInstancesWithProperties = (): void => {
- this.topologyTemplateService.getComponentInstanceProperties(this.metaData.componentType, this.metaData.uniqueId).subscribe((genericResponse: ComponentGenericResponse) => {
- this.componentInstanceProperties = genericResponse.componentInstancesProperties;
- this.updateInstanceAttributes();
- });
+ if (this.component instanceof FullComponentInstance && this.isInput(this.component.resourceType)) {
+ this.componentInstanceServiceNg2
+ .getComponentInstanceInputsByIdAndType(this.metaData.uniqueId, this.metaData.componentType, this.component as ComponentInstance)
+ .subscribe(response => {
+ this.selectedInstanceProperties = response;
+ });
+ } else {
+ this.topologyTemplateService.getComponentInstanceProperties(this.metaData.componentType, this.metaData.uniqueId).subscribe((genericResponse: ComponentGenericResponse) => {
+ this.componentInstanceProperties = genericResponse.componentInstancesProperties;
+ this.updateInstanceAttributes();
+ });
+ }
+ }
+
+ private isInput = (instanceType:string):boolean =>{
+ return instanceType === ResourceType.VF || instanceType === ResourceType.PNF || instanceType === ResourceType.CVFC || instanceType === ResourceType.CR;
}
private updateInstanceAttributes = (): void => {
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
index 67df3e46e1..8c84c0e1a8 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts
@@ -33,6 +33,7 @@ import {InstanceFeDetails} from "../../../../../models/instance-fe-details";
import {ToscaGetFunction} from "../../../../../models/tosca-get-function";
import {FormControl, FormGroup, Validators} from "@angular/forms";
import {ToscaGetFunctionTypeConverter} from "../../../../../models/tosca-get-function-type-converter";
+import {ResourceType} from "app/utils";
@Component({
selector: 'app-tosca-get-function',
@@ -367,6 +368,10 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
if (this.isPropertySourceSelf()) {
return componentGenericResponse.properties;
}
+ let componentInstanceInput = componentGenericResponse.componentInstances.find(compInst => this.isInput(compInst.originType) && compInst.uniqueId === instanceId);
+ if ( componentInstanceInput) {
+ return this.removeSelectedProperty(componentGenericResponse.componentInstancesInputs[instanceId]);
+ }
return this.removeSelectedProperty(componentGenericResponse.componentInstancesProperties[instanceId]);
}
if (this.isPropertySourceSelf()) {
@@ -376,6 +381,10 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
...(componentGenericResponse.componentInstancesProperties[instanceId] || [])];
}
+ private isInput (instanceType:string): boolean {
+ return instanceType === ResourceType.VF || instanceType === ResourceType.PNF || instanceType === ResourceType.CVFC || instanceType === ResourceType.CR;
+ }
+
private isPropertySourceSelf() {
return this.propertySource.value === PropertySource.SELF;
}
@@ -388,7 +397,8 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges {
if (this.isPropertySourceSelf()) {
return this.topologyTemplateService.findAllComponentProperties(this.componentMetadata.componentType, this.componentMetadata.uniqueId);
}
- return this.topologyTemplateService.getComponentInstanceProperties(this.componentMetadata.componentType, this.componentMetadata.uniqueId);
+ return this.topologyTemplateService.getComponentInstancesAndInputsAndProperties(this.componentMetadata.componentType, this.componentMetadata.uniqueId);
+ // return this.topologyTemplateService.getComponentInstanceInputsAndProperties(this.componentMetadata.componentType, this.componentMetadata.uniqueId);
}
if (this.isGetAttribute()) {
if (this.isPropertySourceSelf()) {
diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
index 1e4ddda9c0..c2258fd01e 100644
--- a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
@@ -72,7 +72,12 @@ export class ComponentInstanceServiceNg2 {
}
getComponentInstanceInputs(component: Component, componentInstance: ComponentInstance): Observable<Array<PropertyBEModel>> {
- return this.http.get<Array<InputBEModel>>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstance.uniqueId + '/' + componentInstance.componentUid + '/inputs')
+ return this.getComponentInstanceInputsByIdAndType(component.uniqueId, component.componentType, componentInstance);
+ }
+
+
+ getComponentInstanceInputsByIdAndType(componentId: string, componentType:string, componentInstance: ComponentInstance): Observable<Array<PropertyBEModel>> {
+ return this.http.get<Array<InputBEModel>>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/componentInstances/' + componentInstance.uniqueId + '/' + componentInstance.componentUid + '/inputs')
.map(res => {
return CommonUtils.initInputs(res);
})
diff --git a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts
index 405d2bb8af..fce785e9e6 100644
--- a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts
@@ -480,6 +480,10 @@ export class TopologyTemplateService {
return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES]);
}
+ getComponentInstancesAndInputsAndProperties(componentType: string, componentId: string): Observable<ComponentGenericResponse> {
+ return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_INSTANCES ,COMPONENT_FIELDS.COMPONENT_INSTANCES_INPUTS, COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES]);
+ }
+
findAllComponentInstanceAttributes(componentType: string, componentId: string): Observable<ComponentGenericResponse> {
return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_ATTRIBUTES]);
}