2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.sdc.be.model;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.List;
28 import org.apache.commons.collections.MapUtils;
29 import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
30 import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
31 import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner;
32 import org.openecomp.sdc.be.datatypes.enums.CreatedFrom;
33 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
34 import org.openecomp.sdc.common.log.api.ILogConfiguration;
38 public class ComponentInstance extends ComponentInstanceDataDefinition implements PropertiesOwner {
40 private Map<String, List<CapabilityDefinition>> capabilities;
41 private Map<String, List<RequirementDefinition>> requirements;
42 private Map<String, ArtifactDefinition> deploymentArtifacts;
43 private Map<String, ArtifactDefinition> artifacts;
44 private List<GroupInstance> groupInstances;
45 private Map<String, Object> interfaces;
46 private List<PropertyDefinition> properties;
47 private List<AttributeDefinition> attributes;
48 private CINodeFilterDataDefinition nodeFilter;
49 private List<InputDefinition> inputs;
51 public ComponentInstance() {
55 public ComponentInstance(ComponentInstanceDataDefinition r) {
59 public Map<String, ArtifactDefinition> safeGetDeploymentArtifacts() {
60 return deploymentArtifacts == null ? Collections.emptyMap() : deploymentArtifacts;
63 public Map<String, ArtifactDefinition> safeGetInformationalArtifacts() {
64 return artifacts == null ? Collections.emptyMap() : deploymentArtifacts;
67 public Map<String, ArtifactDefinition> safeGetArtifacts() {
68 return artifacts == null ? Collections.emptyMap() : artifacts;
71 public String getActualComponentUid() {
72 return getIsProxy() || isServiceSubstitution() ? getSourceModelUid() : getComponentUid();
75 public boolean isArtifactExists(ArtifactGroupTypeEnum groupType, String artifactLabel) {
76 if (ArtifactGroupTypeEnum.DEPLOYMENT == groupType) {
77 return safeGetDeploymentArtifacts().get(artifactLabel) != null;
79 return safeGetInformationalArtifacts().get(artifactLabel) != null;
82 public void addInterface(String interfaceName, Object interfaceDefinition) {
83 if (MapUtils.isEmpty(this.interfaces)) {
84 this.interfaces = new HashMap<>();
86 this.interfaces.put(interfaceName, interfaceDefinition);
89 //supportability log method return map of component metadata teddy.h
90 public Map<String, String> getComponentMetadataForSupportLog() {
91 Map<String, String> componentMetadata = new HashMap<>();
92 componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME, getName());
93 componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION, getVersion());
94 componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID, getSourceModelUuid());
95 return componentMetadata;
98 public boolean isCreatedFromCsar() {
99 return CreatedFrom.CSAR.equals(this.getCreatedFrom());