diff options
Diffstat (limited to 'catalog-model/src/main')
9 files changed, 209 insertions, 16 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java index 24386bc42e..e33ded2fb4 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java @@ -20,8 +20,22 @@ package org.openecomp.sdc.be.model; +import static java.util.Collections.emptyList; +import static java.util.Collections.emptyMap; +import static java.util.stream.Collectors.toMap; +import static org.apache.commons.collections.CollectionUtils.isEmpty; +import static org.apache.commons.collections.MapUtils.isEmpty; + import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.utils.MapUtil; @@ -71,6 +85,7 @@ public abstract class Component implements PropertiesOwner { protected List<AdditionalInformationDefinition> additionalInformation; protected List<PropertyDefinition> properties; private Map<String, InterfaceDefinition> interfaces; + private Map<String, CINodeFilterDataDefinition> nodeFilterComponents; public Map<String, InterfaceDefinition> getInterfaces() { return interfaces; @@ -589,6 +604,14 @@ public abstract class Component implements PropertiesOwner { return result; } + public Map<String, CINodeFilterDataDefinition> getNodeFilterComponents() { + return nodeFilterComponents; + } + + public void setNodeFilterComponents(Map<String, CINodeFilterDataDefinition> nodeFilterComponents) { + this.nodeFilterComponents = nodeFilterComponents; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -725,6 +748,9 @@ public abstract class Component implements PropertiesOwner { else if (!properties.equals(other.properties)) { return false; } + else if (!nodeFilterComponents.equals(other.nodeFilterComponents)) { + return false; + } return true; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java index 0d18676acc..c75f22cef0 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstance.java @@ -145,4 +145,7 @@ public class ComponentInstance extends ComponentInstanceDataDefinition implement this.nodeFilter = nodeFilter; } + + + } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java index 0cff11e19e..087816c053 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java @@ -48,6 +48,7 @@ public class ComponentParametersView { private boolean ignoreCapabiltyProperties = true; private boolean ignoreServicePath = true; private boolean ignorePolicies = false; + private boolean ignoreNodeFilter = false; public ComponentParametersView() { } @@ -90,6 +91,7 @@ public class ComponentParametersView { this.setIgnoreComponentInstances(false); this.setIgnoreCapabilities(false); this.setIgnoreRequirements(false); + this.setIgnoreNodeFilter(false); break; case COMPONENT_INSTANCES_PROPERTIES: this.setIgnoreComponentInstances(false); //we need this in order to get the calculate capabilities requirements @@ -142,6 +144,9 @@ public class ComponentParametersView { case NON_EXCLUDED_POLICIES: this.setIgnorePolicies(false); break; + case NODE_FILTER: + this.setIgnoreNodeFilter(false); + break; default: break; } @@ -216,6 +221,9 @@ public class ComponentParametersView { if (ignoreServicePath && componentType == ComponentTypeEnum.SERVICE) { ((Service) component).setForwardingPaths(null); } + if (ignoreNodeFilter){ + component.setNodeFilterComponents(null); + } return component; } @@ -240,6 +248,7 @@ public class ComponentParametersView { ignoreComponentInstancesInputs = true; ignoreCapabiltyProperties = true; ignoreServicePath = true; + ignoreNodeFilter = true; } public boolean isIgnoreGroups() { @@ -406,6 +415,14 @@ public class ComponentParametersView { this.ignorePolicies = ignorePolicies; } + public boolean isIgnoreNodeFilter() { + return ignoreNodeFilter; + } + + public void setIgnoreNodeFilter(boolean ignoreNodeFilter) { + this.ignoreNodeFilter = ignoreNodeFilter; + } + public JsonParseFlagEnum detectParseFlag() { JsonParseFlagEnum parseFlag; if (isIgnoreComponentInstances()) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java index 3454fd7fa2..7b672acc97 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.be.model; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -31,6 +32,8 @@ public class UploadComponentInstanceInfo { private Map<String, List<UploadPropInfo>> properties; private Map<String, String> capabilitiesNamesToUpdate; private Map<String, String> requirementsNamesToUpdate; + private Collection<String> directives; + private UploadNodeFilterInfo uploadNodeFilterInfo; public Map<String, List<UploadPropInfo>> getProperties() { return properties; @@ -88,4 +91,19 @@ public class UploadComponentInstanceInfo { this.requirementsNamesToUpdate = requirementsNamesToUpdate; } + public Collection<String> getDirectives() { + return directives; + } + + public void setDirectives(Collection<String> directives) { + this.directives = directives; + } + + public UploadNodeFilterInfo getUploadNodeFilterInfo() { + return uploadNodeFilterInfo; + } + + public void setUploadNodeFilterInfo(UploadNodeFilterInfo uploadNodeFilterInfo) { + this.uploadNodeFilterInfo = uploadNodeFilterInfo; + } } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java index ac9f196a92..04cc6ea16a 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java @@ -58,7 +58,8 @@ public class TopologyTemplate extends ToscaElement{ private Map<String, InterfaceDataDefinition> interfaces; private Map<String, MapInterfaceInstanceDataDefinition> instInterfaces; private Map<String, MapInterfaceDataDefinition> componentInstInterfaces; - + + private Map<String, CINodeFilterDataDefinition> nodeFilterComponents; //Component Instances External References (instanceId -> ExternalRefsMap) //----------------------------------------------------------------------- private Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs; @@ -231,7 +232,15 @@ public class TopologyTemplate extends ToscaElement{ this.forwardingPaths = forwardingPaths; } - /** + public Map<String, CINodeFilterDataDefinition> getNodeFilterComponents() { + return nodeFilterComponents; + } + + public void setNodeFilterComponents(Map<String, CINodeFilterDataDefinition> nodeFilters) { + this.nodeFilterComponents = nodeFilters; + } + + /** * Adds component instance to composition of topology template * Note that component instance will be overrided in case if the topology template already contains a component instance with the same name * @param componentInstance 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 f6c4207372..95f518aace 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -136,6 +136,14 @@ public class NodeTemplateOperation extends BaseOperation { if (componentInstance.getOriginType() == OriginTypeEnum.ServiceProxy) { TopologyTemplate updatedContainer = addComponentInstanceRes.left().value(); result = addServerCapAndReqToProxyServerInstance(updatedContainer, componentInstance, componentInstanceData); + if(result.isRight()) { + return result; + } + + result = addServiceInstancePropertiesToProxyServiceInstance(updatedContainer, componentInstance); + if(result.isRight()) { + return result; + } } } @@ -272,6 +280,34 @@ public class NodeTemplateOperation extends BaseOperation { return result; } + private Either<ImmutablePair<TopologyTemplate, String>, StorageOperationStatus> addServiceInstancePropertiesToProxyServiceInstance(TopologyTemplate updatedContainer, ComponentInstance componentInstance) { + + List<PropertyDefinition> propertiesList = componentInstance.getProperties(); + + if (propertiesList != null && !propertiesList.isEmpty()) { + Map<String, PropertyDataDefinition> propertiesMap = propertiesList.stream().map(i -> new PropertyDataDefinition(i)) + .collect(Collectors.toMap(i -> i.getName(), i -> i)); + MapPropertiesDataDefinition instProperties = new MapPropertiesDataDefinition(propertiesMap); + Map<String, MapPropertiesDataDefinition> instPropertiesMap = new HashMap<>(); + instPropertiesMap.put(componentInstance.getUniqueId(), instProperties); + updatedContainer.setInstProperties(instPropertiesMap); + Either<GraphVertex, TitanOperationStatus> getToscaElementRes = titanDao.getVertexById(updatedContainer.getUniqueId(), JsonParseFlagEnum.NoParse); + if(getToscaElementRes.isLeft()){ + deleteToscaDataDeepElementsBlockToToscaElement(getToscaElementRes.left().value(), EdgeLabelEnum.INST_PROPERTIES, + VertexTypeEnum.INST_PROPERTIES, componentInstance.getUniqueId()); + } + StorageOperationStatus status = addToscaDataDeepElementsBlockToToscaElement(updatedContainer.getUniqueId(), + EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, instProperties, + componentInstance.getUniqueId()); + if (status != StorageOperationStatus.OK) { + return Either.right(status); + } + + + } + return Either.left(new ImmutablePair<>(updatedContainer, componentInstance.getUniqueId())); + } + public Either<TopologyTemplate, StorageOperationStatus> addComponentInstanceToTopologyTemplate(TopologyTemplate container, ToscaElement originToscaElement, ComponentInstanceDataDefinition componentInstance, GraphVertex metadataVertex, boolean allowDeleted, User user) { @@ -620,7 +656,7 @@ public class NodeTemplateOperation extends BaseOperation { return status; } - + private MapPropertiesDataDefinition turnInputsIntoProperties(MapPropertiesDataDefinition instInput){ if (instInput.getMapToscaDataDefinition() != null) { for (PropertyDataDefinition currProp : instInput.getMapToscaDataDefinition().values()){ @@ -873,7 +909,7 @@ public class NodeTemplateOperation extends BaseOperation { /** * Prepares a map of capabilities lists Produces a deep copy of the received map of capabilities Sets values to the specific fields according to received component instance - * + * * @param capabilities * @param componentInstance * @return @@ -900,7 +936,7 @@ public class NodeTemplateOperation extends BaseOperation { /** * Prepares a map of requirements lists Produces a deep copy of the received map of requirements Sets values to the specific fields according to received component instance - * + * * @param requirements * @param componentInstance * @return @@ -1284,7 +1320,7 @@ public class NodeTemplateOperation extends BaseOperation { /** * Retrieves fulfilled requirement according to relation and received predicate - * + * * @param componentId * @param instanceId * @param foundRelation @@ -1332,7 +1368,7 @@ public class NodeTemplateOperation extends BaseOperation { /** * Retrieves fulfilled capability according to relation and received predicate - * + * * @param componentId * @param instanceId * @param foundRelation @@ -2018,12 +2054,12 @@ public class NodeTemplateOperation extends BaseOperation { log.debug("Failed to fetch component metadata vertex for id {} error {}", componentId, vertexById.right().value()); return DaoStatusConverter.convertTitanStatusToStorageStatus(vertexById.right().value()); } - GraphVertex metadataVertex = vertexById.left().value(); + GraphVertex metadataVertex = vertexById.left().value(); EnumMap<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class); props.put(GraphPropertyEnum.UUID, serviceUUID); props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true); - + EnumMap<GraphPropertyEnum, Object> hasNot = new EnumMap<>(GraphPropertyEnum.class); hasNot.put(GraphPropertyEnum.IS_DELETED, true); @@ -2037,7 +2073,7 @@ public class NodeTemplateOperation extends BaseOperation { if ( vertecies != null ){ GraphVertex serviceVertex = vertecies.get(0); //remove previous edges - + log.debug("Try to create or update edge between resource {} and service {} ", metadataVertex, serviceVertex.getUniqueId()); // create edge between container and service reference result = createOrUpdateInstanceEdge(metadataVertex, EdgeLabelEnum.ALLOTTED_OF, serviceVertex.getUniqueId(), instanceId).either(v -> StorageOperationStatus.OK, @@ -2045,8 +2081,8 @@ public class NodeTemplateOperation extends BaseOperation { } return result; } - - + + public StorageOperationStatus removeInstanceEdge(GraphVertex metadataVertex, ComponentInstanceDataDefinition componentInstance) { String instUniqueId = componentInstance.getUniqueId(); @@ -2095,7 +2131,7 @@ public class NodeTemplateOperation extends BaseOperation { try { String jsonArr = JsonParserUtils.toJson(property); log.debug("Update INSTANCES edge property with value {} ", jsonArr ); - + edge.property(EdgePropertyEnum.INSTANCES.getProperty(), jsonArr); } catch (IOException e) { log.debug("Failed to convert INSTANCES edge property to json for container {}", metadataVertex.getUniqueId(), e ); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java index 3bdec2a30a..26fe1e262d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java @@ -212,6 +212,13 @@ public class TopologyTemplateOperation extends ToscaElementOperation { return associateForwardingPathToComponent(topologyTemplateVertex,forwardingPaths); } + private StorageOperationStatus associateNodeFilterToResource(GraphVertex topologyTemplateVertex, + TopologyTemplate topologyTemplate) { + Map<String, CINodeFilterDataDefinition> nodeFilters = + topologyTemplate.getNodeFilterComponents(); + return associateNodeFiltersToComponent(topologyTemplateVertex, nodeFilters); + } + private StorageOperationStatus associateCapPropertiesToResource(GraphVertex topologyTemplateVertex, TopologyTemplate topologyTemplate) { Map<String, MapCapabilityProperty> calculatedCapProperties = topologyTemplate.getCalculatedCapabilitiesProperties(); if (calculatedCapProperties != null && !calculatedCapProperties.isEmpty()) { @@ -697,7 +704,15 @@ public class TopologyTemplateOperation extends ToscaElementOperation { } } - + + if (!componentParametersView.isIgnoreNodeFilter()) { + status = setNodeFilterComponentFromGraph(componentV, toscaElement); + if (status != TitanOperationStatus.OK) { + return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); + + } + } + if (!componentParametersView.isIgnoreInterfaces()) { TitanOperationStatus storageStatus = setInterfcesFromGraph(componentV, toscaElement); if (storageStatus != TitanOperationStatus.OK) { @@ -744,6 +759,19 @@ public class TopologyTemplateOperation extends ToscaElementOperation { return TitanOperationStatus.OK; } + public StorageOperationStatus associateNodeFiltersToComponent(GraphVertex nodeTypeVertex, + Map<String, CINodeFilterDataDefinition> filterMaps) { + if (filterMaps != null && !filterMaps.isEmpty()) { + Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData + (nodeTypeVertex, VertexTypeEnum.NODE_FILTER_TEMPLATE, + EdgeLabelEnum.NODE_FILTER_TEMPLATE, filterMaps); + if (assosiateElementToData.isRight()) { + return assosiateElementToData.right().value(); + } + } + return StorageOperationStatus.OK; + } + private TitanOperationStatus setForwardingGraphPropertiesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) { Either<Map<String, ForwardingPathDataDefinition>, TitanOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.FORWARDING_PATH); if (result.isLeft()) { @@ -817,6 +845,21 @@ public class TopologyTemplateOperation extends ToscaElementOperation { return TitanOperationStatus.OK; } + private TitanOperationStatus setNodeFilterComponentFromGraph(GraphVertex componentV, + TopologyTemplate topologyTemplate) { + Either<Map<String, CINodeFilterDataDefinition>, TitanOperationStatus> result = + getDataFromGraph(componentV, + EdgeLabelEnum.NODE_FILTER_TEMPLATE); + if (result.isLeft()) { + topologyTemplate.setNodeFilterComponents(result.left().value()); + } else { + if (result.right().value() != TitanOperationStatus.NOT_FOUND) { + return result.right().value(); + } + } + return TitanOperationStatus.OK; + } + @Override protected <T extends ToscaElement> TitanOperationStatus setRequirementsFromGraph(GraphVertex componentV, T toscaElement) { Either<Map<String, MapListRequirementDataDefinition>, TitanOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.CALCULATED_REQUIREMENTS); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java index 6a49509d6f..5e40bd57e7 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java @@ -131,6 +131,10 @@ public class ModelConverter { convertPolicies(topologyTemplate, service); + convertProperties(topologyTemplate, service); + + convertPolicies(topologyTemplate, service); + convertGroups(topologyTemplate, service); setCapabilitiesToComponentAndGroups(topologyTemplate, service); @@ -147,6 +151,7 @@ public class ModelConverter { convertServiceInterfaces(topologyTemplate, service); + convertNodeFiltersComponents(topologyTemplate, service); return service; } @@ -193,6 +198,8 @@ public class ModelConverter { convertGroups(topologyTemplate, resource); setCapabilitiesToComponentAndGroups(topologyTemplate, resource); convertPolicies(topologyTemplate, resource); + convertNodeFiltersComponents(topologyTemplate, resource); + convertProperties(topologyTemplate, resource); } convertArtifacts(toscaElement, resource); convertAdditionalInformation(toscaElement, resource); @@ -678,6 +685,17 @@ public class ModelConverter { component.setDeploymentArtifacts(copy); } + private static void convertNodeFiltersComponents(TopologyTemplate topologyTemplate, Component component) { + Map<String, CINodeFilterDataDefinition> filters = topologyTemplate.getNodeFilterComponents(); + Map<String, CINodeFilterDataDefinition> copy; + if (filters != null) { + copy = filters.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new CINodeFilterDataDefinition(e.getValue()))); + } else { + copy = new HashMap<>(); + } + component.setNodeFilterComponents(copy); + } + private static void convertServiceApiArtifacts(TopologyTemplate topologyTemplate, Service service) { Map<String, ArtifactDataDefinition> serviceApiArtifacts = topologyTemplate.getServiceApiArtifacts(); Map<String, ArtifactDefinition> copy; @@ -1100,6 +1118,8 @@ public class ModelConverter { List<ComponentInstance> componentInstances = new ArrayList<>(); ComponentInstance currComponentInstance; + Map<String, CINodeFilterDataDefinition> nodeFilterComponents = topologyTemplate.getNodeFilterComponents(); + for (Map.Entry<String, ComponentInstanceDataDefinition> entry : topologyTemplate.getComponentInstances().entrySet()) { String key = entry.getKey(); currComponentInstance = new ComponentInstance(topologyTemplate.getComponentInstances().get(key)); @@ -1116,6 +1136,7 @@ public class ModelConverter { currComponentInstance.setInterfaces(interfacesMap); } componentInstances.add(currComponentInstance); + } component.setComponentInstances(componentInstances); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java index 43df6da2e6..a8a2409715 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.ui.model; +import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.model.AdditionalInformationDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; @@ -80,6 +81,10 @@ public class UiComponentDataTransfer { private Map<String, InterfaceDefinition> interfaces; + private Map<String, CINodeFilterDataDefinition> nodeFilter; + + private Map<String, UINodeFilter> nodeFilterforNode; + public Map<String, InterfaceDefinition> getInterfaces() { return interfaces; } @@ -289,4 +294,19 @@ public class UiComponentDataTransfer { this.policies = policies; } + public Map<String, CINodeFilterDataDefinition> getNodeFilter() { + return nodeFilter; + } + + public void setNodeFilter(Map<String, CINodeFilterDataDefinition> nodeFilter) { + this.nodeFilter = nodeFilter; + } + + public Map<String, UINodeFilter> getNodeFilterData() { + return nodeFilterforNode; + } + + public void setNodeFilterData(Map<String, UINodeFilter> nodeFilterforNode) { + this.nodeFilterforNode = nodeFilterforNode; + } } |