From 06b72689ad69107c35692f4b49577868e751f559 Mon Sep 17 00:00:00 2001 From: vasraz Date: Wed, 29 Apr 2020 14:13:18 +0100 Subject: Fix VFs and Service not visible in SDC Dashboard Change-Id: Ia42775388c3ad9539b7d0020476f0f7a91ce8bb9 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-2938 --- .../lifecycle/LifecycleBusinessLogic.java | 2 +- .../utils/InterfacesOperationsConverterTest.java | 8 +- .../java/org/openecomp/sdc/be/model/Component.java | 711 +++++---------------- .../java/org/openecomp/sdc/be/model/Resource.java | 202 ++---- .../java/org/openecomp/sdc/be/model/Service.java | 268 ++++---- 5 files changed, 364 insertions(+), 827 deletions(-) diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java index d29f23eef8..ebd3e21d9d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java @@ -469,7 +469,7 @@ public class LifecycleBusinessLogic { throw new ByResponseFormatComponentException(componentUtils.getResponseFormatByResource(componentUtils.convertFromStorageResponse(status), resource)); } result = ModelConverter.convertFromToscaElement(certifyResourceRes.left().value()); - resource.setMetadataDefinition(result.getComponentMetadataDefinition()); + resource.setComponentMetadataDefinition(result.getComponentMetadataDefinition()); } finally { log.info("unlock component {}", resource.getUniqueId()); if (!inTransaction) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsConverterTest.java index 13bc009d32..f54b85f492 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsConverterTest.java @@ -92,7 +92,7 @@ public class InterfacesOperationsConverterTest { public void addInterfaceTypeElementToResource() { Component component = new Resource(); component.setNormalizedName("normalizedComponentName"); - component.setMetadataDefinition(new ServiceMetadataDefinition()); + component.setComponentMetadataDefinition(new ServiceMetadataDefinition()); component.getComponentMetadataDefinition().getMetadataDataDefinition().setName("NodeTypeName"); component.getComponentMetadataDefinition().getMetadataDataDefinition().setSystemName("NodeTypeName"); InterfaceDefinition addedInterface = new InterfaceDefinition(); @@ -118,7 +118,7 @@ public class InterfacesOperationsConverterTest { public void addInterfaceTypeElementToService() { Component component = new Service(); component.setNormalizedName("normalizedServiceComponentName"); - component.setMetadataDefinition(new ServiceMetadataDefinition()); + component.setComponentMetadataDefinition(new ServiceMetadataDefinition()); component.getComponentMetadataDefinition().getMetadataDataDefinition().setName("NodeTypeName"); component.getComponentMetadataDefinition().getMetadataDataDefinition().setSystemName("NodeTypeName"); InterfaceDefinition addedInterface = new InterfaceDefinition(); @@ -523,7 +523,7 @@ public class InterfacesOperationsConverterTest { @Test public void testAddInterfaceTypeElementGetCorrectLocalInterfaceName() { Service service = new Service(); - service.setMetadataDefinition(new ServiceMetadataDefinition()); + service.setComponentMetadataDefinition(new ServiceMetadataDefinition()); service.getComponentMetadataDefinition().getMetadataDataDefinition().setName("LocalInterface"); service.getComponentMetadataDefinition().getMetadataDataDefinition().setSystemName("LocalInterface"); service.setInterfaces(Collections.singletonMap("Local", new InterfaceDefinition("Local", null, new HashMap<>()))); @@ -538,7 +538,7 @@ public class InterfacesOperationsConverterTest { @Test public void testAddInterfaceTypeElementNoTypeChangeIfNotLocal() { Service service = new Service(); - service.setMetadataDefinition(new ServiceMetadataDefinition()); + service.setComponentMetadataDefinition(new ServiceMetadataDefinition()); service.getComponentMetadataDefinition().getMetadataDataDefinition().setName("LocalInterface"); service.setInterfaces(Collections.singletonMap("NotLocal", new InterfaceDefinition("NotLocal", null, new HashMap<>()))); 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 3cea34fdef..37be3bebfb 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 @@ -36,6 +36,9 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.utils.MapUtil; @@ -52,146 +55,64 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.common.log.api.ILogConfiguration; +@Getter +@Setter +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public abstract class Component implements PropertiesOwner { - private ComponentMetadataDefinition componentMetadataDefinition; - private Map artifacts; - private Map deploymentArtifacts; - private Map toscaArtifacts; - private List categories; - private List componentInstances; - private List componentInstancesRelations; - private Map> componentInstancesInputs; - private Map> componentInstancesProperties; - private Map> componentInstancesAttributes; - private Map> capabilities; - private Map> requirements; - private Map> componentInstancesInterfaces; - private List inputs; - private List groups; - private Map policies; - private String derivedFromGenericType; - private String derivedFromGenericVersion; - private String toscaType; - protected List additionalInformation; - private Map nodeFilterComponents; - private Map> nodeFilters; - private Map> serviceFilters; - protected List properties; - private Map interfaces; + protected List additionalInformation; + protected List properties; + private ComponentMetadataDefinition componentMetadataDefinition; + private Map artifacts; + private Map deploymentArtifacts; + private Map toscaArtifacts; + @EqualsAndHashCode.Include + private List categories; + private List componentInstances; + private List componentInstancesRelations; + private Map> componentInstancesInputs; + private Map> componentInstancesProperties; + private Map> componentInstancesAttributes; + private Map> capabilities; + private Map> requirements; + private Map> componentInstancesInterfaces; + private List inputs; + private List groups; + private Map policies; + private String derivedFromGenericType; + private String derivedFromGenericVersion; + private String toscaType; + private Map nodeFilterComponents; + private Map interfaces; private List dataTypes; - public List getDataTypes() { - return dataTypes; - } - - public void setDataTypes(List dataTypes) { - this.dataTypes = dataTypes; - } - - public Map getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map interfaces) { - this.interfaces = interfaces; - } - public Component(ComponentMetadataDefinition componentMetadataDefinition) { this.componentMetadataDefinition = componentMetadataDefinition; } - public String getDerivedFromGenericVersion() { - return derivedFromGenericVersion; - } - - public void setDerivedFromGenericVersion(String derivedFromGenericVersion) { - this.derivedFromGenericVersion = derivedFromGenericVersion; - } - - public String getDerivedFromGenericType() { - return derivedFromGenericType; - } - - public void setDerivedFromGenericType(String derivedFromGenericType) { - this.derivedFromGenericType = derivedFromGenericType; - } - - @JsonIgnore public ComponentMetadataDefinition getComponentMetadataDefinition() { return componentMetadataDefinition; } - public Map getArtifacts() { - return artifacts; - } - - public void setArtifacts(Map artifacts) { - this.artifacts = artifacts; - } - - public Map getToscaArtifacts() { - return toscaArtifacts; - } - - public void setToscaArtifacts(Map toscaArtifacts) { - this.toscaArtifacts = toscaArtifacts; + @Override + @EqualsAndHashCode.Include + public String getUniqueId() { + return componentMetadataDefinition.getMetadataDataDefinition().getUniqueId(); } - @Override - public String getUniqueId() { - return componentMetadataDefinition.getMetadataDataDefinition().getUniqueId(); - } - public void setUniqueId(String uniqueId) { componentMetadataDefinition.getMetadataDataDefinition().setUniqueId(uniqueId); } - public void setName(String name) { - componentMetadataDefinition.getMetadataDataDefinition().setName(name); - } - - public void setVersion(String version) { - componentMetadataDefinition.getMetadataDataDefinition().setVersion(version); - } - public void setHighestVersion(Boolean isHighestVersion) { componentMetadataDefinition.getMetadataDataDefinition().setHighestVersion(isHighestVersion); } - public void setCreationDate(Long creationDate) { - componentMetadataDefinition.getMetadataDataDefinition().setCreationDate(creationDate); - } - - public void setLastUpdateDate(Long lastUpdateDate) { - componentMetadataDefinition.getMetadataDataDefinition().setLastUpdateDate(lastUpdateDate); - } - - public void setDescription(String description) { - componentMetadataDefinition.getMetadataDataDefinition().setDescription(description); - } - public void setState(LifecycleStateEnum state) { componentMetadataDefinition.getMetadataDataDefinition().setState(state.name()); } - public void setTags(List tags) { - componentMetadataDefinition.getMetadataDataDefinition().setTags(tags); - } - - public void setConformanceLevel(String conformanceLevel) { - componentMetadataDefinition.getMetadataDataDefinition().setConformanceLevel(conformanceLevel); - } - - public void setIcon(String icon) { - componentMetadataDefinition.getMetadataDataDefinition().setIcon(icon); - } - - public void setContactId(String contactId) { - componentMetadataDefinition.getMetadataDataDefinition().setContactId(contactId); - } - public String getCreatorUserId() { return this.componentMetadataDefinition.getMetadataDataDefinition().getCreatorUserId(); } @@ -224,15 +145,24 @@ public abstract class Component implements PropertiesOwner { this.componentMetadataDefinition.getMetadataDataDefinition().setLastUpdaterFullName(lastUpdaterFullName); } - @Override - public String getName() { - return componentMetadataDefinition.getMetadataDataDefinition().getName(); - } + @Override + @EqualsAndHashCode.Include + public String getName() { + return componentMetadataDefinition.getMetadataDataDefinition().getName(); + } + + public void setName(String name) { + componentMetadataDefinition.getMetadataDataDefinition().setName(name); + } public String getVersion() { return componentMetadataDefinition.getMetadataDataDefinition().getVersion(); } + public void setVersion(String version) { + componentMetadataDefinition.getMetadataDataDefinition().setVersion(version); + } + public Boolean isHighestVersion() { return componentMetadataDefinition.getMetadataDataDefinition().isHighestVersion(); } @@ -241,57 +171,76 @@ public abstract class Component implements PropertiesOwner { return componentMetadataDefinition.getMetadataDataDefinition().getCreationDate(); } + public void setCreationDate(Long creationDate) { + componentMetadataDefinition.getMetadataDataDefinition().setCreationDate(creationDate); + } + public Long getLastUpdateDate() { return componentMetadataDefinition.getMetadataDataDefinition().getLastUpdateDate(); } + public void setLastUpdateDate(Long lastUpdateDate) { + componentMetadataDefinition.getMetadataDataDefinition().setLastUpdateDate(lastUpdateDate); + } + public String getDescription() { return componentMetadataDefinition.getMetadataDataDefinition().getDescription(); } + public void setDescription(String description) { + componentMetadataDefinition.getMetadataDataDefinition().setDescription(description); + } + public LifecycleStateEnum getLifecycleState() { if (componentMetadataDefinition.getMetadataDataDefinition().getState() != null) { return LifecycleStateEnum.valueOf(componentMetadataDefinition.getMetadataDataDefinition().getState()); - } - else { + } else { return null; } } + public void setLifecycleState(LifecycleStateEnum state) { + if (state != null) { + this.componentMetadataDefinition.getMetadataDataDefinition().setState(state.name()); + } + } + public List getTags() { return componentMetadataDefinition.getMetadataDataDefinition().getTags(); } + public void setTags(List tags) { + componentMetadataDefinition.getMetadataDataDefinition().setTags(tags); + } + public String getConformanceLevel() { return componentMetadataDefinition.getMetadataDataDefinition().getConformanceLevel(); } + public void setConformanceLevel(String conformanceLevel) { + componentMetadataDefinition.getMetadataDataDefinition().setConformanceLevel(conformanceLevel); + } + public String getIcon() { return componentMetadataDefinition.getMetadataDataDefinition().getIcon(); } + public void setIcon(String icon) { + componentMetadataDefinition.getMetadataDataDefinition().setIcon(icon); + } + public String getContactId() { return componentMetadataDefinition.getMetadataDataDefinition().getContactId(); } - public List getInputs() { - return inputs; + public void setContactId(String contactId) { + componentMetadataDefinition.getMetadataDataDefinition().setContactId(contactId); } public List safeGetInputs() { return inputs == null ? new ArrayList<>() : inputs; } - public void setInputs(List inputs) { - this.inputs = inputs; - } - - public void setLifecycleState(LifecycleStateEnum state) { - if (state != null) { - this.componentMetadataDefinition.getMetadataDataDefinition().setState(state.name()); - } - } - public String getUUID() { return componentMetadataDefinition.getMetadataDataDefinition().getUUID(); } @@ -300,28 +249,20 @@ public abstract class Component implements PropertiesOwner { componentMetadataDefinition.getMetadataDataDefinition().setUUID(uUID); } - public void setSystemName(String systemName) { - componentMetadataDefinition.getMetadataDataDefinition().setSystemName(systemName); - } - public String getSystemName() { return componentMetadataDefinition.getMetadataDataDefinition().getSystemName(); } - public void setAllVersions(Map allVersions) { - componentMetadataDefinition.getMetadataDataDefinition().setAllVersions(allVersions); + public void setSystemName(String systemName) { + componentMetadataDefinition.getMetadataDataDefinition().setSystemName(systemName); } public Map getAllVersions() { return componentMetadataDefinition.getMetadataDataDefinition().getAllVersions(); } - public Map getDeploymentArtifacts() { - return deploymentArtifacts; - } - - public void setDeploymentArtifacts(Map deploymentArtifacts) { - this.deploymentArtifacts = deploymentArtifacts; + public void setAllVersions(Map allVersions) { + componentMetadataDefinition.getMetadataDataDefinition().setAllVersions(allVersions); } public Map getAllArtifacts() { @@ -331,27 +272,12 @@ public abstract class Component implements PropertiesOwner { return allArtifacts; } - Optional getArtifact(String id) { - HashMap allArtifacts = new HashMap<>(); - allArtifacts.putAll(Optional.ofNullable(this.artifacts).orElse(emptyMap())); - allArtifacts.putAll(Optional.ofNullable(this.deploymentArtifacts).orElse(emptyMap())); - allArtifacts.putAll(Optional.ofNullable(this.toscaArtifacts).orElse(emptyMap())); - return Optional.ofNullable(allArtifacts.get(id)); - } - - public List getCategories() { - return categories; - } - - public void setCategories(List categories) { - this.categories = categories; + @Override + @EqualsAndHashCode.Include + public String getNormalizedName() { + return componentMetadataDefinition.getMetadataDataDefinition().getNormalizedName(); } - @Override - public String getNormalizedName() { - return componentMetadataDefinition.getMetadataDataDefinition().getNormalizedName(); - } - public void setNormalizedName(String normalizedName) { componentMetadataDefinition.getMetadataDataDefinition().setNormalizedName(normalizedName); } @@ -371,28 +297,12 @@ public abstract class Component implements PropertiesOwner { return capabilities; } - public void setCapabilities(Map> capabilities) { - this.capabilities = capabilities; - } - - public Map> getRequirements() { - return requirements; - } - - public void setRequirements(Map> requirements) { - this.requirements = requirements; - } - - public List getComponentInstances() { - return componentInstances; - } - public List safeGetComponentInstances() { - if(componentInstances != null) { - return componentInstances; - }else { - return emptyList(); - } + if (componentInstances != null) { + return componentInstances; + } else { + return emptyList(); + } } public Optional fetchInstanceById(String instanceId) { @@ -401,36 +311,20 @@ public abstract class Component implements PropertiesOwner { public Map safeGetComponentInstanceDeploymentArtifacts(String componentInstanceId) { return getComponentInstanceById(componentInstanceId).map(ComponentInstance::safeGetDeploymentArtifacts) - .orElse(emptyMap()); + .orElse(emptyMap()); } public Map safeGetComponentInstanceInformationalArtifacts(String componentInstanceId) { return getComponentInstanceById(componentInstanceId).map(ComponentInstance::safeGetInformationalArtifacts) - .orElse(emptyMap()); + .orElse(emptyMap()); } public List safeGetComponentInstanceHeatArtifacts(String componentInstanceId) { return safeGetComponentInstanceDeploymentArtifacts(componentInstanceId) - .values() - .stream() - .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.name().equals(artifact.getArtifactType())) - .collect(Collectors.toList()); - } - - public void setComponentInstances(List resourceInstances) { - this.componentInstances = resourceInstances; - } - - public List getComponentInstancesRelations() { - return componentInstancesRelations; - } - - public void setComponentInstancesRelations(List resourceInstancesRelations) { - this.componentInstancesRelations = resourceInstancesRelations; - } - - public Map> getComponentInstancesProperties() { - return componentInstancesProperties; + .values() + .stream() + .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.name().equals(artifact.getArtifactType())) + .collect(Collectors.toList()); } public Map> safeGetComponentInstancesProperties() { @@ -441,14 +335,14 @@ public abstract class Component implements PropertiesOwner { return componentInstancesProperties == null ? emptyMap() : findUiComponentInstancesProperties(); } - private Map> findUiComponentInstancesProperties() { + private Map> findUiComponentInstancesProperties() { List instancesFromUi = componentInstances.stream() - .filter(i->!i.isCreatedFromCsar()) - .map(ComponentInstance::getUniqueId) - .collect(Collectors.toList()); + .filter(i -> !i.isCreatedFromCsar()) + .map(ComponentInstance::getUniqueId) + .collect(Collectors.toList()); return componentInstancesProperties.entrySet().stream() - .filter(e -> instancesFromUi.contains(e.getKey())) - .collect(Collectors.toMap(e->e.getKey(), e->e.getValue())); + .filter(e -> instancesFromUi.contains(e.getKey())) + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); } public Map> safeGetComponentInstancesInputs() { @@ -459,14 +353,14 @@ public abstract class Component implements PropertiesOwner { return componentInstancesInputs == null ? emptyMap() : findUiComponentInstancesInputs(); } - private Map> findUiComponentInstancesInputs() { + private Map> findUiComponentInstancesInputs() { List instancesFromUi = componentInstances.stream() - .filter(i->!i.isCreatedFromCsar()) - .map(ComponentInstance::getUniqueId) - .collect(Collectors.toList()); + .filter(i -> !i.isCreatedFromCsar()) + .map(ComponentInstance::getUniqueId) + .collect(Collectors.toList()); return componentInstancesInputs.entrySet().stream() - .filter(e -> instancesFromUi.contains(e.getKey())) - .collect(Collectors.toMap(e->e.getKey(), e->e.getValue())); + .filter(e -> instancesFromUi.contains(e.getKey())) + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); } public List safeGetComponentInstanceProperties(String cmptInstacneId) { @@ -477,14 +371,9 @@ public abstract class Component implements PropertiesOwner { return this.safeGetComponentInstanceEntity(comptInstanceId, this.componentInstancesInputs); } - public List safeGetComponentInstanceInterfaces(String cmptInstacneId) { - return this.safeGetComponentInstanceEntity(cmptInstacneId, this.componentInstancesInterfaces); - } - - public void setComponentInstancesProperties( - Map> resourceInstancesProperties) { - this.componentInstancesProperties = resourceInstancesProperties; - } + public List safeGetComponentInstanceInterfaces(String cmptInstacneId) { + return this.safeGetComponentInstanceEntity(cmptInstacneId, this.componentInstancesInterfaces); + } public Boolean getIsDeleted() { return componentMetadataDefinition.getMetadataDataDefinition().isDeleted(); @@ -549,10 +438,6 @@ public abstract class Component implements PropertiesOwner { return componentInstances.stream().filter(predicate).findFirst(); } - public List getGroups() { - return groups; - } - public List safeGetGroups() { return groups == null ? emptyList() : groups; } @@ -574,259 +459,32 @@ public abstract class Component implements PropertiesOwner { return Optional.empty(); } return groups.stream() - .filter(predicate) - .findAny(); - } - - public Map> getComponentInstancesInterfaces() { - return componentInstancesInterfaces; - } - - public void setComponentInstancesInterfaces(Map> componentInstancesInterfaces) { - this.componentInstancesInterfaces = componentInstancesInterfaces; - } - - public void setGroups(List groups) { - this.groups = groups; - } - - public void addGroups(List groupsToAdd) { - if (groups == null) { - groups = new ArrayList<>(); + .filter(predicate) + .findAny(); } - groups.addAll(groupsToAdd); - } - public Map getPolicies() { - return policies; - } - - public void setPolicies(Map policies) { - this.policies = policies; + public void addGroups(List groupsToAdd) { + if (groups == null) { + groups = new ArrayList<>(); + } + groups.addAll(groupsToAdd); } public void addPolicy(PolicyDefinition policyDefinition) { - if(MapUtils.isEmpty(this.policies)) { - this.policies = new HashMap<>(); + if (MapUtils.isEmpty(this.policies)) { + this.policies = new HashMap<>(); } this.policies.put(policyDefinition.getUniqueId(), policyDefinition); } - public Map getNodeFilterComponents() { - return nodeFilterComponents; - } - - public void setNodeFilterComponents(Map nodeFilter) { - this.nodeFilterComponents = nodeFilter; - } - - - - public Map> getNodeFilters() { - return nodeFilters; - } - - public void setNodeFilters( - Map> nodeFilters) { - this.nodeFilters = nodeFilters; - } - - public Map> getServiceFilters() { - return serviceFilters; - } - - public void setServiceFilters( - Map> serviceFilters) { - this.serviceFilters = serviceFilters; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public void addProperty(PropertyDefinition propertyDefinition) { - if(org.apache.commons.collections.CollectionUtils.isEmpty(this.properties)) { - this.properties = new ArrayList<>(); - } - - this.properties.add(propertyDefinition);; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode()); - result = prime * result + ((categories == null) ? 0 : categories.hashCode()); - result = prime * result + ((componentMetadataDefinition == null) ? 0 : componentMetadataDefinition.hashCode()); - result = prime * result + ((deploymentArtifacts == null) ? 0 : deploymentArtifacts.hashCode()); - result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode()); - result = prime * result + ((requirements == null) ? 0 : requirements.hashCode()); - result = prime * result + ((componentInstances == null) ? 0 : componentInstances.hashCode()); - result = prime * result - + ((componentInstancesProperties == null) ? 0 : componentInstancesProperties.hashCode()); - result = prime * result - + ((componentInstancesAttributes == null) ? 0 : componentInstancesAttributes.hashCode()); - result = prime * result + ((componentInstancesInputs == null) ? 0 : componentInstancesInputs.hashCode()); - result = prime * result + ((componentInstancesRelations == null) ? 0 : componentInstancesRelations.hashCode()); - result = prime * result + ((groups == null) ? 0 : groups.hashCode()); - result = prime * result + ((policies == null) ? 0 : policies.hashCode()); - result = prime * result + ((derivedFromGenericType == null) ? 0 : derivedFromGenericType.hashCode()); - result = prime * result + ((derivedFromGenericVersion == null) ? 0 : derivedFromGenericVersion.hashCode()); - result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Component other = (Component) obj; - if (artifacts == null) { - if (other.artifacts != null) { - return false; - } - } - else if (!artifacts.equals(other.artifacts)) { - return false; - } - if (categories == null) { - if (other.categories != null) { - return false; - } - } - else if (!categories.equals(other.categories)) { - return false; - } - if (componentMetadataDefinition == null) { - if (other.componentMetadataDefinition != null) { - return false; - } - } - else if (!componentMetadataDefinition.equals(other.componentMetadataDefinition)) { - return false; - } - - if (deploymentArtifacts == null) { - if (other.deploymentArtifacts != null) { - return false; - } - } - else if (!deploymentArtifacts.equals(other.deploymentArtifacts)) { - return false; - } - - if (componentInstances == null) { - if (other.componentInstances != null) { - return false; - } - } - else if (!componentInstances.equals(other.componentInstances)) { - return false; - } - if (componentInstancesProperties == null) { - if (other.componentInstancesProperties != null) { - return false; - } - } - else if (!componentInstancesProperties.equals(other.componentInstancesProperties)) { - return false; + public void addProperty(PropertyDefinition propertyDefinition) { + if (org.apache.commons.collections.CollectionUtils.isEmpty(this.properties)) { + this.properties = new ArrayList<>(); } - if (!Objects.equals(componentInstancesAttributes, other.componentInstancesAttributes)) { - return false; - } - if (!Objects.equals(componentInstancesInputs, other.componentInstancesInputs)) { - return false; - } - if (componentInstancesRelations == null) { - if (other.componentInstancesRelations != null) { - return false; - } - } - else if (!componentInstancesRelations.equals(other.componentInstancesRelations)) { - return false; - } - if (requirements == null) { - if (other.requirements != null) { - return false; - } - } - else if (!requirements.equals(other.requirements)) { - return false; - } - if (capabilities == null) { - if (other.capabilities != null) { - return false; - } - } - else if (!capabilities.equals(other.capabilities)) { - return false; - } - if (groups == null) { - if (other.groups != null) { - return false; - } - } - else if (!groups.equals(other.groups)) { - return false; - } - if (policies == null) { - if (other.policies != null) { - return false; - } - } - else if (!policies.equals(other.policies)) { - return false; - } - if (derivedFromGenericType == null) { - if (other.derivedFromGenericType != null) { - return false; - } - } - else if (!derivedFromGenericType.equals(other.derivedFromGenericType)) { - return false; - } - if (derivedFromGenericVersion == null) { - if (other.derivedFromGenericVersion != null) { - return false; - } - } - else if (!derivedFromGenericVersion.equals(other.derivedFromGenericVersion)) { - return false; - } - if (interfaces == null) { - if (other.interfaces != null) { - return false; - } - } - else if (!interfaces.equals(other.interfaces)) { - return false; - } - if (properties == null) { - if (other.properties != null) { - return false; - } - } - else if (!properties.equals(other.properties)) { - return false; - } - else if (!nodeFilterComponents.equals(other.nodeFilterComponents)) { - return false; - } - return true; + this.properties.add(propertyDefinition); + ; } public void addCategory(String category, String subCategory) { @@ -903,27 +561,14 @@ public abstract class Component implements PropertiesOwner { } } - public Map> getComponentInstancesAttributes() { - return componentInstancesAttributes; - } - - public void setComponentInstancesAttributes( - Map> componentInstancesAttributes) { - this.componentInstancesAttributes = componentInstancesAttributes; - } - - public Map> getComponentInstancesInputs() { - return componentInstancesInputs; - } - public Map> safeGetGroupsProperties() { if (isEmpty(groups)) { return emptyMap(); } return groups.stream() - .filter(gr -> Objects.nonNull(gr.getProperties())) - .collect(toMap(GroupDataDefinition::getUniqueId, - GroupDataDefinition::getProperties)); + .filter(gr -> Objects.nonNull(gr.getProperties())) + .collect(toMap(GroupDataDefinition::getUniqueId, + GroupDataDefinition::getProperties)); } public Map> safeGetPolicyProperties() { @@ -931,10 +576,10 @@ public abstract class Component implements PropertiesOwner { return emptyMap(); } return policies.values() - .stream() - .filter(policy -> Objects.nonNull(policy.getProperties())) - .collect(toMap(PolicyDataDefinition::getUniqueId, - PolicyDataDefinition::getProperties)); + .stream() + .filter(policy -> Objects.nonNull(policy.getProperties())) + .collect(toMap(PolicyDataDefinition::getUniqueId, + PolicyDataDefinition::getProperties)); } public List safeGetComponentInstanceInputsByName(String cmptInstanceName) { @@ -943,11 +588,11 @@ public abstract class Component implements PropertiesOwner { return emptyPropsList; } return this.componentInstances.stream() - .filter(ci -> ci.getName().equals(cmptInstanceName)) - .map(ComponentInstance::getUniqueId) - .map(instanceId -> safeGetComponentInstanceEntity(instanceId, this.componentInstancesInputs)) - .findAny() - .orElse(emptyPropsList); + .filter(ci -> ci.getName().equals(cmptInstanceName)) + .map(ComponentInstance::getUniqueId) + .map(instanceId -> safeGetComponentInstanceEntity(instanceId, this.componentInstancesInputs)) + .findAny() + .orElse(emptyPropsList); } private List safeGetComponentInstanceEntity(String cmptInstanceId, Map> instanceEntities) { @@ -960,24 +605,16 @@ public abstract class Component implements PropertiesOwner { } - public void setComponentInstancesInputs(Map> componentInstancesInputs) { - this.componentInstancesInputs = componentInstancesInputs; - } - public void setSpecificComponetTypeArtifacts(Map specificComponentTypeArtifacts) { // Implement where needed } - public void setMetadataDefinition(ComponentMetadataDefinition metadataDefinition) { - this.componentMetadataDefinition = metadataDefinition; - } - public String fetchGenericTypeToscaNameFromConfig() { // Implement where needed return ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getGenericAssetNodeTypes() - .get(this.assetType()); + .getConfiguration() + .getGenericAssetNodeTypes() + .get(this.assetType()); } public String assetType() { @@ -1004,22 +641,6 @@ public abstract class Component implements PropertiesOwner { return ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue().equals(toscaType); } - public String getToscaType() { - return toscaType; - } - - public void setToscaType(String toscaType) { - this.toscaType = toscaType; - } - - public List getAdditionalInformation() { - return additionalInformation; - } - - public void setAdditionalInformation(List additionalInformation) { - this.additionalInformation = additionalInformation; - } - public PolicyDefinition getPolicyById(String id) { return policies != null ? policies.get(id) : null; } @@ -1041,8 +662,8 @@ public abstract class Component implements PropertiesOwner { return emptyList(); } return policies.values().stream() - .filter(policyPredicate) - .collect(Collectors.toList()); + .filter(policyPredicate) + .collect(Collectors.toList()); } public List resolveGroupsByMember(String instanceId) { @@ -1050,34 +671,46 @@ public abstract class Component implements PropertiesOwner { return emptyList(); } return groups.stream() - .filter(group -> group.containsInstanceAsMember(instanceId)) - .collect(Collectors.toList()); + .filter(group -> group.containsInstanceAsMember(instanceId)) + .collect(Collectors.toList()); } public String getActualComponentType() { return componentMetadataDefinition.getMetadataDataDefinition().getActualComponentType(); } - public Boolean isArchived() { return componentMetadataDefinition.getMetadataDataDefinition().isArchived(); } + public Boolean isArchived() { + return componentMetadataDefinition.getMetadataDataDefinition().isArchived(); + } - public void setArchived(Boolean archived) { componentMetadataDefinition.getMetadataDataDefinition().setArchived(archived); } + public void setArchived(Boolean archived) { + componentMetadataDefinition.getMetadataDataDefinition().setArchived(archived); + } - public Long getArchiveTime() { return componentMetadataDefinition.getMetadataDataDefinition().getArchiveTime(); } + public Long getArchiveTime() { + return componentMetadataDefinition.getMetadataDataDefinition().getArchiveTime(); + } - public void setArchiveTime(Long archiveTime) { componentMetadataDefinition.getMetadataDataDefinition().setArchiveTime(archiveTime); } + public void setArchiveTime(Long archiveTime) { + componentMetadataDefinition.getMetadataDataDefinition().setArchiveTime(archiveTime); + } - public Boolean isVspArchived() { return componentMetadataDefinition.getMetadataDataDefinition().isVspArchived(); } + public Boolean isVspArchived() { + return componentMetadataDefinition.getMetadataDataDefinition().isVspArchived(); + } - public void setVspArchived(Boolean vspArchived) { componentMetadataDefinition.getMetadataDataDefinition().setVspArchived(vspArchived); } + public void setVspArchived(Boolean vspArchived) { + componentMetadataDefinition.getMetadataDataDefinition().setVspArchived(vspArchived); + } //supportability log method return map of component metadata teddy.h - public Map getComponentMetadataForSupportLog(){ - MapcomponentMetadata=new HashMap<>(); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME,this.getName()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION,this.getVersion()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID,this.getUUID()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID,this.getCsarUUID()); - componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION,this.getCsarVersion()); + public Map getComponentMetadataForSupportLog() { + Map componentMetadata = new HashMap<>(); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME, this.getName()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION, this.getVersion()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID, this.getUUID()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID, this.getCsarUUID()); + componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION, this.getCsarVersion()); return componentMetadata; } 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 8100f988a2..7ee8af1bc0 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 @@ -20,35 +20,43 @@ package org.openecomp.sdc.be.model; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +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.InterfaceInstanceDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - +@Getter +@Setter +@EqualsAndHashCode(callSuper = true) +@ToString public class Resource extends Component { + /** + * Please note that more than one "derivedFrom" resource is not currently supported by the app. The first list + * element is always addressed. + */ private List derivedFrom; - + /** + * The derivedList is a chain of derivedFrom. e.g. if resource C is derived from resource B that is derived from + * resource A - then A, B is the "DerivedList" of resource C + */ private List derivedList; - private List attributes; - - private Map instInterfaces; - private List defaultCapabilities; public Resource() { super(new ResourceMetadataDefinition()); this.getComponentMetadataDefinition().getMetadataDataDefinition() - .setComponentType(ComponentTypeEnum.RESOURCE); + .setComponentType(ComponentTypeEnum.RESOURCE); } public Resource(ComponentMetadataDefinition componentMetadataDefinition) { @@ -59,82 +67,20 @@ public class Resource extends Component { this.getComponentMetadataDefinition().getMetadataDataDefinition().setComponentType(ComponentTypeEnum.RESOURCE); } - /** - * Please note that more than one "derivedFrom" resource is not currently - * supported by the app. The first list element is always addressed. - * - * @return - */ - public List getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(List derivedFrom) { - this.derivedFrom = derivedFrom; - } - - /** - * The derivedList is a chain of derivedFrom. e.g. if resource C is derived - * from resource B that is derived from resource A - then A, B is the - * "DerivedList" of resource C - * - * @return - */ - public List getDerivedList() { - return derivedList; - } - - public void setDerivedList(List derivedList) { - this.derivedList = derivedList; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public List getAttributes() { - return attributes; - } - - public void setAttributes(List attributes) { - this.attributes = attributes; - } - - public Map getInstInterfaces() { - return instInterfaces; - } - - public void setInstInterfaces( - Map instInterfaces) { - this.instInterfaces = instInterfaces; - } - public Boolean isAbstract() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition() - .getMetadataDataDefinition()) - .isAbstract(); + .getMetadataDataDefinition()) + .isAbstract(); } public void setAbstract(Boolean isAbstract) { ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setAbstract(isAbstract); - } - - public List getDefaultCapabilities() { - return defaultCapabilities; - } - - public void setDefaultCapabilities(List defaultCapabilities) { - this.defaultCapabilities = defaultCapabilities; + .setAbstract(isAbstract); } public String getCost() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getCost(); + .getCost(); } public void setCost(String cost) { @@ -143,103 +89,71 @@ public class Resource extends Component { public String getLicenseType() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getLicenseType(); + .getLicenseType(); } public void setLicenseType(String licenseType) { ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setLicenseType(licenseType); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + super.hashCode(); - result = prime * result + ((attributes == null) ? 0 : attributes.hashCode()); - result = prime * result + ((defaultCapabilities == null) ? 0 : defaultCapabilities.hashCode()); - result = prime * result + ((derivedFrom == null) ? 0 : derivedFrom.hashCode()); - result = prime * result + ((properties == null) ? 0 : properties.hashCode()); - result = prime * result + ((derivedList == null) ? 0 : derivedList.hashCode()); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - Resource resource = (Resource) o; - return Objects.equals(derivedFrom, resource.derivedFrom) && - Objects.equals(derivedList, resource.derivedList) && - Objects.equals(properties, resource.properties) && - Objects.equals(attributes, resource.attributes) && - Objects.equals(defaultCapabilities, resource.defaultCapabilities); - } - - - @Override - public String toString() { - return "Resource [derivedFrom=" + derivedFrom + ", properties=" + properties + ", attributes=" + attributes - + ", defaultCapabilities=" + defaultCapabilities + ", additionalInformation=" + additionalInformation - + "Metadata [" + getComponentMetadataDefinition().getMetadataDataDefinition().toString() + "]"; + .setLicenseType(licenseType); } public String getToscaResourceName() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getToscaResourceName(); + .getToscaResourceName(); } public void setToscaResourceName(String toscaResourceName) { ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setToscaResourceName(toscaResourceName); + .setToscaResourceName(toscaResourceName); } public ResourceTypeEnum getResourceType() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getResourceType(); + .getResourceType(); } public void setResourceType(ResourceTypeEnum resourceType) { ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setResourceType(resourceType); + .setResourceType(resourceType); } - public void setVendorName(String vendorName) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setVendorName(vendorName); + public String getVendorName() { + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) + .getVendorName(); } - public void setVendorRelease(String vendorRelease) { + public void setVendorName(String vendorName) { ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setVendorRelease(vendorRelease); - } - - public void setResourceVendorModelNumber(String resourceVendorModelNumber) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()). - setResourceVendorModelNumber(resourceVendorModelNumber); + .setVendorName(vendorName); } - public String getVendorName() { + public String getVendorRelease() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getVendorName(); + .getVendorRelease(); } - public String getVendorRelease() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getVendorRelease(); + public void setVendorRelease(String vendorRelease) { + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) + .setVendorRelease(vendorRelease); } public String getResourceVendorModelNumber() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getResourceVendorModelNumber(); + .getResourceVendorModelNumber(); + } + + public void setResourceVendorModelNumber(String resourceVendorModelNumber) { + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()). + setResourceVendorModelNumber(resourceVendorModelNumber); } @Override public String fetchGenericTypeToscaNameFromConfig() { String result = super.fetchGenericTypeToscaNameFromConfig(); - if (null == result) - result = ConfigurationManager.getConfigurationManager().getConfiguration().getGenericAssetNodeTypes().get(ResourceTypeEnum.VFC.getValue()); + if (null == result) { + result = ConfigurationManager.getConfigurationManager().getConfiguration().getGenericAssetNodeTypes() + .get(ResourceTypeEnum.VFC.getValue()); + } return result; } @@ -249,19 +163,23 @@ public class Resource extends Component { } @Override - public boolean shouldGenerateInputs(){ + public boolean shouldGenerateInputs() { return !(this.getResourceType().isAtomicType()); } @Override public boolean deriveFromGeneric() { - return this.shouldGenerateInputs() || (derivedFrom != null && derivedFrom.contains(fetchGenericTypeToscaNameFromConfig())); + return this.shouldGenerateInputs() || (derivedFrom != null && derivedFrom + .contains(fetchGenericTypeToscaNameFromConfig())); } public Map> groupRelationsFromCsarByInstanceName(Resource resource) { - List componentInstanceRelationsFromCsar = resource.getComponentInstancesRelations().stream().filter(r->!r.isOriginUI()).collect(Collectors.toList()); - Map> relationsByInstanceId = MapUtil.groupListBy(componentInstanceRelationsFromCsar, RequirementCapabilityRelDef::getFromNode); - return MapUtil.convertMapKeys(relationsByInstanceId, instId -> getInstanceInvariantNameFromInstanceId(resource, instId)); + List componentInstanceRelationsFromCsar = resource.getComponentInstancesRelations() + .stream().filter(r -> !r.isOriginUI()).collect(Collectors.toList()); + Map> relationsByInstanceId = MapUtil + .groupListBy(componentInstanceRelationsFromCsar, RequirementCapabilityRelDef::getFromNode); + return MapUtil + .convertMapKeys(relationsByInstanceId, instId -> getInstanceInvariantNameFromInstanceId(resource, instId)); } private String getInstanceNameFromInstanceId(Resource resource, String instId) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java index e5122aacf3..3040f6bb6c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Service.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,159 +20,145 @@ package org.openecomp.sdc.be.model; -import org.apache.commons.lang.StringUtils; -import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition; import java.util.HashMap; import java.util.Map; - +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.apache.commons.lang.StringUtils; +import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.InstantiationTypes; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum; +@Getter +@Setter +@EqualsAndHashCode(callSuper = true) +@ToString public class Service extends Component { + private Map serviceApiArtifacts; + private Map forwardingPaths; + public Service() { super(new ServiceMetadataDefinition()); this.getComponentMetadataDefinition().getMetadataDataDefinition().setComponentType(ComponentTypeEnum.SERVICE); this.setToscaType(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue()); } - public Service(ComponentMetadataDefinition serviceMetadataDefinition) { - super(serviceMetadataDefinition); - ComponentMetadataDataDefinition metadataDataDefinition = this.getComponentMetadataDefinition().getMetadataDataDefinition(); - if(metadataDataDefinition != null) { - metadataDataDefinition.setComponentType(ComponentTypeEnum.SERVICE); - } - this.setToscaType(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue()); - } - - private Map serviceApiArtifacts; - private Map forwardingPaths; - - public Map getServiceApiArtifacts() { - return serviceApiArtifacts; - } - - public void setServiceApiArtifacts(Map serviceApiArtifacts) { - this.serviceApiArtifacts = serviceApiArtifacts; - } - - public String getProjectCode() { - return getServiceMetadataDefinition().getProjectCode(); - } - - public Map getForwardingPaths() { - return forwardingPaths; - } - - public void setForwardingPaths(Map forwardingPaths) { - this.forwardingPaths = forwardingPaths; - } - - public ForwardingPathDataDefinition addForwardingPath(ForwardingPathDataDefinition forwardingPathDataDefinition){ - if(forwardingPaths == null){ - forwardingPaths = new HashMap<>(); - } - return forwardingPaths.put(forwardingPathDataDefinition.getUniqueId(),forwardingPathDataDefinition); - } - - public void setProjectCode(String projectName) { - getServiceMetadataDefinition().setProjectCode(projectName); - } - - public DistributionStatusEnum getDistributionStatus() { - String distributionStatus = getServiceMetadataDefinition().getDistributionStatus(); - if (distributionStatus != null) { - return DistributionStatusEnum.valueOf(distributionStatus); - } else { - return null; - } - } - - public void setDistributionStatus(DistributionStatusEnum distributionStatus) { - if (distributionStatus != null) - getServiceMetadataDefinition().setDistributionStatus(distributionStatus.name()); - } - - public void setEcompGeneratedNaming(Boolean ecompGeneratedNaming) { - getServiceMetadataDefinition().setEcompGeneratedNaming(ecompGeneratedNaming); - } - - public Boolean isEcompGeneratedNaming() { - return getServiceMetadataDefinition().isEcompGeneratedNaming(); - } - - public void setNamingPolicy(String namingPolicy) { - getServiceMetadataDefinition().setNamingPolicy(namingPolicy); - } - - public String getNamingPolicy() { - return getServiceMetadataDefinition().getNamingPolicy(); - } - - public String getEnvironmentContext() { return getServiceMetadataDefinition().getEnvironmentContext(); } - - public void setEnvironmentContext(String environmentContext) { - getServiceMetadataDefinition().setEnvironmentContext(environmentContext); - } - - public void setServiceType(String serviceType){ - getServiceMetadataDefinition().setServiceType(serviceType); - } - - public String getServiceType(){ - return getServiceMetadataDefinition().getServiceType(); - } - - public void setServiceRole(String serviceRole){ - getServiceMetadataDefinition().setServiceRole(serviceRole); - } - - public String getServiceRole(){ - return getServiceMetadataDefinition().getServiceRole(); - } - - public void setInstantiationType(String instantiationType){ - getServiceMetadataDefinition().setInstantiationType(instantiationType); - } - - public String getInstantiationType(){ - return getServiceMetadataDefinition().getInstantiationType(); - } - - private ServiceMetadataDataDefinition getServiceMetadataDefinition() { - return (ServiceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition(); - } - - public void setServiceFunction(String serviceFunction){ - getServiceMetadataDefinition().setServiceFunction(serviceFunction); - } - - public String getServiceFunction(){ - return getServiceMetadataDefinition().getServiceFunction(); - } - - public void validateAndSetInstantiationType() { - if (this.getInstantiationType().equals(StringUtils.EMPTY)) { - this.setInstantiationType(InstantiationTypes.A_LA_CARTE.getValue()); - } - } - - - @Override - public String toString() { - return "Service [componentMetadataDefinition=" + getComponentMetadataDefinition() - // + ", resourceInstances=" + resourceInstances + ", - // resourceInstancesRelations=" + resourceInstancesRelations + ", - // resourceInstancesRelations=" - // + resourceInstancesRelations - + " ]"; - } - - @Override - public void setSpecificComponetTypeArtifacts(Map specificComponentTypeArtifacts) { - setServiceApiArtifacts(specificComponentTypeArtifacts); - } + public Service(ComponentMetadataDefinition serviceMetadataDefinition) { + super(serviceMetadataDefinition); + ComponentMetadataDataDefinition metadataDataDefinition = this.getComponentMetadataDefinition() + .getMetadataDataDefinition(); + if (metadataDataDefinition != null) { + metadataDataDefinition.setComponentType(ComponentTypeEnum.SERVICE); + } + this.setToscaType(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE.getValue()); + } + + @Override + public String getProjectCode() { + return getServiceMetadataDefinition().getProjectCode(); + } + + @Override + public void setProjectCode(String projectName) { + getServiceMetadataDefinition().setProjectCode(projectName); + } + + public ForwardingPathDataDefinition addForwardingPath(ForwardingPathDataDefinition forwardingPathDataDefinition) { + if (forwardingPaths == null) { + forwardingPaths = new HashMap<>(); + } + return forwardingPaths.put(forwardingPathDataDefinition.getUniqueId(), forwardingPathDataDefinition); + } + + public DistributionStatusEnum getDistributionStatus() { + String distributionStatus = getServiceMetadataDefinition().getDistributionStatus(); + if (distributionStatus != null) { + return DistributionStatusEnum.valueOf(distributionStatus); + } else { + return null; + } + } + + public void setDistributionStatus(DistributionStatusEnum distributionStatus) { + if (distributionStatus != null) { + getServiceMetadataDefinition().setDistributionStatus(distributionStatus.name()); + } + } + + public void setEcompGeneratedNaming(Boolean ecompGeneratedNaming) { + getServiceMetadataDefinition().setEcompGeneratedNaming(ecompGeneratedNaming); + } + + public Boolean isEcompGeneratedNaming() { + return getServiceMetadataDefinition().isEcompGeneratedNaming(); + } + + public String getNamingPolicy() { + return getServiceMetadataDefinition().getNamingPolicy(); + } + + public void setNamingPolicy(String namingPolicy) { + getServiceMetadataDefinition().setNamingPolicy(namingPolicy); + } + + public String getEnvironmentContext() { + return getServiceMetadataDefinition().getEnvironmentContext(); + } + + public void setEnvironmentContext(String environmentContext) { + getServiceMetadataDefinition().setEnvironmentContext(environmentContext); + } + + public String getServiceType() { + return getServiceMetadataDefinition().getServiceType(); + } + + public void setServiceType(String serviceType) { + getServiceMetadataDefinition().setServiceType(serviceType); + } + + public String getServiceRole() { + return getServiceMetadataDefinition().getServiceRole(); + } + + public void setServiceRole(String serviceRole) { + getServiceMetadataDefinition().setServiceRole(serviceRole); + } + + public String getInstantiationType() { + return getServiceMetadataDefinition().getInstantiationType(); + } + + public void setInstantiationType(String instantiationType) { + getServiceMetadataDefinition().setInstantiationType(instantiationType); + } + + private ServiceMetadataDataDefinition getServiceMetadataDefinition() { + return (ServiceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition(); + } + + public String getServiceFunction() { + return getServiceMetadataDefinition().getServiceFunction(); + } + + public void setServiceFunction(String serviceFunction) { + getServiceMetadataDefinition().setServiceFunction(serviceFunction); + } + + public void validateAndSetInstantiationType() { + if (this.getInstantiationType().equals(StringUtils.EMPTY)) { + this.setInstantiationType(InstantiationTypes.A_LA_CARTE.getValue()); + } + } + + @Override + public void setSpecificComponetTypeArtifacts(Map specificComponentTypeArtifacts) { + setServiceApiArtifacts(specificComponentTypeArtifacts); + } } -- cgit 1.2.3-korg