[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 / 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 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   @Column(name = "icon")
49   private String iconRef;
50
51   @Computed("writetime(vendor_name)")
52   private Long writetimeMicroSeconds;
53
54   public VendorLicenseModelEntity() {
55   }
56
57   public VendorLicenseModelEntity(String id, Version version) {
58     this.id = id;
59     this.version = version;
60   }
61
62   @Override
63   public String getEntityType() {
64     return ENTITY_TYPE;
65   }
66
67   @Override
68   public String getFirstClassCitizenId() {
69     return getId();
70   }
71
72   public String getId() {
73     return id;
74   }
75
76   public void setId(String id) {
77     this.id = id;
78   }
79
80   @Override
81   public Version getVersion() {
82     return version;
83   }
84
85   @Override
86   public void setVersion(Version version) {
87     this.version = version;
88   }
89
90   public String getVendorName() {
91     return vendorName;
92   }
93
94   public void setVendorName(String vendorName) {
95     this.vendorName = vendorName;
96   }
97
98   public String getDescription() {
99     return description;
100   }
101
102   public void setDescription(String description) {
103     this.description = description;
104   }
105
106   public String getIconRef() {
107     return iconRef;
108   }
109
110   public void setIconRef(String iconRef) {
111     this.iconRef = iconRef;
112   }
113
114   @Override
115   public int hashCode() {
116     return Objects.hash(id, version, vendorName, description, iconRef);
117   }
118
119   @Override
120   public boolean equals(Object obj) {
121     if (this == obj) {
122       return true;
123     }
124     if (obj == null || getClass() != obj.getClass()) {
125       return false;
126     }
127     VendorLicenseModelEntity that = (VendorLicenseModelEntity) obj;
128     return Objects.equals(id, that.id)
129         && Objects.equals(version, that.version)
130         && Objects.equals(vendorName, that.vendorName)
131         && Objects.equals(description, that.description)
132         && Objects.equals(iconRef, that.iconRef);
133   }
134
135   public Long getWritetimeMicroSeconds() {
136     return writetimeMicroSeconds;
137   }
138
139   public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) {
140     this.writetimeMicroSeconds = writetimeMicroSeconds;
141   }
142 }