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.Frozen;
26 import com.datastax.driver.mapping.annotations.PartitionKey;
27 import com.datastax.driver.mapping.annotations.Table;
29 import org.openecomp.sdc.versioning.dao.types.Version;
30 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
32 import java.util.HashSet;
33 import java.util.Objects;
36 @Table(keyspace = "dox", name = "license_agreement")
37 public class LicenseAgreementEntity implements VersionableEntity {
38 public static final String ENTITY_TYPE = "License Agreement";
40 @PartitionKey(value = 0)
41 @Column(name = "vlm_id")
42 private String vendorLicenseModelId;
44 @PartitionKey(value = 1)
46 private Version version;
49 @Column(name = "la_id")
52 private String description;
54 @Column(name = "lic_term")
56 private ChoiceOrOther<LicenseTerm> licenseTerm;
58 @Column(name = "req_const")
59 private String requirementsAndConstrains;
61 @Column(name = "fg_ids")
62 private Set<String> featureGroupIds = new HashSet<>();
65 * Every entity class must have a default constructor according to
66 * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
67 * Definition of mapped classes</a>.
69 public LicenseAgreementEntity() {
70 // Don't delete! Default constructor is required by DataStax driver
74 * Instantiates a new License agreement entity.
76 * @param vlmId the vlm id
77 * @param version the version
80 public LicenseAgreementEntity(String vlmId, Version version, String id) {
81 this.vendorLicenseModelId = vlmId;
83 this.version = version;
87 public String getEntityType() {
92 public String getFirstClassCitizenId() {
93 return getVendorLicenseModelId();
97 public String getId() {
102 public void setId(String id) {
107 public Version getVersion() {
112 public void setVersion(Version version) {
113 this.version = version;
116 public String getVendorLicenseModelId() {
117 return vendorLicenseModelId;
120 public void setVendorLicenseModelId(String vendorLicenseModelId) {
121 this.vendorLicenseModelId = vendorLicenseModelId;
124 public String getName() {
128 public void setName(String name) {
132 public String getDescription() {
136 public void setDescription(String description) {
137 this.description = description;
140 public ChoiceOrOther<LicenseTerm> getLicenseTerm() {
144 public void setLicenseTerm(ChoiceOrOther<LicenseTerm> licenseTerm) {
145 licenseTerm.resolveEnum(LicenseTerm.class);
146 this.licenseTerm = licenseTerm;
149 public String getRequirementsAndConstrains() {
150 return requirementsAndConstrains;
153 public void setRequirementsAndConstrains(String requirementsAndConstrains) {
154 this.requirementsAndConstrains = requirementsAndConstrains;
157 public Set<String> getFeatureGroupIds() {
158 return featureGroupIds;
161 public void setFeatureGroupIds(Set<String> featureGroupIds) {
162 this.featureGroupIds = featureGroupIds;
166 public int hashCode() {
167 return Objects.hash(vendorLicenseModelId, version, id, name, description, licenseTerm,
168 requirementsAndConstrains, featureGroupIds);
172 public boolean equals(Object obj) {
176 if (obj == null || getClass() != obj.getClass()) {
179 LicenseAgreementEntity that = (LicenseAgreementEntity) obj;
180 return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
181 && Objects.equals(version, that.version)
182 && Objects.equals(id, that.id)
183 && Objects.equals(name, that.name)
184 && Objects.equals(description, that.description)
185 && Objects.equals(licenseTerm, that.licenseTerm)
186 && Objects.equals(requirementsAndConstrains, that.requirementsAndConstrains)
187 && Objects.equals(featureGroupIds, that.featureGroupIds);