Add collaboration feature
[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   private String oldVersion;
49   @Column(name = "icon")
50   private String iconRef;
51
52   @Computed("writetime(vendor_name)")
53   private Long writetimeMicroSeconds;
54
55   public VendorLicenseModelEntity() {
56   }
57
58   public VendorLicenseModelEntity(String id, Version version) {
59     this.id = id;
60     this.version = version;
61   }
62
63   @Override
64   public String getEntityType() {
65     return ENTITY_TYPE;
66   }
67
68   @Override
69   public String getFirstClassCitizenId() {
70     return getId();
71   }
72
73   public String getId() {
74     return id;
75   }
76
77   public void setId(String id) {
78     this.id = id;
79   }
80
81   @Override
82   public Version getVersion() {
83     return version;
84   }
85
86   @Override
87   public void setVersion(Version version) {
88     this.version = version;
89   }
90
91   public String getVendorName() {
92     return vendorName;
93   }
94
95   public void setVendorName(String vendorName) {
96     this.vendorName = vendorName;
97   }
98
99   public String getDescription() {
100     return description;
101   }
102
103   public void setDescription(String description) {
104     this.description = description;
105   }
106
107   public String getIconRef() {
108     return iconRef;
109   }
110
111   public void setIconRef(String iconRef) {
112     this.iconRef = iconRef;
113   }
114
115   public void setOldVersion(String oldVersion) {
116     this.oldVersion = oldVersion;
117   }
118
119   public String getOldVersion() {
120     return oldVersion;
121   }
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)
139         && Objects.equals(version, that.version)
140         && Objects.equals(vendorName, that.vendorName)
141         && Objects.equals(description, that.description)
142         && Objects.equals(iconRef, that.iconRef);
143   }
144
145   public Long getWritetimeMicroSeconds() {
146     return writetimeMicroSeconds;
147   }
148
149   public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) {
150     this.writetimeMicroSeconds = writetimeMicroSeconds;
151   }
152 }