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;
136 public ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
137 this.uniqueId = other.getUniqueId();
138 this.name = other.getName();
139 this.version = other.getVersion();
140 this.highestVersion = other.isHighestVersion();
141 this.creationDate = other.getCreationDate();
142 this.lastUpdateDate = other.getLastUpdateDate();
143 this.description = other.getDescription();
144 this.state = other.getState();
145 this.tags = new ArrayList<>(other.getTags() != null ? other.getTags() : new LinkedList<>());
146 this.icon = other.getIcon();
147 this.contactId = other.getContactId();
148 this.UUID = other.getUUID();
149 this.normalizedName = other.getNormalizedName();
150 this.systemName = other.getSystemName();
151 this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
152 this.isDeleted = other.getIsDeleted();
153 this.projectCode = other.getProjectCode();
154 this.csarUUID = other.getCsarUUID();
155 this.csarVersion = other.csarVersion;
156 this.importedToscaChecksum = other.getImportedToscaChecksum();
157 this.invariantUUID = other.getInvariantUUID();
158 this.isArchived = other.isArchived;
159 this.isVspArchived = other.isVspArchived;
160 this.archiveTime = other.getArchiveTime();
161 this.categorySpecificMetadata = other.getCategorySpecificMetadata();
164 public ComponentMetadataDataDefinition(JsonPresentationFieldsExtractor extractor) {
165 this.uniqueId = extractor.getUniqueId();
166 this.name = extractor.getName();
167 this.version = extractor.getVersion();
168 this.highestVersion = extractor.isHighestVersion();
169 this.creationDate = extractor.getCreationDate();
170 this.lastUpdateDate = extractor.getLastUpdateDate();
171 this.description = extractor.getDescription();
172 this.state = extractor.getState();
173 this.tags = extractor.getTags();
174 this.icon = extractor.getIcon();
175 this.contactId = extractor.getContactId();
176 this.UUID = extractor.getUUID();
177 this.normalizedName = extractor.getNormalizedName();
178 this.systemName = extractor.getSystemName();
179 this.isDeleted = extractor.isDeleted();
180 this.projectCode = extractor.getProjectCode();
181 this.csarUUID = extractor.getCsarUuid();
182 this.csarVersion = extractor.getCsarVersion();
183 this.importedToscaChecksum = extractor.getImportedToscaChecksum();
184 this.invariantUUID = extractor.getInvariantUuid();
185 this.isArchived = extractor.isArchived();
186 this.isVspArchived = extractor.isVspArchived();
187 this.archiveTime = extractor.getArchiveTime();
190 public void setUniqueId(String uniqueId) {
191 if (this.uniqueId != null && !this.uniqueId.equals(uniqueId)) {
192 LOGGER.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId, uniqueId);
194 this.uniqueId = uniqueId;
197 public void setUUID(String UUID) {
198 if (this.UUID != null && !this.UUID.equals(UUID)) {
199 LOGGER.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID);
204 public void setInvariantUUID(String invariantUUID) {
205 if (this.invariantUUID != null && !this.invariantUUID.equals(invariantUUID)) {
206 LOGGER.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID, invariantUUID);
208 this.invariantUUID = invariantUUID;
211 public Boolean isHighestVersion() {
212 return highestVersion;
215 public String getLifecycleState() {
219 public void setLifecycleState(String state) {
223 public Boolean isDeleted() {
224 return getIsDeleted();
227 public Boolean isArchived() {
228 return getIsArchived();
231 public void setArchived(Boolean archived) {
232 setIsArchived(archived);
235 public Boolean isVspArchived() {
236 return getIsVspArchived();
239 public void setVspArchived(Boolean vspArchived) {
240 setIsVspArchived(vspArchived);
244 * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
248 public abstract String getActualComponentType();