diff options
Diffstat (limited to 'catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java | 85 |
1 files changed, 30 insertions, 55 deletions
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 0e4753c3f7..a75ed9f68b 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 @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.model; import java.util.List; @@ -41,19 +40,15 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; 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. + * Please note that more than one "derivedFrom" resource is not currently supported by the app. The first list element is always addressed. */ private List<String> 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 + * 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<String> derivedList; - private Map<String, String> derivedFromMapOfIdToName; - private String toscaVersion; public Resource() { @@ -64,25 +59,21 @@ public class Resource extends Component { public Resource(ComponentMetadataDefinition componentMetadataDefinition) { super(componentMetadataDefinition); if (this.getComponentMetadataDefinition().getMetadataDataDefinition() == null) { - this.getComponentMetadataDefinition().componentMetadataDataDefinition = - new ResourceMetadataDataDefinition(); + this.getComponentMetadataDefinition().componentMetadataDataDefinition = new ResourceMetadataDataDefinition(); } this.getComponentMetadataDefinition().getMetadataDataDefinition().setComponentType(ComponentTypeEnum.RESOURCE); } public Boolean isAbstract() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .isAbstract(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).isAbstract(); } public void setAbstract(Boolean isAbstract) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setAbstract(isAbstract); + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).setAbstract(isAbstract); } public String getCost() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getCost(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).getCost(); } public void setCost(String cost) { @@ -90,58 +81,47 @@ public class Resource extends Component { } public String getLicenseType() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getLicenseType(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).getLicenseType(); } public void setLicenseType(String licenseType) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setLicenseType(licenseType); + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).setLicenseType(licenseType); } public String getToscaResourceName() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getToscaResourceName(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).getToscaResourceName(); } public void setToscaResourceName(String toscaResourceName) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setToscaResourceName(toscaResourceName); + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).setToscaResourceName(toscaResourceName); } public ResourceTypeEnum getResourceType() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getResourceType(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).getResourceType(); } public void setResourceType(ResourceTypeEnum resourceType) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setResourceType(resourceType); + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).setResourceType(resourceType); } public String getVendorName() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getVendorName(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorName(); } public void setVendorName(String vendorName) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setVendorName(vendorName); + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).setVendorName(vendorName); } public String getVendorRelease() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getVendorRelease(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorRelease(); } public void setVendorRelease(String vendorRelease) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setVendorRelease(vendorRelease); + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).setVendorRelease(vendorRelease); } public String getResourceVendorModelNumber() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .getResourceVendorModelNumber(); + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()).getResourceVendorModelNumber(); } public void setResourceVendorModelNumber(String resourceVendorModelNumber) { @@ -164,16 +144,14 @@ public class Resource extends Component { } private Optional<String> fetchToscaNameFromConfigBasedOnCategory() { - return getHeadOption(this.getCategories()).flatMap(category -> getHeadOption(category.getSubcategories()).map( - subCategory -> fetchToscaNameFromConfigBasedOnCategory(category.getName(), subCategory.getName()))); + return getHeadOption(this.getCategories()).flatMap(category -> getHeadOption(category.getSubcategories()) + .map(subCategory -> fetchToscaNameFromConfigBasedOnCategory(category.getName(), subCategory.getName()))); } - private String fetchToscaNameFromConfigBasedOnCategory(final String resourceCategory, - final String resourceSubCategory) { - return Optional - .ofNullable(ConfigurationManager.getConfigurationManager().getConfiguration().getResourceNodeTypes()) - .map(categoryNames -> categoryNames.get(resourceCategory)) - .map(subCategoryNames -> subCategoryNames.get(resourceSubCategory)).orElse(null); + private String fetchToscaNameFromConfigBasedOnCategory(final String resourceCategory, final String resourceSubCategory) { + return Optional.ofNullable(ConfigurationManager.getConfigurationManager().getConfiguration().getResourceNodeTypes()) + .map(categoryNames -> categoryNames.get(resourceCategory)).map(subCategoryNames -> subCategoryNames.get(resourceSubCategory)) + .orElse(null); } @Override @@ -188,22 +166,19 @@ public class Resource extends Component { @Override public boolean deriveFromGeneric() { - return this.shouldGenerateInputs() - || (derivedFrom != null && derivedFrom.contains(fetchGenericTypeToscaNameFromConfig())); + return this.shouldGenerateInputs() || (derivedFrom != null && derivedFrom.contains(fetchGenericTypeToscaNameFromConfig())); } public Map<String, List<RequirementCapabilityRelDef>> groupRelationsFromCsarByInstanceName(Resource resource) { - List<RequirementCapabilityRelDef> componentInstanceRelationsFromCsar = resource.getComponentInstancesRelations() - .stream().filter(r -> !r.isOriginUI()).collect(Collectors.toList()); - Map<String, List<RequirementCapabilityRelDef>> relationsByInstanceId = - MapUtil.groupListBy(componentInstanceRelationsFromCsar, RequirementCapabilityRelDef::getFromNode); - return MapUtil.convertMapKeys(relationsByInstanceId, - instId -> getInstanceInvariantNameFromInstanceId(resource, instId)); + List<RequirementCapabilityRelDef> componentInstanceRelationsFromCsar = resource.getComponentInstancesRelations().stream() + .filter(r -> !r.isOriginUI()).collect(Collectors.toList()); + Map<String, List<RequirementCapabilityRelDef>> relationsByInstanceId = MapUtil + .groupListBy(componentInstanceRelationsFromCsar, RequirementCapabilityRelDef::getFromNode); + return MapUtil.convertMapKeys(relationsByInstanceId, instId -> getInstanceInvariantNameFromInstanceId(resource, instId)); } private String getInstanceInvariantNameFromInstanceId(Resource resource, String instId) { Optional<ComponentInstance> componentInstanceById = resource.getComponentInstanceById(instId); return componentInstanceById.isPresent() ? componentInstanceById.get().getInvariantName() : null; } - } |