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.LicenseKeyTypeForXml;
30 import org.openecomp.sdc.versioning.dao.types.Version;
31 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
33 import java.util.HashSet;
34 import java.util.Objects;
37 @Table(keyspace = "dox", name = "license_key_group")
38 public class LicenseKeyGroupEntity implements VersionableEntity {
39 private static final String ENTITY_TYPE = "License Key Group";
42 @Column(name = "vlm_id")
43 private String vendorLicenseModelId;
44 @PartitionKey(value = 1)
46 private Version version;
48 @Column(name = "lkg_id")
51 private String description;
53 private LicenseKeyType type;
54 @Column(name = "operational_scope")
56 private MultiChoiceOrOther<OperationalScope> operationalScope;
57 @Column(name = "ref_fg_ids")
58 private Set<String> referencingFeatureGroups = new HashSet<>();
59 @Column(name = "version_uuid")
60 private String versionUuId;
63 public LicenseKeyGroupEntity() {
67 * Instantiates a new License key group entity.
69 * @param vendorLicenseModelId the vendor license model id
70 * @param version the version
73 public LicenseKeyGroupEntity(String vendorLicenseModelId, Version version, String id) {
74 this.vendorLicenseModelId = vendorLicenseModelId;
75 this.version = version;
80 public String getEntityType() {
85 public String getFirstClassCitizenId() {
86 return getVendorLicenseModelId();
89 public String getId() {
93 public void setId(String id) {
97 public Version getVersion() {
101 public void setVersion(Version version) {
102 this.version = version;
106 public String getVersionUuId() {
111 public void setVersionUuId(String uuId) {
115 public String getVendorLicenseModelId() {
116 return vendorLicenseModelId;
119 public void setVendorLicenseModelId(String vendorLicenseModelId) {
120 this.vendorLicenseModelId = vendorLicenseModelId;
123 public String getName() {
127 public void setName(String name) {
131 public String getDescription() {
135 public void setDescription(String description) {
136 this.description = description;
139 public LicenseKeyType getType() {
143 public void setType(LicenseKeyType type) {
147 public MultiChoiceOrOther<OperationalScope> getOperationalScope() {
148 return operationalScope;
151 public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
152 operationalScope.resolveEnum(OperationalScope.class);
153 this.operationalScope = operationalScope;
156 public Set<String> getReferencingFeatureGroups() {
157 return referencingFeatureGroups;
160 public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) {
161 this.referencingFeatureGroups = referencingFeatureGroups;
165 public int hashCode() {
167 .hash(vendorLicenseModelId, version, id, name, description, type, operationalScope,
168 referencingFeatureGroups);
172 public boolean equals(Object obj) {
176 if (obj == null || getClass() != obj.getClass()) {
179 LicenseKeyGroupEntity that = (LicenseKeyGroupEntity) obj;
180 return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
181 && Objects.equals(id, that.id)
182 && Objects.equals(name, that.name)
183 && Objects.equals(description, that.description)
185 && Objects.equals(operationalScope, that.operationalScope)
186 && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups);
190 public String toString() {
191 return "LicenseKeyGroupEntity{" + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
192 + ", version=" + version
193 + ", id='" + id + '\''
194 + ", name='" + name + '\''
195 + ", description='" + description + '\''
197 + ", operationalScope=" + operationalScope
198 + ", referencingFeatureGroups=" + referencingFeatureGroups
199 + ", versionUuId='" + versionUuId + '\''
204 * Gets operational scope for artifact.
206 * @return the operational scope for artifact
208 public Set<String> getOperationalScopeForArtifact() {
209 if (operationalScope != null) {
210 return operationalScope.getResults();
217 * Gets version for artifact.
218 * @return version in format suitable for artifact
220 public String getVersionForArtifact() {
221 return version.toString();
225 * Gets type for artifact.
227 * @return the type for artifact
229 public LicenseKeyTypeForXml getTypeForArtifact() {
230 LicenseKeyTypeForXml typeXml = new LicenseKeyTypeForXml();
232 typeXml.setValue(type.toString());
234 typeXml.setValue(null);