BrightSide Workbench Full Report + Source Code
SystemLog.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2021 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.elephant.entities.db;
20 
21 import java.io.Serializable;
22 import java.util.Date;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.Id;
26 import javax.persistence.IdClass;
27 import javax.persistence.Index;
28 import javax.persistence.Lob;
29 import javax.persistence.Table;
30 import javax.persistence.Temporal;
31 import org.turro.log.SystemLogType;
32 import org.turro.plugin.GenericObject;
33 
38 @Entity
39 @IdClass(SystemLogPK.class)
40 @Table(indexes={
41  @Index(name = "generatorIndex", columnList = "generatorPath, dateLog"),
42  @Index(name = "entityIndex", columnList = "entityPath, dateLog")
43 })
44 public class SystemLog implements java.io.Serializable {
45 
46  @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
47  @Id private Date dateLog;
48 
49  @Id private SystemLogType logType;
50 
51  @Id private String generatorPath;
52  @Id private String entityPath;
53 
54  private String generatorName;
55  private String entityName;
56  private String comment;
57 
58  private int counts;
59 
60  @Lob
61  @Column(name="LOG_DATA")
62  private byte[] data;
63 
64  public Date getDateLog() {
65  return dateLog;
66  }
67 
68  public void setDateLog(Date dateLog) {
69  this.dateLog = dateLog;
70  }
71 
73  return logType;
74  }
75 
76  public void setLogType(SystemLogType logType) {
77  this.logType = logType;
78  }
79 
80  public String getGeneratorPath() {
81  return generatorPath;
82  }
83 
84  public void setGeneratorPath(String generatorPath) {
85  this.generatorPath = generatorPath;
86  }
87 
88  public String getEntityPath() {
89  return entityPath;
90  }
91 
92  public void setEntityPath(String entityPath) {
93  this.entityPath = entityPath;
94  }
95 
96  public String getGeneratorName() {
97  return generatorName;
98  }
99 
100  public void setGeneratorName(String generatorName) {
101  this.generatorName = generatorName;
102  }
103 
104  public String getEntityName() {
105  return entityName;
106  }
107 
108  public void setEntityName(String entityName) {
109  this.entityName = entityName;
110  }
111 
112  public String getComment() {
113  return comment;
114  }
115 
116  public void setComment(String comment) {
117  this.comment = comment;
118  }
119 
120  public byte[] getData() {
121  return data;
122  }
123 
124  public void setData(byte[] data) {
125  this.data = data;
126  }
127 
128  public int getCounts() {
129  return counts;
130  }
131 
132  public void setCounts(int counts) {
133  this.counts = counts;
134  }
135 
136  /* Helpers */
137 
138  public String getString() {
139  if(data != null && data.length > 0) {
140  return new String(data);
141  }
142  return null;
143  }
144 
145  public Object getObject() {
146  if(data != null) {
147  GenericObject go = new GenericObject();
148  go.bytesToObject(data);
149  return go.getObject();
150  } else {
151  return null;
152  }
153  }
154 
155  public void setObject(Serializable object) {
156  if(object != null) {
157  GenericObject go = new GenericObject();
158  go.setObject(object);
159  data = go.objectToBytes();
160  } else {
161  data = null;
162  }
163  }
164 
165 }
void setEntityName(String entityName)
Definition: SystemLog.java:108
void setLogType(SystemLogType logType)
Definition: SystemLog.java:76
void setGeneratorPath(String generatorPath)
Definition: SystemLog.java:84
void setObject(Serializable object)
Definition: SystemLog.java:155
void setGeneratorName(String generatorName)
Definition: SystemLog.java:100
void setEntityPath(String entityPath)
Definition: SystemLog.java:92