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