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;
59 @Column(name = "threshold")
60 private int thresholdValue;
62 @Column(name = "threshold_unit")
64 private ThresholdUnit thresholdUnit;
66 @Column(name = "entitlement_metric")
68 private ChoiceOrOther<EntitlementMetric> entitlementMetric;
69 private String increments;
71 @Column(name = "aggregation_func")
73 private ChoiceOrOther<AggregationFunction> aggregationFunction;
75 @Column(name = "operational_scope")
77 private MultiChoiceOrOther<OperationalScope> operationalScope;
80 private ChoiceOrOther<EntitlementTime> time;
82 @Column(name = "manufacturer_ref_num")
83 private String manufacturerReferenceNumber;
85 @Column(name = "ref_fg_ids")
86 private Set<String> referencingFeatureGroups = new HashSet<>();
88 @Column(name = "version_uuid")
89 private String versionUuId;
91 public EntitlementPoolEntity() {
95 * Instantiates a new Entitlement pool entity.
97 * @param vlmId the vlm id
98 * @param version the version
101 public EntitlementPoolEntity(String vlmId, Version version, String id) {
102 this.vendorLicenseModelId = vlmId;
103 this.version = version;
108 public String getEntityType() {
113 public String getFirstClassCitizenId() {
114 return getVendorLicenseModelId();
117 public String getVendorLicenseModelId() {
118 return vendorLicenseModelId;
121 public void setVendorLicenseModelId(String vendorLicenseModelId) {
122 this.vendorLicenseModelId = vendorLicenseModelId;
126 public String getId() {
131 public void setId(String id) {
136 public Version getVersion() {
141 public void setVersion(Version version) {
142 this.version = version;
145 public Set<String> getReferencingFeatureGroups() {
146 return referencingFeatureGroups;
149 public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) {
150 this.referencingFeatureGroups = referencingFeatureGroups;
153 public String getName() {
157 public void setName(String name) {
161 public String getDescription() {
165 public void setDescription(String description) {
166 this.description = description;
169 public int getThresholdValue() {
170 return thresholdValue;
173 public void setThresholdValue(int thresholdValue) {
174 this.thresholdValue = thresholdValue;
177 public ThresholdUnit getThresholdUnit() {
178 return thresholdUnit;
181 public void setThresholdUnit(ThresholdUnit thresholdUnits) {
182 this.thresholdUnit = thresholdUnits;
185 public ChoiceOrOther<EntitlementMetric> getEntitlementMetric() {
186 return entitlementMetric;
189 public void setEntitlementMetric(ChoiceOrOther<EntitlementMetric> entitlementMetric) {
190 entitlementMetric.resolveEnum(EntitlementMetric.class);
191 this.entitlementMetric = entitlementMetric;
194 public String getIncrements() {
198 public void setIncrements(String increments) {
199 this.increments = increments;
202 public ChoiceOrOther<AggregationFunction> getAggregationFunction() {
203 return aggregationFunction;
206 public void setAggregationFunction(ChoiceOrOther<AggregationFunction> aggregationFunction) {
207 aggregationFunction.resolveEnum(AggregationFunction.class);
208 this.aggregationFunction = aggregationFunction;
211 public MultiChoiceOrOther<OperationalScope> getOperationalScope() {
212 return operationalScope;
215 public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
216 operationalScope.resolveEnum(OperationalScope.class);
217 this.operationalScope = operationalScope;
220 public ChoiceOrOther<EntitlementTime> getTime() {
224 public void setTime(ChoiceOrOther<EntitlementTime> time) {
225 time.resolveEnum(EntitlementTime.class);
229 public String getManufacturerReferenceNumber() {
230 return manufacturerReferenceNumber;
233 public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
234 this.manufacturerReferenceNumber = manufacturerReferenceNumber;
239 * Gets threshold for artifact.
241 * @return the threshold for artifact
243 //util methods for XML
244 public ThresholdForXml getThresholdForArtifact() {
245 ThresholdForXml threshold = new ThresholdForXml();
246 threshold.setUnit(getThresholdUnit() == null ? null : getThresholdUnit().name());
247 threshold.setValue(getThresholdValue());
252 * Gets entitlement metric for artifact.
254 * @return the entitlement metric for artifact
256 public EntitlementMetricForXml getEntitlementMetricForArtifact() {
257 EntitlementMetricForXml metric = new EntitlementMetricForXml();
258 if (entitlementMetric != null) {
259 metric.setValue(entitlementMetric.getResult());
261 metric.setValue(null);
267 * Gets time for artifact.
269 * @return the time for artifact
271 public EntitlementTimeForXml getTimeForArtifact() {
272 EntitlementTimeForXml timeForXml = new EntitlementTimeForXml();
274 timeForXml.setValue(time.getResult());
282 public String toString() {
283 return "EntitlementPoolEntity{"
284 + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
285 + ", version=" + version
286 + ", id='" + id + '\''
287 + ", name='" + name + '\''
288 + ", description='" + description + '\''
289 + ", thresholdValue=" + thresholdValue
290 + ", thresholdUnit='" + thresholdUnit + '\''
291 + ", entitlementMetric=" + entitlementMetric
292 + ", increments='" + increments + '\''
293 + ", aggregationFunction=" + aggregationFunction
294 + ", operationalScope=" + operationalScope
296 + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
297 + ", referencingFeatureGroups=" + referencingFeatureGroups
298 + ", version_uuid=" + versionUuId
303 public boolean equals(Object obj) {
307 if (obj == null || getClass() != obj.getClass()) {
310 EntitlementPoolEntity that = (EntitlementPoolEntity) obj;
311 return Float.compare(that.thresholdValue, thresholdValue) == 0
312 && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
313 && Objects.equals(version, that.version)
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 int hashCode() {
330 .hash(vendorLicenseModelId, version, id, name, description, thresholdValue, thresholdUnit,
331 entitlementMetric, increments, aggregationFunction, operationalScope, time,
332 manufacturerReferenceNumber, referencingFeatureGroups);
336 * Gets aggregation function for artifact.
338 * @return the aggregation function for artifact
340 public AggregationFunctionForXml getAggregationFunctionForArtifact() {
341 AggregationFunctionForXml aggregationFunctionForXml = new AggregationFunctionForXml();
342 if (entitlementMetric != null) {
343 aggregationFunctionForXml.setValue(aggregationFunction.getResult());
345 aggregationFunctionForXml.setValue(null);
347 return aggregationFunctionForXml;
351 * Gets operational scope for artifact.
353 * @return the operational scope for artifact
355 public Set<String> getOperationalScopeForArtifact() {
356 if (operationalScope != null) {
357 return operationalScope.getResults();
363 public String getVersionUuId() {
367 public void setVersionUuId(String uuId) {