b277fe1cb5b0d83c00d2fb6c7bc63aae48246a87
[sdc.git] /
1 /*
2  * Copyright © 2016-2017 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.activitylog.dao.type;
18
19 import com.datastax.driver.mapping.annotations.ClusteringColumn;
20 import com.datastax.driver.mapping.annotations.Column;
21 import com.datastax.driver.mapping.annotations.Enumerated;
22 import com.datastax.driver.mapping.annotations.PartitionKey;
23 import com.datastax.driver.mapping.annotations.Table;
24 import org.openecomp.sdc.versioning.dao.types.Version;
25
26 import java.util.Date;
27
28 @Table(keyspace = "dox", name = "activity_log")
29 public class ActivityLogEntity {
30   @PartitionKey
31   @Column(name = "item_id")
32   private String itemId;
33   @ClusteringColumn(value = 1)
34   @Column(name = "version_id")
35   private String versionId;
36   @ClusteringColumn
37   @Column(name = "activity_id")
38   private String id;
39   @Enumerated
40   private ActivityType type;
41   private String user;
42   private Date timestamp;
43   private boolean success;
44   private String message;
45   private String comment;
46
47   /**
48    * Every entity class must have a default constructor according to
49    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
50    * Definition of mapped classes</a>.
51    */
52   public ActivityLogEntity() {
53     // Don't delete! Default constructor is required by DataStax driver
54   }
55
56   public ActivityLogEntity(String itemId, Version version) {
57     this.itemId = itemId;
58     setVersion(version);
59   }
60
61   public ActivityLogEntity(String itemId, Version version, ActivityType type, String user,
62                            boolean success, String message, String comment) {
63     this(itemId, version);
64     this.type = type;
65     this.user = user;
66     this.success = success;
67     this.message = message;
68     this.comment = comment;
69     this.timestamp = new Date();
70   }
71
72   public String getItemId() {
73     return itemId;
74   }
75
76   public void setItemId(String itemId) {
77     this.itemId = itemId;
78   }
79
80   public Version getVersion() {
81     return versionId == null ? null : new Version(versionId);
82   }
83
84   public void setVersion(Version version) {
85     this.versionId = version == null ? null : version.getId();
86   }
87
88   public String getVersionId() {
89     return versionId;
90   }
91
92   public void setVersionId(String versionId) {
93     this.versionId = versionId;
94   }
95
96   public String getId() {
97     return id;
98   }
99
100   public void setId(String id) {
101     this.id = id;
102   }
103
104   public ActivityType getType() {
105     return type;
106   }
107
108   public void setType(ActivityType type) {
109     this.type = type;
110   }
111
112   public String getUser() {
113     return user;
114   }
115
116   public void setUser(String user) {
117     this.user = user;
118   }
119
120   public Date getTimestamp() {
121     return timestamp;
122   }
123
124   public void setTimestamp(Date timestamp) {
125     this.timestamp = timestamp;
126   }
127
128   public boolean isSuccess() {
129     return success;
130   }
131
132   public void setSuccess(boolean success) {
133     this.success = success;
134   }
135
136   public String getMessage() {
137     return message;
138   }
139
140   public void setMessage(String message) {
141     this.message = message;
142   }
143
144   public String getComment() {
145     return comment;
146   }
147
148   public void setComment(String comment) {
149     this.comment = comment;
150   }
151 }