3c65624c154a9d69dbece497e7488f463099f45c
[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.PartitionKey;
22 import com.datastax.driver.mapping.annotations.Table;
23 import org.openecomp.sdc.versioning.dao.types.Version;
24
25 import java.util.Date;
26
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   private ActivityType type;
40   private String user;
41   private Date timestamp;
42   private boolean success;
43   private String message;
44   private String comment;
45
46   /**
47    * Every entity class must have a default constructor according to
48    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
49    * Definition of mapped classes</a>.
50    */
51   public ActivityLogEntity() {
52     // Don't delete! Default constructor is required by DataStax driver
53   }
54
55   public ActivityLogEntity(String itemId, Version version) {
56     this.itemId = itemId;
57     this.versionId = version == null ? null : version.getId();
58   }
59
60   public ActivityLogEntity(String itemId, Version version, ActivityType type, String user,
61                            boolean success, String message, String comment) {
62     this(itemId, version);
63     this.type = type;
64     this.user = user;
65     this.success = success;
66     this.message = message;
67     this.comment = comment;
68     this.timestamp = new Date();
69   }
70
71   public String getItemId() {
72     return itemId;
73   }
74
75   public void setItemId(String itemId) {
76     this.itemId = itemId;
77   }
78
79   public String getVersionId() {
80     return versionId;
81   }
82
83   public void setVersionId(String versionId) {
84     this.versionId = versionId;
85   }
86
87   public String getId() {
88     return id;
89   }
90
91   public void setId(String id) {
92     this.id = id;
93   }
94
95   public ActivityType getType() {
96     return type;
97   }
98
99   public void setType(ActivityType type) {
100     this.type = type;
101   }
102
103   public String getUser() {
104     return user;
105   }
106
107   public void setUser(String user) {
108     this.user = user;
109   }
110
111   public Date getTimestamp() {
112     return timestamp;
113   }
114
115   public void setTimestamp(Date timestamp) {
116     this.timestamp = timestamp;
117   }
118
119   public boolean isSuccess() {
120     return success;
121   }
122
123   public void setSuccess(boolean success) {
124     this.success = success;
125   }
126
127   public String getMessage() {
128     return message;
129   }
130
131   public void setMessage(String message) {
132     this.message = message;
133   }
134
135   public String getComment() {
136     return comment;
137   }
138
139   public void setComment(String comment) {
140     this.comment = comment;
141   }
142 }