diff options
9 files changed, 58 insertions, 52 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index baa794c6cc..3f48328cc9 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -1254,9 +1254,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { ComponentInstance componentInstance = componentInstanceOptional.get(); try { - if (containerComponent instanceof Service || containerComponent instanceof Resource && - isVFC(componentInstance.getOriginType())) { - + if (containerComponent instanceof Service || containerComponent instanceof Resource) { final Either<String, StorageOperationStatus> deleteServiceFilterEither = nodeFilterOperation.deleteNodeFilter(containerComponent, componentInstanceId); if (deleteServiceFilterEither.isRight()) { @@ -3454,10 +3452,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } } - public boolean isVFC(final OriginTypeEnum originTypeEnum) { - return OriginTypeEnum.VFC.equals(originTypeEnum); - } - public void validateUser(final String userId) { final User user = userValidations.validateUserExists(userId); userValidations.validateUserRole(user, Arrays.asList(Role.DESIGNER, Role.ADMIN)); 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 d742fb3aea..494ec9c6e8 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 @@ -390,6 +390,16 @@ public class UiComponentDataConverter { } break; + case NODE_FILTER: + if (resource.getNodeFilterComponents() == null) { + dataTransfer.setNodeFilterforNode(null); + } else { + final NodeFilterConverter nodeFilterConverter = new NodeFilterConverter(); + dataTransfer.setNodeFilterforNode( + nodeFilterConverter.convertDataMapToUI(resource.getNodeFilterComponents())); + } + break; + default: setUiTranferDataByFieldName(dataTransfer, resource, fieldName); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java index 0896891ad3..c5c89f7665 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java @@ -256,9 +256,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { final ComponentInstance resultValue = actionResponse.left().value(); if (ComponentTypeEnum.SERVICE.equals(componentTypeEnum) || - ComponentTypeEnum.RESOURCE.equals(componentTypeEnum) && - componentInstanceBusinessLogic.isVFC(componentInstance.getOriginType())) { - + ComponentTypeEnum.RESOURCE.equals(componentTypeEnum)) { if(CollectionUtils.isNotEmpty(componentInstance.getDirectives())) { final Optional<CINodeFilterDataDefinition> nodeFilterDataDefinition = nodeFilterBusinessLogic.createNodeFilterIfNotExist(componentId, componentInstanceId, 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 84dd3b1e8c..ffe3d06e2a 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 @@ -18,8 +18,17 @@ package org.openecomp.sdc.be.datamodel; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hibernate.validator.internal.util.CollectionHelper.asSet; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -47,18 +56,6 @@ import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer; import org.openecomp.sdc.be.ui.model.UiComponentMetadata; import org.openecomp.sdc.be.ui.model.UiServiceDataTransfer; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.validator.internal.util.CollectionHelper.asSet; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class UiComponentDataConverterTest { private PolicyDefinition policy1, policy2; @@ -312,7 +309,7 @@ public class UiComponentDataConverterTest { UiComponentDataTransfer uiComponentDataTransfer = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resource, Collections.singletonList("nodeFilter")); - assertThat(uiComponentDataTransfer.getNodeFilter()).isNotEmpty(); + assertThat(uiComponentDataTransfer.getNodeFilterforNode()).isNotEmpty(); } @Test diff --git a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts index ff3779119d..f9f9286fe5 100644 --- a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts +++ b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts @@ -97,6 +97,8 @@ class I18nTexts { static deleteNodeFilterMsg: string; static validateCapabilitiesTxt: string static validateCapabilitiesMsg: string + static validateNodePropertiesTxt: string + static validateNodePropertiesMsg: string public static translateTexts(translateService) { I18nTexts.removeDirectiveModalTitle = translateService.translate('DIRECTIVES_AND_NODE_FILTER_REMOVE_TITLE'); @@ -114,6 +116,8 @@ class I18nTexts { I18nTexts.deleteNodeFilterMsg = translateService.translate('DIRECTIVES_AND_NODE_FILTER_DELETE_NODE_FILTER_MSG'); I18nTexts.validateCapabilitiesTxt = translateService.translate('VALIDATE_CAPABILITIES_TXT'); I18nTexts.validateCapabilitiesMsg = translateService.translate('VALIDATE_CAPABILITIES_MSG'); + I18nTexts.validateNodePropertiesTxt = translateService.translate('VALIDATE_NODE_PROPERTIES_TXT'); + I18nTexts.validateNodePropertiesMsg = translateService.translate('VALIDATE_NODE_PROPERTIES_MSG'); } } @@ -281,23 +285,27 @@ export class ServiceDependenciesComponent { } onAddNodeFilter = () => { - const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'outline white', this.modalServiceNg2.closeCurrentModal); - const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalCreate, 'blue', () => this.createNodeFilter(this.properties), this.getDisabled); - const modalModel: ModalModel = new ModalModel('l', I18nTexts.addNodeFilterTxt, '', [saveButton, cancelButton], 'standard'); - this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel); - this.modalServiceNg2.addDynamicContentToModal( - this.modalInstance, - ServiceDependenciesEditorComponent, - { - currentServiceName: this.currentServiceInstance.name, - operatorTypes: this.operatorTypes, - compositeServiceName: this.compositeService.name, - parentServiceInputs: this.parentServiceInputs, - selectedInstanceProperties: this.selectedInstanceProperties, - selectedInstanceSiblings: this.selectedInstanceSiblings - } - ); - this.modalInstance.instance.open(); + if (!this.selectedInstanceProperties) { + this.modalServiceNg2.openAlertModal(I18nTexts.validateNodePropertiesTxt, I18nTexts.validateNodePropertiesMsg); + } else { + const cancelButton: ButtonModel = new ButtonModel(I18nTexts.modalCancel, 'outline white', this.modalServiceNg2.closeCurrentModal); + const saveButton: ButtonModel = new ButtonModel(I18nTexts.modalCreate, 'blue', () => this.createNodeFilter(this.properties), this.getDisabled); + const modalModel: ModalModel = new ModalModel('l', I18nTexts.addNodeFilterTxt, '', [saveButton, cancelButton], 'standard'); + this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel); + this.modalServiceNg2.addDynamicContentToModal( + this.modalInstance, + ServiceDependenciesEditorComponent, + { + currentServiceName: this.currentServiceInstance.name, + operatorTypes: this.operatorTypes, + compositeServiceName: this.compositeService.name, + parentServiceInputs: this.parentServiceInputs, + selectedInstanceProperties: this.selectedInstanceProperties, + selectedInstanceSiblings: this.selectedInstanceSiblings + } + ); + this.modalInstance.instance.open(); + } } onAddNodeFilterCapabilities = () => { @@ -406,7 +414,7 @@ export class ServiceDependenciesComponent { } getDisabled = (): boolean => { - return false; + return !this.modalInstance.instance.dynamicContent.instance.checkFormValidForSubmit(); } updateNodeFilter = (constraintType: string, index: number) => { diff --git a/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts b/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts index 1205556ee0..2cd4f4d1c7 100644 --- a/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/capabilities-filter-properties-editor/capabilities-filter-properties-editor.component.ts @@ -135,9 +135,11 @@ export class CapabilitiesFilterPropertiesEditorComponent { if (!this.currentRule.sourceName && this.currentRule.sourceType === this.SOURCE_TYPES.STATIC.value) { this.currentRule.sourceName = this.SOURCE_TYPES.STATIC.value; } - this.selectedCapabilitiesPropertyObject = Array.from(this.input.componentInstanceCapabilitiesMap - .get(this.currentRule.capabilityName)) - .find(property => property.name == this.currentRule.servicePropertyName); + if (!this.input.componentInstanceCapabilitiesMap){ + this.selectedCapabilitiesPropertyObject = Array.from(this.input.componentInstanceCapabilitiesMap + .get(this.currentRule.capabilityName)) + .find(property => property.name == this.currentRule.servicePropertyName); + } this.updateOperatorTypesList(); this.updateSourceTypesRelatedValues(); } diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/__snapshots__/composition-panel.component.spec.ts.snap b/catalog-ui/src/app/ng2/pages/composition/panel/__snapshots__/composition-panel.component.spec.ts.snap index 2c96e92c7e..beae93e7bd 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/__snapshots__/composition-panel.component.spec.ts.snap +++ b/catalog-ui/src/app/ng2/pages/composition/panel/__snapshots__/composition-panel.component.spec.ts.snap @@ -11,7 +11,6 @@ exports[`composition-panel component should match current snapshot of compositio isVF={[Function Function]} selectedComponentIsServiceProxyInstance={[Function Function]} selectedComponentIsServiceSubstitutionInstance={[Function Function]} - selectedComponentIsVfcInstance={[Function Function]} setActive={[Function Function]} store={[Function Store]} toggleSidebarDisplay={[Function Function]} diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts index 4feaac8272..2fce002844 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts @@ -151,7 +151,7 @@ export class CompositionPanelComponent { if (component.isService() && (this.selectedComponentIsServiceProxyInstance() || this.selectedComponentIsServiceSubstitutionInstance())) { this.tabs.push(tabs.consumption); this.tabs.push(tabs.dependencies); - } else if (component.isResource() && this.selectedComponentIsVfcInstance()) { + } else if (component.isResource() && this.isComponentInstanceSelected()) { this.tabs.push(tabs.dependencies); } @@ -185,8 +185,4 @@ export class CompositionPanelComponent { private selectedComponentIsServiceSubstitutionInstance = (): boolean => { return this.isComponentInstanceSelected() && this.selectedComponent.isServiceSubstitution(); } - - private selectedComponentIsVfcInstance = (): boolean => { - return this.isComponentInstanceSelected() && this.selectedComponent.isVFC(); - } } diff --git a/catalog-ui/src/assets/languages/en_US.json b/catalog-ui/src/assets/languages/en_US.json index 2417b0d4ae..cad8fc78df 100644 --- a/catalog-ui/src/assets/languages/en_US.json +++ b/catalog-ui/src/assets/languages/en_US.json @@ -511,6 +511,8 @@ "DIRECTIVES_AND_NODE_FILTER_UPDATE_TEXT": "Changing \"Directive Option\" will remove directives value and erase all the node filter. Are you sure you want to update directives?", "VALIDATE_CAPABILITIES_TXT": "Node Filter for Capabilities Properties", "VALIDATE_CAPABILITIES_MSG": "The selected Component Instance does not have any capability property", + "VALIDATE_NODE_PROPERTIES_TXT": "Node Filter for Properties", + "VALIDATE_NODE_PROPERTIES_MSG": "The selected Component Instance does not have any property", "============= SUBSTITUTION FILTER MANAGE TAB ======" : "", "ADD_SUBSTITUTION_FILTER": "Add Substitution Filter", |