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.datatypes.components;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.LinkedList;
26 import java.util.List;
28 import lombok.EqualsAndHashCode;
30 import lombok.NoArgsConstructor;
32 import lombok.ToString;
33 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
34 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor;
35 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
36 import org.openecomp.sdc.common.log.wrappers.Logger;
41 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
43 private static final Logger LOGGER = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
46 private String uniqueId;
49 private String name; // archiveName
52 private String version; // archiveVersion
55 private Boolean highestVersion;
58 private Long creationDate;
61 private Long lastUpdateDate;
64 private String description;
70 private List<String> tags;
73 private String conformanceLevel;
81 private String normalizedName;
84 private String systemName;
87 private String contactId;
90 private Map<String, String> allVersions;
93 private Boolean isDeleted;
96 private String projectCode;
99 private String csarUUID;
102 private String csarVersion;
105 private String importedToscaChecksum;
107 private String invariantUUID;
110 protected ComponentTypeEnum componentType;
114 private String creatorUserId;
117 private String creatorFullName;
120 private String lastUpdaterUserId;
123 private String lastUpdaterFullName;
127 private Boolean isArchived = false;
130 private Long archiveTime;
133 private Boolean isVspArchived = false;
135 public ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
136 this.uniqueId = other.getUniqueId();
137 this.name = other.getName();
138 this.version = other.getVersion();
139 this.highestVersion = other.isHighestVersion();
140 this.creationDate = other.getCreationDate();
141 this.lastUpdateDate = other.getLastUpdateDate();
142 this.description = other.getDescription();
143 this.state = other.getState();
144 this.tags = new ArrayList<>(other.getTags() != null ? other.getTags() : new LinkedList<>());
145 this.icon = other.getIcon();
146 this.contactId = other.getContactId();
147 this.UUID = other.getUUID();
148 this.normalizedName = other.getNormalizedName();
149 this.systemName = other.getSystemName();
150 this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
151 this.isDeleted = other.getIsDeleted();
152 this.projectCode = other.getProjectCode();
153 this.csarUUID = other.getCsarUUID();
154 this.csarVersion = other.csarVersion;
155 this.importedToscaChecksum = other.getImportedToscaChecksum();
156 this.invariantUUID = other.getInvariantUUID();
157 this.isArchived = other.isArchived;
158 this.isVspArchived = other.isVspArchived;
159 this.archiveTime = other.getArchiveTime();
162 public ComponentMetadataDataDefinition(JsonPresentationFieldsExtractor extractor) {
163 this.uniqueId = extractor.getUniqueId();
164 this.name = extractor.getName();
165 this.version = extractor.getVersion();
166 this.highestVersion = extractor.isHighestVersion();
167 this.creationDate = extractor.getCreationDate();
168 this.lastUpdateDate = extractor.getLastUpdateDate();
169 this.description = extractor.getDescription();
170 this.state = extractor.getState();
171 this.tags = extractor.getTags();
172 this.icon = extractor.getIcon();
173 this.contactId = extractor.getContactId();
174 this.UUID = extractor.getUUID();
175 this.normalizedName = extractor.getNormalizedName();
176 this.systemName = extractor.getSystemName();
177 this.isDeleted = extractor.isDeleted();
178 this.projectCode = extractor.getProjectCode();
179 this.csarUUID = extractor.getCsarUuid();
180 this.csarVersion = extractor.getCsarVersion();
181 this.importedToscaChecksum = extractor.getImportedToscaChecksum();
182 this.invariantUUID = extractor.getInvariantUuid();
183 this.isArchived = extractor.isArchived();
184 this.isVspArchived = extractor.isVspArchived();
185 this.archiveTime = extractor.getArchiveTime();
188 public void setUniqueId(String uniqueId) {
189 if (this.uniqueId != null && !this.uniqueId.equals(uniqueId)) {
190 LOGGER.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId, uniqueId);
192 this.uniqueId = uniqueId;
195 public void setUUID(String UUID) {
196 if (this.UUID != null && !this.UUID.equals(UUID)) {
197 LOGGER.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID);
202 public void setInvariantUUID(String invariantUUID) {
203 if (this.invariantUUID != null && !this.invariantUUID.equals(invariantUUID)) {
204 LOGGER.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID,
207 this.invariantUUID = invariantUUID;
210 public Boolean isHighestVersion() {
211 return highestVersion;
214 public String getLifecycleState() {
218 public void setLifecycleState(String state) {
222 public Boolean isDeleted() {
223 return getIsDeleted();
226 public Boolean isArchived() {
227 return getIsArchived();
230 public void setArchived(Boolean archived) {
231 setIsArchived(archived);
234 public Boolean isVspArchived() {
235 return getIsVspArchived();
238 public void setVspArchived(Boolean vspArchived) {
239 setIsVspArchived(vspArchived);
243 * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
247 public abstract String getActualComponentType();