Add node filter with getInput function 77/125877/4
authoraribeiro <anderson.ribeiro@est.tech>
Thu, 18 Nov 2021 10:29:39 +0000 (10:29 +0000)
committerMichael Morris <michael.morris@est.tech>
Mon, 6 Dec 2021 11:51:31 +0000 (11:51 +0000)
Support get_input functions for creating node and substitution filters

Issue-ID: SDC-3793
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: Ie00f621be8418b4a9c88afcbbc07d80c22165e9b

catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts
catalog-ui/src/app/ng2/components/logic/substitution-filter/substitution-filter.component.ts
catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.html
catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/substitution-filter-tab/substitution-filter-tab.component.ts
catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.html
catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts
catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceDependenciesEditor.java

index 6bfe26a..eddc8ff 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Objects;
 import java.util.Optional;
 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.ResponseFormatManager;
 import org.openecomp.sdc.be.components.impl.utils.NodeFilterConstraintAction;
@@ -40,6 +41,7 @@ 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.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.InputDefinition;
 import org.openecomp.sdc.be.model.PropertyDefinition;
 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
 import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
@@ -48,7 +50,6 @@ import org.openecomp.sdc.exception.ResponseFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.CollectionUtils;
 
 @org.springframework.stereotype.Component("NodeFilterValidator")
 public class NodeFilterValidator {
@@ -100,7 +101,15 @@ public class NodeFilterValidator {
                         if (booleanResponseFormatEither.isRight()) {
                             return booleanResponseFormatEither;
                         }
-                    } else if (ConstraintConvertor.STATIC_CONSTRAINT.equals(constraint.getSourceType())) {
+                    }
+                    else if (ConstraintConvertor.SERVICE_INPUT_CONSTRAINT.equals(constraint.getSourceType())) {
+                        final Either<Boolean, ResponseFormat> booleanResponseFormatEither = validateInputConstraint(parentComponent,
+                            componentInstanceId, constraint);
+                        if (booleanResponseFormatEither.isRight()) {
+                            return booleanResponseFormatEither;
+                        }
+                    }
+                    else if (ConstraintConvertor.STATIC_CONSTRAINT.equals(constraint.getSourceType())) {
                         Either<Boolean, ResponseFormat> booleanResponseFormatEither;
                         if (NodeFilterConstraintType.PROPERTIES.equals(nodeFilterConstraintType)) {
                             booleanResponseFormatEither = isComponentPropertyFilterValid(parentComponent, componentInstanceId, constraint);
@@ -148,7 +157,7 @@ public class NodeFilterValidator {
                 sourcePropertyDefinition = componentInstanceProperties == null ? new ArrayList<>() : componentInstanceProperties;
             }
         }
-        if (!CollectionUtils.isEmpty(sourcePropertyDefinition)) {
+        if (CollectionUtils.isNotEmpty(sourcePropertyDefinition)) {
             final Optional<? extends PropertyDefinition> sourceSelectedProperty = sourcePropertyDefinition.stream()
                 .filter(property -> uiConstraint.getValue().equals(property.getName())).findFirst();
             final Optional<? extends PropertyDefinition> targetComponentInstanceProperty = parentComponent.getComponentInstancesProperties()
@@ -162,6 +171,22 @@ public class NodeFilterValidator {
         return Either.right(componentsUtils.getResponseFormat(ActionStatus.MAPPED_PROPERTY_NOT_FOUND, source, missingProperty));
     }
 
+    private Either<Boolean, ResponseFormat> validateInputConstraint(final Component parentComponent, final String componentInstanceId,
+                                                                    final UIConstraint uiConstraint) {
+        final List<InputDefinition> sourceInputDefinition = parentComponent.getInputs();
+        if (CollectionUtils.isNotEmpty(sourceInputDefinition)) {
+            final Optional<? extends InputDefinition> sourceSelectedProperty = sourceInputDefinition.stream()
+                .filter(input -> uiConstraint.getValue().equals(input.getName())).findFirst();
+            final Optional<? extends PropertyDefinition> targetComponentInstanceProperty = parentComponent.getComponentInstancesProperties()
+                .get(componentInstanceId).stream().filter(property -> uiConstraint.getServicePropertyName().equals(property.getName())).findFirst();
+            if (sourceSelectedProperty.isPresent() && targetComponentInstanceProperty.isPresent()) {
+                return validatePropertyData(uiConstraint, sourceSelectedProperty, targetComponentInstanceProperty);
+            }
+        }
+        LOGGER.debug("Parent component does not have inputs", parentComponent);
+        return Either.right(componentsUtils.getResponseFormat(ActionStatus.INPUTS_NOT_FOUND));
+    }
+
     private Either<Boolean, ResponseFormat> validatePropertyData(UIConstraint uiConstraint,
                                                                  Optional<? extends PropertyDefinition> sourceSelectedProperty,
                                                                  Optional<? extends PropertyDefinition> targetComponentInstanceProperty) {
@@ -292,7 +317,7 @@ public class NodeFilterValidator {
         final List<PropertyDefinition> propertyDefinitions = component.getProperties();
         List<? extends PropertyDefinition> sourcePropertyDefinition =
             component.getName().equals(uiConstraint.getSourceName()) && propertyDefinitions != null ? propertyDefinitions : Collections.emptyList();
-        if (!CollectionUtils.isEmpty(sourcePropertyDefinition)) {
+        if (CollectionUtils.isNotEmpty(sourcePropertyDefinition)) {
             final Optional<? extends PropertyDefinition> sourceSelectedProperty = sourcePropertyDefinition.stream()
                 .filter(property -> uiConstraint.getValue().equals(property.getName())).findFirst();
             final Optional<? extends PropertyDefinition> targetComponentProperty = component.getProperties().stream()
index f9f9286..35e80dc 100644 (file)
@@ -134,6 +134,7 @@ export class ServiceDependenciesComponent {
     isDependent: boolean;
     isLoading: boolean;
     parentServiceInputs: InputBEModel[] = [];
+    parentServiceProperties: PropertyBEModel[] = [];
     constraintProperties: ConstraintObject[] = [];
     constraintCapabilities: CapabilitiesConstraintObject[] = [];
     operatorTypes: any[];
@@ -167,8 +168,10 @@ export class ServiceDependenciesComponent {
             {label: '<', value: OPERATOR_TYPES.LESS_THAN},
             {label: '=', value: OPERATOR_TYPES.EQUAL}
         ];
-        this.topologyTemplateService.getComponentInputsWithProperties(this.compositeService.componentType, this.compositeService.uniqueId).subscribe((result: ComponentGenericResponse) => {
+        this.topologyTemplateService.getComponentInputsWithProperties(this.compositeService.componentType, this.compositeService.uniqueId)
+        .subscribe((result: ComponentGenericResponse) => {
             this.parentServiceInputs = result.inputs;
+            this.parentServiceProperties = result.properties;
         });
         this.loadNodeFilter();
         this.translateService.languageChangedObservable.subscribe((lang) => {
@@ -300,6 +303,7 @@ export class ServiceDependenciesComponent {
                     operatorTypes: this.operatorTypes,
                     compositeServiceName: this.compositeService.name,
                     parentServiceInputs: this.parentServiceInputs,
+                    parentServiceProperties: this.parentServiceProperties,
                     selectedInstanceProperties: this.selectedInstanceProperties,
                     selectedInstanceSiblings: this.selectedInstanceSiblings
                 }
@@ -406,6 +410,7 @@ export class ServiceDependenciesComponent {
                 operatorTypes: this.operatorTypes,
                 compositeServiceName: this.compositeService.name,
                 parentServiceInputs: this.parentServiceInputs,
+                parentServiceProperties: this.parentServiceProperties,
                 selectedInstanceProperties: this.selectedInstanceProperties,
                 selectedInstanceSiblings: this.selectedInstanceSiblings
             }
index e0754af..7671d65 100644 (file)
@@ -30,7 +30,6 @@ import {ServiceDependenciesEditorComponent} from 'app/ng2/pages/service-dependen
 import {ModalService} from 'app/ng2/services/modal.service';
 import {TranslateService} from 'app/ng2/shared/translator/translate.service';
 import {ComponentMetadata} from '../../../../models/component-metadata';
-import {ServiceInstanceObject} from '../../../../models/service-instance-properties-and-interfaces';
 import {TopologyTemplateService} from '../../../services/component-services/topology-template.service';
 import {ToscaFilterConstraintType} from "../../../../models/tosca-filter-constraint-type.enum";
 
@@ -112,7 +111,6 @@ class I18nTexts {
 export class SubstitutionFilterComponent {
   modalInstance: ComponentRef<ModalComponent>;
   isLoading: boolean;
-  parentServiceInputs: InputBEModel[] = [];
   operatorTypes: any[];
   constraintProperties: ConstraintObject[] = [];
   PROPERTIES: string = ToscaFilterConstraintType.PROPERTIES;
@@ -120,9 +118,10 @@ export class SubstitutionFilterComponent {
   @Input() readonly: boolean;
   @Input() compositeService: ComponentMetadata;
   @Input() currentServiceInstance: ComponentInstance;
-  @Input() selectedInstanceSiblings: ServiceInstanceObject[];
   @Input() selectedInstanceConstraints: ConstraintObject[] = [];
   @Input() selectedInstanceProperties: PropertyBEModel[] = [];
+  @Input() parentServiceProperties: PropertyBEModel[] = [];
+  @Input() parentServiceInputs: InputBEModel[] = [];
   @Output() updateSubstitutionFilterProperties: EventEmitter<ConstraintObject[]> = new EventEmitter<ConstraintObject[]>();
   @Output() updateConstraintListEvent: EventEmitter<ConstraintObject[]> = new EventEmitter<ConstraintObject[]>();
   @Output() loadConstraintListEvent: EventEmitter<any> = new EventEmitter();
@@ -176,8 +175,8 @@ export class SubstitutionFilterComponent {
           operatorTypes: this.operatorTypes,
           compositeServiceName: this.compositeService.name,
           parentServiceInputs: this.parentServiceInputs,
-          selectedInstanceProperties: this.selectedInstanceProperties,
-          selectedInstanceSiblings: this.selectedInstanceSiblings
+          parentServiceProperties: this.parentServiceProperties,
+          selectedInstanceProperties: this.parentServiceProperties,
         }
     );
     this.modalInstance.instance.open();
@@ -216,8 +215,8 @@ export class SubstitutionFilterComponent {
           operatorTypes: this.operatorTypes,
           compositeServiceName: this.compositeService.name,
           parentServiceInputs: this.parentServiceInputs,
-          selectedInstanceProperties: this.selectedInstanceProperties,
-          selectedInstanceSiblings: this.selectedInstanceSiblings
+          parentServiceProperties: this.parentServiceProperties,
+          selectedInstanceProperties: this.parentServiceProperties,
         }
     );
     this.modalInstance.instance.open();
index c8845de..a9fad5a 100644 (file)
@@ -23,8 +23,9 @@
     <substitution-filter
             [compositeService]="metaData"
             [currentServiceInstance]="component"
-            [selectedInstanceProperties]="selectedInstanceProperties"
-            [selectedInstanceSiblings]="selectedInstanceSiblings"
+            [parentServiceProperties]="parentServiceProperties"
+            [parentServiceInputs]="parentServiceInputs"
+            [selectedInstanceProperties]="parentServiceProperties"
             [selectedInstanceConstraints]="selectedInstanceConstraints"
             [readonly]="isViewOnly"
             (hasSubstitutionFilter)="notifyDependencyEventsObserver($event)"
index c4101ab..bf8d1e4 100644 (file)
@@ -21,7 +21,7 @@ import { Component, Input } from '@angular/core';
 import { Store } from '@ngxs/store';
 import {
     Component as TopologyTemplate,
-    FullComponentInstance,
+    FullComponentInstance, InputBEModel,
     PropertiesGroup,
     PropertyBEModel,
 } from 'app/models';
@@ -47,7 +47,8 @@ export class SubstitutionFilterTabComponent {
     selectedInstanceSiblings: ServiceInstanceObject[];
     componentInstancesConstraints: any[];
     selectedInstanceConstraints: ConstraintObject[];
-    selectedInstanceProperties: PropertyBEModel[];
+    parentServiceProperties: PropertyBEModel[];
+    parentServiceInputs: InputBEModel[];
     componentInstanceProperties: PropertiesGroup;
     metaData: ComponentMetadata;
 
@@ -85,21 +86,11 @@ export class SubstitutionFilterTabComponent {
     }
 
     private initInstancesWithProperties = (): void => {
-        this.topologyTemplateService.getComponentPropertiesSubstitutionFilter(this.metaData.componentType, this.metaData.uniqueId).subscribe((genericResponse: ComponentGenericResponse) => {
-            this.selectedInstanceProperties = genericResponse.properties;
-            this.updateInstanceAttributes();
+        this.topologyTemplateService.getComponentPropertiesAndInputsForSubstitutionFilter(this.metaData.componentType, this.metaData.uniqueId)
+        .subscribe((genericResponse: ComponentGenericResponse) => {
+            this.parentServiceProperties = genericResponse.properties;
+            this.parentServiceInputs = genericResponse.inputs;
         });
     }
 
-    private updateInstanceAttributes = (): void => {
-        if (this.isComponentInstanceSelected && this.componentInstanceProperties) {
-            const instancesMappedList = this.compositionService.componentInstances.map((coInstance) => new ServiceInstanceObject({
-                id: coInstance.uniqueId,
-                name: coInstance.name,
-                properties: this.componentInstanceProperties[coInstance.uniqueId] || []
-            }));
-            this.selectedInstanceProperties = this.componentInstanceProperties[this.component.uniqueId];
-            this.selectedInstanceSiblings = instancesMappedList.filter((coInstance) => coInstance.id !== this.component.uniqueId);
-        }
-    }
 }
index f84214e..8a577ae 100644 (file)
@@ -6,7 +6,7 @@
         <div class="i-sdc-form-content">
             <div class="rule-builder-content">
                 <div class="i-sdc-form-item rule-input-field">
-                    <label class="i-sdc-form-label required">Service {{currentServiceName}} Property</label>
+                    <label class="i-sdc-form-label required">{{currentServiceName}} Property</label>
                     <ui-element-dropdown
                             class="i-sdc-form-select"
                             data-tests-id="servicePropertyName"
                 </div>
 
                 <div class="i-sdc-form-item rule-input-field">
+                    <label class="i-sdc-form-label required" >Function Type</label>
+                    <ui-element-dropdown class="i-sdc-form-select" data-tests-id="functionType" [values]="functionTypes" [(value)]="currentRule.sourceType" (change)="onSelectFunctionType()"></ui-element-dropdown>
+                </div>
+
+                <div class="i-sdc-form-item rule-input-field" *ngIf="isPropertyFunctionSelected()">
                     <label class="i-sdc-form-label required" >Source</label>
-                    <ui-element-dropdown class="i-sdc-form-select" data-tests-id="sourceType" [values]="sourceTypes" [(value)]="currentRule.sourceName" (change)="onSelectSourceType($event)"></ui-element-dropdown>
+                    <ui-element-dropdown class="i-sdc-form-select" data-tests-id="sourceType" [values]="sourceTypes" [(value)]="currentRule.sourceName" (change)="onSelectSourceType()"></ui-element-dropdown>
                 </div>
+
                 <div  [ngClass]="isComplexListMapType() && isStaticSource() ? 'complex-input-field' : ''"
                     class="rule-input-field assigned-value-field">
                     <label class="i-sdc-form-label required" >{{assignedValueLabel}}</label>
index cb3e87c..c6b3b65 100644 (file)
@@ -56,6 +56,7 @@ export class ServiceDependenciesEditorComponent {
     compositeServiceName: string,
     currentServiceName: string,
     parentServiceInputs: InputBEModel[],
+    parentServiceProperties: PropertyBEModel[];
     selectedInstanceProperties: PropertyBEModel[],
     operatorTypes: DropdownValue[],
     selectedInstanceSiblings: ServiceInstanceObject[]
@@ -65,6 +66,7 @@ export class ServiceDependenciesEditorComponent {
   selectedPropertyObj: PropertyFEModel;
   ddValueSelectedServicePropertiesNames: DropdownValue[];
   operatorTypes: DropdownValue[];
+  functionTypes: DropdownValue[];
   sourceTypes: UIDropDownSourceTypesElement[] = [];
   currentRule: ConstraintObjectUI;
   currentIndex: number;
@@ -75,7 +77,8 @@ export class ServiceDependenciesEditorComponent {
 
   SOURCE_TYPES = {
     STATIC: {label: 'Static', value: 'static'},
-    SERVICE_PROPERTY: {label: 'Service Property', value: 'property'}
+    SERVICE_PROPERTY: {label: 'Service Property', value: 'property'},
+    SERVICE_INPUT: {label: 'Service Input', value: 'service_input'}
   };
 
   constructor(private propertiesUtils: PropertiesUtils) {}
@@ -83,6 +86,19 @@ export class ServiceDependenciesEditorComponent {
   ngOnInit() {
     this.currentIndex = this.input.serviceRuleIndex;
     this.serviceRulesList = this.input.serviceRules;
+    this.initCurrentRule();
+    this.currentServiceName = this.input.currentServiceName;
+    this.operatorTypes = this.input.operatorTypes;
+    this.selectedServiceProperties = this.input.selectedInstanceProperties;
+    this.ddValueSelectedServicePropertiesNames = _.map(this.input.selectedInstanceProperties, (prop) => new DropdownValue(prop.name, prop.name));
+    this.initFunctionTypes();
+    if (this.SOURCE_TYPES.STATIC.value !== this.currentRule.sourceType) {
+      this.loadSourceTypesData();
+    }
+    this.syncRuleData();
+  }
+
+  private initCurrentRule() {
     this.currentRule = this.serviceRulesList && this.input.serviceRuleIndex >= 0 ?
         this.serviceRulesList[this.input.serviceRuleIndex] :
         new ConstraintObjectUI({
@@ -91,39 +107,73 @@ export class ServiceDependenciesEditorComponent {
           value: '',
           constraintOperator: OPERATOR_TYPES.EQUAL
         });
-    this.currentServiceName = this.input.currentServiceName;
-    this.operatorTypes = this.input.operatorTypes;
-    this.selectedServiceProperties = this.input.selectedInstanceProperties;
-    this.ddValueSelectedServicePropertiesNames = _.map(this.input.selectedInstanceProperties, (prop) => new DropdownValue(prop.name, prop.name));
-    this.initSourceTypes();
-    this.syncRuleData();
+    if (this.currentRule && this.currentRule.sourceType === this.SOURCE_TYPES.SERVICE_INPUT.value) {
+      this.currentRule.sourceName = this.input.compositeServiceName;
+    }
+  }
+
+  private initFunctionTypes() {
+    this.functionTypes = [
+      {label: this.SOURCE_TYPES.STATIC.label, value: this.SOURCE_TYPES.STATIC.value},
+      {label: this.SOURCE_TYPES.SERVICE_PROPERTY.label, value: this.SOURCE_TYPES.SERVICE_PROPERTY.value},
+      {label: this.SOURCE_TYPES.SERVICE_INPUT.label, value: this.SOURCE_TYPES.SERVICE_INPUT.value}];
+  }
+
+  onServicePropertyChanged() {
+    this.updateSelectedPropertyObj();
+    this.updateOperatorTypesList();
+    this.currentRule.sourceName = "";
+    this.currentRule.value = "";
+  }
+
+  onSelectFunctionType() {
+    this.currentRule.value = "";
+    this.currentRule.sourceName = "";
+    this.listOfValuesToAssign = [];
+    this.currentRule.sourceType = this.updateCurrentSourceType(this.currentRule.sourceType);
+    this.loadSourceTypesData();
     this.updateSourceTypesRelatedValues();
   }
 
-  initSourceTypes() {
-    this.sourceTypes.push({
-      label: this.SOURCE_TYPES.STATIC.label,
-      value: this.SOURCE_TYPES.STATIC.value,
-      options: [],
-      assignedLabel: this.SOURCE_TYPES.STATIC.label,
-      type: this.SOURCE_TYPES.STATIC.value
-    });
+  onSelectSourceType() {
+    this.currentRule.value = "";
+    this.updateSourceTypesRelatedValues();
+  }
+
+  loadSourceTypesData() {
+    this.sourceTypes = [];
     this.sourceTypes.push({
       label: this.input.compositeServiceName,
       value: this.input.compositeServiceName,
-      assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
-      type: this.SOURCE_TYPES.SERVICE_PROPERTY.value,
-      options: this.input.parentServiceInputs
+      assignedLabel: this.currentRule.sourceType == this.SOURCE_TYPES.SERVICE_PROPERTY.value
+          ? this.SOURCE_TYPES.SERVICE_PROPERTY.label : this.SOURCE_TYPES.SERVICE_INPUT.label,
+      type: this.currentRule.sourceType == this.SOURCE_TYPES.SERVICE_PROPERTY.value
+          ? this.SOURCE_TYPES.SERVICE_PROPERTY.value : this.SOURCE_TYPES.SERVICE_INPUT.value,
+      options: this.loadSourceTypeBySelectedFunction().get(this.currentRule.sourceType)
     });
-    _.forEach(this.input.selectedInstanceSiblings, (sib) =>
-        this.sourceTypes.push({
-          label: sib.name,
-          value: sib.name,
-          options: sib.properties || [],
-          assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
-          type: this.SOURCE_TYPES.SERVICE_PROPERTY.value
-        })
-    );
+
+    if (this.currentRule.sourceType === this.SOURCE_TYPES.SERVICE_INPUT.value) {
+      this.currentRule.sourceName = this.input.compositeServiceName;
+    } else {
+      if (this.input.selectedInstanceSiblings && this.isPropertyFunctionSelected) {
+        _.forEach(this.input.selectedInstanceSiblings, (sib) =>
+            this.sourceTypes.push({
+              label: sib.name,
+              value: sib.name,
+              options: sib.properties || [],
+              assignedLabel: this.SOURCE_TYPES.SERVICE_PROPERTY.label,
+              type: this.SOURCE_TYPES.SERVICE_PROPERTY.value
+            })
+        );
+      }
+    }
+  }
+
+  loadSourceTypeBySelectedFunction = (): any => {
+    let parentDataMap = new Map();
+    parentDataMap.set(this.SOURCE_TYPES.SERVICE_PROPERTY.value, this.input.parentServiceProperties);
+    parentDataMap.set(this.SOURCE_TYPES.SERVICE_INPUT.value , this.input.parentServiceInputs);
+    return parentDataMap;
   }
 
   syncRuleData() {
@@ -151,6 +201,7 @@ export class ServiceDependenciesEditorComponent {
           (t) => t.value === this.currentRule.sourceName && t.type === this.currentRule.sourceType
       );
       if (selectedSourceType) {
+        this.listOfSourceOptions = [];
         this.listOfSourceOptions = selectedSourceType.options || [];
         this.assignedValueLabel = selectedSourceType.assignedLabel || this.SOURCE_TYPES.STATIC.label;
         this.filterOptionsByType();
@@ -166,19 +217,15 @@ export class ServiceDependenciesEditorComponent {
     }
   }
 
-  onServicePropertyChanged() {
-    this.currentRule.value = '';
-    this.updateSelectedPropertyObj();
-    this.updateOperatorTypesList();
-    this.filterOptionsByType();
-  }
-
-  onSelectSourceType() {
-    this.currentRule.value = '';
-    this.currentRule.sourceType = this.currentRule.sourceName === this.SOURCE_TYPES.STATIC.value ?
-        this.SOURCE_TYPES.STATIC.value :
-        this.SOURCE_TYPES.SERVICE_PROPERTY.value;
-    this.updateSourceTypesRelatedValues();
+  private updateCurrentSourceType = (sourceType: string): string => {
+    switch (sourceType) {
+      case this.SOURCE_TYPES.STATIC.value:
+        return this.SOURCE_TYPES.STATIC.value;
+      case this.SOURCE_TYPES.SERVICE_PROPERTY.value:
+        return this.SOURCE_TYPES.SERVICE_PROPERTY.value;
+      case this.SOURCE_TYPES.SERVICE_INPUT.value:
+        return this.SOURCE_TYPES.SERVICE_INPUT.value;
+    }
   }
 
   filterOptionsByType() {
@@ -214,7 +261,9 @@ export class ServiceDependenciesEditorComponent {
       newProp.value = JSON.stringify(this.currentRule.value);
       this.propertiesUtils.initValueObjectRef(newProp);
       console.log("TEST" + newProp.value);
-      setTimeout(() => {this.selectedPropertyObj = newProp})
+      setTimeout(() => {
+        this.selectedPropertyObj = newProp})
+      this.selectedPropertyObj = newProp;
     }
   }
 
@@ -222,6 +271,10 @@ export class ServiceDependenciesEditorComponent {
     return this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value
   }
 
+  isPropertyFunctionSelected(): boolean {
+    return this.currentRule.sourceType === this.SOURCE_TYPES.SERVICE_PROPERTY.value;
+  }
+
   isComplexListMapType(): boolean {
     return this.selectedPropertyObj && this.selectedPropertyObj.derivedDataType > 0;
   }
@@ -231,4 +284,5 @@ export class ServiceDependenciesEditorComponent {
     this.currentRule.value = JSON.stringify(value);
     this.onValueChange(this.selectedPropertyObj.valueObjIsValid);
   }
+
 }
index 7b726e4..20425f8 100644 (file)
@@ -483,8 +483,8 @@ export class TopologyTemplateService {
         return this.http.delete<any>(this.baseUrl + this.getServerTypeUrl(componentType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/' + constraintType + '/' + constraintIndex + '/nodeFilter')
     }
 
-    getComponentPropertiesSubstitutionFilter(componentType: string, componentId: string): Observable<ComponentGenericResponse> {
-        return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES]);
+    getComponentPropertiesAndInputsForSubstitutionFilter(componentType: string, componentId: string): Observable<ComponentGenericResponse> {
+        return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES, COMPONENT_FIELDS.COMPONENT_INPUTS]);
     }
 
     createSubstitutionFilterConstraints(componentMetaDataId: string, constraint: ConstraintObject, componentType: string, constraintType: string): Observable<any> {
@@ -536,7 +536,6 @@ export class TopologyTemplateService {
     }
 
     protected getComponentDataByFieldsName(componentType: string, componentId: string, fields: string[]): Observable<ComponentGenericResponse> {
-        console.info("Topology template -> getComponentDataByFieldsName with id:", componentId)
         let params: HttpParams = new HttpParams();
         _.forEach(fields, (field: string): void => {
             params = params.append(API_QUERY_PARAMS.INCLUDE, field);
@@ -544,7 +543,6 @@ export class TopologyTemplateService {
         // tslint:disable-next-line:object-literal-shorthand
         return this.http.get<ComponentGenericResponse>(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/filteredDataByParams', {params: params})
             .map((res) => {
-                console.info("Topology template -> getComponentDataByFieldsName response:", res);
                 return componentType === ComponentType.SERVICE ? new ServiceGenericResponse().deserialize(res) :
                         new ComponentGenericResponse().deserialize(res);
             });
index 969854b..aba5f74 100644 (file)
@@ -21,22 +21,19 @@ package org.onap.sdc.frontend.ci.tests.pages;
 
 import static org.junit.jupiter.api.Assertions.fail;
 
+import com.fasterxml.jackson.databind.json.JsonMapper;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.stream.Collectors;
-
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 import org.onap.sdc.frontend.ci.tests.datatypes.ServiceDependencyProperty;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.ui.Select;
 
-import com.fasterxml.jackson.databind.json.JsonMapper;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
 /**
  * Represents the Service Dependencies Editor
  */
@@ -65,8 +62,8 @@ public class ServiceDependenciesEditor extends AbstractPageObject {
         properties.selectByVisibleText(property.getName());
         final Select logicalOperator = new Select(webDriver.findElement(By.xpath(XpathSelector.CONSTRAINT_OPERATOR.xPath)));
         logicalOperator.selectByVisibleText(property.getLogicalOperator().getOperator());
-        final Select sourceType = new Select(webDriver.findElement(By.xpath(XpathSelector.SOURCE_TYPE.xPath)));
-        sourceType.selectByVisibleText(property.getSource());
+        final Select functionType = new Select(webDriver.findElement(By.xpath(XpathSelector.FUNCTION_TYPE.xPath)));
+        functionType.selectByVisibleText(property.getSource());
         try {
             addRuleAssignedValue(property);
         } catch (Exception e) {
@@ -126,6 +123,7 @@ public class ServiceDependenciesEditor extends AbstractPageObject {
         SERVICE_DEPENDENCIES_EDITOR("//service-dependencies-editor"),
         SERVICE_PROPERTY_NAME("//*[@data-tests-id='servicePropertyName']/select"),
         CONSTRAINT_OPERATOR("//*[@data-tests-id='constraintOperator']/select"),
+        FUNCTION_TYPE("//*[@data-tests-id='functionType']/select"),
         SOURCE_TYPE("//*[@data-tests-id='sourceType']/select"),
         RULE_ASSIGNED_VALUE("//*[@data-tests-id='ruleAssignedValue']//*[self::input or self::select]"),
         RULE_ASSIGNED_VALUE_ADD_TO_LIST("//a[@data-tests-id = 'add-to-list-%s']"),