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