f878bea2df6f10ba5f8989924cd812ce9fea05b6
[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 lombok.Getter;
24 import lombok.NoArgsConstructor;
25 import lombok.Setter;
26 import org.openecomp.sdc.versioning.dao.types.Version;
27
28 import java.util.Date;
29
30 @Getter
31 @Setter
32 @NoArgsConstructor
33 @Table(keyspace = "dox", name = "activity_log")
34 public class ActivityLogEntity {
35   @PartitionKey
36   @Column(name = "item_id")
37   private String itemId;
38   @ClusteringColumn(value = 1)
39   @Column(name = "version_id")
40   private String versionId;
41   @ClusteringColumn
42   @Column(name = "activity_id")
43   private String id;
44   private ActivityType type;
45   private String user;
46   private Date timestamp;
47   private boolean success;
48   private String message;
49   private String comment;
50
51   public ActivityLogEntity(String itemId, Version version) {
52     this.itemId = itemId;
53     this.versionId = version == null ? null : version.getId();
54   }
55
56   public ActivityLogEntity(String itemId, Version version, ActivityType type, String user,
57                            boolean success, String message, String comment) {
58     this(itemId, version);
59     this.type = type;
60     this.user = user;
61     this.success = success;
62     this.message = message;
63     this.comment = comment;
64     this.timestamp = new Date();
65   }
66 }