37077a7169cac3b77eeca71ba5af43bc3474c3cd
[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
21 package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
22
23 import com.datastax.driver.mapping.annotations.ClusteringColumn;
24 import com.datastax.driver.mapping.annotations.Column;
25 import com.datastax.driver.mapping.annotations.Enumerated;
26 import com.datastax.driver.mapping.annotations.Frozen;
27 import com.datastax.driver.mapping.annotations.PartitionKey;
28 import com.datastax.driver.mapping.annotations.Table;
29 import org.openecomp.sdc.versioning.dao.types.Version;
30 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
31
32 import java.nio.ByteBuffer;
33
34 @Table(keyspace = "dox", name = "vsp_process")
35 public class ProcessEntity implements VersionableEntity {
36   public static final String ENTITY_TYPE = "Vendor Software Product Process";
37   @PartitionKey
38   @Column(name = "vsp_id")
39   private String vspId;
40   @PartitionKey(value = 1)
41   @Frozen
42   private Version version;
43   @ClusteringColumn
44   @Column(name = "component_id")
45   private String componentId;
46   @ClusteringColumn(value = 1)
47   @Column(name = "process_id")
48   private String id;
49   private String name;
50   private String description;
51   @Column(name = "type")
52   @Enumerated
53   private ProcessType type;
54   @Column(name = "artifact_name")
55   private String artifactName;
56   private ByteBuffer artifact;
57
58   /**
59    * Every entity class must have a default constructor according to
60    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
61    * Definition of mapped classes</a>.
62    */
63   public ProcessEntity() {
64     // Don't delete! Default constructor is required by DataStax driver
65   }
66
67   /**
68    * Instantiates a new Process entity.
69    *
70    * @param vspId       the vsp id
71    * @param version     the version
72    * @param componentId the component id
73    * @param id          the id
74    */
75   public ProcessEntity(String vspId, Version version, String componentId, String id) {
76     this.vspId = vspId;
77     this.version = version;
78     this.componentId = componentId;
79     this.id = id;
80   }
81
82   public String getVspId() {
83     return vspId;
84   }
85
86   public void setVspId(String vspId) {
87     this.vspId = vspId;
88   }
89
90   public String getComponentId() {
91     return componentId;
92   }
93
94   public void setComponentId(String componentId) {
95     this.componentId = componentId;
96   }
97
98   @Override
99   public String getEntityType() {
100     return ENTITY_TYPE;
101   }
102
103   @Override
104   public String getFirstClassCitizenId() {
105     return getVspId();
106   }
107
108   public String getId() {
109     return id;
110   }
111
112   public void setId(String id) {
113     this.id = id;
114   }
115
116   public Version getVersion() {
117     return version;
118   }
119
120   public void setVersion(Version version) {
121     this.version = version;
122   }
123
124   public String getName() {
125     return name == null ? "" : name;
126   }
127
128   public void setName(String name) {
129     this.name = name;
130   }
131
132   public String getDescription() {
133     return description;
134   }
135
136   public void setDescription(String description) {
137     this.description = description;
138   }
139
140   public ProcessType getType() {
141     return type;
142   }
143
144   public void setType(ProcessType type) {
145     this.type = type;
146   }
147
148   public String getArtifactName() {
149     return artifactName;
150   }
151
152   public void setArtifactName(String artifactName) {
153     this.artifactName = artifactName;
154   }
155
156   public ByteBuffer getArtifact() {
157     return artifact;
158   }
159
160   public void setArtifact(ByteBuffer artifact) {
161     this.artifact = artifact;
162   }
163
164   @Override
165   public boolean equals(Object other) {
166     if (this == other) {
167       return true;
168     }
169     if (other == null || getClass() != other.getClass()) {
170       return false;
171     }
172
173     ProcessEntity that = (ProcessEntity) other;
174
175     if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) {
176       return false;
177     }
178     if (version != null ? !version.equals(that.version) : that.version != null) {
179       return false;
180     }
181     if (componentId != null ? !componentId.equals(that.componentId) : that.componentId != null) {
182       return false;
183     }
184     if (id != null ? !id.equals(that.id) : that.id != null) {
185       return false;
186     }
187     if (name != null ? !name.equals(that.name) : that.name != null) {
188       return false;
189     }
190     if (description != null ? !description.equals(that.description) : that.description != null) {
191       return false;
192     }
193     if (artifactName != null ? !artifactName.equals(that.artifactName)
194         : that.artifactName != null) {
195       return false;
196     }
197     if (artifact != null ? !artifact.equals(that.artifact) : that.artifact != null) {
198       return false;
199     }
200
201     if (type != null ? !type.equals(that.type) : that.type != null) {
202       return false;
203     }
204
205     return true;
206   }
207
208   @Override
209   public int hashCode() {
210     int result = vspId != null ? vspId.hashCode() : 0;
211     result = 31 * result + (version != null ? version.hashCode() : 0);
212     result = 31 * result + (componentId != null ? componentId.hashCode() : 0);
213     result = 31 * result + (id != null ? id.hashCode() : 0);
214     result = 31 * result + (name != null ? name.hashCode() : 0);
215     result = 31 * result + (description != null ? description.hashCode() : 0);
216     result = 31 * result + (type != null ? type.hashCode() : 0);
217     result = 31 * result + (artifactName != null ? artifactName.hashCode() : 0);
218     result = 31 * result + (artifact != null ? artifact.hashCode() : 0);
219     return result;
220   }
221
222   @Override
223   public String toString() {
224     return "ProcessEntity{" +
225         "vspId='" + vspId + '\'' +
226         ", version=" + version +
227         ", componentId='" + componentId + '\'' +
228         ", id='" + id + '\'' +
229         ", name='" + name + '\'' +
230         ", description='" + description + '\'' +
231         ", type=" + type +
232         ", artifactName='" + artifactName + '\'' +
233         '}';
234   }
235 }