[SDC-29] Amdocs OnBoard 1707 initial commit.
[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.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   public ProcessEntity() {
59
60   }
61
62   /**
63    * Instantiates a new Process entity.
64    *
65    * @param vspId       the vsp id
66    * @param version     the version
67    * @param componentId the component id
68    * @param id          the id
69    */
70   public ProcessEntity(String vspId, Version version, String componentId, String id) {
71     this.vspId = vspId;
72     this.version = version;
73     this.componentId = componentId;
74     this.id = id;
75   }
76
77   public String getVspId() {
78     return vspId;
79   }
80
81   public void setVspId(String vspId) {
82     this.vspId = vspId;
83   }
84
85   public String getComponentId() {
86     return componentId;
87   }
88
89   public void setComponentId(String componentId) {
90     this.componentId = componentId;
91   }
92
93   @Override
94   public String getEntityType() {
95     return ENTITY_TYPE;
96   }
97
98   @Override
99   public String getFirstClassCitizenId() {
100     return getVspId();
101   }
102
103   public String getId() {
104     return id;
105   }
106
107   public void setId(String id) {
108     this.id = id;
109   }
110
111   public Version getVersion() {
112     return version;
113   }
114
115   public void setVersion(Version version) {
116     this.version = version;
117   }
118
119   public String getName() {
120     return name == null ? "" : name;
121   }
122
123   public void setName(String name) {
124     this.name = name;
125   }
126
127   public String getDescription() {
128     return description;
129   }
130
131   public void setDescription(String description) {
132     this.description = description;
133   }
134
135   public ProcessType getType() {
136     return type;
137   }
138
139   public void setType(ProcessType type) {
140     this.type = type;
141   }
142
143   public String getArtifactName() {
144     return artifactName;
145   }
146
147   public void setArtifactName(String artifactName) {
148     this.artifactName = artifactName;
149   }
150
151   public ByteBuffer getArtifact() {
152     return artifact;
153   }
154
155   public void setArtifact(ByteBuffer artifact) {
156     this.artifact = artifact;
157   }
158
159   @Override
160   public boolean equals(Object other) {
161     if (this == other) {
162       return true;
163     }
164     if (other == null || getClass() != other.getClass()) {
165       return false;
166     }
167
168     ProcessEntity that = (ProcessEntity) other;
169
170     if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) {
171       return false;
172     }
173     if (version != null ? !version.equals(that.version) : that.version != null) {
174       return false;
175     }
176     if (componentId != null ? !componentId.equals(that.componentId) : that.componentId != null) {
177       return false;
178     }
179     if (id != null ? !id.equals(that.id) : that.id != null) {
180       return false;
181     }
182     if (name != null ? !name.equals(that.name) : that.name != null) {
183       return false;
184     }
185     if (description != null ? !description.equals(that.description) : that.description != null) {
186       return false;
187     }
188     if (artifactName != null ? !artifactName.equals(that.artifactName)
189         : that.artifactName != null) {
190       return false;
191     }
192     if (artifact != null ? !artifact.equals(that.artifact) : that.artifact != null) {
193       return false;
194     }
195
196     if (type != null ? !type.equals(that.type) : that.type != null) {
197       return false;
198     }
199
200     return true;
201   }
202
203   @Override
204   public int hashCode() {
205     int result = vspId != null ? vspId.hashCode() : 0;
206     result = 31 * result + (version != null ? version.hashCode() : 0);
207     result = 31 * result + (componentId != null ? componentId.hashCode() : 0);
208     result = 31 * result + (id != null ? id.hashCode() : 0);
209     result = 31 * result + (name != null ? name.hashCode() : 0);
210     result = 31 * result + (description != null ? description.hashCode() : 0);
211     result = 31 * result + (type != null ? type.hashCode() : 0);
212     result = 31 * result + (artifactName != null ? artifactName.hashCode() : 0);
213     result = 31 * result + (artifact != null ? artifact.hashCode() : 0);
214     return result;
215   }
216
217   @Override
218   public String toString() {
219     return "ProcessEntity{" +
220         "vspId='" + vspId + '\'' +
221         ", version=" + version +
222         ", componentId='" + componentId + '\'' +
223         ", id='" + id + '\'' +
224         ", name='" + name + '\'' +
225         ", description='" + description + '\'' +
226         ", type=" + type +
227         ", artifactName='" + artifactName + '\'' +
228         '}';
229   }
230 }