diff options
Diffstat (limited to 'catalog-model/src/main')
18 files changed, 343 insertions, 372 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java new file mode 100644 index 0000000000..a353ae9033 --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020, Nordix Foundation. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.be.model; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.onap.sdc.tosca.datatypes.model.EntrySchema; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; + +@Getter +@Setter +@ToString +public class AttributeDefinition extends AttributeDataDefinition implements IOperationParameter, IComplexDefaultValue { + + // All names are according to TOSCA spec from + // https://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.3/os/TOSCA-Simple-Profile-YAML-v1.3-os.html#DEFN_ELEMENT_ATTRIBUTE_DEFN + private String type; + private String description; + private Object _default; + private String status; + private EntrySchema entry_schema; + + public AttributeDefinition() { + toscaPresentation = null; + } + + public AttributeDefinition(final AttributeDefinition attributeDefinition) { + this.type = attributeDefinition.getType(); + this.description = attributeDefinition.getDescription(); + this._default = attributeDefinition.get_default(); + this.status = attributeDefinition.getStatus(); + this.entry_schema = attributeDefinition.getEntry_schema(); + } + + @Override + public String getDefaultValue() { + return String.valueOf(_default); + } + + @Override + public void setDefaultValue(final String value) { + this._default = value; + } + + @Override + public boolean isDefinition() { + return false; + } +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java index a74243eb7e..061262eec0 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java @@ -21,6 +21,11 @@ package org.openecomp.sdc.be.model; import com.google.common.collect.Lists; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.SetUtils; @@ -31,9 +36,15 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; + /** * Specifies the capabilities that the Node Type exposes. */ +@Getter +@Setter +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@ToString public class CapabilityDefinition extends CapabilityDataDefinition { /** @@ -42,11 +53,6 @@ public class CapabilityDefinition extends CapabilityDataDefinition { */ private List<ComponentInstanceProperty> properties; - - public CapabilityDefinition() { - super(); - } - public CapabilityDefinition(CapabilityDataDefinition cap) { super(cap); } @@ -70,44 +76,6 @@ public class CapabilityDefinition extends CapabilityDataDefinition { } } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((properties == null) ? 0 : properties.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - CapabilityDefinition other = (CapabilityDefinition) obj; - if (properties == null) { - if (other.properties != null) - return false; - } else if (!SetUtils.isEqualSet(properties, other.getProperties())) - return false; - return true; - } - - @Override - public String toString() { - return "CapabilityDefinition [properties=" + properties + "]"; - } - - public List<ComponentInstanceProperty> getProperties() { - return properties; - } - - public void setProperties(List<ComponentInstanceProperty> properties) { - this.properties = properties; - } - public void updateCapabilityProperties(CapabilityDefinition capabilityDefinition) { if(CollectionUtils.isNotEmpty(getProperties()) && capabilityDefinition!= null && CollectionUtils.isNotEmpty(capabilityDefinition.getProperties())){ Map<String, ComponentInstanceProperty> propertiesInfo = capabilityDefinition.getProperties() diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java index 016c117e84..f7627e76df 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java @@ -20,6 +20,10 @@ package org.openecomp.sdc.be.model; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition; import org.openecomp.sdc.be.resources.data.CapabilityTypeData; @@ -30,32 +34,16 @@ import java.util.stream.Collectors; * Specifies the capabilities that the Node Type exposes. */ @SuppressWarnings("serial") +@Getter +@Setter +@NoArgsConstructor +@ToString(callSuper = true) public class CapabilityTypeDefinition extends CapabilityTypeDataDefinition { private String derivedFrom; private Map<String, PropertyDefinition> properties; - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } - - public CapabilityTypeDefinition() { - super(); - } - public CapabilityTypeDefinition(CapabilityTypeDataDefinition p) { super(p); } @@ -75,8 +63,4 @@ public class CapabilityTypeDefinition extends CapabilityTypeDataDefinition { this.setValidSourceTypes( ctd.getCapabilityTypeDataDefinition().getValidSourceTypes()); } - @Override - public String toString() { - return super.toString() + " [ derivedFrom=" + derivedFrom + ", properties=" + properties + " ]"; - } } 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 dc0fb51d7c..ba73e77e05 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 @@ -73,7 +73,7 @@ public abstract class Component implements PropertiesOwner { private List<RequirementCapabilityRelDef> componentInstancesRelations; private Map<String, List<ComponentInstanceInput>> componentInstancesInputs; private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties; - private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes; + private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes; private Map<String, List<CapabilityDefinition>> capabilities; private Map<String, List<RequirementDefinition>> requirements; private Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java new file mode 100644 index 0000000000..91a7b9c14f --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020, Nordix Foundation. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyRule; + +@Getter +@Setter +public class ComponentInstanceAttribute extends AttributeDefinition implements IComponentInstanceConnectedElement, IAttributeInputCommon { + + public ComponentInstanceAttribute(final AttributeDataDefinition value) { + } + public ComponentInstanceAttribute() { + super(); + } + + /** + * The unique id of the property value on graph + */ + private String valueUniqueUid; + + private List<String> path; + + private List<PropertyRule> rules ; + + private String componentInstanceName; + + private String componentInstanceId; + +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java index c5a008085b..487d642a5c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java @@ -16,17 +16,19 @@ package org.openecomp.sdc.be.model; -import com.google.common.annotations.VisibleForTesting; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition; +@Getter +@Setter +@NoArgsConstructor public class ComponentInstanceInterface extends InterfaceDefinition { private String interfaceId; private InterfaceInstanceDataDefinition interfaceInstanceDataDefinition; - @VisibleForTesting - ComponentInstanceInterface() {} - public ComponentInstanceInterface(String interfaceId, InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) { this.interfaceId = interfaceId; @@ -38,20 +40,4 @@ public class ComponentInstanceInterface extends InterfaceDefinition { this.interfaceId = interfaceId; } - public String getInterfaceId() { - return interfaceId; - } - - public void setInterfaceId(String interfaceId) { - this.interfaceId = interfaceId; - } - - public InterfaceInstanceDataDefinition getInterfaceInstanceDataDefinition() { - return interfaceInstanceDataDefinition; - } - - public void setInterfaceInstanceDataDefinition( - InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) { - this.interfaceInstanceDataDefinition = interfaceInstanceDataDefinition; - } } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java new file mode 100644 index 0000000000..fa8c162485 --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020, Nordix Foundation. All rights reserved. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model; + +import java.util.List; +import org.openecomp.sdc.be.datatypes.elements.PropertyRule; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + +public interface IAttributeInputCommon { + + String getType(); + ToscaDataDefinition getSchema(); + List<PropertyRule> getRules(); + String getName(); +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java index 44d6eff4fb..a3d871a511 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java @@ -32,6 +32,7 @@ import lombok.ToString; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.utils.MapUtil; import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.category.CategoryDefinition; @@ -57,7 +58,7 @@ public class Resource extends Component { private Map<String, String> derivedFromMapOfIdToName; - private List<PropertyDefinition> attributes; + private List<AttributeDataDefinition> attributes; private String toscaVersion; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java index 296e80b674..a1b07bc58d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Map; import lombok.Getter; import lombok.Setter; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; @Getter @Setter @@ -38,6 +38,6 @@ public class NodeType extends ToscaElement { private List<String> derivedFrom; private List<String> derivedList; private Map<String, String> derivedFromMapOfIdToName; - private Map<String, PropertyDataDefinition> attributes; + private Map<String, AttributeDataDefinition> attributes; private Map<String, InterfaceDataDefinition> interfaceArtifacts; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java index db330e9b19..7b9fd6fa05 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.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. @@ -20,26 +20,48 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.datamodel; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.collections.MapUtils; -import org.openecomp.sdc.be.datatypes.elements.*; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; +import org.openecomp.sdc.be.datatypes.elements.MapComponentInstanceExternalRefs; +import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; import org.openecomp.sdc.be.model.MapInterfaceInstanceDataDefinition; import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum; -import java.util.HashMap; -import java.util.Map; - -public class TopologyTemplate extends ToscaElement{ +@Getter +@Setter +public class TopologyTemplate extends ToscaElement { public TopologyTemplate() { super(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE); } + private Map<String, PropertyDataDefinition> inputs; private Map<String, MapPropertiesDataDefinition> instInputs; private Map<String, ? extends ToscaDataDefinition> heatParameters; - private Map<String, MapPropertiesDataDefinition> instAttributes; + private Map<String, MapAttributesDataDefinition> instAttributes; private Map<String, MapPropertiesDataDefinition> instProperties; private Map<String, GroupDataDefinition> groups; private Map<String, PolicyDataDefinition> policies; @@ -58,238 +80,61 @@ public class TopologyTemplate extends ToscaElement{ private Map<String, MapInterfaceInstanceDataDefinition> instInterfaces; private Map<String, MapInterfaceDataDefinition> componentInstInterfaces; private Map<String, DataTypeDataDefinition> dataTypes; - private Map<String, CINodeFilterDataDefinition> nodeFilterComponents; private Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap; + //Component Instances External References (instanceId -> ExternalRefsMap) //----------------------------------------------------------------------- private Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs; - - public Map<String, MapComponentInstanceExternalRefs> getMapComponentInstancesExternalRefs() { - return this.mapComponentInstancesExternalRefs; - } - - public void setComponentInstancesExternalRefs(Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs) { - this.mapComponentInstancesExternalRefs = mapComponentInstancesExternalRefs; - } //----------------------------------------------------------------------- - public Map<String, InterfaceDataDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDataDefinition> interfaces) { - this.interfaces = interfaces; - } - - public Map<String, MapInterfaceInstanceDataDefinition> getInstInterfaces() { - return instInterfaces; - } - - public void setInstInterfaces( - Map<String, MapInterfaceInstanceDataDefinition> instInterfaces) { - this.instInterfaces = instInterfaces; - } - public void addInstInterface(String compId, MapInterfaceInstanceDataDefinition - mapInterfaceInstanceDataDefinition) { - if(MapUtils.isEmpty(this.instInterfaces)) { + mapInterfaceInstanceDataDefinition) { + if (MapUtils.isEmpty(this.instInterfaces)) { this.instInterfaces = new HashMap<>(); } this.instInterfaces.put(compId, mapInterfaceInstanceDataDefinition); } - public Map<String, MapInterfaceDataDefinition> getComponentInstInterfaces() { - return componentInstInterfaces; - } - - public void setComponentInstInterfaces( - Map<String, MapInterfaceDataDefinition> componentInstInterfaces) { - this.componentInstInterfaces = componentInstInterfaces; - } - public void addComponentInstanceInterfaceMap(String componentInstanceId, MapInterfaceDataDefinition - mapInterfaceDataDefinition) { - if(MapUtils.isEmpty(this.componentInstInterfaces)) { + mapInterfaceDataDefinition) { + if (MapUtils.isEmpty(this.componentInstInterfaces)) { this.componentInstInterfaces = new HashMap<>(); } this.componentInstInterfaces.put(componentInstanceId, mapInterfaceDataDefinition); } - - public Map<String, PropertyDataDefinition> getInputs() { - return inputs; - } - public void setInputs(Map<String, PropertyDataDefinition> inputs) { - this.inputs = inputs; - } - public Map<String, MapPropertiesDataDefinition> getInstInputs() { - return instInputs; - } - public void setInstInputs(Map<String, MapPropertiesDataDefinition> instInputs) { - this.instInputs = instInputs; - } - public Map<String, ? extends ToscaDataDefinition> getHeatParameters() { - return heatParameters; - } - public void setHeatParameters(Map<String, ? extends ToscaDataDefinition> heatParameters) { - this.heatParameters = heatParameters; - } - public Map<String, MapPropertiesDataDefinition> getInstAttributes() { - return instAttributes; - } - public void setInstAttributes(Map<String, MapPropertiesDataDefinition> instAttributes) { - this.instAttributes = instAttributes; - } - public Map<String, MapPropertiesDataDefinition> getInstProperties() { - return instProperties; - } - public void setInstProperties(Map<String, MapPropertiesDataDefinition> instProperties) { - this.instProperties = instProperties; - } - public Map<String, GroupDataDefinition> getGroups() { - return groups; - } - public void setGroups(Map<String, GroupDataDefinition> groups) { - this.groups = groups; - } - public Map<String, PolicyDataDefinition> getPolicies() { - return policies; - } - public void setPolicies(Map<String, PolicyDataDefinition> policies) { - this.policies = policies; - } - public Map<String, MapGroupsDataDefinition> getInstGroups() { - return instGroups; - } - public void setInstGroups(Map<String, MapGroupsDataDefinition> instGroups) { - this.instGroups = instGroups; - } - public Map<String, ArtifactDataDefinition> getServiceApiArtifacts() { - return serviceApiArtifacts; - } - public void setServiceApiArtifacts(Map<String, ArtifactDataDefinition> serviceApiArtifacts) { - this.serviceApiArtifacts = serviceApiArtifacts; - } - public Map<String, CompositionDataDefinition> getCompositions() { - return compositions; - } - public void setCompositions(Map<String, CompositionDataDefinition> compositions) { - this.compositions = compositions; - } - public Map<String, MapListCapabilityDataDefinition> getCalculatedCapabilities() { - return calculatedCapabilities; - } - public void setCalculatedCapabilities(Map<String, MapListCapabilityDataDefinition> calculatedCapabilities) { - this.calculatedCapabilities = calculatedCapabilities; - } - public Map<String, MapListRequirementDataDefinition> getCalculatedRequirements() { - return calculatedRequirements; - } - public void setCalculatedRequirements(Map<String, MapListRequirementDataDefinition> calculatedRequirements) { - this.calculatedRequirements = calculatedRequirements; - } - public Map<String, MapListCapabilityDataDefinition> getFullfilledCapabilities() { - return fullfilledCapabilities; - } - public void setFullfilledCapabilities(Map<String, MapListCapabilityDataDefinition> fullfilledCapabilities) { - this.fullfilledCapabilities = fullfilledCapabilities; - } - public Map<String, MapListRequirementDataDefinition> getFullfilledRequirements() { - return fullfilledRequirements; - } - public void setFullfilledRequirements(Map<String, MapListRequirementDataDefinition> fullfilledRequirements) { - this.fullfilledRequirements = fullfilledRequirements; - } - - public Map<String, MapArtifactDataDefinition> getInstDeploymentArtifacts() { - return instDeploymentArtifacts; - } - public void setInstDeploymentArtifacts(Map<String, MapArtifactDataDefinition> instDeploymentArtifacts) { - this.instDeploymentArtifacts = instDeploymentArtifacts; - } - - public Map<String, MapCapabilityProperty> getCalculatedCapabilitiesProperties() { - return calculatedCapabilitiesProperties; - } - public void setCalculatedCapabilitiesProperties(Map<String, MapCapabilityProperty> calculatedCapabilitiesProperties) { - this.calculatedCapabilitiesProperties = calculatedCapabilitiesProperties; - } - - public Map<String, MapArtifactDataDefinition> getInstanceArtifacts() { - return instanceArtifacts; - } - public void setInstanceArtifacts(Map<String, MapArtifactDataDefinition> instanceArtifacts) { - this.instanceArtifacts = instanceArtifacts; - } - - public Map<String, ForwardingPathDataDefinition> getForwardingPaths() { - return forwardingPaths; - } - - public void setForwardingPaths(Map<String, ForwardingPathDataDefinition> forwardingPaths) { - this.forwardingPaths = forwardingPaths; - } - - public Map<String, CINodeFilterDataDefinition> getNodeFilterComponents() { - return nodeFilterComponents; - } - - public void setNodeFilterComponents(Map<String, CINodeFilterDataDefinition> nodeFilters) { - this.nodeFilterComponents = nodeFilters; - } - - public Map<String, SubstitutionFilterDataDefinition> getSubstitutionFilterDataDefinitionMap() { - return substitutionFilterDataDefinitionMap; - } - - public void setSubstitutionFilterDataDefinitionMap( - Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap) { - this.substitutionFilterDataDefinitionMap = substitutionFilterDataDefinitionMap; - } - - /** - * Gets data types. - * @return Current data types. - */ - public Map<String, DataTypeDataDefinition> getDataTypes() { - return dataTypes; - } - /** - * Sets data types. - * @param dataTypes New data types. - */ - public void setDataTypes(Map<String, DataTypeDataDefinition> dataTypes) { - this.dataTypes = dataTypes; - } - - /** - * 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 + * 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 */ - public void addComponentInstance(ComponentInstanceDataDefinition componentInstance){ - if(getCompositions() == null){ + public void addComponentInstance(ComponentInstanceDataDefinition componentInstance) { + if (getCompositions() == null) { compositions = new HashMap<>(); } - if(MapUtils.isEmpty(getCompositions())){ + if (MapUtils.isEmpty(getCompositions())) { compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition()); } - if(MapUtils.isEmpty(getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances())){ + if (MapUtils + .isEmpty(getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances())) { getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).setComponentInstances(new HashMap<>()); } - getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances().put(componentInstance.getUniqueId(), componentInstance); + getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances() + .put(componentInstance.getUniqueId(), componentInstance); } + /** * Returns map of component instances from composition + * * @return */ public Map<String, ComponentInstanceDataDefinition> getComponentInstances() { Map<String, ComponentInstanceDataDefinition> instances = null; - if(getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){ + if (getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null) { instances = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances(); } return instances; @@ -297,22 +142,24 @@ public class TopologyTemplate extends ToscaElement{ /** - * Sets map of component instances to composition of topology template - * Note that component instances will be overrided in case if the topology template already contains a component instances + * Sets map of component instances to composition of topology template Note that component instances will be + * overrided in case if the topology template already contains a component instances + * * @param instances */ public void setComponentInstances(Map<String, ComponentInstanceDataDefinition> instances) { - if(getCompositions() == null){ + if (getCompositions() == null) { compositions = new HashMap<>(); } - if(MapUtils.isEmpty(getCompositions())){ + if (MapUtils.isEmpty(getCompositions())) { compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition()); } getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).setComponentInstances(instances); } + public Map<String, RelationshipInstDataDefinition> getRelations() { Map<String, RelationshipInstDataDefinition> relations = null; - if( getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){ + if (getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null) { relations = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getRelations(); } return relations; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java index 930ba791d5..9cadd4e107 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java @@ -63,6 +63,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition; @@ -78,23 +79,7 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.ComponentInstanceInput; -import org.openecomp.sdc.be.model.ComponentInstanceProperty; -import org.openecomp.sdc.be.model.ComponentParametersView; -import org.openecomp.sdc.be.model.GroupDefinition; -import org.openecomp.sdc.be.model.GroupInstance; -import org.openecomp.sdc.be.model.InputDefinition; -import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.be.model.RelationshipImpl; -import org.openecomp.sdc.be.model.RelationshipInfo; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.NodeType; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement; @@ -958,8 +943,8 @@ public class NodeTemplateOperation extends BaseOperation { } if(MapUtils.isNotEmpty(originNodeType.getAttributes())){ - MapPropertiesDataDefinition instAttributes = - new MapPropertiesDataDefinition(originNodeType.getAttributes()); + MapAttributesDataDefinition instAttributes = + new MapAttributesDataDefinition(originNodeType.getAttributes()); status = addToscaDataDeepElementsBlockToToscaElement(updatedContainerVertex, EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, instAttributes, componentInstance.getUniqueId()); if (status != StorageOperationStatus.OK) { @@ -2199,16 +2184,16 @@ public class NodeTemplateOperation extends BaseOperation { return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, properties, pathKeys, JsonPresentationFields.NAME); } - public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ + public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){ List<String> pathKeys = new ArrayList<>(); pathKeys.add(componentInstanceId); return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, property, pathKeys, JsonPresentationFields.NAME); } - public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ + public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){ List<String> pathKeys = new ArrayList<>(); pathKeys.add(componentInstanceId); - return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, property, pathKeys, JsonPresentationFields.NAME); + return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, attribute, pathKeys, JsonPresentationFields.NAME); } public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java index 9a70e9c837..004451c667 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java @@ -389,7 +389,7 @@ public class NodeTypeOperation extends ToscaElementOperation { } private JanusGraphOperationStatus setResourceAttributesFromGraph(GraphVertex componentV, NodeType toscaElement) { - Either<Map<String, PropertyDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES); + Either<Map<String, AttributeDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES); if (result.isLeft()) { toscaElement.setAttributes(result.left().value()); } else { @@ -531,13 +531,13 @@ public class NodeTypeOperation extends ToscaElementOperation { private StorageOperationStatus associateAttributesToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) { // Note : currently only one derived supported!!!! - Either<Map<String, PropertyDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES); + Either<Map<String, AttributeDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES); if (dataFromDerived.isRight()) { return dataFromDerived.right().value(); } - Map<String, PropertyDataDefinition> attributesAll = dataFromDerived.left().value(); + Map<String, AttributeDataDefinition> attributesAll = dataFromDerived.left().value(); - Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes(); + Map<String, AttributeDataDefinition> attributes = nodeType.getAttributes(); if (attributes != null) { attributes.values().stream().filter(p -> p.getUniqueId() == null).forEach(p -> { String uid = UniqueIdBuilder.buildAttributeUid(nodeTypeVertex.getUniqueId(), p.getName()); @@ -660,6 +660,7 @@ public class NodeTypeOperation extends ToscaElementOperation { nodeTypeVertex.setLabel(VertexTypeEnum.NODE_TYPE); fillCommonMetadata(nodeTypeVertex, nodeType); + nodeTypeVertex.setJsonMetadataField(JsonPresentationFields.ATTRIBUTES, nodeType.getAttributes()); return nodeTypeVertex; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java index cc6cd1d430..af6ddd82e5 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java @@ -39,6 +39,9 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; +import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; @@ -537,7 +540,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation { } private StorageOperationStatus associateInstAttributesToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) { - Map<String, MapPropertiesDataDefinition> instAttr = topologyTemplate.getInstAttributes(); + Map<String, MapAttributesDataDefinition> instAttr = topologyTemplate.getInstAttributes(); return associateInstAttributeToComponent(nodeTypeVertex, instAttr); } @@ -551,7 +554,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation { return StorageOperationStatus.OK; } - public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instAttr) { + public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapAttributesDataDefinition> instAttr) { if (instAttr != null && !instAttr.isEmpty()) { Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INST_ATTRIBUTES, EdgeLabelEnum.INST_ATTRIBUTES, instAttr); if (assosiateElementToData.isRight()) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java index ec1185a706..90111e80ac 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java @@ -25,6 +25,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -41,12 +42,14 @@ import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.catalog.CatalogComponent; @@ -92,7 +95,6 @@ public abstract class ToscaElementOperation extends BaseOperation { return gson; } - protected Either<GraphVertex, StorageOperationStatus> getComponentByLabelAndId(String uniqueId, ToscaElementTypeEnum nodeType, JsonParseFlagEnum parseFlag) { Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class); @@ -912,6 +914,7 @@ public abstract class ToscaElementOperation extends BaseOperation { switch (label) { case NODE_TYPE: toscaElement = new NodeType(); + ((NodeType) toscaElement).setAttributes(getAttributesFromComponentV(componentV)); break; case TOPOLOGY_TEMPLATE: toscaElement = new TopologyTemplate(); @@ -923,8 +926,8 @@ public abstract class ToscaElementOperation extends BaseOperation { if (toscaElement != null) { final Map<String, Object> jsonMetada = componentV.getMetadataJson(); + if (MapUtils.isNotEmpty(jsonMetada)) { toscaElement.setMetadata(jsonMetada); - if (jsonMetada != null) { final Object toscaVersion = jsonMetada.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName()); if (toscaVersion != null) { toscaElement.setToscaVersion((String) toscaVersion); @@ -934,6 +937,28 @@ public abstract class ToscaElementOperation extends BaseOperation { return (T) toscaElement; } + private Map<String, AttributeDataDefinition> getAttributesFromComponentV(final GraphVertex componentV) { + final Map<String, Object> jsonMetada = componentV.getMetadataJson(); + final Map<String, AttributeDataDefinition> attributeDataDefinitionMap = new HashMap<>(); + if (MapUtils.isNotEmpty(jsonMetada)) { + final Object attributes = jsonMetada.get(ToscaTagNamesEnum.ATTRIBUTES.getElementName()); + if (attributes instanceof Map) { + final Map<String, Object> map = (Map<String, Object>) attributes; + attributeDataDefinitionMap.putAll(map.values().stream().map(attributeMap -> { + final AttributeDefinition attributeDef = new AttributeDefinition(); + final String name = (String) ((Map<String, Object>) attributeMap).get("name"); + attributeDef.setName(name); + final String type = (String) ((Map<String, Object>) attributeMap).get("type"); + attributeDef.setType(type); + final String description = (String) ((Map<String, Object>) attributeMap).get("description"); + attributeDef.setDescription(description); + return attributeDef; + }).collect(Collectors.toMap(AttributeDefinition::getName, a -> a))); + } + } + return attributeDataDefinitionMap; + } + protected JanusGraphOperationStatus setResourceCategoryFromGraphV(Vertex vertex, CatalogComponent catalogComponent) { List<CategoryDefinition> categories = new ArrayList<>(); SubCategoryDefinition subcategory; @@ -1320,8 +1345,9 @@ public abstract class ToscaElementOperation extends BaseOperation { ResourceTypeEnum resourceType = ResourceTypeEnum.getType((String) resourceTypeStr); if (!CollectionUtils.isEmpty(excludeTypes)) { Optional<ResourceTypeEnum> op = excludeTypes.stream().filter(rt -> rt == resourceType).findAny(); - if (op.isPresent()) + if (op.isPresent()) { isAddToCatalog = false; + } } } return isAddToCatalog; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java index 427939f2f8..5b4388226b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java @@ -1472,7 +1472,7 @@ public class ToscaOperationFacade { } - public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<PropertyDefinition>> instArttributes, Component component) { + public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<AttributeDataDefinition>> instArttributes, Component component) { Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse); if (getVertexEither.isRight()) { @@ -1482,24 +1482,24 @@ public class ToscaOperationFacade { } GraphVertex vertex = getVertexEither.left().value(); - Map<String, MapPropertiesDataDefinition> instAttr = new HashMap<>(); + Map<String, MapAttributesDataDefinition> instAttr = new HashMap<>(); if (instArttributes != null) { - MapPropertiesDataDefinition attributesMap; - for (Entry<String, List<PropertyDefinition>> entry : instArttributes.entrySet()) { - attributesMap = new MapPropertiesDataDefinition(); - attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, e -> e))); + MapAttributesDataDefinition attributesMap; + for (Entry<String, List<AttributeDataDefinition>> entry : instArttributes.entrySet()) { + final List<AttributeDataDefinition> value = entry.getValue(); + attributesMap = new MapAttributesDataDefinition(); + attributesMap.setMapToscaDataDefinition(value.stream().map(AttributeDataDefinition::new).collect(Collectors.toMap(AttributeDataDefinition::getName, e -> e))); instAttr.put(entry.getKey(), attributesMap); } } setComponentInstanceAttributesOnComponent(component, instAttr); return topologyTemplateOperation.associateInstAttributeToComponent(vertex, instAttr); - } // endregion - private void setComponentInstanceAttributesOnComponent(Component resource, Map<String, MapPropertiesDataDefinition> instAttr) { - Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes = resource.getComponentInstancesAttributes(); + private void setComponentInstanceAttributesOnComponent(Component resource, Map<String, MapAttributesDataDefinition> instAttr) { + Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes = resource.getComponentInstancesAttributes(); if (componentInstancesAttributes == null) componentInstancesAttributes = new HashMap<>(); componentInstancesAttributes.putAll(ModelConverter.getComponentInstancesAttributes(instAttr)); @@ -2382,11 +2382,10 @@ public class ToscaOperationFacade { } - - public Either<PropertyDefinition, StorageOperationStatus> addAttributeOfResource(Component component, PropertyDefinition newAttributeDef) { + public Either<AttributeDataDefinition, StorageOperationStatus> addAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { Either<Component, StorageOperationStatus> getUpdatedComponentRes = null; - Either<PropertyDefinition, StorageOperationStatus> result = null; + Either<AttributeDataDefinition, StorageOperationStatus> result = null; if (newAttributeDef.getUniqueId() == null || newAttributeDef.getUniqueId().isEmpty()) { String attUniqueId = UniqueIdBuilder.buildAttributeUid(component.getUniqueId(), newAttributeDef.getName()); newAttributeDef.setUniqueId(attUniqueId); @@ -2407,7 +2406,7 @@ public class ToscaOperationFacade { } } if (result == null) { - Optional<PropertyDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); + Optional<AttributeDataDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); if (newAttribute.isPresent()) { result = Either.left(newAttribute.get()); } else { @@ -2418,10 +2417,10 @@ public class ToscaOperationFacade { return result; } - public Either<PropertyDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, PropertyDefinition newAttributeDef) { + public Either<AttributeDataDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { Either<Component, StorageOperationStatus> getUpdatedComponentRes = null; - Either<PropertyDefinition, StorageOperationStatus> result = null; + Either<AttributeDataDefinition, StorageOperationStatus> result = null; StorageOperationStatus status = getToscaElementOperation(component).updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef, JsonPresentationFields.NAME); if (status != StorageOperationStatus.OK) { CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newAttributeDef.getName(), component.getName(), status); @@ -2437,7 +2436,7 @@ public class ToscaOperationFacade { } } if (result == null) { - Optional<PropertyDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); + Optional<AttributeDataDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); if (newProperty.isPresent()) { result = Either.left(newProperty.get()); } else { @@ -2536,12 +2535,12 @@ public class ToscaOperationFacade { return nodeTemplateOperation.addComponentInstanceProperty(containerComponent, componentInstanceId, property); } - public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ + public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){ return nodeTemplateOperation.updateComponentInstanceAttribute(containerComponent, componentInstanceId, property); } - public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ - return nodeTemplateOperation.addComponentInstanceAttribute(containerComponent, componentInstanceId, property); + public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){ + return nodeTemplateOperation.addComponentInstanceAttribute(containerComponent, componentInstanceId, attribute); } public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java index c278632dad..5ceb7f194c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java @@ -48,6 +48,7 @@ import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; @@ -60,6 +61,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition; @@ -79,10 +81,12 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.AdditionalInformationDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceAttribute; import org.openecomp.sdc.be.model.ComponentInstanceInput; import org.openecomp.sdc.be.model.ComponentInstanceInterface; import org.openecomp.sdc.be.model.ComponentInstanceProperty; @@ -177,8 +181,6 @@ public class ModelConverter { return vertexType; } - - private static Service convertToService(ToscaElement toscaElement) { Service service = new Service(); convertComponentFields(service, toscaElement); @@ -308,9 +310,10 @@ public class ModelConverter { } private static void convertAttributes(NodeType nodeType, Resource resource) { - Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes(); + Map<String, AttributeDataDefinition> attributes = nodeType.getAttributes(); if (attributes != null) { - List<PropertyDefinition> attrs = attributes.values().stream().map(dataDef -> ModelConverter.fromDataDefinition(resource.getUniqueId(), dataDef)).collect(Collectors.toList()); + final List<AttributeDataDefinition> attrs = attributes.values().stream() + .collect(Collectors.toList()); resource.setAttributes(attrs); } } @@ -984,9 +987,10 @@ public class ModelConverter { } private static void convertAttributes(Resource component, NodeType nodeType) { - List<PropertyDefinition> attributes = component.getAttributes(); + List<AttributeDataDefinition> attributes = component.getAttributes(); if (attributes != null) { - Map<String, PropertyDataDefinition> attrsByName = attributes.stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity())); + Map<String, AttributeDataDefinition> attrsByName = attributes.stream() + .collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity())); nodeType.setAttributes(attrsByName); } } @@ -1434,8 +1438,10 @@ public class ModelConverter { for (Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstProperties().entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new PropertyDefinition(e.getValue()))) - .collect(Collectors.toList()); + List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue() + .getMapToscaDataDefinition().entrySet().stream() + .map(e -> new ComponentInstanceProperty(new PropertyDefinition(e.getValue()))) + .collect(Collectors.toList()); properties.put(key, componentInstanceAttributes); } } @@ -1443,13 +1449,16 @@ public class ModelConverter { } } - public static Map<String, List<ComponentInstanceProperty>> getComponentInstancesAttributes(Map<String, MapPropertiesDataDefinition> mapPropertiesDataDefinition) { - Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>(); - for (Map.Entry<String, MapPropertiesDataDefinition> entry : mapPropertiesDataDefinition.entrySet()) { + public static Map<String, List<ComponentInstanceAttribute>> getComponentInstancesAttributes( + Map<String, MapAttributesDataDefinition> mapAttributesDataDefinitionMap) { + Map<String, List<ComponentInstanceAttribute>> attributes = new HashMap<>(); + for (Map.Entry<String, MapAttributesDataDefinition> entry : mapAttributesDataDefinitionMap.entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue()))) - .collect(Collectors.toList()); + List<ComponentInstanceAttribute> componentInstanceAttributes = entry.getValue() + .getMapToscaDataDefinition().entrySet().stream() + .map(e -> new ComponentInstanceAttribute(new ComponentInstanceAttribute(e.getValue()))) + .collect(Collectors.toList()); attributes.put(key, componentInstanceAttributes); } } @@ -1490,12 +1499,15 @@ public class ModelConverter { private static void setComponentInstancesAttributesToComponent(TopologyTemplate topologyTemplate, Component component) { if (topologyTemplate.getInstAttributes() != null) { - Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>(); - for (Map.Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstAttributes().entrySet()) { + Map<String, List<ComponentInstanceAttribute>> attributes = new HashMap<>(); + for (Map.Entry<String, MapAttributesDataDefinition> entry : topologyTemplate.getInstAttributes() + .entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue()))) - .collect(Collectors.toList()); + List<ComponentInstanceAttribute> componentInstanceAttributes = entry.getValue() + .getMapToscaDataDefinition().entrySet().stream() + .map(e -> new ComponentInstanceAttribute(new ComponentInstanceAttribute(e.getValue()))) + .collect(Collectors.toList()); attributes.put(key, componentInstanceAttributes); } } @@ -1857,11 +1869,13 @@ public class ModelConverter { if (component.getComponentInstancesAttributes() != null) { topologyTemplate.setInstAttributes(new HashMap<>()); - MapPropertiesDataDefinition attributesMap; - for (Entry<String, List<ComponentInstanceProperty>> entry : component.getComponentInstancesAttributes().entrySet()) { - attributesMap = new MapPropertiesDataDefinition(); + MapAttributesDataDefinition attributesMap; + for (Entry<String, List<ComponentInstanceAttribute>> entry : component.getComponentInstancesAttributes() + .entrySet()) { + attributesMap = new MapAttributesDataDefinition(); - attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity()))); + attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(AttributeDefinition::new) + .collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity()))); topologyTemplate.getInstAttributes().put(entry.getKey(), attributesMap); } 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 f03a5e724f..d499dfe799 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 @@ -32,6 +32,7 @@ import org.openecomp.sdc.be.model.AdditionalInformationDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceAttribute; import org.openecomp.sdc.be.model.ComponentInstanceInput; import org.openecomp.sdc.be.model.ComponentInstanceInterface; import org.openecomp.sdc.be.model.ComponentInstanceProperty; @@ -63,7 +64,7 @@ public class UiComponentDataTransfer { private List<RequirementCapabilityRelDef> componentInstancesRelations; private Map<String, List<ComponentInstanceInput>> componentInstancesInputs; private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties; - private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes; + private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes; private Map<String, List<CapabilityDefinition>> capabilities; private List<PolicyDefinition> policies; private Map<String, List<RequirementDefinition>> requirements; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java index 380593b4b3..a51c368c71 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java @@ -25,6 +25,8 @@ import java.util.Map; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; @@ -41,7 +43,7 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer { private List<PropertyDefinition> properties; - private List<PropertyDefinition> attributes; + private List<AttributeDataDefinition> attributes; private Map<String, InterfaceDefinition> interfaces; |