message: "Error: The following properties:\n%1\nused in the substitution mapping node type in CSAR are missing from the system. Please add these to the node in the SDC catalog prior to importing the template",
messageId: "SVC4021"
}
+
+ # %1 - Output name
+ #---------SVC4022-----------------------------
+ OUTPUT_NAME_ALREADY_EXIST: {
+ code: 400,
+ message: "Output name '%1' already exist.",
+ messageId: "SVC4022"
+ }
//Creating input from property create on self using add property..Do not add the prefix
generatedInputPrefix = null;
}
- final String generatedOutputName = generateOutputName(generatedInputPrefix, attribOutput);
+ String generatedOutputName = null;
+ if (StringUtils.isNotEmpty(attribOutput.getOutputName())) {
+ generatedOutputName = attribOutput.getOutputName();
+ } else {
+ generatedOutputName = generateOutputName(generatedInputPrefix, attribOutput);
+ }
+
log.debug("createInput: propOwner.uniqueId={}, attribOutput.parentUniqueId={}", propertiesOwner.getUniqueId(),
attribOutput.getParentUniqueId());
return createOutputFromAttribute(component.getUniqueId(), propertiesOwner, generatedOutputName, attribOutput, attributeDataDefinition);
import fj.data.Either;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.jetbrains.annotations.NotNull;
import org.openecomp.sdc.be.components.attribute.AttributeDeclarationOrchestrator;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
try {
validateUserExists(userId);
component = getAndValidateComponentForCreate(userId, componentId, componentType, shouldLockComp);
+ ImmutablePair<StorageOperationStatus, String> status = validateOutputName(component, componentInstOutputsMapUi);
+ if (status.getLeft() != StorageOperationStatus.OK) {
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.OUTPUT_NAME_ALREADY_EXIST, status.getRight()));
+ }
result = attributeDeclarationOrchestrator.declareAttributesToOutputs(component, componentInstOutputsMapUi).left()
.bind(outputsToCreate -> prepareOutputsForCreation(userId, componentId, outputsToCreate)).right()
.map(componentsUtils::getResponseFormat);
}
}
+ private ImmutablePair<StorageOperationStatus, String> validateOutputName(final Component component,
+ final ComponentInstOutputsMap componentInstOutputsMapUi) {
+ final Map<String, List<ComponentInstanceAttribOutput>> outputDeclaredProperties = new HashMap<>();
+ if (MapUtils.isNotEmpty(componentInstOutputsMapUi.getComponentInstanceOutputsMap())) {
+ outputDeclaredProperties.putAll(componentInstOutputsMapUi.getComponentInstanceOutputsMap());
+ } else if (MapUtils.isNotEmpty(componentInstOutputsMapUi.getComponentInstanceAttributes())) {
+ outputDeclaredProperties.putAll(componentInstOutputsMapUi.getComponentInstanceAttributes());
+ }
+ if (MapUtils.isNotEmpty(outputDeclaredProperties) && CollectionUtils.isNotEmpty(component.getOutputs())) {
+ for (final List<ComponentInstanceAttribOutput> componentInstancePropOutputs : outputDeclaredProperties.values()) {
+ for (final ComponentInstanceAttribOutput componentInstancePropOutput : componentInstancePropOutputs) {
+ final Optional<OutputDefinition> outputDefinition = component.getOutputs().stream()
+ .filter(output -> output.getName().equals(componentInstancePropOutput.getOutputName())
+ || output.getName().equals(componentInstancePropOutput.getName())).findAny();
+ if (outputDefinition.isPresent()) {
+ return new ImmutablePair<>(StorageOperationStatus.INVALID_VALUE, outputDefinition.get().getName());
+ }
+ }
+ }
+ }
+ return new ImmutablePair<>(StorageOperationStatus.OK, StringUtils.EMPTY);
+ }
+
private Component getAndValidateComponentForCreate(final String userId, final String componentId,
final ComponentTypeEnum componentType,
final boolean shouldLockComp) {
// Inputs
INPUT_IS_NOT_CHILD_OF_COMPONENT, CFVC_LOOP_DETECTED, INPUT_ALREADY_EXIST, INPUT_NAME_ALREADY_EXIST,
// Outputs
- OUTPUT_IS_NOT_CHILD_OF_COMPONENT, OUTPUT_ALREADY_EXIST,
+ OUTPUT_IS_NOT_CHILD_OF_COMPONENT, OUTPUT_ALREADY_EXIST, OUTPUT_NAME_ALREADY_EXIST,
//Forwarding Path related
FORWARDING_PATH_NAME_MAXIMUM_LENGTH, FORWARDING_PATH_NAME_ALREADY_IN_USE, FORWARDING_PATH_NAME_EMPTY, FORWARDING_PATH_PROTOCOL_MAXIMUM_LENGTH, FORWARDING_PATH_DESTINATION_PORT_MAXIMUM_LENGTH, MISSING_OLD_COMPONENT_INSTANCE, MISSING_NEW_COMPONENT_INSTANCE,
//policies
private String attributesName;
private AttributeDefinition output;
+ private String outputName;
public ComponentInstanceAttribOutput() {
super();
subAttributeOutputPath: string;
outputPath: string;
toscaPresentation: ToscaPresentationData;
+ outputName: string;
constructor(attribute?: AttributeBEModel) {
if (attribute) {
this.subAttributeOutputPath = attribute.subAttributeOutputPath;
this.toscaPresentation = attribute.toscaPresentation;
this.outputPath = attribute.outputPath;
+ this.outputName = attribute.outputName;
}
if (!this.schema || !this.schema.property) {
</div>
</tabs>
<div class="header">
- <button class="tlv-btn blue declare-button" [disabled]="!checkedAttributesCount || isReadonly || hasChangedData" (click)="declareAttributes()" data-tests-id="declare-button declare-output">Declare Output</button>
+ <button class="tlv-btn blue declare-button" [disabled]="!checkedAttributesCount || isReadonly || hasChangedData" (click)="declareOutput()" data-tests-id="declare-button declare-output">Declare Output</button>
</div>
</div>
</div>
import {AttributeBEModel} from "../../../models/attributes-outputs/attribute-be-model";
import {AttributeCreatorComponent} from "app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component";
import {AttributeRowSelectedEvent} from "app/ng2/components/logic/attributes-table/attributes-table.component";
+import { DeclareInputComponent } from '../properties-assignment/declare-input/declare-input.component';
const SERVICE_SELF_TITLE = "SELF";
this.searchQuery = '';
};
+ declareOutput = (): void => {
+ if (this.checkedAttributesCount == 1) {
+ this.openAddOutputNameModal();
+ } else if (this.checkedAttributesCount > 1) {
+ this.declareAttributes();
+ }
+ }
+
+ private openAddOutputNameModal = (): void => {
+ const modalTitle = 'Enter name of the ouput to be created';
+ const modalButtons = [];
+ const modal = this.ModalService.createCustomModal(new ModalModel(
+ 'sm',
+ modalTitle,
+ null,
+ modalButtons,
+ null /* type */
+ ));
+ modalButtons.push(new ButtonModel('Save', 'blue',
+ () => {
+ const outputName: string = modal.instance.dynamicContent.instance.inputNameForm.value;
+ if (outputName) {
+ this.declareAttributes(outputName);
+ } else {
+ this.Notification.warning({
+ message: 'Failed to set input name',
+ title: 'Warning'
+ });
+ }
+ this.ModalService.closeCurrentModal();
+ }
+ ));
+ modalButtons.push(new ButtonModel('Cancel', 'outline grey', () => {
+ this.ModalService.closeCurrentModal();
+ }));
+ this.ModalService.addDynamicContentToModal(modal, DeclareInputComponent, {defaultInputName: this.generateDefaultOutputName()});
+ modal.instance.open();
+ }
+
+ generateDefaultOutputName = (): string => {
+ let defaultInputName: string;
+ let instancesIds = this.keysPipe.transform(this.instanceFeAttributesMap, []);
+ angular.forEach(instancesIds, (instanceId: string) => {
+ const selectedOutput : AttributeBEModel = this.attributesService.getCheckedAttributes(this.instanceFeAttributesMap[instanceId])[0];
+ let selectedInstanceData: any = this.instances.find(instance => instance.uniqueId == instanceId);
+ defaultInputName = selectedOutput.name;
+ if (selectedInstanceData.invariantName) {
+ defaultInputName = selectedInstanceData.invariantName+'_'+selectedOutput.name;
+ }
+ });
+ return defaultInputName;
+ }
/*** DECLARE ATTRIBUTES/OUTPUTS ***/
- declareAttributes = (): void => {
+ declareAttributes = (outputName?: string): void => {
+ this.loadingAttributes = true;
let selectedComponentInstancesAttributes: InstanceBeAttributesMap = new InstanceBeAttributesMap();
let selectedComponentInstancesOutputs: InstanceBeAttributesMap = new InstanceBeAttributesMap();
let instancesIds = this.keysPipe.transform(this.instanceFeAttributesMap, []);
if (!this.isOutput(selectedInstanceData.originType)) {
// convert Attribute FE model -> Attribute BE model, extract only checked
selectedComponentInstancesAttributes[instanceId] = this.attributesService.getCheckedAttributes(this.instanceFeAttributesMap[instanceId]);
+ if (outputName) {
+ selectedComponentInstancesAttributes[instanceId][0].outputName = outputName;
+ }
} else {
selectedComponentInstancesOutputs[instanceId] = this.attributesService.getCheckedAttributes(this.instanceFeAttributesMap[instanceId]);
}
this.outputs.push(newOutput);
this.updateAttributeValueAfterDeclare(newOutput);
});
- });
+ this.loadingAttributes = false;
+ }, error => {this.loadingAttributes = false;}); //ignore error
};
saveChangedData = (): Promise<(AttributeBEModel | OutputBEModel)[]> => {
}
waitForElementVisibility(By.xpath(XpathSelector.ATTRIBUTES_CHECKBOX.getXpath(attributeName))).click();
waitToBeClickable(By.xpath(XpathSelector.DECLARE_OUTPUT_BTN.getXpath())).click();
+ final By setInputNameLocator = By.xpath(XpathSelector.SET_INPUT_NAME_FIELD.getXpath());
+ final WebElement inputNameField = waitForElementVisibility(setInputNameLocator, 5);
+ waitToBeClickable(By.xpath(XpathSelector.INPUT_NAME_SAVE_BTN.getXpath())).click();
waitForAddedOutputNotification();
}
ATTRIBUTES_CHECKBOX("//checkbox[@data-tests-id='%s']"),
DECLARE_OUTPUT_BTN("declare-button declare-output", "//button[@data-tests-id='%s']"),
INSTANCE_SPAN("//div[contains(@class,'table-rows-header')]"),
+ SET_INPUT_NAME_FIELD("//*[@id=\"myText\"]"),
+ INPUT_NAME_SAVE_BTN("//button[@data-tests-id='Save']"),
ADDED_OUTPUT_NOTIFICATION("tab-indication", "//div[@data-tests-id='Outputs']/div[contains(@class, '%s')]");
@Getter