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