re base code
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-license-lib / openecomp-sdc-vendor-license-api / src / main / java / org / openecomp / sdc / vendorlicense / dao / types / VendorLicenseModelEntity.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.Column;
24 import com.datastax.driver.mapping.annotations.Computed;
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
29
30 import org.openecomp.sdc.versioning.dao.types.Version;
31 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
32
33 import java.util.Objects;
34
35 @Table(keyspace = "dox", name = "vendor_license_model")
36 public class VendorLicenseModelEntity implements VersionableEntity {
37   public static final String ENTITY_TYPE = "Vendor License Model";
38
39   @PartitionKey
40   @Column(name = "vlm_id")
41   private String id;
42
43   @PartitionKey(value = 1)
44   @Frozen
45   private Version version;
46
47   @Column(name = "vendor_name")
48   private String vendorName;
49   private String description;
50   private String oldVersion;
51   @Column(name = "icon")
52   private String iconRef;
53
54   @Computed("writetime(vendor_name)")
55   private Long writetimeMicroSeconds;
56
57   /**
58    * Every entity class must have a default constructor according to
59    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
60    * Definition of mapped classes</a>.
61    */
62   public VendorLicenseModelEntity() {
63     // Don't delete! Default constructor is required by DataStax driver
64   }
65
66   public VendorLicenseModelEntity(String id, Version version) {
67     this.id = id;
68     this.version = version;
69   }
70
71   @Override
72   public String getEntityType() {
73     return ENTITY_TYPE;
74   }
75
76   @Override
77   public String getFirstClassCitizenId() {
78     return getId();
79   }
80
81   public String getId() {
82     return id;
83   }
84
85   public void setId(String id) {
86     this.id = id;
87   }
88
89   @Override
90   public Version getVersion() {
91     return version;
92   }
93
94   @Override
95   public void setVersion(Version version) {
96     this.version = version;
97   }
98
99   public String getVendorName() {
100     return vendorName;
101   }
102
103   public void setVendorName(String vendorName) {
104     this.vendorName = vendorName;
105   }
106
107   public String getDescription() {
108     return description;
109   }
110
111   public void setDescription(String description) {
112     this.description = description;
113   }
114
115   public String getIconRef() {
116     return iconRef;
117   }
118
119   public void setIconRef(String iconRef) {
120     this.iconRef = iconRef;
121   }
122
123   public void setOldVersion(String oldVersion) {
124     this.oldVersion = oldVersion;
125   }
126
127   public String getOldVersion() {
128     return oldVersion;
129   }
130
131
132   @Override
133   public int hashCode() {
134     return Objects.hash(id, version, vendorName, description, iconRef);
135   }
136
137   @Override
138   public boolean equals(Object obj) {
139     if (this == obj) {
140       return true;
141     }
142     if (obj == null || getClass() != obj.getClass()) {
143       return false;
144     }
145     VendorLicenseModelEntity that = (VendorLicenseModelEntity) obj;
146     return Objects.equals(id, that.id)
147         && Objects.equals(version, that.version)
148         && Objects.equals(vendorName, that.vendorName)
149         && Objects.equals(description, that.description)
150         && Objects.equals(iconRef, that.iconRef);
151   }
152 }