849153b1acffc3ec454495fa73e817f8fcdcfb5b
[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 package org.openecomp.sdc.be.datatypes.components;
21
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.LinkedList;
25 import java.util.List;
26 import java.util.Map;
27 import lombok.EqualsAndHashCode;
28 import lombok.Getter;
29 import lombok.NoArgsConstructor;
30 import lombok.Setter;
31 import lombok.ToString;
32 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
33 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor;
34 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
35 import org.openecomp.sdc.common.log.wrappers.Logger;
36
37 @NoArgsConstructor
38 @EqualsAndHashCode
39 @ToString
40 public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinition {
41
42     private static final Logger LOGGER = Logger.getLogger(ComponentMetadataDataDefinition.class.getName());
43     @Getter
44     private String uniqueId;
45     @Getter
46     @Setter
47     private String name; // archiveName
48     @Getter
49     @Setter
50     private String version; // archiveVersion
51     @Getter
52     @Setter
53     private Boolean highestVersion;
54     @Getter
55     @Setter
56     private Long creationDate;
57     @Getter
58     @Setter
59     private Long lastUpdateDate;
60     @Getter
61     @Setter
62     private String description;
63     @Getter
64     @Setter
65     private String state;
66     @Getter
67     @Setter
68     private List<String> tags;
69     @Getter
70     @Setter
71     private String conformanceLevel;
72     @Getter
73     @Setter
74     private String icon;
75     @Getter
76     private String UUID;
77     @Getter
78     @Setter
79     private String normalizedName;
80     @Getter
81     @Setter
82     private String systemName;
83     @Getter
84     @Setter
85     private String contactId;
86     @Getter
87     @Setter
88     private Map<String, String> allVersions;
89     @Getter
90     @Setter
91     private Boolean isDeleted;
92     @Getter
93     @Setter
94     private String projectCode;
95     @Getter
96     @Setter
97     private String csarUUID;
98     @Getter
99     @Setter
100     private String csarVersion;
101     @Getter
102     @Setter
103     private String importedToscaChecksum;
104     @Getter
105     private String invariantUUID;
106     @Getter
107     @Setter
108     protected ComponentTypeEnum componentType;
109     // USER
110     @Getter
111     @Setter
112     private String creatorUserId;
113     @Getter
114     @Setter
115     private String creatorFullName;
116     @Getter
117     @Setter
118     private String lastUpdaterUserId;
119     @Getter
120     @Setter
121     private String lastUpdaterFullName;
122     //Archive/Restore
123     @Getter
124     @Setter
125     private Boolean isArchived = false;
126     @Getter
127     @Setter
128     private Long archiveTime;
129     @Getter
130     @Setter
131     private Boolean isVspArchived = false;
132     @Getter
133     @Setter
134     private Map<String, String> categorySpecificMetadata;
135     @Getter
136     @Setter
137     private String model;
138
139     public ComponentMetadataDataDefinition(ComponentMetadataDataDefinition other) {
140         this.uniqueId = other.getUniqueId();
141         this.name = other.getName();
142         this.version = other.getVersion();
143         this.highestVersion = other.isHighestVersion();
144         this.creationDate = other.getCreationDate();
145         this.lastUpdateDate = other.getLastUpdateDate();
146         this.description = other.getDescription();
147         this.state = other.getState();
148         this.tags = new ArrayList<>(other.getTags() != null ? other.getTags() : new LinkedList<>());
149         this.icon = other.getIcon();
150         this.contactId = other.getContactId();
151         this.UUID = other.getUUID();
152         this.normalizedName = other.getNormalizedName();
153         this.systemName = other.getSystemName();
154         this.allVersions = new HashMap<>(other.getAllVersions() != null ? other.getAllVersions() : new HashMap<>());
155         this.isDeleted = other.getIsDeleted();
156         this.projectCode = other.getProjectCode();
157         this.csarUUID = other.getCsarUUID();
158         this.csarVersion = other.csarVersion;
159         this.importedToscaChecksum = other.getImportedToscaChecksum();
160         this.invariantUUID = other.getInvariantUUID();
161         this.isArchived = other.isArchived;
162         this.isVspArchived = other.isVspArchived;
163         this.archiveTime = other.getArchiveTime();
164         this.categorySpecificMetadata = other.getCategorySpecificMetadata();
165         this.model = other.getModel();
166     }
167
168     public ComponentMetadataDataDefinition(JsonPresentationFieldsExtractor extractor) {
169         this.uniqueId = extractor.getUniqueId();
170         this.name = extractor.getName();
171         this.version = extractor.getVersion();
172         this.highestVersion = extractor.isHighestVersion();
173         this.creationDate = extractor.getCreationDate();
174         this.lastUpdateDate = extractor.getLastUpdateDate();
175         this.description = extractor.getDescription();
176         this.state = extractor.getState();
177         this.tags = extractor.getTags();
178         this.icon = extractor.getIcon();
179         this.contactId = extractor.getContactId();
180         this.UUID = extractor.getUUID();
181         this.normalizedName = extractor.getNormalizedName();
182         this.systemName = extractor.getSystemName();
183         this.isDeleted = extractor.isDeleted();
184         this.projectCode = extractor.getProjectCode();
185         this.csarUUID = extractor.getCsarUuid();
186         this.csarVersion = extractor.getCsarVersion();
187         this.importedToscaChecksum = extractor.getImportedToscaChecksum();
188         this.invariantUUID = extractor.getInvariantUuid();
189         this.isArchived = extractor.isArchived();
190         this.isVspArchived = extractor.isVspArchived();
191         this.archiveTime = extractor.getArchiveTime();
192         this.model = extractor.getModel();
193     }
194
195     public void setUniqueId(String uniqueId) {
196         if (this.uniqueId != null && !this.uniqueId.equals(uniqueId)) {
197             LOGGER.warn("uniqueId changed more then once -> OLD : {} , NEW: {} ", this.uniqueId, uniqueId);
198         }
199         this.uniqueId = uniqueId;
200     }
201
202     public void setUUID(String UUID) {
203         if (this.UUID != null && !this.UUID.equals(UUID)) {
204             LOGGER.warn("UUID changed more then once -> OLD : {} , NEW: {} ", this.UUID, UUID);
205         }
206         this.UUID = UUID;
207     }
208
209     public void setInvariantUUID(String invariantUUID) {
210         if (this.invariantUUID != null && !this.invariantUUID.equals(invariantUUID)) {
211             LOGGER.warn("InvariantUUID changed more then once -> OLD : {} , NEW: {} ", this.invariantUUID, invariantUUID);
212         }
213         this.invariantUUID = invariantUUID;
214     }
215
216     public Boolean isHighestVersion() {
217         return highestVersion;
218     }
219
220     public String getLifecycleState() {
221         return state;
222     }
223
224     public void setLifecycleState(String state) {
225         this.state = state;
226     }
227
228     public Boolean isDeleted() {
229         return getIsDeleted();
230     }
231
232     public Boolean isArchived() {
233         return getIsArchived();
234     }
235
236     public void setArchived(Boolean archived) {
237         setIsArchived(archived);
238     }
239
240     public Boolean isVspArchived() {
241         return getIsVspArchived();
242     }
243
244     public void setVspArchived(Boolean vspArchived) {
245         setIsVspArchived(vspArchived);
246     }
247
248     /**
249      * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR
250      *
251      * @return
252      */
253     public abstract String getActualComponentType();
254 }