[SDC] Onboarding 1710 rebase.
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-software-product-lib / openecomp-sdc-vendor-software-product-api / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / dao / type / DeploymentFlavorEntity.java
1 package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
2
3 import com.datastax.driver.mapping.annotations.*;
4 import org.openecomp.core.utilities.json.JsonUtil;
5 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
6 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
7 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
8 import org.openecomp.sdc.versioning.dao.types.Version;
9
10 @Table(keyspace = "dox", name = "vsp_deployment_flavor")
11 public class DeploymentFlavorEntity implements CompositionEntity{
12     private static final String ENTITY_TYPE = "Vendor Software Product Deployment Flavor";
13
14     @PartitionKey
15     @Column(name = "vsp_id")
16     private String vspId;
17     @PartitionKey(value = 1)
18     @Frozen
19     private Version version;
20     @ClusteringColumn
21     @Column(name = "deployment_flavor_id")
22     private String id;
23     @Column(name = "composition_data")
24     private String compositionData;
25     @Column(name = "questionnaire_data")
26     private String questionnaireData;
27
28
29     public DeploymentFlavorEntity(){
30
31     }
32
33     /**
34      * Instantiates a new DeploymentFlavor entity.
35      *
36      * @param vspId   the vsp id
37      * @param version the version
38      * @param id      the id
39      */
40     public DeploymentFlavorEntity(String vspId, Version version, String id) {
41         this.vspId = vspId;
42         this.version = version;
43         this.id = id;
44     }
45     @Override
46     public CompositionEntityType getType() {
47         return CompositionEntityType.deployment;
48     }
49
50     @Override
51     public CompositionEntityId getCompositionEntityId() {
52         return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null));
53     }
54
55     @Override
56     public String getCompositionData() {
57         return compositionData;
58     }
59
60     @Override
61     public void setCompositionData(String compositionData) {
62         this.compositionData = compositionData;
63     }
64
65     @Override
66     public String getQuestionnaireData() {
67         return questionnaireData;
68     }
69
70     @Override
71     public void setQuestionnaireData(String questionnaireData) {
72         this.questionnaireData = questionnaireData;
73     }
74
75     public String getVspId() {
76         return vspId;
77     }
78
79     public void setVspId(String vspId) {
80         this.vspId = vspId;
81     }
82
83     @Override
84     public String getEntityType() {
85         return ENTITY_TYPE;
86     }
87
88     @Override
89     public String getFirstClassCitizenId() {
90         return getVspId();
91     }
92
93     @Override
94     public String getId() {
95         return id;
96     }
97
98     @Override
99     public void setId(String id) {
100         this.id = id;
101     }
102
103     @Override
104     public Version getVersion() {
105         return version;
106     }
107
108     @Override
109     public void setVersion(Version version) {
110         this.version = version;
111     }
112
113    public DeploymentFlavor getDeploymentFlavorCompositionData() {
114         return compositionData == null ? null : JsonUtil.json2Object(compositionData, DeploymentFlavor.class);
115     }
116
117     public void setDeploymentFlavorCompositionData(DeploymentFlavor deploymentFlavor) {
118         this.compositionData = deploymentFlavor == null ? null : JsonUtil.object2Json(deploymentFlavor);
119     }
120
121     @Override
122     public int hashCode() {
123         int result = vspId != null ? vspId.hashCode() : 0;
124         result = 31 * result + (version != null ? version.hashCode() : 0);
125         result = 31 * result + (id != null ? id.hashCode() : 0);
126         result = 31 * result + (compositionData != null ? compositionData.hashCode() : 0);
127         result = 31 * result + (questionnaireData != null ? questionnaireData.hashCode() : 0);
128         return result;
129     }
130
131     @Override
132     public boolean equals(Object object) {
133         if (this == object) {
134             return true;
135         }
136         if (object == null || getClass() != object.getClass()) {
137             return false;
138         }
139
140         DeploymentFlavorEntity that = (DeploymentFlavorEntity) object;
141
142         if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) {
143             return false;
144         }
145         if (version != null ? !version.equals(that.version) : that.version != null) {
146             return false;
147         }
148         if (id != null ? !id.equals(that.id) : that.id != null) {
149             return false;
150         }
151         if (compositionData != null ? !compositionData.equals(that.compositionData)
152                 : that.compositionData != null) {
153             return false;
154         }
155         return questionnaireData != null ? questionnaireData.equals(that.questionnaireData)
156                 : that.questionnaireData == null;
157
158     }
159 }