[SDC] Onboarding 1710 rebase.
[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 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   public FeatureGroupEntity() {
62   }
63
64   /**
65    * Instantiates a new Feature group entity.
66    *
67    * @param vendorLicenseModelId the vendor license model id
68    * @param version              the version
69    * @param id                   the id
70    */
71   public FeatureGroupEntity(String vendorLicenseModelId, Version version, String id) {
72     this.vendorLicenseModelId = vendorLicenseModelId;
73     this.version = version;
74     this.id = id;
75   }
76
77   @Override
78   public String getEntityType() {
79     return ENTITY_TYPE;
80   }
81
82   @Override
83   public String getFirstClassCitizenId() {
84     return getVendorLicenseModelId();
85   }
86
87   @Override
88   public String getId() {
89     return id;
90   }
91
92   @Override
93   public void setId(String id) {
94     this.id = id;
95   }
96
97   @Override
98   public Version getVersion() {
99     return version;
100   }
101
102   @Override
103   public void setVersion(Version version) {
104     this.version = version;
105   }
106
107   public String getVendorLicenseModelId() {
108     return vendorLicenseModelId;
109   }
110
111   public void setVendorLicenseModelId(String vendorLicenseModelId) {
112     this.vendorLicenseModelId = vendorLicenseModelId;
113   }
114
115   public String getName() {
116     return name;
117   }
118
119   public void setName(String name) {
120     this.name = name;
121   }
122
123   public String getDescription() {
124     return description;
125   }
126
127   public void setDescription(String description) {
128     this.description = description;
129   }
130
131   public String getPartNumber() {
132     return partNumber;
133   }
134
135   public void setPartNumber(String partNumber) {
136     this.partNumber = partNumber;
137   }
138
139   public String getManufacturerReferenceNumber() {
140     return manufacturerReferenceNumber;
141   }
142
143   public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
144     this.manufacturerReferenceNumber = manufacturerReferenceNumber;
145   }
146
147   public Set<String> getLicenseKeyGroupIds() {
148     return licenseKeyGroupIds;
149   }
150
151   public void setLicenseKeyGroupIds(Set<String> licenseKeyGroupIds) {
152     this.licenseKeyGroupIds = licenseKeyGroupIds;
153   }
154
155   public Set<String> getEntitlementPoolIds() {
156     return entitlementPoolIds;
157   }
158
159   public void setEntitlementPoolIds(Set<String> entitlementPoolIds) {
160     this.entitlementPoolIds = entitlementPoolIds;
161   }
162
163   public Set<String> getReferencingLicenseAgreements() {
164     return referencingLicenseAgreements;
165   }
166
167   public void setReferencingLicenseAgreements(Set<String> referencingLicenseAgreements) {
168     this.referencingLicenseAgreements = referencingLicenseAgreements;
169   }
170
171   @Override
172   public int hashCode() {
173     return Objects
174         .hash(vendorLicenseModelId, version, id, name, description, partNumber,
175         manufacturerReferenceNumber, licenseKeyGroupIds, entitlementPoolIds,
176             referencingLicenseAgreements);
177   }
178
179   @Override
180   public boolean equals(Object obj) {
181     if (this == obj) {
182       return true;
183     }
184     if (obj == null || getClass() != obj.getClass()) {
185       return false;
186     }
187     FeatureGroupEntity that = (FeatureGroupEntity) obj;
188     return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
189         && Objects.equals(version, that.version)
190         && Objects.equals(id, that.id)
191         && Objects.equals(name, that.name)
192         && Objects.equals(description, that.description)
193         && Objects.equals(partNumber, that.partNumber)
194         && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
195         && Objects.equals(licenseKeyGroupIds, that.licenseKeyGroupIds)
196         && Objects.equals(entitlementPoolIds, that.entitlementPoolIds)
197         && Objects.equals(referencingLicenseAgreements, that.referencingLicenseAgreements);
198   }
199
200   @Override
201   public String toString() {
202     return "FeatureGroupEntity{"
203         + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
204         + ", version=" + version
205         + ", id='" + id + '\''
206         + ", name='" + name + '\''
207         + ", description='" + description + '\''
208         + ", partNumber='" + partNumber + '\''
209         + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
210         + ", licenseKeyGroupIds=" + licenseKeyGroupIds
211         + ", entitlementPoolIds=" + entitlementPoolIds
212         + ", referencingLicenseAgreements=" + referencingLicenseAgreements
213         + '}';
214   }
215 }