2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.vendorlicense.dao.types;
23 import com.datastax.driver.mapping.annotations.ClusteringColumn;
24 import com.datastax.driver.mapping.annotations.Column;
25 import com.datastax.driver.mapping.annotations.Enumerated;
26 import com.datastax.driver.mapping.annotations.Frozen;
27 import com.datastax.driver.mapping.annotations.PartitionKey;
28 import com.datastax.driver.mapping.annotations.Table;
29 import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml;
30 import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml;
31 import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml;
32 import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml;
33 import org.openecomp.sdc.versioning.dao.types.Version;
34 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
36 import java.util.HashSet;
37 import java.util.Objects;
40 @Table(keyspace = "dox", name = "entitlement_pool")
41 public class EntitlementPoolEntity implements VersionableEntity {
42 private static final String ENTITY_TYPE = "Entitlement Pool";
45 @Column(name = "vlm_id")
46 private String vendorLicenseModelId;
48 @PartitionKey(value = 1)
50 private Version version;
53 @Column(name = "ep_id")
56 private String description;
58 @Column(name = "threshold")
59 private int thresholdValue;
61 @Column(name = "threshold_unit")
63 private ThresholdUnit thresholdUnit;
65 @Column(name = "entitlement_metric")
67 private ChoiceOrOther<EntitlementMetric> entitlementMetric;
68 private String increments;
70 @Column(name = "aggregation_func")
72 private ChoiceOrOther<AggregationFunction> aggregationFunction;
74 @Column(name = "operational_scope")
76 private MultiChoiceOrOther<OperationalScope> operationalScope;
79 private ChoiceOrOther<EntitlementTime> time;
81 @Column(name = "manufacturer_ref_num")
82 private String manufacturerReferenceNumber;
84 @Column(name = "ref_fg_ids")
85 private Set<String> referencingFeatureGroups = new HashSet<>();
87 @Column(name = "version_uuid")
88 private String versionUuId;
90 public EntitlementPoolEntity() {
94 * Instantiates a new Entitlement pool entity.
96 * @param vlmId the vlm id
97 * @param version the version
100 public EntitlementPoolEntity(String vlmId, Version version, String id) {
101 this.vendorLicenseModelId = vlmId;
102 this.version = version;
107 public String getEntityType() {
112 public String getFirstClassCitizenId() {
113 return getVendorLicenseModelId();
117 public String getId() {
122 public void setId(String id) {
127 public Version getVersion() {
132 public void setVersion(Version version) {
133 this.version = version;
137 public String getVersionUuId() {
142 public void setVersionUuId(String uuId) {
146 public String getVendorLicenseModelId() {
147 return vendorLicenseModelId;
150 public void setVendorLicenseModelId(String vendorLicenseModelId) {
151 this.vendorLicenseModelId = vendorLicenseModelId;
154 public Set<String> getReferencingFeatureGroups() {
155 return referencingFeatureGroups;
158 public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) {
159 this.referencingFeatureGroups = referencingFeatureGroups;
162 public String getName() {
166 public void setName(String name) {
170 public String getDescription() {
174 public void setDescription(String description) {
175 this.description = description;
178 public int getThresholdValue() {
179 return thresholdValue;
182 public void setThresholdValue(int thresholdValue) {
183 this.thresholdValue = thresholdValue;
186 public ThresholdUnit getThresholdUnit() {
187 return thresholdUnit;
190 public void setThresholdUnit(ThresholdUnit thresholdUnits) {
191 this.thresholdUnit = thresholdUnits;
194 public ChoiceOrOther<EntitlementMetric> getEntitlementMetric() {
195 return entitlementMetric;
198 public void setEntitlementMetric(ChoiceOrOther<EntitlementMetric> entitlementMetric) {
199 entitlementMetric.resolveEnum(EntitlementMetric.class);
200 this.entitlementMetric = entitlementMetric;
203 public String getIncrements() {
207 public void setIncrements(String increments) {
208 this.increments = increments;
211 public ChoiceOrOther<AggregationFunction> getAggregationFunction() {
212 return aggregationFunction;
215 public void setAggregationFunction(ChoiceOrOther<AggregationFunction> aggregationFunction) {
216 aggregationFunction.resolveEnum(AggregationFunction.class);
217 this.aggregationFunction = aggregationFunction;
220 public MultiChoiceOrOther<OperationalScope> getOperationalScope() {
221 return operationalScope;
224 public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
225 operationalScope.resolveEnum(OperationalScope.class);
226 this.operationalScope = operationalScope;
229 public ChoiceOrOther<EntitlementTime> getTime() {
233 public void setTime(ChoiceOrOther<EntitlementTime> time) {
234 time.resolveEnum(EntitlementTime.class);
238 public String getManufacturerReferenceNumber() {
239 return manufacturerReferenceNumber;
242 public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
243 this.manufacturerReferenceNumber = manufacturerReferenceNumber;
247 * Gets threshold for artifact.
249 * @return the threshold for artifact
251 public ThresholdForXml getThresholdForArtifact() {
252 ThresholdForXml threshold = new ThresholdForXml();
253 threshold.setUnit(getThresholdUnit() == null ? null : getThresholdUnit().name());
254 threshold.setValue(getThresholdValue());
259 * Gets version for artifact.
260 * @return version in format suitable for artifact
262 public String getVersionForArtifact() {
263 return version.toString();
267 * Gets entitlement metric for artifact.
269 * @return the entitlement metric for artifact
271 public EntitlementMetricForXml getEntitlementMetricForArtifact() {
272 EntitlementMetricForXml metric = new EntitlementMetricForXml();
273 if (entitlementMetric != null) {
274 metric.setValue(entitlementMetric.getResult());
276 metric.setValue(null);
282 * Gets time for artifact.
284 * @return the time for artifact
286 public EntitlementTimeForXml getTimeForArtifact() {
287 EntitlementTimeForXml timeForXml = new EntitlementTimeForXml();
289 timeForXml.setValue(time.getResult());
296 public int hashCode() {
298 .hash(vendorLicenseModelId, version, id, name, description, thresholdValue, thresholdUnit,
299 entitlementMetric, increments, aggregationFunction, operationalScope, time,
300 manufacturerReferenceNumber, referencingFeatureGroups);
304 public boolean equals(Object obj) {
308 if (obj == null || getClass() != obj.getClass()) {
311 EntitlementPoolEntity that = (EntitlementPoolEntity) obj;
312 return Float.compare(that.thresholdValue, thresholdValue) == 0
313 && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
314 && Objects.equals(id, that.id)
315 && Objects.equals(name, that.name)
316 && Objects.equals(description, that.description)
317 && Objects.equals(thresholdUnit, that.thresholdUnit)
318 && Objects.equals(entitlementMetric, that.entitlementMetric)
319 && Objects.equals(increments, that.increments)
320 && Objects.equals(aggregationFunction, that.aggregationFunction)
321 && Objects.equals(operationalScope, that.operationalScope)
322 && Objects.equals(time, that.time)
323 && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
324 && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups);
328 public String toString() {
329 return "EntitlementPoolEntity{"
330 + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
331 + ", version=" + version
332 + ", id='" + id + '\''
333 + ", name='" + name + '\''
334 + ", description='" + description + '\''
335 + ", thresholdValue=" + thresholdValue
336 + ", thresholdUnit='" + thresholdUnit + '\''
337 + ", entitlementMetric=" + entitlementMetric
338 + ", increments='" + increments + '\''
339 + ", aggregationFunction=" + aggregationFunction
340 + ", operationalScope=" + operationalScope
342 + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
343 + ", referencingFeatureGroups=" + referencingFeatureGroups
344 + ", version_uuid=" + versionUuId
349 * Gets aggregation function for artifact.
351 * @return the aggregation function for artifact
353 public AggregationFunctionForXml getAggregationFunctionForArtifact() {
354 AggregationFunctionForXml aggregationFunctionForXml = new AggregationFunctionForXml();
355 if (entitlementMetric != null) {
356 aggregationFunctionForXml.setValue(aggregationFunction.getResult());
358 aggregationFunctionForXml.setValue(null);
360 return aggregationFunctionForXml;
364 * Gets operational scope for artifact.
366 * @return the operational scope for artifact
368 public Set<String> getOperationalScopeForArtifact() {
369 if (operationalScope != null) {
370 return operationalScope.getResults();