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