From adc29b887ccdfed63cd97e942ae6ac594d3bc44e Mon Sep 17 00:00:00 2001 From: Idan Amit Date: Sun, 16 Jul 2017 14:54:17 +0300 Subject: [sdc] - merged 1707_build into sdc LF Change-Id: Ia91f0206493d0cd8f158779ed1a94f55305c8a97 Signed-off-by: Idan Amit Signed-off-by: Michael Lando --- .../ci/tests/execute/imports/ExportToscaTest.java | 9 +- .../ci/tests/execute/inputs/InputsApiTests.java | 8 +- .../be/components/impl/ArtifactsBusinessLogic.java | 3 +- .../impl/ComponentInstanceBusinessLogic.java | 4 +- .../be/components/impl/InputsBusinessLogic.java | 192 +++++++++++++-------- .../externalapi/servlet/CrudExternalServlet.java | 4 +- .../sdc/be/model/ComponentInstInputsMap.java | 6 +- .../sdc/be/model/ComponentInstanceProperty.java | 4 +- .../model/IComponentInstanceConnectedElement.java | 5 + .../operations/NodeTemplateOperation.java | 20 +-- .../be/model/operations/api/IInputsOperation.java | 2 - .../be/model/operations/impl/InputsOperation.java | 114 ------------ .../properties-assignment/properties.utils.ts | 16 +- pom.xml | 2 +- .../ci/tests/execute/imports/ExportToscaTest.java | 9 +- .../ci/tests/execute/inputs/InputsApiTests.java | 9 +- 16 files changed, 165 insertions(+), 242 deletions(-) diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java index 192f6759c3..6bf0786a4b 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java @@ -49,6 +49,7 @@ import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstInputsMap; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.ComponentInstancePropInput; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.GroupProperty; @@ -472,10 +473,10 @@ public class ExportToscaTest extends ComponentBaseTest { // 6 add instance inputs in service RestResponse getComponentInstanceInputsResponse = InputsRestUtils.getComponentInstanceInputs(service, vfi); BaseValidationUtils.checkSuccess(getComponentInstanceInputsResponse); - List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>() { + List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>() { }.getType()); // Take only the 2 first inputs - List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); + List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); // 7 Build component instances input map to add to server ComponentInstInputsMap buildComponentInstInputsMap = buildComponentInstInputsMap(vfi.getUniqueId(), inputsToAdd); @@ -674,8 +675,8 @@ public class ExportToscaTest extends ComponentBaseTest { return masterArtifact; } - private ComponentInstInputsMap buildComponentInstInputsMap(String addToInput, List inputs) { - Map> map = new HashMap<>(); + private ComponentInstInputsMap buildComponentInstInputsMap(String addToInput, List inputs) { + Map> map = new HashMap<>(); map.put(addToInput, inputs); ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap(); componentInstInputsMap.setComponentInstanceInputsMap(map); diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java index b71240b527..633ce45178 100644 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java +++ b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java @@ -141,10 +141,10 @@ public class InputsApiTests extends ComponentBaseTest { ComponentInstance vfInstance = serviceInstances.get(0); RestResponse getComponentInstanceInputsResponse = InputsRestUtils.getComponentInstanceInputs(service, vfInstance); BaseValidationUtils.checkSuccess(getComponentInstanceInputsResponse); - List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>(){}.getType()); + List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>(){}.getType()); // Take only the 2 first inputs - List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); + List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); // Build component instances input map to add to server ComponentInstInputsMap buildComponentInstInputsMap = buildComponentInstInputsMap(vfInstance.getUniqueId(), inputsToAdd); @@ -321,8 +321,8 @@ public class InputsApiTests extends ComponentBaseTest { * @param inputs * @return {@link org.openecomp.sdc.be.model.ComponentInstInputsMap} */ - private ComponentInstInputsMap buildComponentInstInputsMap (String addToInput, List inputs) { - Map> map = new HashMap<>(); + private ComponentInstInputsMap buildComponentInstInputsMap (String addToInput, List inputs) { + Map> map = new HashMap<>(); map.put(addToInput, inputs); ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap(); componentInstInputsMap.setComponentInstanceInputsMap(map); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index cb04cfcdc9..cec045d8a3 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -3515,11 +3515,12 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private String generateHeatEnvPayload(ArtifactDefinition artifactDefinition) { List heatParameters = artifactDefinition.getListHeatParameters(); - heatParameters.sort(Comparator.comparing(e -> e.getName())); StringBuilder sb = new StringBuilder(); sb.append(ConfigurationManager.getConfigurationManager().getConfiguration().getHeatEnvArtifactHeader()); sb.append("parameters:\n"); if (heatParameters != null) { + heatParameters.sort(Comparator.comparing(e -> e.getName())); + List empltyHeatValues = new ArrayList<>(); for (HeatParameterDefinition heatParameterDefinition : heatParameters) { 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 643b35d17b..5da416ec0b 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 @@ -383,14 +383,14 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { StorageOperationStatus artStatus = toscaOperationFacade.addDeploymentArtifactsToInstance(containerComponent.getUniqueId(), componentInstance, finalDeploymentArtifacts); if ( artStatus != StorageOperationStatus.OK){ log.debug("Failed to add instance deployment artifacts for instance {} in conatiner {} error {}", componentInstance.getUniqueId(), containerComponent.getUniqueId(), artStatus); - return Either.left(componentsUtils.convertFromStorageResponseForResourceInstance(artStatus, false)); + return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponseForResourceInstance(artStatus, false))); } StorageOperationStatus result = toscaOperationFacade .addGroupInstancesToComponentInstance(containerComponent, componentInstance, filteredGroups, groupInstancesArtifacts); if (result != StorageOperationStatus.OK) { log.debug("failed to update group instance for component instance {}", componentInstance.getUniqueId()); - return Either.left(componentsUtils.convertFromStorageResponse(result)); + return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(result))); } componentInstance.setDeploymentArtifacts(finalDeploymentArtifacts); return Either.left(ActionStatus.OK); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java index 4f4ad7f838..d6497b58ea 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java @@ -46,6 +46,7 @@ import org.openecomp.sdc.be.model.ComponentInstancePropInput; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.DataTypeDefinition; +import org.openecomp.sdc.be.model.IComponentInstanceConnectedElement; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.User; @@ -443,10 +444,19 @@ public class InputsBusinessLogic extends BaseBusinessLogic { ////////////////////////////////////////////////////////////////////////////////////////////////////// List resList = new ArrayList(); - Map> newInputsMap = componentInstInputsMapUi.getComponentInstanceInputsMap(); + Map> newInputsMap = componentInstInputsMapUi.getComponentInstanceInputsMap(); List ciList = component.getComponentInstances(); if (newInputsMap != null && !newInputsMap.isEmpty()) { - int index = 0; + + result = createInputsFromProperty(component, origComponentMap, inputsToCreate, propertiesToCreateMap, inputsValueToCreateMap, dataTypes, resList, newInputsMap, true); + + if (result.isRight()) { + log.debug("Failed to create inputs of resource for id {} error {}", component.getUniqueId(), result.right().value()); + return result; + } + resList = result.left().value(); + + /*int index = 0; for (Entry> entry : newInputsMap.entrySet()) { String compInstId = entry.getKey(); @@ -486,14 +496,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic { } } - } + }*/ } Map> newInputsPropsMap = componentInstInputsMapUi.getComponentInstanceProperties(); if (newInputsPropsMap != null && !newInputsPropsMap.isEmpty()) { - result = createInputsFromProperty(component, origComponentMap, inputsToCreate, propertiesToCreateMap, dataTypes, resList, newInputsPropsMap); + result = createInputsFromProperty(component, origComponentMap, inputsToCreate, propertiesToCreateMap, inputsValueToCreateMap, dataTypes, resList, newInputsPropsMap, false); if (result.isRight()) { log.debug("Failed to create inputs of resource for id {} error {}", component.getUniqueId(), result.right().value()); @@ -895,25 +905,20 @@ public class InputsBusinessLogic extends BaseBusinessLogic { if(inputsValue != null && !inputsValue.isEmpty()){ for(ComponentInstanceInput inputValue: inputsValue){ - inputValue.setValue(inputValue.getDefaultValue()); - List getInputsValues = inputValue.getGetInputValues(); - if(getInputsValues != null && !getInputsValues.isEmpty()){ - Optional op = getInputsValues.stream().filter(gi -> gi.getInputId().equals(inputForDelete.getUniqueId())).findAny(); - if(op.isPresent()){ - getInputsValues.remove(op.get()); - } - } - inputValue.setGetInputValues(getInputsValues); + String compInstId = inputValue.getComponentInstanceId(); + prepareValueBeforeDelete(compInstId, inputForDelete, inputValue, inputValue.getPath()); + + status = toscaOperationFacade.updateComponentInstanceInput(component, compInstId, inputValue); List inputList = null; - String ciId = inputValue.getComponentInstanceId(); - status = toscaOperationFacade.updateComponentInstanceInput(component, ciId, inputValue); if(status != StorageOperationStatus.OK){ - log.debug("Component id: {} delete component instance input id: {} failed", componentId, inputId); + log.debug("Component id: {} update component instance property {} id: {} failed", componentId, inputValue.getUniqueId(), inputId); deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), component.getName())); return deleteEither; } + } + } // US848813 delete service input that relates to VL / CP property @@ -923,42 +928,9 @@ public class InputsBusinessLogic extends BaseBusinessLogic { //propertyList = propertyValueStatus.left().value(); for(ComponentInstanceProperty propertyValue: propertiesValue){ - String value = propertyValue.getValue(); - Map mappedToscaTemplate = (Map) new Yaml().load(value); - - resetInputName(mappedToscaTemplate, inputForDelete.getName()); - - value = ""; - if(!mappedToscaTemplate.isEmpty()){ - Either result = cleanNestedMap(mappedToscaTemplate , true); - Map modifiedMappedToscaTemplate = mappedToscaTemplate; - if (result.isLeft()) - modifiedMappedToscaTemplate = (Map)result.left().value(); - else - Log.warn("Map cleanup failed -> " +result.right().value().toString()); //continue, don't break operation - value = gson.toJson(modifiedMappedToscaTemplate); - } - propertyValue.setValue(value); String compInstId = propertyValue.getComponentInstanceId(); - propertyValue.setRules(null); - List getInputsValues = propertyValue.getGetInputValues(); - if(getInputsValues != null && !getInputsValues.isEmpty()){ - Optional op = getInputsValues.stream().filter(gi -> gi.getInputId().equals(inputForDelete.getUniqueId())).findAny(); - if(op.isPresent()){ - getInputsValues.remove(op.get()); - } - } - propertyValue.setGetInputValues(getInputsValues); - - Either findDefaultValue = propertyOperation.findDefaultValueFromSecondPosition(propertyValue.getPath(), propertyValue.getUniqueId(), propertyValue.getDefaultValue()); - if (findDefaultValue.isRight()) { - deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertTitanStatusToStorageStatus(findDefaultValue.right().value())))); - return deleteEither; - - } - String defaultValue = findDefaultValue.left().value(); - propertyValue.setDefaultValue(defaultValue); - log.debug("The returned default value in ResourceInstanceProperty is {}", defaultValue); + prepareValueBeforeDelete(compInstId, inputForDelete, propertyValue, propertyValue.getPath()); + status = toscaOperationFacade.updateComponentInstanceProperty(component, compInstId, propertyValue); if(status != StorageOperationStatus.OK){ log.debug("Component id: {} update component instance property {} id: {} failed", componentId, propertyValue.getUniqueId(), inputId); @@ -984,6 +956,47 @@ public class InputsBusinessLogic extends BaseBusinessLogic { } } + private Either prepareValueBeforeDelete(String compInstId, InputDefinition inputForDelete, PropertyDefinition inputValue, List pathOfComponentInstances) { + Either deleteEither = Either.left(inputForDelete); + String value = inputValue.getValue(); + Map mappedToscaTemplate = (Map) new Yaml().load(value); + + resetInputName(mappedToscaTemplate, inputForDelete.getName()); + + value = ""; + if(!mappedToscaTemplate.isEmpty()){ + Either result = cleanNestedMap(mappedToscaTemplate , true); + Map modifiedMappedToscaTemplate = mappedToscaTemplate; + if (result.isLeft()) + modifiedMappedToscaTemplate = (Map)result.left().value(); + else + Log.warn("Map cleanup failed -> " +result.right().value().toString()); //continue, don't break operation + value = gson.toJson(modifiedMappedToscaTemplate); + } + inputValue.setValue(value); + + + List getInputsValues = inputValue.getGetInputValues(); + if(getInputsValues != null && !getInputsValues.isEmpty()){ + Optional op = getInputsValues.stream().filter(gi -> gi.getInputId().equals(inputForDelete.getUniqueId())).findAny(); + if(op.isPresent()){ + getInputsValues.remove(op.get()); + } + } + inputValue.setGetInputValues(getInputsValues); + + Either findDefaultValue = propertyOperation.findDefaultValueFromSecondPosition(pathOfComponentInstances, inputValue.getUniqueId(), inputValue.getDefaultValue()); + if (findDefaultValue.isRight()) { + deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertTitanStatusToStorageStatus(findDefaultValue.right().value())))); + return deleteEither; + + } + String defaultValue = findDefaultValue.left().value(); + inputValue.setDefaultValue(defaultValue); + log.debug("The returned default value in ResourceInstanceProperty is {}", defaultValue); + return deleteEither; + } + private Either prepareAndValidateInputBeforeCreate(InputDefinition newInputDefinition, Map dataTypes) { @@ -1196,7 +1209,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { - private Either, ResponseFormat> createInputsFromProperty(org.openecomp.sdc.be.model.Component component, Map origComponentMap, Map inputsToCreate, Map> propertiesToCreateMap, Map dataTypes, List resList, Map> newInputsPropsMap) { + private Either, ResponseFormat> createInputsFromProperty(org.openecomp.sdc.be.model.Component component, Map origComponentMap, Map inputsToCreate, Map> propertiesToCreateMap, Map> inputsValueToCreateMap, Map dataTypes, List resList, Map> newInputsPropsMap, boolean isInputValue) { List ciList = component.getComponentInstances(); String componentId = component.getUniqueId(); for (Entry> entry : newInputsPropsMap.entrySet()) { @@ -1206,7 +1219,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic { propertiesToCreate = propertiesToCreateMap.get(compInstId); }else{ propertiesToCreate = new ArrayList<>(); - } + } + + List inputsValueToCreate = null; + if(propertiesToCreateMap.containsKey(compInstId)){ + inputsValueToCreate = inputsValueToCreateMap.get(compInstId); + }else{ + inputsValueToCreate = new ArrayList<>(); + } List properties = entry.getValue(); @@ -1238,7 +1258,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { propInput.setOwnerId(null); propInput.setParentUniqueId(null); - Either createInputRes = createInputForComponentInstance(component, origComponent,ci, inputsToCreate, propertiesToCreate, dataTypes, inputName, propInput); + Either createInputRes = createInputForComponentInstance(component, origComponent,ci, inputsToCreate, propertiesToCreate, inputsValueToCreate, dataTypes, inputName, propInput, isInputValue); if (createInputRes.isRight()) { log.debug("Failed to create input of resource instance for id {} error {}", compInstId, createInputRes.right().value()); @@ -1249,14 +1269,19 @@ public class InputsBusinessLogic extends BaseBusinessLogic { resList.add(createInputRes.left().value()); } - propertiesToCreateMap.put(compInstId, propertiesToCreate); + if(! isInputValue){ + propertiesToCreateMap.put(compInstId, propertiesToCreate); + } + else{ + inputsValueToCreateMap.put(compInstId, inputsValueToCreate); + } } } return Either.left(resList); } - private Either createInputForComponentInstance(org.openecomp.sdc.be.model.Component component,org.openecomp.sdc.be.model.Component orignComponent, ComponentInstance ci, Map inputsToCreate, List propertiesToCreate, Map dataTypes, String inputName, ComponentInstancePropInput propInput) { + private Either createInputForComponentInstance(org.openecomp.sdc.be.model.Component component,org.openecomp.sdc.be.model.Component orignComponent, ComponentInstance ci, Map inputsToCreate, List propertiesToCreate, List inputsValueToCreate, Map dataTypes, String inputName, ComponentInstancePropInput propInput, boolean isInputValue) { String propertiesName = propInput.getPropertiesName() ; PropertyDefinition selectedProp = propInput.getInput(); String[] parsedPropNames = propInput.getParsedPropNames(); @@ -1270,14 +1295,22 @@ public class InputsBusinessLogic extends BaseBusinessLogic { } InputDefinition input = null; - ComponentInstanceProperty prop = propInput; + PropertyDefinition prop = propInput; - if(CollectionUtils.isNotEmpty(propertiesToCreate)){ + if(CollectionUtils.isNotEmpty(propertiesToCreate) && !isInputValue){ Optional propOpt = propertiesToCreate.stream().filter(p -> p.getName().equals(propInput.getName())).findFirst(); if(propOpt.isPresent()){ prop = propOpt.get(); } + }else{ + if(CollectionUtils.isNotEmpty(inputsValueToCreate) && isInputValue){ + Optional propOpt = inputsValueToCreate.stream().filter(p -> p.getName().equals(propInput.getName())).findFirst(); + if(propOpt.isPresent()){ + prop = propOpt.get(); + } + } } + boolean complexProperty = false; if(propertiesName != null && !propertiesName.isEmpty() && selectedProp != null){ complexProperty = true; @@ -1317,7 +1350,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { if(!complexProperty){ jobject.put(GET_INPUT, input.getName()); prop.setValue(jobject.toJSONString()); - prop.setRules(null); + }else{ Map mappedToscaTemplate = (Map) objValue; @@ -1325,18 +1358,19 @@ public class InputsBusinessLogic extends BaseBusinessLogic { String json = gson.toJson(mappedToscaTemplate); prop.setValue(json); - prop.setRules(null); + } }else{ jobject.put(GET_INPUT, input.getName()); prop.setValue(jobject.toJSONString()); - prop.setRules(null); + } } - prop.setComponentInstanceId(ci.getUniqueId()); - prop.setComponentInstanceName(ci.getName()); + + ((IComponentInstanceConnectedElement)prop).setComponentInstanceId(ci.getUniqueId()); + ((IComponentInstanceConnectedElement)prop).setComponentInstanceName(ci.getName()); if(CollectionUtils.isEmpty(prop.getGetInputValues())){ prop.setGetInputValues(new ArrayList<>()); @@ -1348,17 +1382,31 @@ public class InputsBusinessLogic extends BaseBusinessLogic { getInputValueDataDefinition.setInputName(input.getName()); getInputValues.add(getInputValueDataDefinition); - if(!propertiesToCreate.contains(prop)){ - propertiesToCreate.add(prop); + if(!isInputValue){ + if(!propertiesToCreate.contains(prop)){ + propertiesToCreate.add((ComponentInstanceProperty)prop); + } + + inputsToCreate.put(input.getName(), input); + List propertiesList = input.getProperties(); + if(propertiesList == null) + propertiesList = new ArrayList<>(); // adding the property with the new value for UI + propertiesList.add((ComponentInstanceProperty)prop); + input.setProperties(propertiesList); + }else{ + ComponentInstanceInput inputValue = new ComponentInstanceInput(prop); + if(!inputsValueToCreate.contains(inputValue)){ + inputsValueToCreate.add(inputValue);; + } + + inputsToCreate.put(input.getName(), input); + List inputsValueList = input.getInputs(); + if(inputsValueList == null) + inputsValueList = new ArrayList<>(); // adding the property with the new value for UI + inputsValueList.add(inputValue); + input.setInputs(inputsValueList); } - inputsToCreate.put(input.getName(), input); - List propertiesList = input.getProperties(); - if(propertiesList == null) - propertiesList = new ArrayList<>(); // adding the property with the new value for UI - propertiesList.add(prop); - input.setProperties(propertiesList); - return Either.left(input); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java index 529d2aba4d..b4240777a8 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java @@ -120,7 +120,7 @@ public class CrudExternalServlet extends AbstractValidationsServlet { @ApiOperation(value = "creates a resource", httpMethod = "POST", notes = "Creates a resource") @ApiResponses(value = { @ApiResponse(code = 200, message = "ECOMP component is authenticated and Asset created", response = Resource.class), - @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"), + @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"), @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"), @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"), @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"), @@ -269,7 +269,7 @@ public class CrudExternalServlet extends AbstractValidationsServlet { @ApiOperation(value = "Change Resource lifecycle State", httpMethod = "POST") @ApiResponses(value = { @ApiResponse(code = 200, message = "Resource state changed", response = AssetMetadata.class), - @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"), + @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"), @ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"), @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"), @ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"), diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java index 9d016c0799..e436548f60 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java @@ -31,14 +31,14 @@ public class ComponentInstInputsMap implements Serializable{ */ private static final long serialVersionUID = 1136631343963488131L; - Map> componentInstanceInputsMap; + Map> componentInstanceInputsMap; Map> componentInstanceProperties; - public Map> getComponentInstanceInputsMap() { + public Map> getComponentInstanceInputsMap() { return componentInstanceInputsMap; } - public void setComponentInstanceInputsMap(Map> componentInstanceInputsMap) { + public void setComponentInstanceInputsMap(Map> componentInstanceInputsMap) { this.componentInstanceInputsMap = componentInstanceInputsMap; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java index 8bd3a9c809..25bbb50da4 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java @@ -23,11 +23,11 @@ package org.openecomp.sdc.be.model; import java.io.Serializable; import java.util.List; - import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyRule; -public class ComponentInstanceProperty extends PropertyDefinition implements IComponentInstanceConnectedElement, Serializable { + +public class ComponentInstanceProperty extends PropertyDefinition implements IComponentInstanceConnectedElement, Serializable{ /** * diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/IComponentInstanceConnectedElement.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IComponentInstanceConnectedElement.java index 86de3a1584..80e898626e 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/IComponentInstanceConnectedElement.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IComponentInstanceConnectedElement.java @@ -26,4 +26,9 @@ public interface IComponentInstanceConnectedElement { String getValueUniqueUid(); void setValueUniqueUid(String value); + + String getComponentInstanceName(); + void setComponentInstanceName(String componentInstanceName); + String getComponentInstanceId(); + void setComponentInstanceId(String componentInstanceId); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java index 29247996a5..33db64234b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java @@ -598,26 +598,8 @@ public class NodeTemplateOperation extends BaseOperation { if (status != StorageOperationStatus.OK) { return status; } - status = addInstanceDeploymentArtifacts(originNodeType, componentInstance, updatedContainerVertex, user, envType); - if (status != StorageOperationStatus.OK) { - return status; - } + return addCalculatedCapReqFromNodeType(originNodeType, componentInstance, updatedContainerVertex); - - } - - private StorageOperationStatus addInstanceDeploymentArtifacts(ToscaElement originNodeType, ComponentInstanceDataDefinition componentInstance, GraphVertex updatedContainerVertex, User user, String envType) { - Map deploymentArtifacts = originNodeType.getDeploymentArtifacts(); - MapArtifactDataDefinition instArtifacts = prepareInstDeploymentArtifactPerInstance(deploymentArtifacts, componentInstance.getUniqueId(), user, envType); - if (instArtifacts != null) { - StorageOperationStatus calculatedResult = addToscaDataDeepElementsBlockToToscaElement(updatedContainerVertex, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, instArtifacts, - componentInstance.getUniqueId()); - - if (calculatedResult != StorageOperationStatus.OK) { - return calculatedResult; - } - } - return StorageOperationStatus.OK; } public MapArtifactDataDefinition prepareInstDeploymentArtifactPerInstance(Map deploymentArtifacts, String componentInstanceId, User user, String envType) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInputsOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInputsOperation.java index 386864a8b0..8b44229df1 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInputsOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInputsOperation.java @@ -43,8 +43,6 @@ public interface IInputsOperation { Either, TitanOperationStatus> addInputsToGraph(String componentId, NodeTypeEnum nodeType, Map inputs, Map dataTypes); - Either, StorageOperationStatus> addInputsToComponent(String resourceId, NodeTypeEnum nodeType, ComponentInstInputsMap componentInsInputs, Map dataTypes); - TitanOperationStatus findNodeNonInheretedInputs(String uniqueId, List inputs); Either, StorageOperationStatus> getInputsOfComponent(String compId, String fromName, int amount); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java index dba4ff9b75..d3db95df65 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java @@ -1210,121 +1210,7 @@ public class InputsOperation extends AbstractOperation implements IInputsOperati } - public Either, StorageOperationStatus> addInputsToComponent(String resourceId, NodeTypeEnum nodeType, ComponentInstInputsMap componentInsInputs, Map dataTypes) { - List resList = new ArrayList(); - Map> newInputsMap = componentInsInputs.getComponentInstanceInputsMap(); - if (newInputsMap != null && !newInputsMap.isEmpty()) { - for (Entry> entry : newInputsMap.entrySet()) { - String compInstId = entry.getKey(); - Either ciVertexEither = titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), compInstId); - if (ciVertexEither.isRight()) { - log.debug("Failed to fetch vertex of resource instance for id {} error {}", compInstId, ciVertexEither.right().value()); - return Either.right( DaoStatusConverter.convertTitanStatusToStorageStatus(ciVertexEither.right().value())); - } - TitanVertex ciVertex = ciVertexEither.left().value(); - - - //String originType = (String) titanGenericDao.getProperty(originVertex, GraphPropertiesDictionary.LABEL.getProperty()); - String compInstname = (String) titanGenericDao.getProperty(ciVertex, GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()); - - List inputs = entry.getValue(); - - if (inputs != null && !inputs.isEmpty()) { - for (InputDefinition input : inputs) { - - - Either counterRes = componentInstanceOperation.increaseAndGetResourceInstanceSpecificCounter(compInstId, GraphPropertiesDictionary.INPUT_COUNTER, true); - if (counterRes.isRight()) { - log.debug("increaseAndGetResourceInputCounter failed resource instance {}", compInstId); - StorageOperationStatus status = counterRes.right().value(); - return Either.right(status); - } - - Either oldInputEither = getInputFromGraph(input.getUniqueId(), true, true); - if (oldInputEither.isRight()) { - log.error("Failed to get input {} ", input.getUniqueId()); - - return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(oldInputEither.right().value())); - } - - InputDefinition oldInput = oldInputEither.left().value(); - String serviceInputName = compInstname + "_" + input.getName(); - input.setName(serviceInputName); - - JSONObject jobject = new JSONObject(); - jobject.put(GET_INPUT, input.getName()); - - ComponentInstanceInput inputValue = new ComponentInstanceInput(oldInput, jobject.toJSONString(), null); - Integer index = counterRes.left().value(); - - Either eitherStatus = componentInstanceOperation.addInputValueToResourceInstance(inputValue, compInstId, index, true); - - if (eitherStatus.isRight()) { - log.error("Failed to add input value {} to resource instance {} in Graph. status is {}", inputValue, compInstId, eitherStatus.right().value().name()); - - return Either.right(eitherStatus.right().value()); - } - ComponentInstanceInput inputValueData = eitherStatus.left().value(); - - input.setSchema(oldInputEither.left().value().getSchema()); - input.setDefaultValue(oldInput.getDefaultValue()); - input.setConstraints(oldInput.getConstraints()); - input.setDescription(oldInput.getDescription()); - input.setHidden(oldInput.isHidden()); - input.setImmutable(oldInput.isImmutable()); - input.setDefinition(oldInput.isDefinition()); - input.setRequired(oldInput.isRequired()); - - StorageOperationStatus validateAndUpdateProperty = validateAndUpdateProperty(input, dataTypes); - if (validateAndUpdateProperty != StorageOperationStatus.OK) { - log.error("Property {} is invalid. Status is {}", input, validateAndUpdateProperty); - return Either.right(validateAndUpdateProperty); - } - - Either addPropertyToGraph = addInputToGraph(serviceInputName, input, resourceId, nodeType); - if (addPropertyToGraph.isRight()) { - return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(addPropertyToGraph.right().value())); - } - InputDefinition createdInputyDefinition = convertInputDataToInputDefinition(addPropertyToGraph.left().value()); - createdInputyDefinition.setName(serviceInputName); - createdInputyDefinition.setParentUniqueId(resourceId); - - Map props = new HashMap(); - props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), createdInputyDefinition.getName()); - props.put(GraphEdgePropertiesDictionary.OWNER_ID.getProperty(), compInstId); - - GraphNode propertyData = new UniqueIdData(NodeTypeEnum.InputValue, inputValueData.getValueUniqueUid()); - - Either addPropRefResult = titanGenericDao.createRelation(addPropertyToGraph.left().value(), propertyData, GraphEdgeLabels.GET_INPUT, props); - - if (addPropRefResult.isRight()) { - TitanOperationStatus status = addPropRefResult.right().value(); - String description = "Failed to associate input " + addPropertyToGraph.left().value().getUniqueId() + " to input value " + inputValueData.getUniqueId() + " in graph. Status is " + status; - BeEcompErrorManager.getInstance().logInternalFlowError(ASSOCIATING_INPUT_TO_PROP, description, ErrorSeverity.ERROR); - return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); - } - - resList.add(createdInputyDefinition); - - } - } - - } - } - Map> newInputsPropsMap = componentInsInputs.getComponentInstanceProperties(); - if (newInputsPropsMap != null && !newInputsPropsMap.isEmpty()) { - Either, StorageOperationStatus> result = createInputsFromProperty(resourceId, nodeType, dataTypes, resList, newInputsPropsMap); - - if (result.isRight()) { - log.debug("Failed to create inputs of resource for id {} error {}", resourceId, result.right().value()); - return result; - } - resList = result.left().value(); - - } - return Either.left(resList); - } private Either, StorageOperationStatus> createInputsFromProperty(String resourceId, NodeTypeEnum nodeType, Map dataTypes, List resList, Map> newInputsPropsMap) { for (Entry> entry : newInputsPropsMap.entrySet()) { diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts index a3507feb6f..f876af7f8a 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts @@ -56,21 +56,21 @@ export class PropertiesUtils { if (newFEProp.getInputValues && newFEProp.getInputValues.length) { //if this prop (or any children) are declared, set isDeclared and disable checkbox on parents/children newFEProp.getInputValues.forEach(propInputDetail => { let inputPath = propInputDetail.inputPath; - if (!isVF && !inputPath) { //TODO: this is a workaround until Marina adds inputPath + if (!inputPath) { //TODO: this is a workaround until Marina adds inputPath let input = inputs.find(input => input.uniqueId == propInputDetail.inputId); if (!input) { console.log("CANNOT FIND INPUT FOR " + propInputDetail.inputId); return; } else inputPath = input.inputPath; } - if (isVF || inputPath == newFEProp.name) inputPath = undefined; + if (inputPath == newFEProp.name) inputPath = undefined; // if not complex we need to remove the inputPath from FEModel so we not look for a child newFEProp.setAsDeclared(inputPath); //if a path is sent, its a child prop. this param is optional this.propertiesService.disableRelatedProperties(newFEProp, inputPath); }); - } + } this.initValueObjectRef(newFEProp); //initialize valueObj. propertyFeArray.push(newFEProp); newFEProp.updateExpandedChildPropertyId(newFEProp.name); //display only the first level of children this.dataTypeService.checkForCustomBehavior(newFEProp); - } + } }); instanceFePropertiesMap[instanceId] = propertyFeArray; @@ -101,8 +101,8 @@ export class PropertiesUtils { this.dataTypeService.getDerivedDataTypeProperties(dataTypeObj, tempProps, parentName); return tempProps; } - - /* Sets the valueObj of parent property and its children. + + /* Sets the valueObj of parent property and its children. * Note: This logic is different than assignflattenedchildrenvalues - here we merge values, there we pick either the parents value, props value, or default value - without merging. */ public initValueObjectRef = (property: PropertyFEModel): void => { @@ -138,7 +138,7 @@ export class PropertiesUtils { let propNameInObj = prop.propertiesName.substring(prop.propertiesName.indexOf(parentName) + parentName.length + 1).split('#').join('.'); //extract everything after parent name prop.valueObj = _.get(parentValueJSON, propNameInObj, prop.value || prop.defaultValue); //assign value -first value of parent if exists. If not, prop.value if not, prop.defaultvalue - + if ((prop.derivedDataType == DerivedPropertyType.SIMPLE || prop.isDeclared) && typeof prop.valueObj == 'object') { //Stringify objects that should be strings prop.valueObj = JSON.stringify(prop.valueObj); } else { //parse strings that should be objects @@ -148,7 +148,7 @@ export class PropertiesUtils { prop.valueObj = JSON.parse(prop.valueObj || '[]'); } else if (prop.derivedDataType == DerivedPropertyType.MAP && typeof prop.valueObj != 'object' && (!prop.isChildOfListOrMap || !prop.schema.property.isSimpleType)) { //dont parse values for children of map of simple prop.valueObj = JSON.parse(prop.valueObj || '{}'); - } + } if ((prop.derivedDataType == DerivedPropertyType.LIST || prop.derivedDataType == DerivedPropertyType.MAP) && typeof prop.valueObj == 'object' && Object.keys(prop.valueObj).length) { let newProps: Array = []; Object.keys(prop.valueObj).forEach((key) => { diff --git a/pom.xml b/pom.xml index 235da5de6e..b1dfc96bcd 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ 1.1.0-SNAPSHOT 1.1.0-SNAPSHOT - 1.1.0-SNAPSHOT + 1.1.0 1.1.0-SNAPSHOT diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java index 163504fbb0..a6088deac0 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java @@ -50,6 +50,7 @@ import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstInputsMap; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.ComponentInstancePropInput; import org.openecomp.sdc.be.model.ComponentInstanceProperty; import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.InputDefinition; @@ -316,9 +317,9 @@ public class ExportToscaTest extends ComponentBaseTest { //6 add instance inputs in service RestResponse getComponentInstanceInputsResponse = InputsRestUtils.getComponentInstanceInputs(service, vfi); BaseValidationUtils.checkSuccess(getComponentInstanceInputsResponse); - List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>(){}.getType()); + List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>(){}.getType()); // Take only the 2 first inputs - List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); + List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); //7 Build component instances input map to add to server ComponentInstInputsMap buildComponentInstInputsMap = buildComponentInstInputsMap(vfi.getUniqueId(), inputsToAdd); @@ -447,8 +448,8 @@ public class ExportToscaTest extends ComponentBaseTest { } return masterArtifact; } - private ComponentInstInputsMap buildComponentInstInputsMap (String addToInput, List inputs) { - Map> map = new HashMap<>(); + private ComponentInstInputsMap buildComponentInstInputsMap (String addToInput, List inputs) { + Map> map = new HashMap<>(); map.put(addToInput, inputs); ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap(); componentInstInputsMap.setComponentInstanceInputsMap(map); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java index 345b81eb3e..560e5389fe 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/inputs/InputsApiTests.java @@ -37,6 +37,7 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstInputsMap; import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstancePropInput; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; @@ -130,10 +131,10 @@ public class InputsApiTests extends ComponentBaseTest { ComponentInstance vfInstance = serviceInstances.get(0); RestResponse getComponentInstanceInputsResponse = InputsRestUtils.getComponentInstanceInputs(service, vfInstance); BaseValidationUtils.checkSuccess(getComponentInstanceInputsResponse); - List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>(){}.getType()); + List instanceInputs = new Gson().fromJson(getComponentInstanceInputsResponse.getResponse(), new TypeToken>(){}.getType()); // Take only the 2 first inputs - List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); + List inputsToAdd = instanceInputs.stream().limit(2).collect(Collectors.toList()); // Build component instances input map to add to server ComponentInstInputsMap buildComponentInstInputsMap = buildComponentInstInputsMap(vfInstance.getUniqueId(), inputsToAdd); @@ -214,8 +215,8 @@ public class InputsApiTests extends ComponentBaseTest { * @param inputs * @return {@link org.openecomp.sdc.be.model.ComponentInstInputsMap} */ - private ComponentInstInputsMap buildComponentInstInputsMap (String addToInput, List inputs) { - Map> map = new HashMap<>(); + private ComponentInstInputsMap buildComponentInstInputsMap (String addToInput, List inputs) { + Map> map = new HashMap<>(); map.put(addToInput, inputs); ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap(); componentInstInputsMap.setComponentInstanceInputsMap(map); -- cgit 1.2.3-korg