/*- * ============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; import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; public class ComponentInstance extends ComponentInstanceDataDefinition implements PropertiesOwner { private Map> capabilities; private Map> requirements; private Map deploymentArtifacts; private Map artifacts; private List groupInstances; private Map interfaces; private List properties; private CINodeFilterDataDefinition nodeFilter; private List inputs; public ComponentInstance() { super(); } public ComponentInstance(ComponentInstanceDataDefinition r) { super(r); } public Map> getCapabilities() { return capabilities; } public void setCapabilities(Map> capabilities) { this.capabilities = capabilities; } public Map> getRequirements() { return requirements; } public void setRequirements(Map> requirements) { this.requirements = requirements; } public Map getDeploymentArtifacts() { return deploymentArtifacts; } public Map safeGetDeploymentArtifacts() { return deploymentArtifacts == null ? Collections.emptyMap() : deploymentArtifacts; } public Map safeGetInformationalArtifacts() { return artifacts == null ? Collections.emptyMap() : deploymentArtifacts; } public void setDeploymentArtifacts(Map deploymentArtifacts) { this.deploymentArtifacts = deploymentArtifacts; } public Map getArtifacts() { return artifacts; } public Map safeGetArtifacts() { return artifacts == null ? Collections.emptyMap() : artifacts; } public void setArtifacts(Map artifacts) { this.artifacts = artifacts; } public List getGroupInstances() { return groupInstances; } public void setGroupInstances(List groupInstances) { this.groupInstances = groupInstances; } public String getActualComponentUid() { return getIsProxy() ? getSourceModelUid() : getComponentUid(); } public boolean isArtifactExists(ArtifactGroupTypeEnum groupType, String artifactLabel) { if (ArtifactGroupTypeEnum.DEPLOYMENT == groupType) { return safeGetDeploymentArtifacts().get(artifactLabel) != null; } return safeGetInformationalArtifacts().get(artifactLabel) != null; } public Map getInterfaces() { return interfaces; } public void setInterfaces(Map interfaces) { this.interfaces = interfaces; } public void addInterface(String interfaceName, Object interfaceDefinition) { if(MapUtils.isEmpty(this.interfaces)) { this.interfaces = new HashMap<>(); } this.interfaces.put(interfaceName, interfaceDefinition); } public List getProperties() { return properties; } public void setProperties(List properties) { this.properties = properties; } public CINodeFilterDataDefinition getNodeFilter() { return nodeFilter; } public void setNodeFilter(CINodeFilterDataDefinition nodeFilter) { this.nodeFilter = nodeFilter; } public List getInputs() { return inputs; } public void setInputs(List inputs) { this.inputs = inputs; } }