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 java.util.ArrayList;
24 import java.util.List;
26 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
27 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
28 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
29 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
31 public class ArtifactDataDefinition extends ToscaDataDefinition {
33 public ArtifactDataDefinition() {
34 setArtifactVersion("0");
37 public ArtifactDataDefinition(Map<String, Object> art) {
39 setArtifactVersion("0");
43 public ArtifactDataDefinition(ArtifactDataDefinition a) {
44 this.setUniqueId(a.getUniqueId());
45 this.setArtifactType(a.getArtifactType());
46 this.setArtifactRef(a.getArtifactRef());
47 this.setArtifactName(a.getArtifactName());
48 this.setArtifactRepository(a.getArtifactRepository());
49 this.setArtifactChecksum(a.getArtifactChecksum());
50 this.setUserIdCreator(a.getUserIdCreator());
51 this.setUserIdLastUpdater(a.getUserIdLastUpdater());
52 this.setCreatorFullName(a.getCreatorFullName());
53 this.setUpdaterFullName(a.getUpdaterFullName());
54 this.setCreationDate(a.getCreationDate());
55 this.setLastUpdateDate(a.getLastUpdateDate());
56 this.setDescription(a.getDescription());
57 this.setEsId(a.getEsId());
58 this.setArtifactLabel(a.getArtifactLabel());
59 this.setArtifactCreator(a.getArtifactCreator());
60 this.setMandatory(a.getMandatory());
61 this.setArtifactDisplayName(a.getArtifactDisplayName());
62 this.setApiUrl(a.getApiUrl());
63 this.setServiceApi(a.getServiceApi());
64 this.setArtifactGroupType(a.getArtifactGroupType());
65 this.setTimeout(a.getTimeout());
66 this.setArtifactVersion(a.getArtifactVersion());
67 this.setArtifactUUID(a.getArtifactUUID());
68 this.setPayloadUpdateDate(a.getPayloadUpdateDate());
69 this.setHeatParamsUpdateDate(a.getHeatParamsUpdateDate());
70 this.setGenerated(a.getGenerated());
71 this.setDuplicated(a.getDuplicated());
72 if (a.getRequiredArtifacts() != null) {
73 this.setRequiredArtifacts(new ArrayList<>(a.getRequiredArtifacts()));
75 if (a.getHeatParameters() != null) {
76 this.setHeatParameters(new ArrayList<>(a.getHeatParameters()));
78 this.setGeneratedFromId(a.getGeneratedFromId());
79 this.setIsFromCsar(a.getIsFromCsar());
80 if (a.getProperties() != null) {
81 this.setProperties(new ArrayList<>(a.getProperties()));
86 public String getArtifactName() {
87 return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
91 public String getArtifactType() {
92 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE);
95 public boolean isHeatEnvType() {
96 return ArtifactTypeEnum.HEAT_ENV.getType().equals(getArtifactType());
99 public void setArtifactType(String artifactType) {
100 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE, artifactType);
104 public String getArtifactRef() {
105 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_REF);
109 public void setArtifactRef(String artifactRef) {
110 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_REF, artifactRef);
113 public String getArtifactRepository() {
114 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_REPOSITORY);
118 public void setArtifactRepository(String artifactRepository) {
119 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_REPOSITORY, artifactRepository);
122 public void setArtifactName(String artifactName) {
123 setToscaPresentationValue(JsonPresentationFields.NAME, artifactName);
127 public String getArtifactChecksum() {
128 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_CHECKSUM);
131 public void setArtifactChecksum(String artifactChecksum) {
132 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_CHECKSUM, artifactChecksum);
135 public String getUserIdCreator() {
137 return (String) getToscaPresentationValue(JsonPresentationFields.USER_ID_CREATOR);
140 public void setUserIdCreator(String userIdCreator) {
141 setToscaPresentationValue(JsonPresentationFields.USER_ID_CREATOR, userIdCreator);
144 public String getUserIdLastUpdater() {
145 return (String) getToscaPresentationValue(JsonPresentationFields.USER_ID_LAST_UPDATER);
148 public void setUserIdLastUpdater(String userIdLastUpdater) {
149 setToscaPresentationValue(JsonPresentationFields.USER_ID_LAST_UPDATER, userIdLastUpdater);
152 public String getCreatorFullName() {
153 return (String) getToscaPresentationValue(JsonPresentationFields.CREATOR_FULL_NAME);
156 public void setCreatorFullName(String creatorFullName) {
157 setToscaPresentationValue(JsonPresentationFields.CREATOR_FULL_NAME, creatorFullName);
160 public String getUpdaterFullName() {
161 return (String) getToscaPresentationValue(JsonPresentationFields.UPDATER_FULL_NAME);
164 public void setUpdaterFullName(String updaterFullName) {
165 setToscaPresentationValue(JsonPresentationFields.UPDATER_FULL_NAME, updaterFullName);
168 public Long getCreationDate() {
169 return (Long) getToscaPresentationValue(JsonPresentationFields.CREATION_DATE);
172 public void setCreationDate(Long creationDate) {
173 setToscaPresentationValue(JsonPresentationFields.CREATION_DATE, creationDate);
176 public Long getLastUpdateDate() {
177 return (Long) getToscaPresentationValue(JsonPresentationFields.LAST_UPDATE_DATE);
180 public void setLastUpdateDate(Long lastUpdateDate) {
181 setToscaPresentationValue(JsonPresentationFields.LAST_UPDATE_DATE, lastUpdateDate);
184 public String getUniqueId() {
185 return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
188 public void setUniqueId(String uniqueId) {
189 setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
192 public String getDescription() {
193 return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
196 public void setDescription(String description) {
197 setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
200 public String getArtifactLabel() {
201 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL);
204 public void setArtifactLabel(String artifactLabel) {
205 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_LABEL, artifactLabel);
208 public String getEsId() {
209 return (String) getToscaPresentationValue(JsonPresentationFields.ES_ID);
212 public boolean hasNoMandatoryEsId() {
213 return getEsId() == null && getMandatory();
216 public void setEsId(String esId) {
217 setToscaPresentationValue(JsonPresentationFields.ES_ID, esId);
220 public String getArtifactCreator() {
221 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_CREATOR);
224 public void setArtifactCreator(String artifactCreator) {
225 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_CREATOR, artifactCreator);
228 public Boolean getMandatory() {
229 Boolean isMandatory = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_ABSTRACT);
230 return isMandatory == null ? Boolean.FALSE : isMandatory;
233 public void setMandatory(Boolean mandatory) {
234 setToscaPresentationValue(JsonPresentationFields.IS_ABSTRACT, mandatory);
237 public String getArtifactDisplayName() {
238 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_DISPLAY_NAME);
241 public void setArtifactDisplayName(String artifactDisplayName) {
242 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_DISPLAY_NAME, artifactDisplayName);
245 public String getApiUrl() {
246 return (String) getToscaPresentationValue(JsonPresentationFields.API_URL);
249 public void setApiUrl(String apiUrl) {
250 setToscaPresentationValue(JsonPresentationFields.API_URL, apiUrl);
253 public Boolean getServiceApi() {
254 Boolean serviceApi = (Boolean) getToscaPresentationValue(JsonPresentationFields.SERVICE_API);
255 return serviceApi == null ? Boolean.FALSE : serviceApi;
258 public void setServiceApi(Boolean serviceApi) {
259 setToscaPresentationValue(JsonPresentationFields.SERVICE_API, serviceApi);
262 public ArtifactGroupTypeEnum getArtifactGroupType() {
263 ArtifactGroupTypeEnum artifactGroupType = null;
264 String groupType = (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_GROUP_TYPE);
265 if (groupType != null && !groupType.isEmpty()) {
266 artifactGroupType = ArtifactGroupTypeEnum.findType(groupType);
268 return artifactGroupType;
271 public void setArtifactGroupType(ArtifactGroupTypeEnum artifactGroupType) {
272 if (artifactGroupType != null) {
273 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_GROUP_TYPE, artifactGroupType.getType());
277 public Integer getTimeout() {
278 return (Integer) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TIMEOUT);
281 public void setTimeout(Integer timeout) {
282 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_TIMEOUT, timeout);
285 public String getArtifactVersion() {
286 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_VERSION);
289 public void setArtifactVersion(String artifactVersion) {
290 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_VERSION, artifactVersion);
293 public String getArtifactUUID() {
294 return (String) getToscaPresentationValue(JsonPresentationFields.ARTIFACT_UUID);
297 public void setArtifactUUID(String artifactUUID) {
298 setToscaPresentationValue(JsonPresentationFields.ARTIFACT_UUID, artifactUUID);
301 public Long getPayloadUpdateDate() {
302 return (Long) getToscaPresentationValue(JsonPresentationFields.PAYLOAD_UPDATE_DATE);
305 public void setPayloadUpdateDate(Long payloadUpdateDate) {
306 setToscaPresentationValue(JsonPresentationFields.PAYLOAD_UPDATE_DATE, payloadUpdateDate);
309 public Long getHeatParamsUpdateDate() {
310 return (Long) getToscaPresentationValue(JsonPresentationFields.HEAT_PARAMS_UPDATE_DATE);
313 public void setHeatParamsUpdateDate(Long heatParamsUpdateDate) {
314 setToscaPresentationValue(JsonPresentationFields.HEAT_PARAMS_UPDATE_DATE, heatParamsUpdateDate);
317 public List<String> getRequiredArtifacts() {
318 return (List<String>) getToscaPresentationValue(JsonPresentationFields.REQUIRED_ARTIFACTS);
321 public void setRequiredArtifacts(List<String> requiredArtifacts) {
322 setToscaPresentationValue(JsonPresentationFields.REQUIRED_ARTIFACTS, requiredArtifacts);
325 public Boolean getGenerated() {
326 Boolean generated = (Boolean) getToscaPresentationValue(JsonPresentationFields.GENERATED);
327 return generated == null ? Boolean.FALSE : generated;
330 public void setGenerated(Boolean generated) {
331 setToscaPresentationValue(JsonPresentationFields.GENERATED, generated);
334 public Boolean getDuplicated() {
335 Boolean duplicated = (Boolean) getToscaPresentationValue(JsonPresentationFields.DUPLICATED);
336 return duplicated == null ? Boolean.FALSE : duplicated;
339 public void setDuplicated(Boolean duplicated) {
340 setToscaPresentationValue(JsonPresentationFields.DUPLICATED, duplicated);
343 public List<HeatParameterDataDefinition> getHeatParameters() {
344 return (List<HeatParameterDataDefinition>) getToscaPresentationValue(JsonPresentationFields.HEAT_PARAMETERS);
347 public void setHeatParameters(List<HeatParameterDataDefinition> properties) {
348 setToscaPresentationValue(JsonPresentationFields.HEAT_PARAMETERS, properties);
351 public String getGeneratedFromId() {
352 return (String) getToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID);
355 public boolean getIsFromCsar() {
356 Boolean isFromCsar = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR);
357 return isFromCsar == null ? Boolean.FALSE : isFromCsar;
360 public void setIsFromCsar(Boolean isFromCsar) {
361 setToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR, isFromCsar);
364 public void setGeneratedFromId(String generatedFromId) {
365 setToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID, generatedFromId);
369 public List<PropertyDataDefinition> getProperties() {
370 return (List<PropertyDataDefinition>) getToscaPresentationValue(JsonPresentationFields.PROPERTIES);
373 public void addProperty(final PropertyDataDefinition property) {
374 List<PropertyDataDefinition> properties = (List<PropertyDataDefinition>) getToscaPresentationValue(JsonPresentationFields.PROPERTIES);
375 if (properties == null) {
376 properties = new ArrayList<>();
377 setProperties(properties);
379 properties.add(property);
382 private void setProperties(final List<PropertyDataDefinition> properties) {
383 setToscaPresentationValue(JsonPresentationFields.PROPERTIES, properties);
387 public String toString() {
388 return "ArtifactDataDefinition [uniqueId=" + getUniqueId() + ", artifactType=" + getArtifactType() + ", artifactRef=" + getArtifactRef() + ", artifactName=" + getArtifactName() + ", artifactRepository=" + getArtifactRepository() + ", artifactChecksum="
389 + getArtifactChecksum() + ", userIdCreator=" + getUserIdCreator() + ", userIdLastUpdater=" + getUserIdLastUpdater() + ", creatorFullName=" + getCreatorFullName() + ", updaterFullName=" + getUpdaterFullName() + ", creationDate=" + getCreationDate()
390 + ", lastUpdateDate=" + getLastUpdateDate() + ", esId=" + getEsId() + ", artifactLabel=" + getArtifactLabel() + ", artifactCreator=" + getArtifactCreator() + ", description=" + getDescription() + ", mandatory=" + getMandatory() + ", artifactDisplayName="
391 + getArtifactDisplayName() + ", apiUrl=" + getApiUrl() + ", serviceApi=" + getServiceApi() + ", artifactGroupType=" + getArtifactGroupType() + ", timeout=" + getTimeout() + ", artifactVersion=" + getArtifactVersion() + ", artifactUUID=" + getArtifactUUID()
392 + ", payloadUpdateDate=" + getPayloadUpdateDate() + ", heatParamsUpdateDate=" + getHeatParamsUpdateDate() + ", requiredArtifacts=" + getRequiredArtifacts() + "]";
396 public int hashCode() {
397 final int prime = 31;
400 String apiUrl = getApiUrl();
401 String artifactChecksum = getArtifactChecksum();
402 String artifactCreator = getArtifactCreator();
403 String artifactDisplayName = getArtifactDisplayName();
404 ArtifactGroupTypeEnum artifactGroupType = getArtifactGroupType();
405 String artifactLabel = getArtifactLabel();
406 String artifactName = getArtifactName();
407 String artifactRef = getArtifactRef();
408 String artifactRepository = getArtifactRepository();
409 String artifactType = getArtifactType();
411 String artifactUUID = getArtifactUUID();
412 String artifactVersion = getArtifactVersion();
413 String userIdCreator = getUserIdCreator();
414 String userIdLastUpdater = getUserIdLastUpdater();
415 Long creationDate = getCreationDate();
417 String creatorFullName = getCreatorFullName();
418 String description = getDescription();
419 String esId = getEsId();
420 Long heatParamsUpdateDate = getHeatParamsUpdateDate();
421 Long lastUpdateDate = getLastUpdateDate();
422 Boolean mandatory = getMandatory();
424 Long payloadUpdateDate = getPayloadUpdateDate();
425 List<String> requiredArtifacts = getRequiredArtifacts();
426 Boolean serviceApi = getServiceApi();
427 Integer timeout = getTimeout();
428 String uniqueId = getUniqueId();
429 String updaterFullName = getUpdaterFullName();
431 result = prime * result + ((apiUrl == null) ? 0 : apiUrl.hashCode());
432 result = prime * result + ((artifactChecksum == null) ? 0 : artifactChecksum.hashCode());
433 result = prime * result + ((artifactCreator == null) ? 0 : artifactCreator.hashCode());
434 result = prime * result + ((artifactDisplayName == null) ? 0 : artifactDisplayName.hashCode());
435 result = prime * result + ((artifactGroupType == null) ? 0 : artifactGroupType.hashCode());
436 result = prime * result + ((artifactLabel == null) ? 0 : artifactLabel.hashCode());
437 result = prime * result + ((artifactName == null) ? 0 : artifactName.hashCode());
438 result = prime * result + ((artifactRef == null) ? 0 : artifactRef.hashCode());
439 result = prime * result + ((artifactRepository == null) ? 0 : artifactRepository.hashCode());
440 result = prime * result + ((artifactType == null) ? 0 : artifactType.hashCode());
441 result = prime * result + ((artifactUUID == null) ? 0 : artifactUUID.hashCode());
442 result = prime * result + ((artifactVersion == null) ? 0 : artifactVersion.hashCode());
443 result = prime * result + ((userIdCreator == null) ? 0 : userIdCreator.hashCode());
444 result = prime * result + ((userIdLastUpdater == null) ? 0 : userIdLastUpdater.hashCode());
445 result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
446 result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode());
447 result = prime * result + ((description == null) ? 0 : description.hashCode());
448 result = prime * result + ((esId == null) ? 0 : esId.hashCode());
449 result = prime * result + ((heatParamsUpdateDate == null) ? 0 : heatParamsUpdateDate.hashCode());
450 result = prime * result + ((lastUpdateDate == null) ? 0 : lastUpdateDate.hashCode());
451 result = prime * result + ((mandatory == null) ? 0 : mandatory.hashCode());
452 result = prime * result + ((payloadUpdateDate == null) ? 0 : payloadUpdateDate.hashCode());
453 result = prime * result + ((requiredArtifacts == null) ? 0 : requiredArtifacts.hashCode());
454 result = prime * result + ((serviceApi == null) ? 0 : serviceApi.hashCode());
455 result = prime * result + ((timeout == null) ? 0 : timeout.hashCode());
456 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
457 result = prime * result + ((updaterFullName == null) ? 0 : updaterFullName.hashCode());
462 public boolean equals(Object obj) {
469 if (getClass() != obj.getClass()) {
472 ArtifactDataDefinition other = (ArtifactDataDefinition) obj;
473 if (getApiUrl() == null) {
474 if (other.getApiUrl() != null) {
477 } else if (!getArtifactRepository().equals(other.getArtifactRepository())) {
480 if (getArtifactName() == null) {
481 if (other.getArtifactName() != null) {
484 } else if (!getArtifactName().equals(other.getArtifactName())) {
487 if (getArtifactType() == null) {
488 if (other.getArtifactType() != null) {
491 } else if (!getArtifactType().equals(other.getArtifactType())) {
494 if (getArtifactUUID() == null) {
495 if (other.getArtifactUUID() != null) {
498 } else if (!getArtifactUUID().equals(other.getArtifactUUID())) {
501 if (getArtifactVersion() == null) {
502 if (other.getArtifactVersion() != null) {
505 } else if (!getArtifactVersion().equals(other.getArtifactVersion())) {
508 if (getUserIdCreator() == null) {
509 if (other.getUserIdCreator() != null) {
512 } else if (!getUserIdCreator().equals(other.getUserIdCreator())) {
515 if (getUserIdLastUpdater() == null) {
516 if (other.getUserIdLastUpdater() != null) {
519 } else if (!getUserIdLastUpdater().equals(other.getUserIdLastUpdater())) {
522 if (getCreationDate() == null) {
523 if (other.getCreationDate() != null) {
526 } else if (!getCreationDate().equals(other.getCreationDate())) {
529 if (getCreatorFullName() == null) {
530 if (other.getCreatorFullName() != null) {
533 } else if (!getCreatorFullName().equals(other.getCreatorFullName())) {
536 if (getDescription() == null) {
537 if (other.getDescription() != null) {
540 } else if (!getDescription().equals(other.getDescription())) {
543 if (getEsId() == null) {
544 if (other.getEsId() != null) {
547 } else if (!getEsId().equals(other.getEsId())) {
550 if (getHeatParamsUpdateDate() == null) {
551 if (other.getHeatParamsUpdateDate() != null) {
554 } else if (!getHeatParamsUpdateDate().equals(other.getHeatParamsUpdateDate())) {
557 if (getLastUpdateDate() == null) {
558 if (other.getLastUpdateDate() != null) {
561 } else if (!getLastUpdateDate().equals(other.getLastUpdateDate())) {
564 if (getMandatory() == null) {
565 if (other.getMandatory() != null) {
568 } else if (!getMandatory().equals(other.getMandatory())) {
571 if (getPayloadUpdateDate() == null) {
572 if (other.getPayloadUpdateDate() != null) {
575 } else if (!getPayloadUpdateDate().equals(other.getPayloadUpdateDate())) {
578 if (getRequiredArtifacts() == null) {
579 if (other.getRequiredArtifacts() != null) {
582 } else if (!getRequiredArtifacts().equals(other.getRequiredArtifacts())) {
585 if (getServiceApi() == null) {
586 if (other.getServiceApi() != null) {
589 } else if (!getServiceApi().equals(other.getServiceApi())) {
592 if (getTimeout() == null) {
593 if (other.getTimeout() != null) {
596 } else if (!getTimeout().equals(other.getTimeout())) {
599 if (getUniqueId() == null) {
600 if (other.getUniqueId() != null) {
603 } else if (!getUniqueId().equals(other.getUniqueId())) {
606 if (getUpdaterFullName() == null) {
607 if (other.getUpdaterFullName() != null) {
610 } else if (!getUpdaterFullName().equals(other.getUpdaterFullName())) {