4cee3ff49d1e0220c67b1d20f68a50c4f7c66846
[sdc.git] /
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.ArrayList;
28 import java.util.HashMap;
29 import java.util.LinkedList;
30 import java.util.List;
31 import java.util.Map;
32
33 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
34
35     private static final Logger LOGGER = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
36
37     private String uniqueId;
38
39     private String name; // archiveName
40
41     private String version; // archiveVersion
42
43     private Boolean isHighestVersion;
44
45     private Long creationDate;
46
47     private Long lastUpdateDate;
48
49     private String description;
50
51     private String state;
52
53     private List<String> tags;
54
55     private String conformanceLevel;
56
57     private String icon;
58
59     private String UUID;
60
61     private String normalizedName;
62
63     private String systemName;
64
65     private String contactId;
66
67     private Map<String, String> allVersions;
68
69     private Boolean isDeleted;
70
71     private String projectCode;
72
73     private String csarUUID;
74
75     private String csarVersion;
76
77     private String importedToscaChecksum;
78
79     private String invariantUUID;
80
81     protected ComponentTypeEnum componentType;
82
83     // USER
84     private String creatorUserId;
85
86     private String creatorFullName;
87
88     private String lastUpdaterUserId;
89
90     private String lastUpdaterFullName;
91
92     //Archive/Restore
93     private Boolean isArchived = false;
94
95     private Long archiveTime;
96
97     private Boolean isVspArchived = false;
98
99     public Boolean getIsHighestVersion() {
100         return isHighestVersion;
101     }
102
103     public void setIsHighestVersion(Boolean isHighestVersion) {
104         this.isHighestVersion = isHighestVersion;
105     }
106
107     public ComponentTypeEnum getComponentType() {
108         return componentType;
109     }
110
111     public void setComponentType(ComponentTypeEnum componentType) {
112         this.componentType = componentType;
113     }
114
115     public String getCreatorUserId() {
116         return creatorUserId;
117     }
118
119     public void setCreatorUserId(String creatorUserId) {
120         this.creatorUserId = creatorUserId;
121     }
122
123     public String getCreatorFullName() {
124         return creatorFullName;
125     }
126
127     public void setCreatorFullName(String creatorFullName) {
128         this.creatorFullName = creatorFullName;
129     }
130
131     public String getLastUpdaterUserId() {
132         return lastUpdaterUserId;
133     }
134
135     public void setLastUpdaterUserId(String lastUpdaterUserId) {
136         this.lastUpdaterUserId = lastUpdaterUserId;
137     }
138
139     public String getLastUpdaterFullName() {
140         return lastUpdaterFullName;
141     }
142
143     public void setLastUpdaterFullName(String lastUpdaterFullName) {
144         this.lastUpdaterFullName = lastUpdaterFullName;
145     }
146
147     public Boolean getIsDeleted() {
148         return isDeleted;
149     }
150
151     public Boolean isArchived() {
152         return isArchived;
153     }
154
155     public void setArchived(Boolean archived) {
156         isArchived = archived;
157     }
158
159     public Long getArchiveTime() {
160         return archiveTime;
161     }
162
163     public void setArchiveTime(Long archiveTime) {
164         this.archiveTime = archiveTime;
165     }
166
167     public Boolean isVspArchived() {
168         return isVspArchived;
169     }
170
171     public void setVspArchived(Boolean vspArchived) {
172         isVspArchived = vspArchived;
173     }
174
175     public ComponentMetadataDataDefinition() {
176
177     }
178
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();
204     }
205
206     public String getUniqueId() {
207         return uniqueId;
208     }
209
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);
213         }
214         this.uniqueId = uniqueId;
215     }
216
217     public String getName() {
218         return name;
219     }
220
221     public void setName(String name) {
222         this.name = name;
223     }
224
225     public String getVersion() {
226         return version;
227     }
228
229     public void setVersion(String version) {
230         this.version = version;
231     }
232
233     public Boolean isHighestVersion() {
234         return isHighestVersion;
235     }
236
237     public void setHighestVersion(Boolean isHighestVersion) {
238         this.isHighestVersion = isHighestVersion;
239     }
240
241     public Long getCreationDate() {
242         return creationDate;
243     }
244
245     public void setCreationDate(Long creationDate) {
246         this.creationDate = creationDate;
247     }
248
249     public Long getLastUpdateDate() {
250         return lastUpdateDate;
251     }
252
253     public void setLastUpdateDate(Long lastUpdateDate) {
254         this.lastUpdateDate = lastUpdateDate;
255     }
256
257     public String getDescription() {
258         return description;
259     }
260
261     public void setDescription(String description) {
262         this.description = description;
263     }
264
265     public String getState() {
266         return state;
267     }
268
269     public void setState(String state) {
270         this.state = state;
271     }
272
273     public List<String> getTags() {
274         return tags;
275     }
276
277     public void setTags(List<String> tags) {
278         this.tags = tags;
279     }
280
281     public String getIcon() {
282         return icon;
283     }
284
285     public void setIcon(String icon) {
286         this.icon = icon;
287     }
288
289     public String getContactId() {
290         return contactId;
291     }
292
293     public void setContactId(String contactId) {
294         this.contactId = contactId;
295     }
296
297     public String getUUID() {
298         return UUID;
299     }
300
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);
304         }
305         this.UUID = UUID;
306     }
307
308     public String getNormalizedName() {
309         return normalizedName;
310     }
311
312     public void setNormalizedName(String normalizedName) {
313         this.normalizedName = normalizedName;
314     }
315
316     public String getSystemName() {
317         return systemName;
318     }
319
320     public void setSystemName(String systemName) {
321         this.systemName = systemName;
322     }
323
324     public Map<String, String> getAllVersions() {
325         return allVersions;
326     }
327
328     public void setAllVersions(Map<String, String> allVersions) {
329         this.allVersions = allVersions;
330     }
331
332     public String getInvariantUUID() {
333         return invariantUUID;
334     }
335
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);
339         }
340         this.invariantUUID = invariantUUID;
341     }
342
343     public Boolean isDeleted() {
344         return isDeleted;
345     }
346
347     public void setIsDeleted(Boolean isDeleted) {
348         this.isDeleted = isDeleted;
349     }
350
351     public String getProjectCode() {
352         return projectCode;
353     }
354
355     public void setProjectCode(String projectCode) {
356         this.projectCode = projectCode;
357     }
358
359     public String getCsarUUID() {
360         return csarUUID;
361     }
362
363     public void setCsarUUID(String csarUUID) {
364         this.csarUUID = csarUUID;
365     }
366
367     public String getCsarVersion() {
368         return csarVersion;
369     }
370
371     public void setCsarVersion(String csarVersion) {
372         this.csarVersion = csarVersion;
373     }
374
375     public String getImportedToscaChecksum() {
376         return importedToscaChecksum;
377     }
378
379     public void setImportedToscaChecksum(String importedToscaChecksum) {
380         this.importedToscaChecksum = importedToscaChecksum;
381     }
382
383     public String getConformanceLevel() {
384         return conformanceLevel;
385     }
386
387     public void setConformanceLevel(String conformanceLevel) {
388         this.conformanceLevel = conformanceLevel;
389     }
390
391     public String getLifecycleState() {
392         return state;
393     }
394
395     public void setLifecycleState(String state) {
396         this.state = state;
397     }
398
399     @Override
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 + "]";
411     }
412
413     @Override
414     public int hashCode() {
415         final int prime = 31;
416         int result = 1;
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());
444         return result;
445     }
446
447     @Override
448     public boolean equals(Object obj) {
449         if (this == obj) {
450             return true;
451         }
452         if (obj == null) {
453             return false;
454         }
455         if (getClass() != obj.getClass()) {
456             return false;
457         }
458         ComponentMetadataDataDefinition other = (ComponentMetadataDataDefinition) obj;
459         if (UUID == null) {
460             if (other.UUID != null) {
461                 return false;
462             }
463         } else if (!UUID.equals(other.UUID)) {
464             return false;
465         }
466         if (allVersions == null) {
467             if (other.allVersions != null) {
468                 return false;
469             }
470         } else if (!allVersions.equals(other.allVersions)) {
471             return false;
472         }
473         if (componentType != other.componentType) {
474             return false;
475         }
476         if (conformanceLevel == null) {
477             if (other.conformanceLevel != null) {
478                 return false;
479             }
480         } else if (!conformanceLevel.equals(other.conformanceLevel)) {
481             return false;
482         }
483         if (contactId == null) {
484             if (other.contactId != null) {
485                 return false;
486             }
487         } else if (!contactId.equals(other.contactId)) {
488             return false;
489         }
490         if (creationDate == null) {
491             if (other.creationDate != null) {
492                 return false;
493             }
494         } else if (!creationDate.equals(other.creationDate)) {
495             return false;
496         }
497         if (creatorFullName == null) {
498             if (other.creatorFullName != null) {
499                 return false;
500             }
501         } else if (!creatorFullName.equals(other.creatorFullName)) {
502             return false;
503         }
504         if (creatorUserId == null) {
505             if (other.creatorUserId != null) {
506                 return false;
507             }
508         } else if (!creatorUserId.equals(other.creatorUserId)) {
509             return false;
510         }
511         if (csarUUID == null) {
512             if (other.csarUUID != null) {
513                 return false;
514             }
515         } else if (!csarUUID.equals(other.csarUUID)) {
516             return false;
517         }
518         if (csarVersion == null) {
519             if (other.csarVersion != null) {
520                 return false;
521             }
522         } else if (!csarVersion.equals(other.csarVersion)) {
523             return false;
524         }
525         if (description == null) {
526             if (other.description != null) {
527                 return false;
528             }
529         } else if (!description.equals(other.description)) {
530             return false;
531         }
532         if (icon == null) {
533             if (other.icon != null) {
534                 return false;
535             }
536         } else if (!icon.equals(other.icon)) {
537             return false;
538         }
539         if (importedToscaChecksum == null) {
540             if (other.importedToscaChecksum != null) {
541                 return false;
542             }
543         } else if (!importedToscaChecksum.equals(other.importedToscaChecksum)) {
544             return false;
545         }
546         if (invariantUUID == null) {
547             if (other.invariantUUID != null) {
548                 return false;
549             }
550         } else if (!invariantUUID.equals(other.invariantUUID)) {
551             return false;
552         }
553         if (isDeleted == null) {
554             if (other.isDeleted != null) {
555                 return false;
556             }
557         } else if (!isDeleted.equals(other.isDeleted)) {
558             return false;
559         }
560         if (isHighestVersion == null) {
561             if (other.isHighestVersion != null) {
562                 return false;
563             }
564         } else if (!isHighestVersion.equals(other.isHighestVersion)) {
565             return false;
566         }
567         if (lastUpdateDate == null) {
568             if (other.lastUpdateDate != null) {
569                 return false;
570             }
571         } else if (!lastUpdateDate.equals(other.lastUpdateDate)) {
572             return false;
573         }
574         if (lastUpdaterFullName == null) {
575             if (other.lastUpdaterFullName != null) {
576                 return false;
577             }
578         } else if (!lastUpdaterFullName.equals(other.lastUpdaterFullName)) {
579             return false;
580         }
581         if (lastUpdaterUserId == null) {
582             if (other.lastUpdaterUserId != null) {
583                 return false;
584             }
585         } else if (!lastUpdaterUserId.equals(other.lastUpdaterUserId)) {
586             return false;
587         }
588         if (name == null) {
589             if (other.name != null) {
590                 return false;
591             }
592         } else if (!name.equals(other.name)) {
593             return false;
594         }
595         if (normalizedName == null) {
596             if (other.normalizedName != null) {
597                 return false;
598             }
599         } else if (!normalizedName.equals(other.normalizedName)) {
600             return false;
601         }
602         if (projectCode == null) {
603             if (other.projectCode != null) {
604                 return false;
605             }
606         } else if (!projectCode.equals(other.projectCode)) {
607             return false;
608         }
609         if (state == null) {
610             if (other.state != null) {
611                 return false;
612             }
613         } else if (!state.equals(other.state)) {
614             return false;
615         }
616         if (systemName == null) {
617             if (other.systemName != null) {
618                 return false;
619             }
620         } else if (!systemName.equals(other.systemName)) {
621             return false;
622         }
623         if (tags == null) {
624             if (other.tags != null) {
625                 return false;
626             }
627         } else if (!tags.equals(other.tags)) {
628             return false;
629         }
630         if (uniqueId == null) {
631             if (other.uniqueId != null) {
632                 return false;
633             }
634         } else if (!uniqueId.equals(other.uniqueId)) {
635             return false;
636         }
637         if (version == null) {
638             return other.version == null;
639         } else {
640             return version.equals(other.version);
641         }
642     }
643
644     /**
645      * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
646      *
647      * @return
648      */
649     public abstract String getActualComponentType();
650 }