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 org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
24 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor;
25 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
26 import org.openecomp.sdc.common.log.wrappers.Logger;
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.LinkedList;
31 import java.util.List;
34 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
36 private static final Logger LOGGER = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
38 private String uniqueId;
40 private String name; // archiveName
42 private String version; // archiveVersion
44 private Boolean isHighestVersion;
46 private Long creationDate;
48 private Long lastUpdateDate;
50 private String description;
54 private List<String> tags;
56 private String conformanceLevel;
62 private String normalizedName;
64 private String systemName;
66 private String contactId;
68 private Map<String, String> allVersions;
70 private Boolean isDeleted;
72 private String projectCode;
74 private String csarUUID;
76 private String csarVersion;
78 private String importedToscaChecksum;
80 private String invariantUUID;
82 protected ComponentTypeEnum componentType;
85 private String creatorUserId;
87 private String creatorFullName;
89 private String lastUpdaterUserId;
91 private String lastUpdaterFullName;
94 private Boolean isArchived = false;
96 private Long archiveTime;
98 private Boolean isVspArchived = false;
100 public Boolean getIsHighestVersion() {
101 return isHighestVersion;
104 public void setIsHighestVersion(Boolean isHighestVersion) {
105 this.isHighestVersion = isHighestVersion;
108 public ComponentTypeEnum getComponentType() {
109 return componentType;
112 public void setComponentType(ComponentTypeEnum componentType) {
113 this.componentType = componentType;
116 public String getCreatorUserId() {
117 return creatorUserId;
120 public void setCreatorUserId(String creatorUserId) {
121 this.creatorUserId = creatorUserId;
124 public String getCreatorFullName() {
125 return creatorFullName;
128 public void setCreatorFullName(String creatorFullName) {
129 this.creatorFullName = creatorFullName;
132 public String getLastUpdaterUserId() {
133 return lastUpdaterUserId;
136 public void setLastUpdaterUserId(String lastUpdaterUserId) {
137 this.lastUpdaterUserId = lastUpdaterUserId;
140 public String getLastUpdaterFullName() {
141 return lastUpdaterFullName;
144 public void setLastUpdaterFullName(String lastUpdaterFullName) {
145 this.lastUpdaterFullName = lastUpdaterFullName;
148 public Boolean getIsDeleted() {
152 public Boolean isArchived() {
156 public void setArchived(Boolean archived) {
157 isArchived = archived;
160 public Long getArchiveTime() {
164 public void setArchiveTime(Long archiveTime) {
165 this.archiveTime = archiveTime;
168 public Boolean isVspArchived() {
169 return isVspArchived;
172 public void setVspArchived(Boolean vspArchived) {
173 isVspArchived = vspArchived;
176 public ComponentMetadataDataDefinition() {
180 public ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
181 this.uniqueId = other.getUniqueId();
182 this.name = other.getName();
183 this.version = other.getVersion();
184 this.isHighestVersion = other.isHighestVersion();
185 this.creationDate = other.getCreationDate();
186 this.lastUpdateDate = other.getLastUpdateDate();
187 this.description = other.getDescription();
188 this.state = other.getState();
189 this.tags = new ArrayList<>(other.getTags() != null ? other.getTags() : new LinkedList<>());
190 this.icon = other.getIcon();
191 this.contactId = other.getContactId();
192 this.UUID = other.getUUID();
193 this.normalizedName = other.getNormalizedName();
194 this.systemName = other.getSystemName();
195 this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
196 this.isDeleted = other.isDeleted();
197 this.projectCode = other.getProjectCode();
198 this.csarUUID = other.getCsarUUID();
199 this.csarVersion = other.csarVersion;
200 this.importedToscaChecksum = other.getImportedToscaChecksum();
201 this.invariantUUID = other.getInvariantUUID();
202 this.isArchived = other.isArchived;
203 this.isVspArchived = other.isVspArchived;
204 this.archiveTime = other.getArchiveTime();
207 public ComponentMetadataDataDefinition(JsonPresentationFieldsExtractor extractor){
208 this.uniqueId = extractor.getUniqueId();
209 this.name = extractor.getName();
210 this.version = extractor.getVersion();
211 this.isHighestVersion = extractor.isHighestVersion();
212 this.creationDate = extractor.getCreationDate();
213 this.lastUpdateDate = extractor.getLastUpdateDate();
214 this.description = extractor.getDescription();
215 this.state = extractor.getState();
216 this.tags = extractor.getTags();
217 this.icon = extractor.getIcon();
218 this.contactId = extractor.getContactId();
219 this.UUID = extractor.getUUID();
220 this.normalizedName = extractor.getNormalizedName();
221 this.systemName = extractor.getSystemName();
222 this.isDeleted = extractor.isDeleted();
223 this.projectCode = extractor.getProjectCode();
224 this.csarUUID = extractor.getCsarUuid();
225 this.csarVersion = extractor.getCsarVersion();
226 this.importedToscaChecksum = extractor.getImportedToscaChecksum();
227 this.invariantUUID = extractor.getInvariantUuid();
228 this.isArchived = extractor.isArchived();
229 this.isVspArchived = extractor.isVspArchived();
230 this.archiveTime = extractor.getArchiveTime();
234 public String getUniqueId() {
238 public void setUniqueId(String uniqueId) {
239 if (this.uniqueId != null && !this.uniqueId.equals(uniqueId)) {
240 LOGGER.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId, uniqueId);
242 this.uniqueId = uniqueId;
245 public String getName() {
249 public void setName(String name) {
253 public String getVersion() {
257 public void setVersion(String version) {
258 this.version = version;
261 public Boolean isHighestVersion() {
262 return isHighestVersion;
265 public void setHighestVersion(Boolean isHighestVersion) {
266 this.isHighestVersion = isHighestVersion;
269 public Long getCreationDate() {
273 public void setCreationDate(Long creationDate) {
274 this.creationDate = creationDate;
277 public Long getLastUpdateDate() {
278 return lastUpdateDate;
281 public void setLastUpdateDate(Long lastUpdateDate) {
282 this.lastUpdateDate = lastUpdateDate;
285 public String getDescription() {
289 public void setDescription(String description) {
290 this.description = description;
293 public String getState() {
297 public void setState(String state) {
301 public List<String> getTags() {
305 public void setTags(List<String> tags) {
309 public String getIcon() {
313 public void setIcon(String icon) {
317 public String getContactId() {
321 public void setContactId(String contactId) {
322 this.contactId = contactId;
325 public String getUUID() {
329 public void setUUID(String UUID) {
330 if (this.UUID != null && !this.UUID.equals(UUID)) {
331 LOGGER.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID);
336 public String getNormalizedName() {
337 return normalizedName;
340 public void setNormalizedName(String normalizedName) {
341 this.normalizedName = normalizedName;
344 public String getSystemName() {
348 public void setSystemName(String systemName) {
349 this.systemName = systemName;
352 public Map<String, String> getAllVersions() {
356 public void setAllVersions(Map<String, String> allVersions) {
357 this.allVersions = allVersions;
360 public String getInvariantUUID() {
361 return invariantUUID;
364 public void setInvariantUUID(String invariantUUID) {
365 if (this.invariantUUID != null && !this.invariantUUID.equals(invariantUUID)) {
366 LOGGER.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID, invariantUUID);
368 this.invariantUUID = invariantUUID;
371 public Boolean isDeleted() {
375 public void setIsDeleted(Boolean isDeleted) {
376 this.isDeleted = isDeleted;
379 public String getProjectCode() {
383 public void setProjectCode(String projectCode) {
384 this.projectCode = projectCode;
387 public String getCsarUUID() {
391 public void setCsarUUID(String csarUUID) {
392 this.csarUUID = csarUUID;
395 public String getCsarVersion() {
399 public void setCsarVersion(String csarVersion) {
400 this.csarVersion = csarVersion;
403 public String getImportedToscaChecksum() {
404 return importedToscaChecksum;
407 public void setImportedToscaChecksum(String importedToscaChecksum) {
408 this.importedToscaChecksum = importedToscaChecksum;
411 public String getConformanceLevel() {
412 return conformanceLevel;
415 public void setConformanceLevel(String conformanceLevel) {
416 this.conformanceLevel = conformanceLevel;
419 public String getLifecycleState() {
423 public void setLifecycleState(String state) {
428 public String toString() {
429 return "ComponentMetadataDataDefinition [uniqueId=" + uniqueId + ", name=" + name + ", version=" + version
430 + ", isHighestVersion=" + isHighestVersion + ", creationDate=" + creationDate + ", lastUpdateDate="
431 + lastUpdateDate + ", description=" + description + ", state=" + state + ", tags=" + tags
432 + ", conformanceLevel=" + conformanceLevel + ", icon=" + icon + ", UUID=" + UUID + ", normalizedName="
433 + normalizedName + ", systemName=" + systemName + ", contactId=" + contactId + ", allVersions="
434 + allVersions + ", isDeleted=" + isDeleted + ", projectCode=" + projectCode + ", csarUUID=" + csarUUID
435 + ", csarVersion=" + csarVersion + ", importedToscaChecksum=" + importedToscaChecksum
436 + ", invariantUUID=" + invariantUUID + ", componentType=" + componentType + ", creatorUserId="
437 + creatorUserId + ", creatorFullName=" + creatorFullName + ", lastUpdaterUserId=" + lastUpdaterUserId
438 + ", lastUpdaterFullName=" + lastUpdaterFullName + "]";
442 public int hashCode() {
443 final int prime = 31;
445 result = prime * result + ((UUID == null) ? 0 : UUID.hashCode());
446 result = prime * result + ((allVersions == null) ? 0 : allVersions.hashCode());
447 result = prime * result + ((componentType == null) ? 0 : componentType.hashCode());
448 result = prime * result + ((conformanceLevel == null) ? 0 : conformanceLevel.hashCode());
449 result = prime * result + ((contactId == null) ? 0 : contactId.hashCode());
450 result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
451 result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode());
452 result = prime * result + ((creatorUserId == null) ? 0 : creatorUserId.hashCode());
453 result = prime * result + ((csarUUID == null) ? 0 : csarUUID.hashCode());
454 result = prime * result + ((csarVersion == null) ? 0 : csarVersion.hashCode());
455 result = prime * result + ((description == null) ? 0 : description.hashCode());
456 result = prime * result + ((icon == null) ? 0 : icon.hashCode());
457 result = prime * result + ((importedToscaChecksum == null) ? 0 : importedToscaChecksum.hashCode());
458 result = prime * result + ((invariantUUID == null) ? 0 : invariantUUID.hashCode());
459 result = prime * result + ((isDeleted == null) ? 0 : isDeleted.hashCode());
460 result = prime * result + ((isHighestVersion == null) ? 0 : isHighestVersion.hashCode());
461 result = prime * result + ((lastUpdateDate == null) ? 0 : lastUpdateDate.hashCode());
462 result = prime * result + ((lastUpdaterFullName == null) ? 0 : lastUpdaterFullName.hashCode());
463 result = prime * result + ((lastUpdaterUserId == null) ? 0 : lastUpdaterUserId.hashCode());
464 result = prime * result + ((name == null) ? 0 : name.hashCode());
465 result = prime * result + ((normalizedName == null) ? 0 : normalizedName.hashCode());
466 result = prime * result + ((projectCode == null) ? 0 : projectCode.hashCode());
467 result = prime * result + ((state == null) ? 0 : state.hashCode());
468 result = prime * result + ((systemName == null) ? 0 : systemName.hashCode());
469 result = prime * result + ((tags == null) ? 0 : tags.hashCode());
470 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
471 result = prime * result + ((version == null) ? 0 : version.hashCode());
476 public boolean equals(Object obj) {
483 if (getClass() != obj.getClass()) {
486 ComponentMetadataDataDefinition other = (ComponentMetadataDataDefinition) obj;
488 if (other.UUID != null) {
491 } else if (!UUID.equals(other.UUID)) {
494 if (allVersions == null) {
495 if (other.allVersions != null) {
498 } else if (!allVersions.equals(other.allVersions)) {
501 if (componentType != other.componentType) {
504 if (conformanceLevel == null) {
505 if (other.conformanceLevel != null) {
508 } else if (!conformanceLevel.equals(other.conformanceLevel)) {
511 if (contactId == null) {
512 if (other.contactId != null) {
515 } else if (!contactId.equals(other.contactId)) {
518 if (creationDate == null) {
519 if (other.creationDate != null) {
522 } else if (!creationDate.equals(other.creationDate)) {
525 if (creatorFullName == null) {
526 if (other.creatorFullName != null) {
529 } else if (!creatorFullName.equals(other.creatorFullName)) {
532 if (creatorUserId == null) {
533 if (other.creatorUserId != null) {
536 } else if (!creatorUserId.equals(other.creatorUserId)) {
539 if (csarUUID == null) {
540 if (other.csarUUID != null) {
543 } else if (!csarUUID.equals(other.csarUUID)) {
546 if (csarVersion == null) {
547 if (other.csarVersion != null) {
550 } else if (!csarVersion.equals(other.csarVersion)) {
553 if (description == null) {
554 if (other.description != null) {
557 } else if (!description.equals(other.description)) {
561 if (other.icon != null) {
564 } else if (!icon.equals(other.icon)) {
567 if (importedToscaChecksum == null) {
568 if (other.importedToscaChecksum != null) {
571 } else if (!importedToscaChecksum.equals(other.importedToscaChecksum)) {
574 if (invariantUUID == null) {
575 if (other.invariantUUID != null) {
578 } else if (!invariantUUID.equals(other.invariantUUID)) {
581 if (isDeleted == null) {
582 if (other.isDeleted != null) {
585 } else if (!isDeleted.equals(other.isDeleted)) {
588 if (isHighestVersion == null) {
589 if (other.isHighestVersion != null) {
592 } else if (!isHighestVersion.equals(other.isHighestVersion)) {
595 if (lastUpdateDate == null) {
596 if (other.lastUpdateDate != null) {
599 } else if (!lastUpdateDate.equals(other.lastUpdateDate)) {
602 if (lastUpdaterFullName == null) {
603 if (other.lastUpdaterFullName != null) {
606 } else if (!lastUpdaterFullName.equals(other.lastUpdaterFullName)) {
609 if (lastUpdaterUserId == null) {
610 if (other.lastUpdaterUserId != null) {
613 } else if (!lastUpdaterUserId.equals(other.lastUpdaterUserId)) {
617 if (other.name != null) {
620 } else if (!name.equals(other.name)) {
623 if (normalizedName == null) {
624 if (other.normalizedName != null) {
627 } else if (!normalizedName.equals(other.normalizedName)) {
630 if (projectCode == null) {
631 if (other.projectCode != null) {
634 } else if (!projectCode.equals(other.projectCode)) {
638 if (other.state != null) {
641 } else if (!state.equals(other.state)) {
644 if (systemName == null) {
645 if (other.systemName != null) {
648 } else if (!systemName.equals(other.systemName)) {
652 if (other.tags != null) {
655 } else if (!tags.equals(other.tags)) {
658 if (uniqueId == null) {
659 if (other.uniqueId != null) {
662 } else if (!uniqueId.equals(other.uniqueId)) {
665 if (version == null) {
666 return other.version == null;
668 return version.equals(other.version);
673 * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
677 public abstract String getActualComponentType();