/*- * ============LICENSE_START======================================================= * SDC * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. 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.jsontitan.datamodel; import java.util.HashMap; import java.util.Map; import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition; 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.MapCapabiltyProperty; import org.openecomp.sdc.be.datatypes.elements.MapComponentInstanceExternalRefs; import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition; 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.tosca.ToscaDataDefinition; import org.openecomp.sdc.be.model.jsontitan.enums.JsonConstantKeysEnum; public class TopologyTemplate extends ToscaElement{ public TopologyTemplate() { super(ToscaElementTypeEnum.TopologyTemplate); } private Map inputs; private Map instInputs; private Map heatParameters; private Map instAttributes; private Map instProperties; private Map groups; private Map policies; private Map instGroups; private Map serviceApiArtifacts; private Map forwardingPaths; private Map compositions; private Map calculatedCapabilities; private Map calculatedRequirements; private Map fullfilledCapabilities; private Map fullfilledRequirements; private Map calculatedCapabilitiesProperties; private Map instDeploymentArtifacts; private Map instanceArtifacts; private Map interfaces; //Component Instances External References (instanceId -> ExternalRefsMap) //----------------------------------------------------------------------- private Map mapComponentInstancesExternalRefs; public Map getMapComponentInstancesExternalRefs() { return this.mapComponentInstancesExternalRefs; } public void setComponentInstancesExternalRefs(Map mapComponentInstancesExternalRefs) { this.mapComponentInstancesExternalRefs = mapComponentInstancesExternalRefs; } //----------------------------------------------------------------------- public Map getInterfaces() { return interfaces; } public void setInterfaces(Map interfaces) { this.interfaces = interfaces; } public Map getInputs() { return inputs; } public void setInputs(Map inputs) { this.inputs = inputs; } public Map getInstInputs() { return instInputs; } public void setInstInputs(Map instInputs) { this.instInputs = instInputs; } public Map getHeatParameters() { return heatParameters; } public void setHeatParameters(Map heatParameters) { this.heatParameters = heatParameters; } public Map getInstAttributes() { return instAttributes; } public void setInstAttributes(Map instAttributes) { this.instAttributes = instAttributes; } public Map getInstProperties() { return instProperties; } public void setInstProperties(Map instProperties) { this.instProperties = instProperties; } public Map getGroups() { return groups; } public void setGroups(Map groups) { this.groups = groups; } public Map getPolicies() { return policies; } public void setPolicies(Map policies) { this.policies = policies; } public Map getInstGroups() { return instGroups; } public void setInstGroups(Map instGroups) { this.instGroups = instGroups; } public Map getServiceApiArtifacts() { return serviceApiArtifacts; } public void setServiceApiArtifacts(Map serviceApiArtifacts) { this.serviceApiArtifacts = serviceApiArtifacts; } public Map getCompositions() { return compositions; } public void setCompositions(Map compositions) { this.compositions = compositions; } public Map getCalculatedCapabilities() { return calculatedCapabilities; } public void setCalculatedCapabilities(Map calculatedCapabilities) { this.calculatedCapabilities = calculatedCapabilities; } public Map getCalculatedRequirements() { return calculatedRequirements; } public void setCalculatedRequirements(Map calculatedRequirements) { this.calculatedRequirements = calculatedRequirements; } public Map getFullfilledCapabilities() { return fullfilledCapabilities; } public void setFullfilledCapabilities(Map fullfilledCapabilities) { this.fullfilledCapabilities = fullfilledCapabilities; } public Map getFullfilledRequirements() { return fullfilledRequirements; } public void setFullfilledRequirements(Map fullfilledRequirements) { this.fullfilledRequirements = fullfilledRequirements; } public Map getInstDeploymentArtifacts() { return instDeploymentArtifacts; } public void setInstDeploymentArtifacts(Map instDeploymentArtifacts) { this.instDeploymentArtifacts = instDeploymentArtifacts; } public Map getCalculatedCapabilitiesProperties() { return calculatedCapabilitiesProperties; } public void setCalculatedCapabilitiesProperties(Map calculatedCapabilitiesProperties) { this.calculatedCapabilitiesProperties = calculatedCapabilitiesProperties; } public Map getInstanceArtifacts() { return instanceArtifacts; } public void setInstanceArtifacts(Map instanceArtifacts) { this.instanceArtifacts = instanceArtifacts; } public Map getForwardingPaths() { return forwardingPaths; } public void setForwardingPaths(Map forwardingPaths) { this.forwardingPaths = forwardingPaths; } /** * 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){ compositions = new HashMap<>(); } if(MapUtils.isEmpty(getCompositions())){ compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition()); } 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); } /** * Returns map of component instances from composition * @return */ public Map getComponentInstances() { Map instances = null; if(getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){ instances = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances(); } return 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 instances) { if(getCompositions() == null){ compositions = new HashMap<>(); } if(MapUtils.isEmpty(getCompositions())){ compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition()); } getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).setComponentInstances(instances); } public Map getRelations() { Map relations = null; if( getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){ relations = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getRelations(); } return relations; } }