diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes')
5 files changed, 46 insertions, 23 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java index 1c272770b3..814011d846 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/EntityConsolidationData.java @@ -31,7 +31,6 @@ import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.onap.sdc.tosca.datatypes.model.RequirementAssignment; -import org.openecomp.sdc.translator.services.heattotosca.ConsolidationDataUtil; /** * The type Entity consolidation data. @@ -106,7 +105,7 @@ public class EntityConsolidationData { * @param requirementAssignment the requirement assignment */ public void addNodesConnectedIn(String nodeTemplateId, String requirementId, - RequirementAssignment requirementAssignment) { + RequirementAssignment requirementAssignment) { if (this.nodesConnectedIn == null) { this.nodesConnectedIn = ArrayListMultimap.create(); @@ -152,7 +151,7 @@ public class EntityConsolidationData { * @param requirementAssignment the requirement assignment */ public void addNodesConnectedOut(String nodeTemplateId, String requirementId, - RequirementAssignment requirementAssignment) { + RequirementAssignment requirementAssignment) { if (this.nodesConnectedOut == null) { this.nodesConnectedOut = ArrayListMultimap.create(); @@ -280,7 +279,7 @@ public class EntityConsolidationData { * otherwise return false */ public boolean isGetAttrOutFromEntityLegal(Collection<? extends EntityConsolidationData> - entityConsolidationDataList, Map<String, List<String>> portTypeToIds) { + entityConsolidationDataList, Map<String, List<String>> portTypeToIds) { if (CollectionUtils.isEmpty(entityConsolidationDataList) || MapUtils.isEmpty(portTypeToIds)) { return true; @@ -288,11 +287,11 @@ public class EntityConsolidationData { for (String portType : portTypeToIds.keySet()) { Set<GetAttrFuncData> startingGetAttrFunc = - getEntityGetAttrFuncAsSet(portType); + getEntityGetAttrFuncAsSet(portType, portTypeToIds); for (EntityConsolidationData entity : entityConsolidationDataList) { Set<GetAttrFuncData> currentGetAttrFuncData = - entity.getEntityGetAttrFuncAsSet(portType); + entity.getEntityGetAttrFuncAsSet(portType, portTypeToIds); if (!(startingGetAttrFunc.equals(currentGetAttrFuncData))) { return false; } @@ -301,15 +300,25 @@ public class EntityConsolidationData { return true; } - private Set<GetAttrFuncData> getEntityGetAttrFuncAsSet(String portType) { + private Set<GetAttrFuncData> getEntityGetAttrFuncAsSet(String portType, Map<String, List<String>> portTypeToIds) { if (MapUtils.isEmpty(nodesGetAttrOut)) { return new HashSet<>(); } return nodesGetAttrOut.entrySet().stream() - .filter(entry -> portType.equals(ConsolidationDataUtil.getPortType(entry.getKey()))) - .flatMap(entry -> entry.getValue().stream()) - .collect(Collectors.toSet()); + .filter(entry -> portType.equals(getPortTypeFromNodeTemplateId(entry.getKey(), + portTypeToIds))) + .flatMap(entry -> entry.getValue().stream()) + .collect(Collectors.toSet()); + } + + private String getPortTypeFromNodeTemplateId(String portNodeTemplateId, Map<String, List<String>> portTypeToIds) { + for (Map.Entry<String, List<String>> portTypeToIdEntry : portTypeToIds.entrySet()) { + if (portTypeToIdEntry.getValue().contains(portNodeTemplateId)) { + return portTypeToIdEntry.getKey(); + } + } + return ""; } /** diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java index 229e680bda..0300f9fcd9 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/FilePortConsolidationData.java @@ -77,7 +77,7 @@ public class FilePortConsolidationData { PortTemplateConsolidationData consolidationData = addPortTemplateConsolidationData(parentPortNodeTemplateId, parentPortResourceId, - parentPortResourceType); + parentPortResourceType, null); return consolidationData.addSubInterfaceTemplateConsolidationData(resource, subInterfaceNodeTemplateId, parentPortNodeTemplateId); @@ -90,13 +90,16 @@ public class FilePortConsolidationData { * @return port template consolidation data entity by given keys */ PortTemplateConsolidationData addPortTemplateConsolidationData( - String portNodeTemplateId, String portResourceId, String portResourceType) { + String portNodeTemplateId, String portResourceId, String portResourceType, String portType) { PortTemplateConsolidationData consolidationData = getPortTemplateConsolidationData(portNodeTemplateId); if (consolidationData == null) { consolidationData = createPortTemplateConsolidationData(portNodeTemplateId, - portResourceId, portResourceType); + portResourceId, portResourceType, portType); setPortTemplateConsolidationData(portNodeTemplateId, consolidationData); } + if (consolidationData.getPortType() == null) { + consolidationData.setPortType(portType); + } return consolidationData; } @@ -116,9 +119,10 @@ public class FilePortConsolidationData { } private PortTemplateConsolidationData createPortTemplateConsolidationData(String portNodeTemplateId, - String portResourceId, String portResourceType) { + String portResourceId, String portResourceType, String portType) { PortTemplateConsolidationData consolidationData = new PortTemplateConsolidationData(); consolidationData.setNodeTemplateId(portNodeTemplateId); + consolidationData.setPortType(portType); Optional<String> portNetworkRole = HeatResourceUtil.evaluateNetworkRoleFromResourceId(portResourceId, portResourceType); portNetworkRole.ifPresent(consolidationData::setNetworkRole); diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java index 1c830646d6..132a507298 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationData.java @@ -50,10 +50,10 @@ public class PortConsolidationData { * @return port template consolidation data */ PortTemplateConsolidationData addPortTemplateConsolidationData(String serviceTemplateFileName, - String portNodeTemplateId, String portResourceId, String portResourceType) { + String portNodeTemplateId, String portResourceId, String portResourceType, String portType) { FilePortConsolidationData consolidationData = addFilePortConsolidationData(serviceTemplateFileName); return consolidationData - .addPortTemplateConsolidationData(portNodeTemplateId, portResourceId, portResourceType); + .addPortTemplateConsolidationData(portNodeTemplateId, portResourceId, portResourceType, portType); } /** diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java index c28c54c861..5114e5d25d 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortConsolidationDataHandler.java @@ -66,7 +66,7 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { Resource resource = heatOrchestrationTemplate.getResources().get(contrailSharedResourceId); String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate); EntityConsolidationData entityConsolidationData = getPortTemplateConsolidationData(serviceTemplateFileName, - contrailSharedResourceId, resource.getType(), sharedTranslatedResourceId); + contrailSharedResourceId, resource.getType(), sharedTranslatedResourceId, null); entityConsolidationData.removeParamNameFromAttrFuncList(paramName); } @@ -76,9 +76,9 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { * */ public void addConsolidationData(String serviceTemplateFileName, - String portResourceId, String portResourceType, String portNodeTemplateId) { + String portResourceId, String portResourceType, String portNodeTemplateId, String portType) { getPortTemplateConsolidationData( - serviceTemplateFileName, portResourceId, portResourceType, portNodeTemplateId); + serviceTemplateFileName, portResourceId, portResourceType, portNodeTemplateId, portType); } @Override @@ -133,7 +133,7 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { Resource resource = heatOrchestrationTemplate.getResources().get(targetResourceId); ServiceTemplate serviceTemplate = functionTranslator.getServiceTemplate(); return getPortTemplateConsolidationData(ToscaUtil.getServiceTemplateFileName(serviceTemplate), - targetResourceId, resource.getType(), targetResourceTranslatedId); + targetResourceId, resource.getType(), targetResourceTranslatedId, null); } private PortTemplateConsolidationData getPortTemplateConsolidationData(TranslateTo translateTo, @@ -141,14 +141,14 @@ public class PortConsolidationDataHandler implements ConsolidationDataHandler { ServiceTemplate serviceTemplate = translateTo.getServiceTemplate(); String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate); return getPortTemplateConsolidationData(serviceTemplateFileName, - portResourceId, portResourceType, portNodeTemplateId); + portResourceId, portResourceType, portNodeTemplateId, null); } private PortTemplateConsolidationData getPortTemplateConsolidationData(String serviceTemplateFileName, - String portResourceId, String portResourceType, String portNodeTemplateId) { + String portResourceId, String portResourceType, String portNodeTemplateId, String portType) { return portConsolidationData.addPortTemplateConsolidationData(serviceTemplateFileName, - portNodeTemplateId, portResourceId, portResourceType); + portNodeTemplateId, portResourceId, portResourceType, portType); } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java index f612c35abe..b529c7a55e 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/PortTemplateConsolidationData.java @@ -36,6 +36,8 @@ public class PortTemplateConsolidationData extends EntityConsolidationData { private final ListMultimap<String, SubInterfaceTemplateConsolidationData> subInterfaceConsolidationData = Multimaps.synchronizedListMultimap(ArrayListMultimap.create()); + private String portType; + private String networkRole; public String getNetworkRole() { @@ -46,6 +48,14 @@ public class PortTemplateConsolidationData extends EntityConsolidationData { this.networkRole = networkRole; } + public String getPortType() { + return portType; + } + + public void setPortType(String portType) { + this.portType = portType; + } + public boolean isPortBoundToSubInterface() { return !subInterfaceConsolidationData.isEmpty(); } |