From 1468fdc4558bb82c025a05b03d1511018d8fd835 Mon Sep 17 00:00:00 2001 From: Talio Date: Tue, 5 Feb 2019 11:05:05 +0200 Subject: fix review comments on property assignment Change-Id: Ia986294cb552f4e26b3ebf1d1b50c9b7941553ab Issue-ID: SDC-2097 Signed-off-by: Talio --- .../sdc/be/model/InterfaceInstanceDefinition.java | 39 ------------ .../java/org/openecomp/sdc/be/model/Resource.java | 71 +++++++++++----------- 2 files changed, 35 insertions(+), 75 deletions(-) delete mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java (limited to 'catalog-model/src/main') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java deleted file mode 100644 index d16370d151..0000000000 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/InterfaceInstanceDefinition.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.openecomp.sdc.be.model; - -import org.apache.commons.collections.MapUtils; -import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.OperationInstance; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -public class InterfaceInstanceDefinition extends InterfaceInstanceDataDefinition { - - public InterfaceInstanceDefinition(InterfaceInstanceDataDefinition inter) { - super(inter); - } - - public InterfaceInstanceDefinition(){} - - public Map getInputs() { - return this.inputs; - } - - public void setInputs( - Map inputs) { - this.inputs = inputs; - } - - public Map getOperations() { - return operations; - } - - public void addInstanceOperation(String operationName, OperationInstance operation) { - if(MapUtils.isEmpty(this.operations)) { - this.operations = new HashMap<>(); - } - - this.operations.put(operationName, operation); - } -} 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 0603538833..9b2b609fdb 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 @@ -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. @@ -23,6 +23,7 @@ package org.openecomp.sdc.be.model; 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; @@ -32,33 +33,31 @@ import java.util.Optional; public class Resource extends Component { - - + private List derivedFrom; private List derivedList; - private List properties; - private List attributes; - private Map instInterfaces; + private Map instInterfaces; - private List defaultCapabilities; + private List defaultCapabilities; - public Resource() { - super(new ResourceMetadataDefinition()); - this.getComponentMetadataDefinition().getMetadataDataDefinition() - .setComponentType(ComponentTypeEnum.RESOURCE); - } + public Resource() { + super(new ResourceMetadataDefinition()); + this.getComponentMetadataDefinition().getMetadataDataDefinition() + .setComponentType(ComponentTypeEnum.RESOURCE); + } public Resource(ComponentMetadataDefinition componentMetadataDefinition) { super(componentMetadataDefinition); - if(this.getComponentMetadataDefinition().getMetadataDataDefinition() == null) { + if (this.getComponentMetadataDefinition().getMetadataDataDefinition() == null) { this.getComponentMetadataDefinition().componentMetadataDataDefinition = new ResourceMetadataDataDefinition(); } 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. @@ -104,20 +103,20 @@ public class Resource extends Component { this.attributes = attributes; } - public Map getInstInterfaces() { - return instInterfaces; - } + public Map getInstInterfaces() { + return instInterfaces; + } - public void setInstInterfaces( - Map instInterfaces) { - this.instInterfaces = instInterfaces; - } + public void setInstInterfaces( + Map instInterfaces) { + this.instInterfaces = instInterfaces; + } - public Boolean isAbstract() { - return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition() - .getMetadataDataDefinition()) - .isAbstract(); - } + public Boolean isAbstract() { + return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition() + .getMetadataDataDefinition()) + .isAbstract(); + } public void setAbstract(Boolean isAbstract) { ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) @@ -240,9 +239,9 @@ public class Resource extends Component { .setVendorRelease(vendorRelease); } - public void setResourceVendorModelNumber(String resourceVendorModelNumber){ + public void setResourceVendorModelNumber(String resourceVendorModelNumber) { ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()). - setResourceVendorModelNumber(resourceVendorModelNumber); + setResourceVendorModelNumber(resourceVendorModelNumber); } public String getVendorName() { @@ -255,32 +254,32 @@ public class Resource extends Component { .getVendorRelease(); } - public String getResourceVendorModelNumber(){ + public String getResourceVendorModelNumber() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) .getResourceVendorModelNumber(); } @Override - public String fetchGenericTypeToscaNameFromConfig(){ + public String fetchGenericTypeToscaNameFromConfig() { String result = super.fetchGenericTypeToscaNameFromConfig(); - if(null == result) + if (null == result) result = ConfigurationManager.getConfigurationManager().getConfiguration().getGenericAssetNodeTypes().get(ResourceTypeEnum.VFC.getValue()); return result; } @Override - public String assetType(){ + public String assetType() { return this.getResourceType().name(); } @Override - public boolean shouldGenerateInputs(){ + public boolean shouldGenerateInputs() { //TODO add complex VFC condition when supported return !(this.getResourceType().isAtomicType()); } @Override - public boolean deriveFromGeneric(){ + public boolean deriveFromGeneric() { return this.shouldGenerateInputs() || (derivedFrom != null && derivedFrom.contains(fetchGenericTypeToscaNameFromConfig())); } @@ -290,7 +289,7 @@ public class Resource extends Component { } private String getInstanceNameFromInstanceId(Resource resource, String instId) { - Optional componentInstanceById = resource.getComponentInstanceById(instId); - return componentInstanceById.isPresent() ? componentInstanceById.get().getName() : null; + Optional componentInstanceById = resource.getComponentInstanceById(instId); + return componentInstanceById.isPresent() ? componentInstanceById.get().getName() : null; } } -- cgit 1.2.3-korg