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