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