* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.openecomp.sdc.be.components.impl;
import static java.util.stream.Collectors.joining;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SubPropertyToscaFunction;
import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
private final IGraphLockOperation graphLockOperation;
private final ToscaFunctionService toscaFunctionService;
private final DataTypeBusinessLogic dataTypeBusinessLogic;
- private ApplicationDataTypeCache applicationDataTypeCache;
private final ArtifactTypeOperation artifactTypeOperation;
-
private final GroupTypeImportManager groupTypeImportManager;
private final GroupTypeOperation groupTypeOperation;
- private InterfaceLifecycleOperation interfaceLifecycleTypeOperation;
- private InterfaceLifecycleTypeImportManager interfaceLifecycleTypeImportManager;
-
private final CapabilityTypeImportManager capabilityTypeImportManager;
private final CapabilityTypeOperation capabilityTypeOperation;
+ private ApplicationDataTypeCache applicationDataTypeCache;
+ private InterfaceLifecycleOperation interfaceLifecycleTypeOperation;
+ private InterfaceLifecycleTypeImportManager interfaceLifecycleTypeImportManager;
public ServiceImportBusinessLogic(final GroupBusinessLogic groupBusinessLogic, final ArtifactsBusinessLogic artifactsBusinessLogic,
final ComponentsUtils componentsUtils, final ToscaOperationFacade toscaOperationFacade,
Map<String, Object> combinedMappedToscaTemplate =
getNewChangesToToscaTemplate(newMappedToscaTemplate, (Map<String, Object>) existingMappedToscaTemplate.getValue());
if (!combinedMappedToscaTemplate.equals(existingMappedToscaTemplate.getValue())) {
+ if (latestResource.getComponentMetadataDefinition().getMetadataDataDefinition().isNormative()) {
+ nodeTypeDefinition.getNodeTypeMetadata().setNormative(true);
+ }
existingMappedToscaTemplate.setValue(combinedMappedToscaTemplate);
nodeTypeDefinition.setMappedNodeType(existingMappedToscaTemplate);
namesOfNodeTypesToCreate.add(nodeTypeDefinition);
Map<String, InputDefinition> inputs = parsedToscaYamlInfo.getInputs();
service = serviceImportParseLogic.createInputsOnService(service, inputs);
log.trace("************* Finished to add inputs from yaml {}", yamlName);
- ListDataDefinition<SubstitutionFilterPropertyDataDefinition> substitutionFilterProperties = parsedToscaYamlInfo.getSubstitutionFilterProperties();
+ ListDataDefinition<SubstitutionFilterPropertyDataDefinition> substitutionFilterProperties =
+ parsedToscaYamlInfo.getSubstitutionFilterProperties();
service = serviceImportParseLogic.createSubstitutionFilterOnService(service, substitutionFilterProperties);
log.trace("************* Added Substitution filter from interface yaml {}", yamlName);
Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = parsedToscaYamlInfo.getInstances();
}
}
if (shouldLock) {
- graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(), NodeTypeEnum.Resource);
+ graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(), NodeTypeEnum.Service);
}
}
}
final List<ComponentInstance> componentInstances = component.getComponentInstances();
final String componentUniqueId = component.getUniqueId();
for (final InputDefinition input : inputs) {
- if (isInputFromComponentInstanceProperty(input.getName(), componentInstances)) {
+ boolean isSubMapProp = false;
+ if (substitutionMappingProperties != null && !substitutionMappingProperties.isEmpty()) {
+ isSubMapProp = substitutionMappingProperties.entrySet().stream()
+ .anyMatch(stringEntry -> stringEntry.getValue().get(0).equals(input.getName()));
+ }
+ if (!isSubMapProp && isInputFromComponentInstanceProperty(input.getName(), componentInstances)) {
associateInputToComponentInstanceProperty(userId, input, componentInstances, componentUniqueId);
} else {
associateInputToServiceProperty(userId, input, component, substitutionMappingProperties);
}
}
-
Either<List<InputDefinition>, StorageOperationStatus> either = toscaOperationFacade.updateInputsToComponent(inputs, componentUniqueId);
if (either.isRight()) {
throw new ComponentException(ActionStatus.GENERAL_ERROR);
AtomicBoolean isInputFromCIProp = new AtomicBoolean(false);
if (CollectionUtils.isNotEmpty(componentInstances)) {
- outer: for (ComponentInstance instance : componentInstances) {
+ outer:
+ for (ComponentInstance instance : componentInstances) {
for (PropertyDefinition instanceProperty : instance.getProperties()) {
if (CollectionUtils.isNotEmpty(instanceProperty.getGetInputValues())) {
for (GetInputValueDataDefinition getInputValueDataDefinition : instanceProperty.getGetInputValues()) {
String componentInstanceId = null;
ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
- outer: for (ComponentInstance instance : componentInstances) {
+ outer:
+ for (ComponentInstance instance : componentInstances) {
for (PropertyDefinition instanceProperty : instance.getProperties()) {
if (CollectionUtils.isNotEmpty(instanceProperty.getGetInputValues())) {
for (GetInputValueDataDefinition getInputValueDataDefinition : instanceProperty.getGetInputValues()) {
}
});
- final Optional<PropertyDefinition> propDefOptional = properties.stream().filter(prop -> prop.getName().equals(propertyNameFromInput.get()))
- .findFirst();
+ final Optional<PropertyDefinition> propDefOptional =
+ properties.stream().filter(prop -> prop.getName().equals(propertyNameFromInput.get()))
+ .findFirst();
if (propDefOptional.isPresent()) {
// From SELF
final String componentUniqueId = component.getUniqueId();
if (either.isRight()) {
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
+ } else {
+ input.setMappedToComponentProperty(false);
}
}
}
boolean inTransaction, boolean shouldLock) {
String nodeName = nodeTypeInfoToUpdateArtifacts.getNodeName();
Resource resource = preparedResource;
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = nodeTypeInfoToUpdateArtifacts
- .getNodeTypesArtifactsToHandle();
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle =
+ nodeTypeInfoToUpdateArtifacts
+ .getNodeTypesArtifactsToHandle();
if (preparedResource.getResourceType() == ResourceTypeEnum.VF) {
if (nodeName != null && nodeTypesArtifactsToHandle.get(nodeName) != null && !nodeTypesArtifactsToHandle.get(nodeName).isEmpty()) {
Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes = handleNodeTypeArtifacts(preparedResource,
vfCsarArtifactsToHandle = new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class);
vfCsarArtifactsToHandle.put(artifactOperation.getArtifactOperationEnum(), artifactPathAndNameList.left().value());
} else {
- Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes = findVfCsarArtifactsToHandle(
+ Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat>
+ findVfCsarArtifactsToHandleRes = findVfCsarArtifactsToHandle(
component, artifactPathAndNameList.left().value(), csarInfo.getModifier());
if (findVfCsarArtifactsToHandleRes.isRight()) {
resStatus = Either.right(findVfCsarArtifactsToHandleRes.right().value());
EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> nodeTypeArtifactsToHandle = new EnumMap<>(
ArtifactsBusinessLogic.ArtifactOperationEnum.class);
Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
- Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> nodeTypeArtifactsToHandleRes = Either
+ Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat>
+ nodeTypeArtifactsToHandleRes = Either
.left(nodeTypeArtifactsToHandle);
try {
List<CsarUtils.NonMetaArtifactInfo> artifactsToUpload = new ArrayList<>(artifactPathAndNameList);
log.debug("************* Going to create all nodes {}", yamlName);
handleServiceNodeTypes(yamlName, service, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts,
nodeTypesInfo, csarInfo, nodeName);
+ List<PropertyDefinition> serviceProperties = null != service ? service.getProperties() : Collections.emptyList();
if (MapUtils.isNotEmpty(uploadComponentInstanceInfoMap)) {
log.debug("************* Going to create all resource instances {}", yamlName);
service = createServiceInstances(yamlName, service, uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
log.debug("************* Going to create all relations {}", yamlName);
- service = createServiceInstancesRelations(csarInfo.getModifier(), yamlName, service, uploadComponentInstanceInfoMap);
+ service = createServiceInstancesRelations(csarInfo.getModifier(), yamlName, service, uploadComponentInstanceInfoMap, serviceProperties);
log.debug("************* Going to create positions {}", yamlName);
compositionBusinessLogic.setPositionsForComponentInstances(service, csarInfo.getModifier().getUserId());
log.debug("************* Finished to set positions {}", yamlName);
}
protected Service createServiceInstancesRelations(User user, String yamlName, Service service,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
+ List<PropertyDefinition> serviceProperties) {
log.debug("#createResourceInstancesRelations - Going to create relations ");
List<ComponentInstance> componentInstancesList = service.getComponentInstances();
if (MapUtils.isEmpty(uploadResInstancesMap) || CollectionUtils.isEmpty(componentInstancesList)) { // PNF can have no resource instances
final Map<String, DataTypeDefinition> allDataTypesMap =
componentsUtils.getAllDataTypes(applicationDataTypeCache, service.getModel());
final Service service1 = service;
+ service1.setProperties(serviceProperties);
uploadResInstancesMap.values().forEach(
i -> processComponentInstance(yamlName, service1, componentInstancesList,
allDataTypesMap, instProperties,
//Inputs
ListDataDefinition<OperationInputDefinition> instanceInputs = instanceOperation.getInputs();
mergeOperationInputDefinitions(templateOperation.getInputs(), instanceInputs);
+ if (null != instanceInputs) {
+ component.getProperties()
+ .forEach(property -> instanceInputs.getListToscaDataDefinition().stream()
+ .filter(instanceInput ->
+ instanceInput.getToscaFunction() instanceof ToscaGetFunctionDataDefinition &&
+ property.getName().equals(instanceInput.getToscaFunction() != null ?
+ ((ToscaGetFunctionDataDefinition) instanceInput.getToscaFunction()).getPropertyName() :
+ null))
+ .forEach(oldInput -> oldInput.setType(property.getType()))
+ );
+ }
templateOperation.setInputs(instanceInputs);
//Implementation
templateOperation.setImplementation(instanceOperation.getImplementation());
Resource origResource = existingnodeTypeMap.get(uploadComponentInstanceInfo.getType());
componentInstance.setName(uploadComponentInstanceInfo.getName());
componentInstance.setIcon(origResource.getIcon());
+ componentInstance.setMinOccurrences(uploadComponentInstanceInfo.getMinOccurrences());
+ componentInstance.setMaxOccurrences(uploadComponentInstanceInfo.getMaxOccurrences());
+ componentInstance.setInstanceCount(uploadComponentInstanceInfo.getInstanceCount());
resourcesInstancesMap.put(componentInstance, origResource);
} catch (final ComponentException e) {
throw e;