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