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.datatypes.components;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.LinkedList;
25 import java.util.List;
27 import lombok.EqualsAndHashCode;
29 import lombok.NoArgsConstructor;
31 import lombok.ToString;
32 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
33 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor;
34 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
35 import org.openecomp.sdc.common.log.wrappers.Logger;
42 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
44 private static final Logger LOGGER = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
45 private String uniqueId;
46 private String name; // archiveName
47 private String version; // archiveVersion
48 private Boolean highestVersion;
49 private Long creationDate;
50 private Long lastUpdateDate;
51 private String description;
53 private List<String> tags;
54 private String conformanceLevel;
57 private String normalizedName;
58 private String systemName;
59 private String contactId;
60 private Map<String, String> allVersions;
61 private Boolean isDeleted;
62 private String projectCode;
63 private String csarUUID;
64 private String csarVersion;
65 private String importedToscaChecksum;
66 private String invariantUUID;
67 protected ComponentTypeEnum componentType;
68 private String creatorUserId;
69 private String creatorFullName;
70 private String lastUpdaterUserId;
71 private String lastUpdaterFullName;
72 private Boolean isArchived = false;
73 private Long archiveTime;
74 private Boolean isVspArchived = false;
75 private Map<String, String> categorySpecificMetadata;
77 private boolean normative = false;
79 protected ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
80 this.uniqueId = other.getUniqueId();
81 this.name = other.getName();
82 this.version = other.getVersion();
83 this.highestVersion = other.isHighestVersion();
84 this.creationDate = other.getCreationDate();
85 this.lastUpdateDate = other.getLastUpdateDate();
86 this.description = other.getDescription();
87 this.state = other.getState();
88 this.tags = new ArrayList<>(other.getTags() != null ? other.getTags() : new LinkedList<>());
89 this.icon = other.getIcon();
90 this.contactId = other.getContactId();
91 this.UUID = other.getUUID();
92 this.normalizedName = other.getNormalizedName();
93 this.systemName = other.getSystemName();
94 this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
95 this.isDeleted = other.getIsDeleted();
96 this.projectCode = other.getProjectCode();
97 this.csarUUID = other.getCsarUUID();
98 this.csarVersion = other.csarVersion;
99 this.importedToscaChecksum = other.getImportedToscaChecksum();
100 this.invariantUUID = other.getInvariantUUID();
101 this.isArchived = other.isArchived;
102 this.isVspArchived = other.isVspArchived;
103 this.archiveTime = other.getArchiveTime();
104 this.categorySpecificMetadata = other.getCategorySpecificMetadata();
105 this.model = other.getModel();
106 this.normative = other.isNormative();
109 protected ComponentMetadataDataDefinition(JsonPresentationFieldsExtractor extractor) {
110 this.uniqueId = extractor.getUniqueId();
111 this.name = extractor.getName();
112 this.version = extractor.getVersion();
113 this.highestVersion = extractor.isHighestVersion();
114 this.creationDate = extractor.getCreationDate();
115 this.lastUpdateDate = extractor.getLastUpdateDate();
116 this.description = extractor.getDescription();
117 this.state = extractor.getState();
118 this.tags = extractor.getTags();
119 this.icon = extractor.getIcon();
120 this.contactId = extractor.getContactId();
121 this.UUID = extractor.getUUID();
122 this.normalizedName = extractor.getNormalizedName();
123 this.systemName = extractor.getSystemName();
124 this.isDeleted = extractor.isDeleted();
125 this.projectCode = extractor.getProjectCode();
126 this.csarUUID = extractor.getCsarUuid();
127 this.csarVersion = extractor.getCsarVersion();
128 this.importedToscaChecksum = extractor.getImportedToscaChecksum();
129 this.invariantUUID = extractor.getInvariantUuid();
130 this.isArchived = extractor.isArchived();
131 this.isVspArchived = extractor.isVspArchived();
132 this.archiveTime = extractor.getArchiveTime();
133 this.model = extractor.getModel();
134 this.normative = extractor.isNormative() == null ? false: extractor.isNormative();
137 public void setUniqueId(String uniqueId) {
138 if (this.uniqueId != null && !this.uniqueId.equals(uniqueId)) {
139 LOGGER.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId, uniqueId);
141 this.uniqueId = uniqueId;
144 public void setUUID(String UUID) {
145 if (this.UUID != null && !this.UUID.equals(UUID)) {
146 LOGGER.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID);
151 public void setInvariantUUID(String invariantUUID) {
152 if (this.invariantUUID != null && !this.invariantUUID.equals(invariantUUID)) {
153 LOGGER.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID, invariantUUID);
155 this.invariantUUID = invariantUUID;
158 public Boolean isHighestVersion() {
159 return highestVersion;
162 public String getLifecycleState() {
166 public void setLifecycleState(String state) {
170 public Boolean isDeleted() {
171 return getIsDeleted();
174 public Boolean isArchived() {
175 return getIsArchived();
178 public void setArchived(Boolean archived) {
179 setIsArchived(archived);
182 public Boolean isVspArchived() {
183 return getIsVspArchived();
186 public void setVspArchived(Boolean vspArchived) {
187 setIsVspArchived(vspArchived);
191 * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
195 public abstract String getActualComponentType();