2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.datatypes.elements;
23 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
24 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
25 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
27 import java.util.ArrayList;
28 import java.util.List;
31 //import com.google.gson.reflect.TypeToken;
33 public class ArtifactDataDefinition extends ToscaDataDefinition {
35 public ArtifactDataDefinition() {
36 setArtifactVersion("0");
39 public ArtifactDataDefinition(Map<String, Object> art) {
41 setArtifactVersion("0");
46 public ArtifactDataDefinition(ArtifactDataDefinition a ) {
47 this.setUniqueId(a.getUniqueId());
48 this.setArtifactType(a.getArtifactType());
49 this.setArtifactRef( a.getArtifactRef());
50 this.setArtifactName( a.getArtifactName());
51 this.setArtifactRepository( a.getArtifactRepository());
52 this.setArtifactChecksum( a.getArtifactChecksum());
53 this.setUserIdCreator( a.getUserIdCreator());
54 this.setUserIdLastUpdater( a.getUserIdLastUpdater());
55 this.setCreatorFullName( a.getCreatorFullName());
56 this.setUpdaterFullName( a.getUpdaterFullName());
57 this.setCreationDate ( a.getCreationDate());
58 this.setLastUpdateDate ( a.getLastUpdateDate());
59 this.setDescription ( a.getDescription());
60 this.setEsId ( a.getEsId());
61 this.setArtifactLabel( a.getArtifactLabel());
62 this.setArtifactCreator( a.getArtifactCreator());
63 this.setMandatory ( a.getMandatory());
64 this.setArtifactDisplayName( a.getArtifactDisplayName());
65 this.setApiUrl( a.getApiUrl());
66 this.setServiceApi ( a.getServiceApi());
67 this.setArtifactGroupType ( a.getArtifactGroupType());
68 this.setTimeout ( a.getTimeout());
69 this.setArtifactVersion( a.getArtifactVersion());
70 this.setArtifactUUID ( a.getArtifactUUID());
71 this.setPayloadUpdateDate ( a.getPayloadUpdateDate());
72 this.setHeatParamsUpdateDate ( a.getHeatParamsUpdateDate());
73 this.setGenerated(a.getGenerated());
74 this.setDuplicated(a.getDuplicated());
75 if (a.getRequiredArtifacts() != null)
76 this.setRequiredArtifacts(new ArrayList<>(a.getRequiredArtifacts()));
77 if (a.getHeatParameters() != null)
78 this.setHeatParameters(new ArrayList<>(a.getHeatParameters()));
79 this.setGeneratedFromId( a.getGeneratedFromId());
80 this.setIsFromCsar(a.getIsFromCsar());
85 public String getArtifactName() {
86 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
90 public String getArtifactType() {
91 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE);
94 public void setArtifactType(String artifactType) {
95 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE, artifactType);
99 public String getArtifactRef() {
100 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_REF);
104 public void setArtifactRef(String artifactRef) {
105 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_REF, artifactRef);
108 public String getArtifactRepository() {
109 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_REPOSITORY);
113 public void setArtifactRepository(String artifactRepository) {
114 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_REPOSITORY, artifactRepository);
117 public void setArtifactName(String artifactName) {
118 setToscaPresentationValue(JsonPresentationFields.NAME, artifactName);
122 public String getArtifactChecksum() {
123 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_CHECKSUM);
126 public void setArtifactChecksum(String artifactChecksum) {
127 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_CHECKSUM, artifactChecksum);
130 public String getUserIdCreator() {
132 return (String) getToscaPresentationValue(JsonPresentationFields.USER_ID_CREATOR);
135 public void setUserIdCreator(String userIdCreator) {
136 setToscaPresentationValue(JsonPresentationFields.USER_ID_CREATOR, userIdCreator);
139 public String getUserIdLastUpdater() {
140 return (String) getToscaPresentationValue(JsonPresentationFields.USER_ID_LAST_UPDATER);
143 public void setUserIdLastUpdater(String userIdLastUpdater) {
144 setToscaPresentationValue(JsonPresentationFields.USER_ID_LAST_UPDATER, userIdLastUpdater);
147 public String getCreatorFullName() {
148 return (String) getToscaPresentationValue(JsonPresentationFields.CREATOR_FULL_NAME);
151 public void setCreatorFullName(String creatorFullName) {
152 setToscaPresentationValue(JsonPresentationFields.CREATOR_FULL_NAME, creatorFullName);
155 public String getUpdaterFullName() {
156 return (String) getToscaPresentationValue(JsonPresentationFields.UPDATER_FULL_NAME);
159 public void setUpdaterFullName(String updaterFullName) {
160 setToscaPresentationValue(JsonPresentationFields.UPDATER_FULL_NAME, updaterFullName);
163 public Long getCreationDate() {
164 return (Long) getToscaPresentationValue(JsonPresentationFields.CREATION_DATE);
167 public void setCreationDate(Long creationDate) {
168 setToscaPresentationValue(JsonPresentationFields.CREATION_DATE, creationDate);
171 public Long getLastUpdateDate() {
172 return (Long) getToscaPresentationValue(JsonPresentationFields.LAST_UPDATE_DATE);
175 public void setLastUpdateDate(Long lastUpdateDate) {
176 setToscaPresentationValue(JsonPresentationFields.LAST_UPDATE_DATE, lastUpdateDate);
179 public String getUniqueId() {
180 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
183 public void setUniqueId(String uniqueId) {
184 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
187 public String getDescription() {
188 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
191 public void setDescription(String description) {
192 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
195 public String getArtifactLabel() {
196 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL);
199 public void setArtifactLabel(String artifactLabel) {
200 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL, artifactLabel);
203 public String getEsId() {
204 return (String) getToscaPresentationValue(JsonPresentationFields.ES_ID);
207 public void setEsId(String esId) {
208 setToscaPresentationValue(JsonPresentationFields.ES_ID, esId);
211 public String getArtifactCreator() {
212 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_CREATOR);
215 public void setArtifactCreator(String artifactCreator) {
216 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_CREATOR, artifactCreator);
219 public Boolean getMandatory() {
220 Boolean isMandatory = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_ABSTRACT);
221 return isMandatory == null? Boolean.FALSE: isMandatory;
224 public void setMandatory(Boolean mandatory) {
225 setToscaPresentationValue(JsonPresentationFields.IS_ABSTRACT, mandatory);
228 public String getArtifactDisplayName() {
229 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_DISPLAY_NAME);
232 public void setArtifactDisplayName(String artifactDisplayName) {
233 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_DISPLAY_NAME, artifactDisplayName);
236 public String getApiUrl() {
237 return (String) getToscaPresentationValue(JsonPresentationFields.API_URL);
240 public void setApiUrl(String apiUrl) {
241 setToscaPresentationValue(JsonPresentationFields.API_URL, apiUrl);
244 public Boolean getServiceApi() {
245 Boolean serviceApi = (Boolean) getToscaPresentationValue(JsonPresentationFields.SERVICE_API);
246 return serviceApi == null? Boolean.FALSE: serviceApi;
249 public void setServiceApi(Boolean serviceApi) {
250 setToscaPresentationValue(JsonPresentationFields.SERVICE_API, serviceApi);
253 public ArtifactGroupTypeEnum getArtifactGroupType() {
254 ArtifactGroupTypeEnum artifactGroupType = null;
255 String groupType = (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_GROUP_TYPE);
256 if (groupType != null && !groupType.isEmpty()) {
258 artifactGroupType = ArtifactGroupTypeEnum.findType(groupType);
260 return artifactGroupType;
263 public void setArtifactGroupType(ArtifactGroupTypeEnum artifactGroupType) {
264 if(artifactGroupType != null)
265 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_GROUP_TYPE, artifactGroupType.getType());
268 public Integer getTimeout() {
269 return (Integer) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TIMEOUT);
272 public void setTimeout(Integer timeout) {
273 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_TIMEOUT, timeout);
276 public String getArtifactVersion() {
277 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_VERSION);
280 public void setArtifactVersion(String artifactVersion) {
281 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_VERSION, artifactVersion);
284 public String getArtifactUUID() {
285 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_UUID);
288 public void setArtifactUUID(String artifactUUID) {
289 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_UUID, artifactUUID);
292 public Long getPayloadUpdateDate() {
293 return (Long) getToscaPresentationValue(JsonPresentationFields.PAYLOAD_UPDATE_DATE);
296 public void setPayloadUpdateDate(Long payloadUpdateDate) {
297 setToscaPresentationValue(JsonPresentationFields.PAYLOAD_UPDATE_DATE, payloadUpdateDate);
300 public Long getHeatParamsUpdateDate() {
301 return (Long) getToscaPresentationValue(JsonPresentationFields.HEAT_PARAMS_UPDATE_DATE);
304 public void setHeatParamsUpdateDate(Long heatParamsUpdateDate) {
305 setToscaPresentationValue(JsonPresentationFields.HEAT_PARAMS_UPDATE_DATE, heatParamsUpdateDate);
308 public List<String> getRequiredArtifacts() {
309 return (List<String>) getToscaPresentationValue(JsonPresentationFields.REQUIRED_ARTIFACTS);
312 public void setRequiredArtifacts(List<String> requiredArtifacts) {
313 setToscaPresentationValue(JsonPresentationFields.REQUIRED_ARTIFACTS, requiredArtifacts);
316 public Boolean getGenerated() {
317 Boolean generated = (Boolean) getToscaPresentationValue(JsonPresentationFields.GENERATED);
318 return generated == null ? Boolean.FALSE: generated;
321 public void setGenerated(Boolean generated) {
322 setToscaPresentationValue(JsonPresentationFields.GENERATED, generated);
325 public Boolean getDuplicated() {
326 Boolean duplicated = (Boolean) getToscaPresentationValue(JsonPresentationFields.DUPLICATED);
327 return duplicated == null ? Boolean.FALSE: duplicated;
330 public void setDuplicated(Boolean duplicated) {
331 setToscaPresentationValue(JsonPresentationFields.DUPLICATED, duplicated);
334 public List<HeatParameterDataDefinition> getHeatParameters() {
335 return (List<HeatParameterDataDefinition>) getToscaPresentationValue(JsonPresentationFields.HEAT_PARAMETERS);
338 public void setHeatParameters(List<HeatParameterDataDefinition> properties) {
339 setToscaPresentationValue(JsonPresentationFields.HEAT_PARAMETERS, properties);
342 public String getGeneratedFromId() {
343 return (String) getToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID);
345 public boolean getIsFromCsar(){
346 Boolean isFromCsar = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR);
347 return isFromCsar == null ? Boolean.FALSE: isFromCsar;
349 public void setIsFromCsar(Boolean isFromCsar) {
350 setToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR, isFromCsar);
353 public void setGeneratedFromId(String generatedFromId) {
354 setToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID, generatedFromId);
359 public String toString() {
360 return "ArtifactDataDefinition [uniqueId=" + getUniqueId() + ", artifactType=" + getArtifactType() + ", artifactRef=" + getArtifactRef() + ", artifactName=" + getArtifactName() + ", artifactRepository=" + getArtifactRepository() + ", artifactChecksum="
361 + getArtifactChecksum() + ", userIdCreator=" + getUserIdCreator() + ", userIdLastUpdater=" + getUserIdLastUpdater() + ", creatorFullName=" + getCreatorFullName() + ", updaterFullName=" + getUpdaterFullName() + ", creationDate=" + getCreationDate()
362 + ", lastUpdateDate=" + getLastUpdateDate() + ", esId=" + getEsId() + ", artifactLabel=" + getArtifactLabel() + ", artifactCreator=" + getArtifactCreator() + ", description=" + getDescription() + ", mandatory=" + getMandatory() + ", artifactDisplayName="
363 + getArtifactDisplayName() + ", apiUrl=" + getApiUrl() + ", serviceApi=" + getServiceApi() + ", artifactGroupType=" + getArtifactGroupType() + ", timeout=" + getTimeout() + ", artifactVersion=" + getArtifactVersion() + ", artifactUUID=" + getArtifactUUID()
364 + ", payloadUpdateDate=" + getPayloadUpdateDate() + ", heatParamsUpdateDate=" + getHeatParamsUpdateDate() + ", requiredArtifacts=" + getRequiredArtifacts() + "]";
368 public int hashCode() {
369 final int prime = 31;
372 String apiUrl = getApiUrl();
373 String artifactChecksum = getArtifactChecksum();
374 String artifactCreator = getArtifactCreator();
375 String artifactDisplayName = getArtifactDisplayName();
376 ArtifactGroupTypeEnum artifactGroupType = getArtifactGroupType();
377 String artifactLabel = getArtifactLabel();
378 String artifactName = getArtifactName();
379 String artifactRef = getArtifactRef();
380 String artifactRepository = getArtifactRepository();
381 String artifactType = getArtifactType();
383 String artifactUUID = getArtifactUUID();
384 String artifactVersion = getArtifactVersion();
385 String userIdCreator = getUserIdCreator();
386 String userIdLastUpdater = getUserIdLastUpdater();
387 Long creationDate = getCreationDate();
389 String creatorFullName = getCreatorFullName();
390 String description = getDescription();
391 String esId = getEsId();
392 Long heatParamsUpdateDate = getHeatParamsUpdateDate();
393 Long lastUpdateDate = getLastUpdateDate();
394 Boolean mandatory = getMandatory();
396 Long payloadUpdateDate = getPayloadUpdateDate();
397 List<String> requiredArtifacts = getRequiredArtifacts();
398 Boolean serviceApi = getServiceApi();
399 Integer timeout = getTimeout();
400 String uniqueId = getUniqueId();
401 String updaterFullName = getUpdaterFullName();
403 result = prime * result + ((apiUrl == null) ? 0 : apiUrl.hashCode());
404 result = prime * result + ((artifactChecksum == null) ? 0 : artifactChecksum.hashCode());
405 result = prime * result + ((artifactCreator == null) ? 0 : artifactCreator.hashCode());
406 result = prime * result + ((artifactDisplayName == null) ? 0 : artifactDisplayName.hashCode());
407 result = prime * result + ((artifactGroupType == null) ? 0 : artifactGroupType.hashCode());
408 result = prime * result + ((artifactLabel == null) ? 0 : artifactLabel.hashCode());
409 result = prime * result + ((artifactName == null) ? 0 : artifactName.hashCode());
410 result = prime * result + ((artifactRef == null) ? 0 : artifactRef.hashCode());
411 result = prime * result + ((artifactRepository == null) ? 0 : artifactRepository.hashCode());
412 result = prime * result + ((artifactType == null) ? 0 : artifactType.hashCode());
413 result = prime * result + ((artifactUUID == null) ? 0 : artifactUUID.hashCode());
414 result = prime * result + ((artifactVersion == null) ? 0 : artifactVersion.hashCode());
415 result = prime * result + ((userIdCreator == null) ? 0 : userIdCreator.hashCode());
416 result = prime * result + ((userIdLastUpdater == null) ? 0 : userIdLastUpdater.hashCode());
417 result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
418 result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode());
419 result = prime * result + ((description == null) ? 0 : description.hashCode());
420 result = prime * result + ((esId == null) ? 0 : esId.hashCode());
421 result = prime * result + ((heatParamsUpdateDate == null) ? 0 : heatParamsUpdateDate.hashCode());
422 result = prime * result + ((lastUpdateDate == null) ? 0 : lastUpdateDate.hashCode());
423 result = prime * result + ((mandatory == null) ? 0 : mandatory.hashCode());
424 result = prime * result + ((payloadUpdateDate == null) ? 0 : payloadUpdateDate.hashCode());
425 result = prime * result + ((requiredArtifacts == null) ? 0 : requiredArtifacts.hashCode());
426 result = prime * result + ((serviceApi == null) ? 0 : serviceApi.hashCode());
427 result = prime * result + ((timeout == null) ? 0 : timeout.hashCode());
428 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
429 result = prime * result + ((updaterFullName == null) ? 0 : updaterFullName.hashCode());
434 public boolean equals(Object obj) {
439 if (getClass() != obj.getClass())
441 ArtifactDataDefinition other = (ArtifactDataDefinition) obj;
442 if (getApiUrl() == null) {
443 if (other.getApiUrl() != null)
445 } else if (!getApiUrl().equals(other.getApiUrl()))
447 if (getArtifactChecksum() == null) {
448 if (other.getArtifactChecksum() != null)
450 } else if (!getArtifactChecksum().equals(other.getArtifactChecksum()))
452 if (getArtifactCreator() == null) {
453 if (other.getArtifactCreator() != null)
455 } else if (!getArtifactCreator().equals(other.getArtifactCreator()))
457 if (getArtifactDisplayName() == null) {
458 if (other.getArtifactDisplayName() != null)
460 } else if (!getArtifactDisplayName().equals(other.getArtifactDisplayName()))
462 if (getArtifactGroupType() != other.getArtifactGroupType())
464 if (getArtifactLabel() == null) {
465 if (other.getArtifactLabel() != null)
467 } else if (!getArtifactLabel().equals(other.getArtifactLabel()))
469 if (getArtifactName() == null) {
470 if (other.getArtifactName() != null)
472 } else if (!getArtifactName().equals(other.getArtifactName()))
474 if (getArtifactRef() == null) {
475 if (other.getArtifactRef() != null)
477 } else if (!getArtifactRef().equals(other.getArtifactRef()))
479 if (getArtifactRepository() == null) {
480 if (other.getArtifactRepository() != null)
482 } else if (!getArtifactRepository().equals(other.getArtifactRepository()))
484 if (getArtifactType() == null) {
485 if (other.getArtifactType() != null)
487 } else if (!getArtifactType().equals(other.getArtifactType()))
489 if (getArtifactUUID() == null) {
490 if (other.getArtifactUUID() != null)
492 } else if (!getArtifactUUID().equals(other.getArtifactUUID()))
494 if (getArtifactVersion() == null) {
495 if (other.getArtifactVersion() != null)
497 } else if (!getArtifactVersion().equals(other.getArtifactVersion()))
499 if (getUserIdCreator() == null) {
500 if (other.getUserIdCreator() != null)
502 } else if (!getUserIdCreator().equals(other.getUserIdCreator()))
504 if (getUserIdLastUpdater() == null) {
505 if (other.getUserIdLastUpdater() != null)
507 } else if (!getUserIdLastUpdater().equals(other.getUserIdLastUpdater()))
509 if (getCreationDate() == null) {
510 if (other.getCreationDate() != null)
512 } else if (!getCreationDate().equals(other.getCreationDate()))
514 if (getCreatorFullName() == null) {
515 if (other.getCreatorFullName() != null)
517 } else if (!getCreatorFullName().equals(other.getCreatorFullName()))
519 if (getDescription() == null) {
520 if (other.getDescription() != null)
522 } else if (!getDescription().equals(other.getDescription()))
524 if (getEsId() == null) {
525 if (other.getEsId() != null)
527 } else if (!getEsId().equals(other.getEsId()))
529 if (getHeatParamsUpdateDate() == null) {
530 if (other.getHeatParamsUpdateDate() != null)
532 } else if (!getHeatParamsUpdateDate().equals(other.getHeatParamsUpdateDate()))
534 if (getLastUpdateDate() == null) {
535 if (other.getLastUpdateDate() != null)
537 } else if (!getLastUpdateDate().equals(other.getLastUpdateDate()))
539 if (getMandatory() == null) {
540 if (other.getMandatory() != null)
542 } else if (!getMandatory().equals(other.getMandatory()))
544 if (getPayloadUpdateDate() == null) {
545 if (other.getPayloadUpdateDate() != null)
547 } else if (!getPayloadUpdateDate().equals(other.getPayloadUpdateDate()))
549 if (getRequiredArtifacts() == null) {
550 if (other.getRequiredArtifacts() != null)
552 } else if (!getRequiredArtifacts().equals(other.getRequiredArtifacts()))
554 if (getServiceApi() == null) {
555 if (other.getServiceApi() != null)
557 } else if (!getServiceApi().equals(other.getServiceApi()))
559 if (getTimeout() == null) {
560 if (other.getTimeout() != null)
562 } else if (!getTimeout().equals(other.getTimeout()))
564 if (getUniqueId() == null) {
565 if (other.getUniqueId() != null)
567 } else if (!getUniqueId().equals(other.getUniqueId()))
569 if (getUpdaterFullName() == null) {
570 if (other.getUpdaterFullName() != null)
572 } else if (!getUpdaterFullName().equals(other.getUpdaterFullName()))