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 / ComponentDependencyModelEntity.java
1 package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
2
3 import com.datastax.driver.mapping.annotations.*;
4 import org.openecomp.sdc.versioning.dao.types.Version;
5 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
6
7 @Table(keyspace = "dox", name = "vsp_component_dependency_model")
8 public class ComponentDependencyModelEntity implements VersionableEntity {
9
10   public static final String ENTITY_TYPE = "Vendor Software Product Component Dependency Model";
11   @PartitionKey
12   @Column(name = "vsp_id")
13   private String vspId;
14   @PartitionKey(value = 1)
15   @Frozen
16   private Version version;
17   @ClusteringColumn
18   @Column(name = "dependency_id")
19   private String id;
20   @Column(name = "sourcecomponent_id")
21   private String sourceComponentId;
22   @Column(name = "targetcomponent_id")
23   private String targetComponentId;
24   @Column(name = "relation")
25   private String relation;
26
27   /**
28    * Every entity class must have a default constructor according to
29    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
30    * Definition of mapped classes</a>.
31    */
32   public ComponentDependencyModelEntity() {
33     // Don't delete! Default constructor is required by DataStax driver
34   }
35
36   /**
37    * Instantiates a new ComponentDependencyModelEntity entity.
38    *
39    * @param vspId   the vsp id
40    * @param version the version
41    * @param dependencyId      the dependencyId
42    */
43   public ComponentDependencyModelEntity(String vspId, Version version, String dependencyId) {
44     this.vspId = vspId;
45     this.version = version;
46     this.id = dependencyId;
47   }
48
49   @Override
50   public String getEntityType() {
51     return ENTITY_TYPE;
52   }
53
54   @Override
55   public String getFirstClassCitizenId() {
56     return getVspId();
57   }
58
59   @Override
60   public String getId() {
61     return id;
62   }
63
64   @Override
65   public void setId(String id) {
66     this.id = id;
67   }
68
69   @Override
70   public Version getVersion() {
71     return version;
72   }
73
74   @Override
75   public void setVersion(Version version) {
76     this.version = version;
77   }
78
79   public String getVspId() {
80     return vspId;
81   }
82
83   public void setVspId(String vspId) {
84     this.vspId = vspId;
85   }
86
87   public String getTargetComponentId() {
88     return targetComponentId;
89   }
90
91   public void setTargetComponentId(String targetComponentId) {
92     this.targetComponentId = targetComponentId;
93   }
94
95   public String getSourceComponentId() {
96     return sourceComponentId;
97   }
98
99   public void setSourceComponentId(String sourceComponentId) {
100         this.sourceComponentId = sourceComponentId;
101   }
102
103   public String getRelation() {
104     return relation;
105   }
106
107   public void setRelation(String relation) {
108     this.relation = relation;
109   }
110
111   @Override
112   public boolean equals(Object o) {
113     if (this == o) {
114       return true;
115     }
116     if (o == null || getClass() != o.getClass()) {
117       return false;
118     }
119
120     ComponentDependencyModelEntity that = (ComponentDependencyModelEntity) o;
121
122     if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) {
123       return false;
124     }
125     if (version != null ? !version.equals(that.version) : that.version != null) {
126       return false;
127     }
128     if (id != null ? !id.equals(that.id) : that.id != null) {
129       return false;
130     }
131     if (sourceComponentId != null ? !sourceComponentId.equals(that.sourceComponentId)
132         : that.sourceComponentId != null) {
133       return false;
134     }
135     if (targetComponentId != null ? !targetComponentId.equals(that.targetComponentId)
136         : that.targetComponentId != null) {
137       return false;
138     }
139     if (relation != null ? !relation.equals(that.relation) : that.relation != null) {
140       return false;
141     }
142
143     return true;
144   }
145
146   @Override
147   public int hashCode() {
148     int result = vspId != null ? vspId.hashCode() : 0;
149     result = 31 * result + (version != null ? version.hashCode() : 0);
150     result = 31 * result + (id != null ? id.hashCode() : 0);
151     result = 31 * result + (sourceComponentId != null ? sourceComponentId.hashCode() : 0);
152     result = 31 * result + (targetComponentId != null ? targetComponentId.hashCode() : 0);
153     result = 31 * result + (relation != null ? relation.hashCode() : 0);
154     return result;
155   }
156 }