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.tosca.ToscaDataDefinition;
25 import org.openecomp.sdc.common.log.wrappers.Logger;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.LinkedList;
30 import java.util.List;
33 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
35 private static final Logger LOGGER = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
37 private String uniqueId;
39 private String name; // archiveName
41 private String version; // archiveVersion
43 private Boolean isHighestVersion;
45 private Long creationDate;
47 private Long lastUpdateDate;
49 private String description;
53 private List<String> tags;
55 private String conformanceLevel;
61 private String normalizedName;
63 private String systemName;
65 private String contactId;
67 private Map<String, String> allVersions;
69 private Boolean isDeleted;
71 private String projectCode;
73 private String csarUUID;
75 private String csarVersion;
77 private String importedToscaChecksum;
79 private String invariantUUID;
81 protected ComponentTypeEnum componentType;
84 private String creatorUserId;
86 private String creatorFullName;
88 private String lastUpdaterUserId;
90 private String lastUpdaterFullName;
93 private Boolean isArchived = false;
95 private Long archiveTime;
97 private Boolean isVspArchived = false;
99 public Boolean getIsHighestVersion() {
100 return isHighestVersion;
103 public void setIsHighestVersion(Boolean isHighestVersion) {
104 this.isHighestVersion = isHighestVersion;
107 public ComponentTypeEnum getComponentType() {
108 return componentType;
111 public void setComponentType(ComponentTypeEnum componentType) {
112 this.componentType = componentType;
115 public String getCreatorUserId() {
116 return creatorUserId;
119 public void setCreatorUserId(String creatorUserId) {
120 this.creatorUserId = creatorUserId;
123 public String getCreatorFullName() {
124 return creatorFullName;
127 public void setCreatorFullName(String creatorFullName) {
128 this.creatorFullName = creatorFullName;
131 public String getLastUpdaterUserId() {
132 return lastUpdaterUserId;
135 public void setLastUpdaterUserId(String lastUpdaterUserId) {
136 this.lastUpdaterUserId = lastUpdaterUserId;
139 public String getLastUpdaterFullName() {
140 return lastUpdaterFullName;
143 public void setLastUpdaterFullName(String lastUpdaterFullName) {
144 this.lastUpdaterFullName = lastUpdaterFullName;
147 public Boolean getIsDeleted() {
151 public Boolean isArchived() {
155 public void setArchived(Boolean archived) {
156 isArchived = archived;
159 public Long getArchiveTime() {
163 public void setArchiveTime(Long archiveTime) {
164 this.archiveTime = archiveTime;
167 public Boolean isVspArchived() {
168 return isVspArchived;
171 public void setVspArchived(Boolean vspArchived) {
172 isVspArchived = vspArchived;
175 public ComponentMetadataDataDefinition() {
179 public ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
180 this.uniqueId = other.getUniqueId();
181 this.name = other.getName();
182 this.version = other.getVersion();
183 this.isHighestVersion = other.isHighestVersion();
184 this.creationDate = other.getCreationDate();
185 this.lastUpdateDate = other.getLastUpdateDate();
186 this.description = other.getDescription();
187 this.state = other.getState();
188 this.tags = new ArrayList<>(other.getTags() != null ? other.getTags() : new LinkedList<>());
189 this.icon = other.getIcon();
190 this.contactId = other.getContactId();
191 this.UUID = other.getUUID();
192 this.normalizedName = other.getNormalizedName();
193 this.systemName = other.getSystemName();
194 this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
195 this.isDeleted = other.isDeleted();
196 this.projectCode = other.getProjectCode();
197 this.csarUUID = other.getCsarUUID();
198 this.csarVersion = other.csarVersion;
199 this.importedToscaChecksum = other.getImportedToscaChecksum();
200 this.invariantUUID = other.getInvariantUUID();
201 this.isArchived = other.isArchived;
202 this.isVspArchived = other.isVspArchived;
203 this.archiveTime = other.getArchiveTime();
206 public String getUniqueId() {
210 public void setUniqueId(String uniqueId) {
211 if (this.uniqueId != null && !this.uniqueId.equals(uniqueId)) {
212 LOGGER.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId, uniqueId);
214 this.uniqueId = uniqueId;
217 public String getName() {
221 public void setName(String name) {
225 public String getVersion() {
229 public void setVersion(String version) {
230 this.version = version;
233 public Boolean isHighestVersion() {
234 return isHighestVersion;
237 public void setHighestVersion(Boolean isHighestVersion) {
238 this.isHighestVersion = isHighestVersion;
241 public Long getCreationDate() {
245 public void setCreationDate(Long creationDate) {
246 this.creationDate = creationDate;
249 public Long getLastUpdateDate() {
250 return lastUpdateDate;
253 public void setLastUpdateDate(Long lastUpdateDate) {
254 this.lastUpdateDate = lastUpdateDate;
257 public String getDescription() {
261 public void setDescription(String description) {
262 this.description = description;
265 public String getState() {
269 public void setState(String state) {
273 public List<String> getTags() {
277 public void setTags(List<String> tags) {
281 public String getIcon() {
285 public void setIcon(String icon) {
289 public String getContactId() {
293 public void setContactId(String contactId) {
294 this.contactId = contactId;
297 public String getUUID() {
301 public void setUUID(String UUID) {
302 if (this.UUID != null && !this.UUID.equals(UUID)) {
303 LOGGER.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID);
308 public String getNormalizedName() {
309 return normalizedName;
312 public void setNormalizedName(String normalizedName) {
313 this.normalizedName = normalizedName;
316 public String getSystemName() {
320 public void setSystemName(String systemName) {
321 this.systemName = systemName;
324 public Map<String, String> getAllVersions() {
328 public void setAllVersions(Map<String, String> allVersions) {
329 this.allVersions = allVersions;
332 public String getInvariantUUID() {
333 return invariantUUID;
336 public void setInvariantUUID(String invariantUUID) {
337 if (this.invariantUUID != null && !this.invariantUUID.equals(invariantUUID)) {
338 LOGGER.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID, invariantUUID);
340 this.invariantUUID = invariantUUID;
343 public Boolean isDeleted() {
347 public void setIsDeleted(Boolean isDeleted) {
348 this.isDeleted = isDeleted;
351 public String getProjectCode() {
355 public void setProjectCode(String projectCode) {
356 this.projectCode = projectCode;
359 public String getCsarUUID() {
363 public void setCsarUUID(String csarUUID) {
364 this.csarUUID = csarUUID;
367 public String getCsarVersion() {
371 public void setCsarVersion(String csarVersion) {
372 this.csarVersion = csarVersion;
375 public String getImportedToscaChecksum() {
376 return importedToscaChecksum;
379 public void setImportedToscaChecksum(String importedToscaChecksum) {
380 this.importedToscaChecksum = importedToscaChecksum;
383 public String getConformanceLevel() {
384 return conformanceLevel;
387 public void setConformanceLevel(String conformanceLevel) {
388 this.conformanceLevel = conformanceLevel;
391 public String getLifecycleState() {
395 public void setLifecycleState(String state) {
400 public String toString() {
401 return "ComponentMetadataDataDefinition [uniqueId=" + uniqueId + ", name=" + name + ", version=" + version
402 + ", isHighestVersion=" + isHighestVersion + ", creationDate=" + creationDate + ", lastUpdateDate="
403 + lastUpdateDate + ", description=" + description + ", state=" + state + ", tags=" + tags
404 + ", conformanceLevel=" + conformanceLevel + ", icon=" + icon + ", UUID=" + UUID + ", normalizedName="
405 + normalizedName + ", systemName=" + systemName + ", contactId=" + contactId + ", allVersions="
406 + allVersions + ", isDeleted=" + isDeleted + ", projectCode=" + projectCode + ", csarUUID=" + csarUUID
407 + ", csarVersion=" + csarVersion + ", importedToscaChecksum=" + importedToscaChecksum
408 + ", invariantUUID=" + invariantUUID + ", componentType=" + componentType + ", creatorUserId="
409 + creatorUserId + ", creatorFullName=" + creatorFullName + ", lastUpdaterUserId=" + lastUpdaterUserId
410 + ", lastUpdaterFullName=" + lastUpdaterFullName + "]";
414 public int hashCode() {
415 final int prime = 31;
417 result = prime * result + ((UUID == null) ? 0 : UUID.hashCode());
418 result = prime * result + ((allVersions == null) ? 0 : allVersions.hashCode());
419 result = prime * result + ((componentType == null) ? 0 : componentType.hashCode());
420 result = prime * result + ((conformanceLevel == null) ? 0 : conformanceLevel.hashCode());
421 result = prime * result + ((contactId == null) ? 0 : contactId.hashCode());
422 result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
423 result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode());
424 result = prime * result + ((creatorUserId == null) ? 0 : creatorUserId.hashCode());
425 result = prime * result + ((csarUUID == null) ? 0 : csarUUID.hashCode());
426 result = prime * result + ((csarVersion == null) ? 0 : csarVersion.hashCode());
427 result = prime * result + ((description == null) ? 0 : description.hashCode());
428 result = prime * result + ((icon == null) ? 0 : icon.hashCode());
429 result = prime * result + ((importedToscaChecksum == null) ? 0 : importedToscaChecksum.hashCode());
430 result = prime * result + ((invariantUUID == null) ? 0 : invariantUUID.hashCode());
431 result = prime * result + ((isDeleted == null) ? 0 : isDeleted.hashCode());
432 result = prime * result + ((isHighestVersion == null) ? 0 : isHighestVersion.hashCode());
433 result = prime * result + ((lastUpdateDate == null) ? 0 : lastUpdateDate.hashCode());
434 result = prime * result + ((lastUpdaterFullName == null) ? 0 : lastUpdaterFullName.hashCode());
435 result = prime * result + ((lastUpdaterUserId == null) ? 0 : lastUpdaterUserId.hashCode());
436 result = prime * result + ((name == null) ? 0 : name.hashCode());
437 result = prime * result + ((normalizedName == null) ? 0 : normalizedName.hashCode());
438 result = prime * result + ((projectCode == null) ? 0 : projectCode.hashCode());
439 result = prime * result + ((state == null) ? 0 : state.hashCode());
440 result = prime * result + ((systemName == null) ? 0 : systemName.hashCode());
441 result = prime * result + ((tags == null) ? 0 : tags.hashCode());
442 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
443 result = prime * result + ((version == null) ? 0 : version.hashCode());
448 public boolean equals(Object obj) {
455 if (getClass() != obj.getClass()) {
458 ComponentMetadataDataDefinition other = (ComponentMetadataDataDefinition) obj;
460 if (other.UUID != null) {
463 } else if (!UUID.equals(other.UUID)) {
466 if (allVersions == null) {
467 if (other.allVersions != null) {
470 } else if (!allVersions.equals(other.allVersions)) {
473 if (componentType != other.componentType) {
476 if (conformanceLevel == null) {
477 if (other.conformanceLevel != null) {
480 } else if (!conformanceLevel.equals(other.conformanceLevel)) {
483 if (contactId == null) {
484 if (other.contactId != null) {
487 } else if (!contactId.equals(other.contactId)) {
490 if (creationDate == null) {
491 if (other.creationDate != null) {
494 } else if (!creationDate.equals(other.creationDate)) {
497 if (creatorFullName == null) {
498 if (other.creatorFullName != null) {
501 } else if (!creatorFullName.equals(other.creatorFullName)) {
504 if (creatorUserId == null) {
505 if (other.creatorUserId != null) {
508 } else if (!creatorUserId.equals(other.creatorUserId)) {
511 if (csarUUID == null) {
512 if (other.csarUUID != null) {
515 } else if (!csarUUID.equals(other.csarUUID)) {
518 if (csarVersion == null) {
519 if (other.csarVersion != null) {
522 } else if (!csarVersion.equals(other.csarVersion)) {
525 if (description == null) {
526 if (other.description != null) {
529 } else if (!description.equals(other.description)) {
533 if (other.icon != null) {
536 } else if (!icon.equals(other.icon)) {
539 if (importedToscaChecksum == null) {
540 if (other.importedToscaChecksum != null) {
543 } else if (!importedToscaChecksum.equals(other.importedToscaChecksum)) {
546 if (invariantUUID == null) {
547 if (other.invariantUUID != null) {
550 } else if (!invariantUUID.equals(other.invariantUUID)) {
553 if (isDeleted == null) {
554 if (other.isDeleted != null) {
557 } else if (!isDeleted.equals(other.isDeleted)) {
560 if (isHighestVersion == null) {
561 if (other.isHighestVersion != null) {
564 } else if (!isHighestVersion.equals(other.isHighestVersion)) {
567 if (lastUpdateDate == null) {
568 if (other.lastUpdateDate != null) {
571 } else if (!lastUpdateDate.equals(other.lastUpdateDate)) {
574 if (lastUpdaterFullName == null) {
575 if (other.lastUpdaterFullName != null) {
578 } else if (!lastUpdaterFullName.equals(other.lastUpdaterFullName)) {
581 if (lastUpdaterUserId == null) {
582 if (other.lastUpdaterUserId != null) {
585 } else if (!lastUpdaterUserId.equals(other.lastUpdaterUserId)) {
589 if (other.name != null) {
592 } else if (!name.equals(other.name)) {
595 if (normalizedName == null) {
596 if (other.normalizedName != null) {
599 } else if (!normalizedName.equals(other.normalizedName)) {
602 if (projectCode == null) {
603 if (other.projectCode != null) {
606 } else if (!projectCode.equals(other.projectCode)) {
610 if (other.state != null) {
613 } else if (!state.equals(other.state)) {
616 if (systemName == null) {
617 if (other.systemName != null) {
620 } else if (!systemName.equals(other.systemName)) {
624 if (other.tags != null) {
627 } else if (!tags.equals(other.tags)) {
630 if (uniqueId == null) {
631 if (other.uniqueId != null) {
634 } else if (!uniqueId.equals(other.uniqueId)) {
637 if (version == null) {
638 return other.version == null;
640 return version.equals(other.version);
645 * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
649 public abstract String getActualComponentType();