28a84e0a4ffc413b26e9fc8b5fac5be4277dd0a5
[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   public ComponentDependencyModelEntity() {
32
33   }
34
35   /**
36    * Instantiates a new ComponentDependencyModelEntity entity.
37    *
38    * @param vspId   the vsp id
39    * @param version the version
40    * @param dependencyId      the dependencyId
41    */
42   public ComponentDependencyModelEntity(String vspId, Version version, String dependencyId) {
43     this.vspId = vspId;
44     this.version = version;
45     this.id = dependencyId;
46   }
47
48   @Override
49   public String getEntityType() {
50     return ENTITY_TYPE;
51   }
52
53   @Override
54   public String getFirstClassCitizenId() {
55     return getVspId();
56   }
57
58   @Override
59   public String getId() {
60     return id;
61   }
62
63   @Override
64   public void setId(String id) {
65     this.id = id;
66   }
67
68   @Override
69   public Version getVersion() {
70     return version;
71   }
72
73   @Override
74   public void setVersion(Version version) {
75     this.version = version;
76   }
77
78   public String getVspId() {
79     return vspId;
80   }
81
82   public void setVspId(String vspId) {
83     this.vspId = vspId;
84   }
85
86   public String getTargetComponentId() {
87     return targetComponentId;
88   }
89
90   public void setTargetComponentId(String targetComponentId) {
91     this.targetComponentId = targetComponentId;
92   }
93
94   public String getSourceComponentId() {
95     return sourceComponentId;
96   }
97
98   public void setSourceComponentId(String sourceComponentId) {
99         this.sourceComponentId = sourceComponentId;
100   }
101
102   public String getRelation() {
103     return relation;
104   }
105
106   public void setRelation(String relation) {
107     this.relation = relation;
108   }
109
110   @Override
111   public boolean equals(Object o) {
112     if (this == o) {
113       return true;
114     }
115     if (o == null || getClass() != o.getClass()) {
116       return false;
117     }
118
119     ComponentDependencyModelEntity that = (ComponentDependencyModelEntity) o;
120
121     if (vspId != null ? !vspId.equals(that.vspId) : that.vspId != null) {
122       return false;
123     }
124     if (version != null ? !version.equals(that.version) : that.version != null) {
125       return false;
126     }
127     if (id != null ? !id.equals(that.id) : that.id != null) {
128       return false;
129     }
130     if (sourceComponentId != null ? !sourceComponentId.equals(that.sourceComponentId)
131         : that.sourceComponentId != null) {
132       return false;
133     }
134     if (targetComponentId != null ? !targetComponentId.equals(that.targetComponentId)
135         : that.targetComponentId != null) {
136       return false;
137     }
138     if (relation != null ? !relation.equals(that.relation) : that.relation != null) {
139       return false;
140     }
141
142     return true;
143   }
144
145   @Override
146   public int hashCode() {
147     int result = vspId != null ? vspId.hashCode() : 0;
148     result = 31 * result + (version != null ? version.hashCode() : 0);
149     result = 31 * result + (id != null ? id.hashCode() : 0);
150     result = 31 * result + (sourceComponentId != null ? sourceComponentId.hashCode() : 0);
151     result = 31 * result + (targetComponentId != null ? targetComponentId.hashCode() : 0);
152     result = 31 * result + (relation != null ? relation.hashCode() : 0);
153     return result;
154   }
155 }