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