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