[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-license-lib / openecomp-sdc-vendor-license-api / src / main / java / org / openecomp / sdc / vendorlicense / dao / types / LicenseAgreementEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.vendorlicense.dao.types;
22
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;
28 import org.openecomp.sdc.versioning.dao.types.Version;
29 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
30
31 import java.util.HashSet;
32 import java.util.Objects;
33 import java.util.Set;
34
35 @Table(keyspace = "dox", name = "license_agreement")
36 public class LicenseAgreementEntity implements VersionableEntity {
37   public static final String ENTITY_TYPE = "License Agreement";
38
39   @PartitionKey(value = 0)
40   @Column(name = "vlm_id")
41   private String vendorLicenseModelId;
42
43   @PartitionKey(value = 1)
44   @Frozen
45   private Version version;
46
47   @ClusteringColumn
48   @Column(name = "la_id")
49   private String id;
50   private String name;
51   private String description;
52
53   @Column(name = "lic_term")
54   @Frozen
55   private ChoiceOrOther<LicenseTerm> licenseTerm;
56
57   @Column(name = "req_const")
58   private String requirementsAndConstrains;
59
60   @Column(name = "fg_ids")
61   private Set<String> featureGroupIds = new HashSet<>();
62
63   public LicenseAgreementEntity() {
64   }
65
66   /**
67    * Instantiates a new License agreement entity.
68    *
69    * @param vlmId   the vlm id
70    * @param version the version
71    * @param id      the id
72    */
73   public LicenseAgreementEntity(String vlmId, Version version, String id) {
74     this.vendorLicenseModelId = vlmId;
75     this.id = id;
76     this.version = version;
77   }
78
79   @Override
80   public String getEntityType() {
81     return ENTITY_TYPE;
82   }
83
84   @Override
85   public String getFirstClassCitizenId() {
86     return getVendorLicenseModelId();
87   }
88
89   @Override
90   public String getId() {
91     return id;
92   }
93
94   @Override
95   public void setId(String id) {
96     this.id = id;
97   }
98
99   @Override
100   public Version getVersion() {
101     return version;
102   }
103
104   @Override
105   public void setVersion(Version version) {
106     this.version = version;
107   }
108
109   public String getVendorLicenseModelId() {
110     return vendorLicenseModelId;
111   }
112
113   public void setVendorLicenseModelId(String vendorLicenseModelId) {
114     this.vendorLicenseModelId = vendorLicenseModelId;
115   }
116
117   public String getName() {
118     return name;
119   }
120
121   public void setName(String name) {
122     this.name = name;
123   }
124
125   public String getDescription() {
126     return description;
127   }
128
129   public void setDescription(String description) {
130     this.description = description;
131   }
132
133   public ChoiceOrOther<LicenseTerm> getLicenseTerm() {
134     return licenseTerm;
135   }
136
137   public void setLicenseTerm(ChoiceOrOther<LicenseTerm> licenseTerm) {
138     licenseTerm.resolveEnum(LicenseTerm.class);
139     this.licenseTerm = licenseTerm;
140   }
141
142   public String getRequirementsAndConstrains() {
143     return requirementsAndConstrains;
144   }
145
146   public void setRequirementsAndConstrains(String requirementsAndConstrains) {
147     this.requirementsAndConstrains = requirementsAndConstrains;
148   }
149
150   public Set<String> getFeatureGroupIds() {
151     return featureGroupIds;
152   }
153
154   public void setFeatureGroupIds(Set<String> featureGroupIds) {
155     this.featureGroupIds = featureGroupIds;
156   }
157
158   @Override
159   public int hashCode() {
160     return Objects.hash(vendorLicenseModelId, version, id, name, description, licenseTerm,
161         requirementsAndConstrains, featureGroupIds);
162   }
163
164   @Override
165   public boolean equals(Object obj) {
166     if (this == obj) {
167       return true;
168     }
169     if (obj == null || getClass() != obj.getClass()) {
170       return false;
171     }
172     LicenseAgreementEntity that = (LicenseAgreementEntity) obj;
173     return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
174         && Objects.equals(version, that.version)
175         && Objects.equals(id, that.id)
176         && Objects.equals(name, that.name)
177         && Objects.equals(description, that.description)
178         && Objects.equals(licenseTerm, that.licenseTerm)
179         && Objects.equals(requirementsAndConstrains, that.requirementsAndConstrains)
180         && Objects.equals(featureGroupIds, that.featureGroupIds);
181   }
182 }