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=========================================================
21 package org.openecomp.sdc.be.model;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.List;
29 import org.apache.commons.collections.MapUtils;
30 import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
31 import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
32 import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner;
33 import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
34 import org.openecomp.sdc.be.datatypes.enums.CreatedFrom;
35 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
36 import org.openecomp.sdc.common.log.api.ILogConfiguration;
40 public class ComponentInstance extends ComponentInstanceDataDefinition implements PropertiesOwner {
42 private Map<String, List<CapabilityDefinition>> capabilities;
43 private Map<String, List<RequirementDefinition>> requirements;
44 private Map<String, ArtifactDefinition> deploymentArtifacts;
45 private Map<String, ArtifactDefinition> artifacts;
46 private List<GroupInstance> groupInstances;
47 private Map<String, Object> interfaces;
48 private List<PropertyDefinition> properties;
49 private CINodeFilterDataDefinition nodeFilter;
50 private List<InputDefinition> inputs;
52 public ComponentInstance() {
56 public ComponentInstance(ComponentInstanceDataDefinition r) {
60 public Map<String, ArtifactDefinition> safeGetDeploymentArtifacts() {
61 return deploymentArtifacts == null ? Collections.emptyMap() : deploymentArtifacts;
64 public Map<String, ArtifactDefinition> safeGetInformationalArtifacts() {
65 return artifacts == null ? Collections.emptyMap() : deploymentArtifacts;
68 public Map<String, ArtifactDefinition> safeGetArtifacts() {
69 return artifacts == null ? Collections.emptyMap() : artifacts;
72 public String getActualComponentUid() {
73 return getIsProxy() ? getSourceModelUid() : getComponentUid();
76 public boolean isArtifactExists(ArtifactGroupTypeEnum groupType, String artifactLabel) {
77 if (ArtifactGroupTypeEnum.DEPLOYMENT == groupType) {
78 return safeGetDeploymentArtifacts().get(artifactLabel) != null;
80 return safeGetInformationalArtifacts().get(artifactLabel) != null;
83 public void addInterface(String interfaceName, Object interfaceDefinition) {
84 if (MapUtils.isEmpty(this.interfaces)) {
85 this.interfaces = new HashMap<>();
87 this.interfaces.put(interfaceName, interfaceDefinition);
90 //supportability log method return map of component metadata teddy.h
91 public Map<String, String> getComponentMetadataForSupportLog() {
92 Map<String, String> componentMetadata = new HashMap<>();
93 componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME, getName());
94 componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION, getVersion());
95 componentMetadata.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID, getSourceModelUuid());
96 return componentMetadata;
99 public boolean isCreatedFromCsar() {
100 return CreatedFrom.CSAR.equals(this.getCreatedFrom());