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