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