re base code
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-license-lib / openecomp-sdc-vendor-license-api / src / main / java / org / openecomp / sdc / vendorlicense / dao / types / FeatureGroupEntity.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.vendorlicense.dao.types;
22
23 import com.datastax.driver.mapping.annotations.ClusteringColumn;
24 import com.datastax.driver.mapping.annotations.Column;
25 import com.datastax.driver.mapping.annotations.Frozen;
26 import com.datastax.driver.mapping.annotations.PartitionKey;
27 import com.datastax.driver.mapping.annotations.Table;
28
29 import org.openecomp.sdc.versioning.dao.types.Version;
30 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
31
32 import java.util.HashSet;
33 import java.util.Objects;
34 import java.util.Set;
35
36 @Table(name = "feature_group", keyspace = "dox")
37 public class FeatureGroupEntity implements VersionableEntity {
38   private static final String ENTITY_TYPE = "Feature Group";
39
40   @PartitionKey
41   @Column(name = "vlm_id")
42   private String vendorLicenseModelId;
43   @PartitionKey(value = 1)
44   @Frozen
45   private Version version;
46   @ClusteringColumn
47   @Column(name = "fg_id")
48   private String id;
49   private String name;
50   private String description;
51   @Column(name = "part_num")
52   private String partNumber;
53   @Column(name = "manufacturer_ref_num")
54   private String manufacturerReferenceNumber;
55   @Column(name = "lkg_ids")
56   private Set<String> licenseKeyGroupIds = new HashSet<>();
57   @Column(name = "ep_ids")
58   private Set<String> entitlementPoolIds = new HashSet<>();
59   @Column(name = "ref_la_ids")
60   private Set<String> referencingLicenseAgreements = new HashSet<>();
61
62   /**
63    * Every entity class must have a default constructor according to
64    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
65    * Definition of mapped classes</a>.
66    */
67   public FeatureGroupEntity() {
68     // Don't delete! Default constructor is required by DataStax driver
69   }
70
71   /**
72    * Instantiates a new Feature group entity.
73    *
74    * @param vendorLicenseModelId the vendor license model id
75    * @param version              the version
76    * @param id                   the id
77    */
78   public FeatureGroupEntity(String vendorLicenseModelId, Version version, String id) {
79     this.vendorLicenseModelId = vendorLicenseModelId;
80     this.version = version;
81     this.id = id;
82   }
83
84   @Override
85   public String getEntityType() {
86     return ENTITY_TYPE;
87   }
88
89   @Override
90   public String getFirstClassCitizenId() {
91     return getVendorLicenseModelId();
92   }
93
94   @Override
95   public String getId() {
96     return id;
97   }
98
99   @Override
100   public void setId(String id) {
101     this.id = id;
102   }
103
104   @Override
105   public Version getVersion() {
106     return version;
107   }
108
109   @Override
110   public void setVersion(Version version) {
111     this.version = version;
112   }
113
114   public String getVendorLicenseModelId() {
115     return vendorLicenseModelId;
116   }
117
118   public void setVendorLicenseModelId(String vendorLicenseModelId) {
119     this.vendorLicenseModelId = vendorLicenseModelId;
120   }
121
122   public String getName() {
123     return name;
124   }
125
126   public void setName(String name) {
127     this.name = name;
128   }
129
130   public String getDescription() {
131     return description;
132   }
133
134   public void setDescription(String description) {
135     this.description = description;
136   }
137
138   public String getPartNumber() {
139     return partNumber;
140   }
141
142   public void setPartNumber(String partNumber) {
143     this.partNumber = partNumber;
144   }
145
146   public String getManufacturerReferenceNumber() {
147     return manufacturerReferenceNumber;
148   }
149
150   public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
151     this.manufacturerReferenceNumber = manufacturerReferenceNumber;
152   }
153
154   public Set<String> getLicenseKeyGroupIds() {
155     return licenseKeyGroupIds;
156   }
157
158   public void setLicenseKeyGroupIds(Set<String> licenseKeyGroupIds) {
159     this.licenseKeyGroupIds = licenseKeyGroupIds;
160   }
161
162   public Set<String> getEntitlementPoolIds() {
163     return entitlementPoolIds;
164   }
165
166   public void setEntitlementPoolIds(Set<String> entitlementPoolIds) {
167     this.entitlementPoolIds = entitlementPoolIds;
168   }
169
170   public Set<String> getReferencingLicenseAgreements() {
171     return referencingLicenseAgreements;
172   }
173
174   public void setReferencingLicenseAgreements(Set<String> referencingLicenseAgreements) {
175     this.referencingLicenseAgreements = referencingLicenseAgreements;
176   }
177
178   @Override
179   public int hashCode() {
180     return Objects
181         .hash(vendorLicenseModelId, version, id, name, description, partNumber,
182         manufacturerReferenceNumber, licenseKeyGroupIds, entitlementPoolIds,
183             referencingLicenseAgreements);
184   }
185
186   @Override
187   public boolean equals(Object obj) {
188     if (this == obj) {
189       return true;
190     }
191     if (obj == null || getClass() != obj.getClass()) {
192       return false;
193     }
194     FeatureGroupEntity that = (FeatureGroupEntity) obj;
195     return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
196         && Objects.equals(version, that.version)
197         && Objects.equals(id, that.id)
198         && Objects.equals(name, that.name)
199         && Objects.equals(description, that.description)
200         && Objects.equals(partNumber, that.partNumber)
201         && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
202         && Objects.equals(licenseKeyGroupIds, that.licenseKeyGroupIds)
203         && Objects.equals(entitlementPoolIds, that.entitlementPoolIds)
204         && Objects.equals(referencingLicenseAgreements, that.referencingLicenseAgreements);
205   }
206
207   @Override
208   public String toString() {
209     return "FeatureGroupEntity{"
210         + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
211         + ", version=" + version
212         + ", id='" + id + '\''
213         + ", name='" + name + '\''
214         + ", description='" + description + '\''
215         + ", partNumber='" + partNumber + '\''
216         + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
217         + ", licenseKeyGroupIds=" + licenseKeyGroupIds
218         + ", entitlementPoolIds=" + entitlementPoolIds
219         + ", referencingLicenseAgreements=" + referencingLicenseAgreements
220         + '}';
221   }
222 }