re base code
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / components / ComponentMetadataDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.datatypes.components;
22
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;
26
27 import java.util.*;
28
29 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
30
31         private static final Logger log = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
32         
33         private String uniqueId;
34
35         private String name; // archiveName
36
37         private String version; // archiveVersion
38
39         private Boolean isHighestVersion;
40
41         private Long creationDate;
42
43         private Long lastUpdateDate;
44
45         private String description;
46
47         private String state;
48
49         private List<String> tags;
50
51         private String conformanceLevel;
52
53         private String icon;
54
55         private String UUID;
56
57         private String normalizedName;
58
59         private String systemName;
60
61         private String contactId;
62
63         private Map<String, String> allVersions;
64
65         private Boolean isDeleted;
66
67         private String projectCode;
68
69         private String csarUUID;
70
71         private String csarVersion;
72
73         private String importedToscaChecksum;
74
75         private String invariantUUID;
76
77         protected ComponentTypeEnum componentType;
78
79         // USER
80         private String creatorUserId;
81
82         private String creatorFullName;
83
84         private String lastUpdaterUserId;
85
86         private String lastUpdaterFullName;
87
88         //Archive/Restore
89         private Boolean isArchived = false;
90
91         private Long archiveTime;
92
93         private Boolean isVspArchived = false;
94
95         public Boolean getIsHighestVersion() {
96                 return isHighestVersion;
97         }
98
99         public void setIsHighestVersion(Boolean isHighestVersion) {
100                 this.isHighestVersion = isHighestVersion;
101         }
102
103         public ComponentTypeEnum getComponentType() {
104                 return componentType;
105         }
106
107         public void setComponentType(ComponentTypeEnum componentType) {
108                 this.componentType = componentType;
109         }
110
111         public String getCreatorUserId() {
112                 return creatorUserId;
113         }
114
115         public void setCreatorUserId(String creatorUserId) {
116                 this.creatorUserId = creatorUserId;
117         }
118
119         public String getCreatorFullName() {
120                 return creatorFullName;
121         }
122
123         public void setCreatorFullName(String creatorFullName) {
124                 this.creatorFullName = creatorFullName;
125         }
126
127         public String getLastUpdaterUserId() {
128                 return lastUpdaterUserId;
129         }
130
131         public void setLastUpdaterUserId(String lastUpdaterUserId) {
132                 this.lastUpdaterUserId = lastUpdaterUserId;
133         }
134
135         public String getLastUpdaterFullName() {
136                 return lastUpdaterFullName;
137         }
138
139         public void setLastUpdaterFullName(String lastUpdaterFullName) {
140                 this.lastUpdaterFullName = lastUpdaterFullName;
141         }
142
143         public Boolean getIsDeleted() {
144                 return isDeleted;
145         }
146
147         public Boolean isArchived() { return isArchived; }
148
149         public void setArchived(Boolean archived) { isArchived = archived; }
150
151         public Long getArchiveTime() { return archiveTime; }
152
153         public void setArchiveTime(Long archiveTime) { this.archiveTime = archiveTime; }
154
155         public Boolean isVspArchived() { return isVspArchived;  }
156
157         public void setVspArchived(Boolean vspArchived) { isVspArchived = vspArchived; }
158
159         public ComponentMetadataDataDefinition() {
160
161         }
162
163         public ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
164                 this.uniqueId = other.getUniqueId();
165                 this.name = other.getName();
166                 this.version = other.getVersion();
167                 this.isHighestVersion = other.isHighestVersion();
168                 this.creationDate = other.getCreationDate();
169                 this.lastUpdateDate = other.getLastUpdateDate();
170                 this.description = other.getDescription();
171                 this.state = other.getState();
172                 this.tags = new ArrayList<>(other.getTags() != null  ? other.getTags() : new LinkedList<>());
173                 this.icon = other.getIcon();
174                 this.contactId = other.getContactId();
175                 this.UUID = other.getUUID();
176                 this.normalizedName = other.getNormalizedName();
177                 this.systemName = other.getSystemName();
178                 this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
179                 this.isDeleted = other.isDeleted();
180                 this.projectCode = other.getProjectCode();
181                 this.csarUUID = other.getCsarUUID();
182                 this.csarVersion = other.csarVersion;
183                 this.importedToscaChecksum = other.getImportedToscaChecksum();
184                 this.invariantUUID = other.getInvariantUUID();
185                 this.isArchived = other.isArchived;
186                 this.isVspArchived = other.isVspArchived;
187                 this.archiveTime = other.getArchiveTime();
188         }
189
190         public String getUniqueId() {
191                 return uniqueId;
192         }
193
194         public void setUniqueId(String uniqueId) {
195                 if ( this.uniqueId != null && !this.uniqueId.equals( uniqueId ) )
196                         log.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId ,uniqueId );
197                 this.uniqueId = uniqueId;
198         }
199
200         public String getName() {
201                 return name;
202         }
203
204         public void setName(String name) {
205                 this.name = name;
206         }
207
208         public String getVersion() {
209                 return version;
210         }
211
212         public void setVersion(String version) {
213                 this.version = version;
214         }
215
216         public Boolean isHighestVersion() {
217                 return isHighestVersion;
218         }
219
220         public void setHighestVersion(Boolean isHighestVersion) {
221                 this.isHighestVersion = isHighestVersion;
222         }
223
224         public Long getCreationDate() {
225                 return creationDate;
226         }
227
228         public void setCreationDate(Long creationDate) {
229                 this.creationDate = creationDate;
230         }
231
232         public Long getLastUpdateDate() {
233                 return lastUpdateDate;
234         }
235
236         public void setLastUpdateDate(Long lastUpdateDate) {
237                 this.lastUpdateDate = lastUpdateDate;
238         }
239
240         public String getDescription() {
241                 return description;
242         }
243
244         public void setDescription(String description) {
245                 this.description = description;
246         }
247
248         public String getState() {
249                 return state;
250         }
251
252         public void setState(String state) {
253                 this.state = state;
254         }
255
256         public List<String> getTags() {
257                 return tags;
258         }
259
260         public void setTags(List<String> tags) {
261                 this.tags = tags;
262         }
263
264         public String getIcon() {
265                 return icon;
266         }
267
268         public void setIcon(String icon) {
269                 this.icon = icon;
270         }
271
272         public String getContactId() {
273                 return contactId;
274         }
275
276         public void setContactId(String contactId) {
277                 this.contactId = contactId;
278         }
279
280         public String getUUID() {
281                 return UUID;
282         }
283
284         public void setUUID(String UUID) {
285                 if ( this.UUID != null && !this.UUID.equals( UUID ) )
286                         log.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID );
287                 this.UUID = UUID;
288         }
289
290         public String getNormalizedName() {
291                 return normalizedName;
292         }
293
294         public void setNormalizedName(String normalizedName) {
295                 this.normalizedName = normalizedName;
296         }
297
298         public String getSystemName() {
299                 return systemName;
300         }
301
302         public void setSystemName(String systemName) {
303                 this.systemName = systemName;
304         }
305
306         public Map<String, String> getAllVersions() {
307                 return allVersions;
308         }
309
310         public void setAllVersions(Map<String, String> allVersions) {
311                 this.allVersions = allVersions;
312         }
313
314         public String getInvariantUUID() {
315                 return invariantUUID;
316         }
317
318         public void setInvariantUUID(String invariantUUID) {
319                 if ( this.invariantUUID != null && !this.invariantUUID.equals( invariantUUID ) )
320                         log.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID ,invariantUUID );
321                 this.invariantUUID = invariantUUID;
322         }
323
324         public Boolean isDeleted() {
325                 return isDeleted;
326         }
327
328         public void setIsDeleted(Boolean isDeleted) {
329                 this.isDeleted = isDeleted;
330         }
331
332         public String getProjectCode() {
333                 return projectCode;
334         }
335
336         public void setProjectCode(String projectCode) {
337                 this.projectCode = projectCode;
338         }
339
340         public String getCsarUUID() {
341                 return csarUUID;
342         }
343
344         public void setCsarUUID(String csarUUID) {
345                 this.csarUUID = csarUUID;
346         }
347
348         public String getCsarVersion() {
349                 return csarVersion;
350         }
351
352         public void setCsarVersion(String csarVersion) {
353                 this.csarVersion = csarVersion;
354         }
355
356         public String getImportedToscaChecksum() {
357                 return importedToscaChecksum;
358         }
359
360         public void setImportedToscaChecksum(String importedToscaChecksum) {
361                 this.importedToscaChecksum = importedToscaChecksum;
362         }
363         
364         public String getConformanceLevel() {
365                 return conformanceLevel;
366         }
367
368         public void setConformanceLevel(String conformanceLevel) {
369                 this.conformanceLevel = conformanceLevel;
370         }
371
372         public String getLifecycleState() {
373                 return state;
374         }
375
376         public void setLifecycleState(String state) {
377                 this.state = state;
378         }
379         
380         @Override
381         public String toString() {
382                 return "ComponentMetadataDataDefinition [uniqueId=" + uniqueId + ", name=" + name + ", version=" + version
383                                 + ", isHighestVersion=" + isHighestVersion + ", creationDate=" + creationDate + ", lastUpdateDate="
384                                 + lastUpdateDate + ", description=" + description + ", state=" + state + ", tags=" + tags
385                                 + ", conformanceLevel=" + conformanceLevel + ", icon=" + icon + ", UUID=" + UUID + ", normalizedName="
386                                 + normalizedName + ", systemName=" + systemName + ", contactId=" + contactId + ", allVersions="
387                                 + allVersions + ", isDeleted=" + isDeleted + ", projectCode=" + projectCode + ", csarUUID=" + csarUUID
388                                 + ", csarVersion=" + csarVersion + ", importedToscaChecksum=" + importedToscaChecksum
389                                 + ", invariantUUID=" + invariantUUID + ", componentType=" + componentType + ", creatorUserId="
390                                 + creatorUserId + ", creatorFullName=" + creatorFullName + ", lastUpdaterUserId=" + lastUpdaterUserId
391                                 + ", lastUpdaterFullName=" + lastUpdaterFullName + "]";
392         }
393
394         @Override
395         public int hashCode() {
396                 final int prime = 31;
397                 int result = 1;
398                 result = prime * result + ((UUID == null) ? 0 : UUID.hashCode());
399                 result = prime * result + ((allVersions == null) ? 0 : allVersions.hashCode());
400                 result = prime * result + ((componentType == null) ? 0 : componentType.hashCode());
401                 result = prime * result + ((conformanceLevel == null) ? 0 : conformanceLevel.hashCode());
402                 result = prime * result + ((contactId == null) ? 0 : contactId.hashCode());
403                 result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
404                 result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode());
405                 result = prime * result + ((creatorUserId == null) ? 0 : creatorUserId.hashCode());
406                 result = prime * result + ((csarUUID == null) ? 0 : csarUUID.hashCode());
407                 result = prime * result + ((csarVersion == null) ? 0 : csarVersion.hashCode());
408                 result = prime * result + ((description == null) ? 0 : description.hashCode());
409                 result = prime * result + ((icon == null) ? 0 : icon.hashCode());
410                 result = prime * result + ((importedToscaChecksum == null) ? 0 : importedToscaChecksum.hashCode());
411                 result = prime * result + ((invariantUUID == null) ? 0 : invariantUUID.hashCode());
412                 result = prime * result + ((isDeleted == null) ? 0 : isDeleted.hashCode());
413                 result = prime * result + ((isHighestVersion == null) ? 0 : isHighestVersion.hashCode());
414                 result = prime * result + ((lastUpdateDate == null) ? 0 : lastUpdateDate.hashCode());
415                 result = prime * result + ((lastUpdaterFullName == null) ? 0 : lastUpdaterFullName.hashCode());
416                 result = prime * result + ((lastUpdaterUserId == null) ? 0 : lastUpdaterUserId.hashCode());
417                 result = prime * result + ((name == null) ? 0 : name.hashCode());
418                 result = prime * result + ((normalizedName == null) ? 0 : normalizedName.hashCode());
419                 result = prime * result + ((projectCode == null) ? 0 : projectCode.hashCode());
420                 result = prime * result + ((state == null) ? 0 : state.hashCode());
421                 result = prime * result + ((systemName == null) ? 0 : systemName.hashCode());
422                 result = prime * result + ((tags == null) ? 0 : tags.hashCode());
423                 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
424                 result = prime * result + ((version == null) ? 0 : version.hashCode());
425                 return result;
426         }
427
428         @Override
429         public boolean equals(Object obj) {
430                 if (this == obj)
431                         return true;
432                 if (obj == null)
433                         return false;
434                 if (getClass() != obj.getClass())
435                         return false;
436                 ComponentMetadataDataDefinition other = (ComponentMetadataDataDefinition) obj;
437                 if (UUID == null) {
438                         if (other.UUID != null)
439                                 return false;
440                 } else if (!UUID.equals(other.UUID))
441                         return false;
442                 if (allVersions == null) {
443                         if (other.allVersions != null)
444                                 return false;
445                 } else if (!allVersions.equals(other.allVersions))
446                         return false;
447                 if (componentType != other.componentType)
448                         return false;
449                 if (conformanceLevel == null) {
450                         if (other.conformanceLevel != null)
451                                 return false;
452                 } else if (!conformanceLevel.equals(other.conformanceLevel))
453                         return false;
454                 if (contactId == null) {
455                         if (other.contactId != null)
456                                 return false;
457                 } else if (!contactId.equals(other.contactId))
458                         return false;
459                 if (creationDate == null) {
460                         if (other.creationDate != null)
461                                 return false;
462                 } else if (!creationDate.equals(other.creationDate))
463                         return false;
464                 if (creatorFullName == null) {
465                         if (other.creatorFullName != null)
466                                 return false;
467                 } else if (!creatorFullName.equals(other.creatorFullName))
468                         return false;
469                 if (creatorUserId == null) {
470                         if (other.creatorUserId != null)
471                                 return false;
472                 } else if (!creatorUserId.equals(other.creatorUserId))
473                         return false;
474                 if (csarUUID == null) {
475                         if (other.csarUUID != null)
476                                 return false;
477                 } else if (!csarUUID.equals(other.csarUUID))
478                         return false;
479                 if (csarVersion == null) {
480                         if (other.csarVersion != null)
481                                 return false;
482                 } else if (!csarVersion.equals(other.csarVersion))
483                         return false;
484                 if (description == null) {
485                         if (other.description != null)
486                                 return false;
487                 } else if (!description.equals(other.description))
488                         return false;
489                 if (icon == null) {
490                         if (other.icon != null)
491                                 return false;
492                 } else if (!icon.equals(other.icon))
493                         return false;
494                 if (importedToscaChecksum == null) {
495                         if (other.importedToscaChecksum != null)
496                                 return false;
497                 } else if (!importedToscaChecksum.equals(other.importedToscaChecksum))
498                         return false;
499                 if (invariantUUID == null) {
500                         if (other.invariantUUID != null)
501                                 return false;
502                 } else if (!invariantUUID.equals(other.invariantUUID))
503                         return false;
504                 if (isDeleted == null) {
505                         if (other.isDeleted != null)
506                                 return false;
507                 } else if (!isDeleted.equals(other.isDeleted))
508                         return false;
509                 if (isHighestVersion == null) {
510                         if (other.isHighestVersion != null)
511                                 return false;
512                 } else if (!isHighestVersion.equals(other.isHighestVersion))
513                         return false;
514                 if (lastUpdateDate == null) {
515                         if (other.lastUpdateDate != null)
516                                 return false;
517                 } else if (!lastUpdateDate.equals(other.lastUpdateDate))
518                         return false;
519                 if (lastUpdaterFullName == null) {
520                         if (other.lastUpdaterFullName != null)
521                                 return false;
522                 } else if (!lastUpdaterFullName.equals(other.lastUpdaterFullName))
523                         return false;
524                 if (lastUpdaterUserId == null) {
525                         if (other.lastUpdaterUserId != null)
526                                 return false;
527                 } else if (!lastUpdaterUserId.equals(other.lastUpdaterUserId))
528                         return false;
529                 if (name == null) {
530                         if (other.name != null)
531                                 return false;
532                 } else if (!name.equals(other.name))
533                         return false;
534                 if (normalizedName == null) {
535                         if (other.normalizedName != null)
536                                 return false;
537                 } else if (!normalizedName.equals(other.normalizedName))
538                         return false;
539                 if (projectCode == null) {
540                         if (other.projectCode != null)
541                                 return false;
542                 } else if (!projectCode.equals(other.projectCode))
543                         return false;
544                 if (state == null) {
545                         if (other.state != null)
546                                 return false;
547                 } else if (!state.equals(other.state))
548                         return false;
549                 if (systemName == null) {
550                         if (other.systemName != null)
551                                 return false;
552                 } else if (!systemName.equals(other.systemName))
553                         return false;
554                 if (tags == null) {
555                         if (other.tags != null)
556                                 return false;
557                 } else if (!tags.equals(other.tags))
558                         return false;
559                 if (uniqueId == null) {
560                         if (other.uniqueId != null)
561                                 return false;
562                 } else if (!uniqueId.equals(other.uniqueId))
563                         return false;
564                 if (version == null) {
565                         if (other.version != null)
566                                 return false;
567                 } else if (!version.equals(other.version))
568                         return false;
569                 return true;
570         }
571
572         /**
573          * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
574          * @return
575          */
576         public abstract String getActualComponentType();
577 }