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;
40 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
42 private static final Logger LOGGER = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
44 private String uniqueId;
47 private String name; // archiveName
50 private String version; // archiveVersion
53 private Boolean highestVersion;
56 private Long creationDate;
59 private Long lastUpdateDate;
62 private String description;
68 private List<String> tags;
71 private String conformanceLevel;
79 private String normalizedName;
82 private String systemName;
85 private String contactId;
88 private Map<String, String> allVersions;
91 private Boolean isDeleted;
94 private String projectCode;
97 private String csarUUID;
100 private String csarVersion;
103 private String importedToscaChecksum;
105 private String invariantUUID;
108 protected ComponentTypeEnum componentType;
112 private String creatorUserId;
115 private String creatorFullName;
118 private String lastUpdaterUserId;
121 private String lastUpdaterFullName;
125 private Boolean isArchived = false;
128 private Long archiveTime;
131 private Boolean isVspArchived = false;
134 private Map<String, String> categorySpecificMetadata;
137 private String model;
139 public ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
140 this.uniqueId = other.getUniqueId();
141 this.name = other.getName();
142 this.version = other.getVersion();
143 this.highestVersion = other.isHighestVersion();
144 this.creationDate = other.getCreationDate();
145 this.lastUpdateDate = other.getLastUpdateDate();
146 this.description = other.getDescription();
147 this.state = other.getState();
148 this.tags = new ArrayList<>(other.getTags() != null ? other.getTags() : new LinkedList<>());
149 this.icon = other.getIcon();
150 this.contactId = other.getContactId();
151 this.UUID = other.getUUID();
152 this.normalizedName = other.getNormalizedName();
153 this.systemName = other.getSystemName();
154 this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
155 this.isDeleted = other.getIsDeleted();
156 this.projectCode = other.getProjectCode();
157 this.csarUUID = other.getCsarUUID();
158 this.csarVersion = other.csarVersion;
159 this.importedToscaChecksum = other.getImportedToscaChecksum();
160 this.invariantUUID = other.getInvariantUUID();
161 this.isArchived = other.isArchived;
162 this.isVspArchived = other.isVspArchived;
163 this.archiveTime = other.getArchiveTime();
164 this.categorySpecificMetadata = other.getCategorySpecificMetadata();
165 this.model = other.getModel();
168 public ComponentMetadataDataDefinition(JsonPresentationFieldsExtractor extractor) {
169 this.uniqueId = extractor.getUniqueId();
170 this.name = extractor.getName();
171 this.version = extractor.getVersion();
172 this.highestVersion = extractor.isHighestVersion();
173 this.creationDate = extractor.getCreationDate();
174 this.lastUpdateDate = extractor.getLastUpdateDate();
175 this.description = extractor.getDescription();
176 this.state = extractor.getState();
177 this.tags = extractor.getTags();
178 this.icon = extractor.getIcon();
179 this.contactId = extractor.getContactId();
180 this.UUID = extractor.getUUID();
181 this.normalizedName = extractor.getNormalizedName();
182 this.systemName = extractor.getSystemName();
183 this.isDeleted = extractor.isDeleted();
184 this.projectCode = extractor.getProjectCode();
185 this.csarUUID = extractor.getCsarUuid();
186 this.csarVersion = extractor.getCsarVersion();
187 this.importedToscaChecksum = extractor.getImportedToscaChecksum();
188 this.invariantUUID = extractor.getInvariantUuid();
189 this.isArchived = extractor.isArchived();
190 this.isVspArchived = extractor.isVspArchived();
191 this.archiveTime = extractor.getArchiveTime();
192 this.model = extractor.getModel();
195 public void setUniqueId(String uniqueId) {
196 if (this.uniqueId != null && !this.uniqueId.equals(uniqueId)) {
197 LOGGER.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId, uniqueId);
199 this.uniqueId = uniqueId;
202 public void setUUID(String UUID) {
203 if (this.UUID != null && !this.UUID.equals(UUID)) {
204 LOGGER.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID);
209 public void setInvariantUUID(String invariantUUID) {
210 if (this.invariantUUID != null && !this.invariantUUID.equals(invariantUUID)) {
211 LOGGER.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID, invariantUUID);
213 this.invariantUUID = invariantUUID;
216 public Boolean isHighestVersion() {
217 return highestVersion;
220 public String getLifecycleState() {
224 public void setLifecycleState(String state) {
228 public Boolean isDeleted() {
229 return getIsDeleted();
232 public Boolean isArchived() {
233 return getIsArchived();
236 public void setArchived(Boolean archived) {
237 setIsArchived(archived);
240 public Boolean isVspArchived() {
241 return getIsVspArchived();
244 public void setVspArchived(Boolean vspArchived) {
245 setIsVspArchived(vspArchived);
249 * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
253 public abstract String getActualComponentType();