Allows to set directives and node_filters in any node type.
Issue-ID: SDC-3404
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: Ib75821e27bf949f841c990b1353f156eda2ae8f0
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()) {
}
}
- 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));
}
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);
}
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,
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;
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;
UiComponentDataTransfer uiComponentDataTransfer = uiComponentDataConverter.getUiDataTransferFromResourceByParams(resource,
Collections.singletonList("nodeFilter"));
- assertThat(uiComponentDataTransfer.getNodeFilter()).isNotEmpty();
+ assertThat(uiComponentDataTransfer.getNodeFilterforNode()).isNotEmpty();
}
@Test
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');
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');
}
}
}
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 = () => {
}
getDisabled = (): boolean => {
- return false;
+ return !this.modalInstance.instance.dynamicContent.instance.checkFormValidForSubmit();
}
updateNodeFilter = (constraintType: string, index: number) => {
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();
}
isVF={[Function Function]}
selectedComponentIsServiceProxyInstance={[Function Function]}
selectedComponentIsServiceSubstitutionInstance={[Function Function]}
- selectedComponentIsVfcInstance={[Function Function]}
setActive={[Function Function]}
store={[Function Store]}
toggleSidebarDisplay={[Function Function]}
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);
}
private selectedComponentIsServiceSubstitutionInstance = (): boolean => {
return this.isComponentInstanceSelected() && this.selectedComponent.isServiceSubstitution();
}
-
- private selectedComponentIsVfcInstance = (): boolean => {
- return this.isComponentInstanceSelected() && this.selectedComponent.isVFC();
- }
}
"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",