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;
34 import java.util.HashSet;
35 import java.util.Objects;
38 @Table(keyspace = "dox", name = "license_key_group")
39 public class LicenseKeyGroupEntity implements VersionableEntity {
40 private static final String ENTITY_TYPE = "License Key Group";
43 @Column(name = "vlm_id")
44 private String vendorLicenseModelId;
45 @PartitionKey(value = 1)
47 private Version version;
49 @Column(name = "lkg_id")
52 private String description;
54 private LicenseKeyType type;
55 @Column(name = "operational_scope")
57 private MultiChoiceOrOther<OperationalScope> operationalScope;
58 @Column(name = "ref_fg_ids")
59 private Set<String> referencingFeatureGroups = new HashSet<>();
60 @Column(name = "version_uuid")
61 private String versionUuId;
64 public LicenseKeyGroupEntity() {
68 * Instantiates a new License key group entity.
70 * @param vendorLicenseModelId the vendor license model id
71 * @param version the version
74 public LicenseKeyGroupEntity(String vendorLicenseModelId, Version version, String id) {
75 this.vendorLicenseModelId = vendorLicenseModelId;
76 this.version = version;
81 public String getEntityType() {
86 public String getFirstClassCitizenId() {
87 return getVendorLicenseModelId();
90 public String getVendorLicenseModelId() {
91 return vendorLicenseModelId;
94 public void setVendorLicenseModelId(String vendorLicenseModelId) {
95 this.vendorLicenseModelId = vendorLicenseModelId;
98 public String getId() {
102 public void setId(String id) {
106 public Version getVersion() {
110 public void setVersion(Version version) {
111 this.version = version;
114 public String getName() {
118 public void setName(String name) {
122 public String getDescription() {
126 public void setDescription(String description) {
127 this.description = description;
130 public LicenseKeyType getType() {
134 public void setType(LicenseKeyType type) {
138 public MultiChoiceOrOther<OperationalScope> getOperationalScope() {
139 return operationalScope;
142 public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
143 operationalScope.resolveEnum(OperationalScope.class);
144 this.operationalScope = operationalScope;
147 public Set<String> getReferencingFeatureGroups() {
148 return referencingFeatureGroups;
151 public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) {
152 this.referencingFeatureGroups = referencingFeatureGroups;
156 public String toString() {
157 return "LicenseKeyGroupEntity{" + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
158 + ", version=" + version
159 + ", id='" + id + '\''
160 + ", name='" + name + '\''
161 + ", description='" + description + '\''
163 + ", operationalScope=" + operationalScope
164 + ", referencingFeatureGroups=" + referencingFeatureGroups
165 + ", versionUuId='" + versionUuId + '\''
170 public boolean equals(Object obj) {
174 if (obj == null || getClass() != obj.getClass()) {
177 LicenseKeyGroupEntity that = (LicenseKeyGroupEntity) obj;
178 return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
179 && Objects.equals(version, that.version)
180 && Objects.equals(id, that.id)
181 && Objects.equals(name, that.name)
182 && Objects.equals(description, that.description)
184 && Objects.equals(operationalScope, that.operationalScope)
185 && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups);
189 public int hashCode() {
191 .hash(vendorLicenseModelId, version, id, name, description, type, operationalScope,
192 referencingFeatureGroups);
196 * Gets operational scope for artifact.
198 * @return the operational scope for artifact
200 public Set<String> getOperationalScopeForArtifact() {
201 if (operationalScope != null) {
202 return operationalScope.getResults();
209 * Gets type for artifact.
211 * @return the type for artifact
213 public LicenseKeyTypeForXml getTypeForArtifact() {
214 LicenseKeyTypeForXml typeXml = new LicenseKeyTypeForXml();
216 typeXml.setValue(type.toString());
218 typeXml.setValue(null);
224 public String getVersionUuId() {
228 public void setVersionUuId(String uuId) {