1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package net.taylor.audit.entity.editor;
27 import javax.ejb.Stateful;
28
29 import net.taylor.audit.entity.Action;
30 import net.taylor.audit.entity.AuditEntry;
31 import net.taylor.richfaces.Picker;
32 import net.taylor.seam.AbstractFinderBean;
33 import net.taylor.seam.ComboBox;
34 import net.taylor.seam.Filter;
35 import net.taylor.seam.PieChart;
36
37 import org.jboss.seam.ScopeType;
38 import org.jboss.seam.annotations.Name;
39 import org.jboss.seam.annotations.Scope;
40
41
42
43
44
45
46
47 @Name("auditEntryFinder")
48 @Stateful
49 @Scope(ScopeType.SESSION)
50 public class AuditEntryFinderBean extends AbstractFinderBean< AuditEntry > implements AuditEntryFinder {
51
52
53 private static final long serialVersionUID = 1L;
54
55
56 public AuditEntryFinderBean() {
57 }
58
59
60 protected void initFilter(Filter filter) {
61 filter.addStringParameter("user");
62 filter.addDateParameter("timestamp");
63 filter.addStringParameter("entityName");
64 filter.addEnumParameter("action", Action.class);
65 }
66
67
68 protected void initColumns() {
69
70 addColumn("user", "String", null);
71 addColumn("timestamp", "Timestamp", null);
72 addColumn("entityName", "String", null);
73 addColumn("entityId", "Integer", null);
74 addColumn("action", "Enum", null);
75
76 }
77
78
79 public boolean isSimpleEntity() {
80 return false;
81 }
82
83 public boolean isRenderCreate() {
84 return false;
85 }
86
87 public boolean isRenderEdit() {
88 return false;
89 }
90
91 public boolean isRenderDelete() {
92 return false;
93 }
94
95 public boolean isRenderImport() {
96 return false;
97 }
98
99
100 public PieChart getActionPieChart() {
101 return new PieChart(getEntityManager(), "AuditEntry", "action");
102 }
103
104 public PieChart getEntityNamePieChart() {
105 return new PieChart(getEntityManager(), "AuditEntry", "entityName");
106 }
107
108 public PieChart getUserPieChart() {
109 return new PieChart(getEntityManager(), "AuditEntry", "user");
110 }
111
112
113
114
115
116
117
118
119 public static class AuditEntryComboBox<COMP, SRC> extends ComboBox<COMP, AuditEntry, SRC> {
120
121
122 public AuditEntryComboBox(Object component, String name) {
123 super(component, name);
124 }
125
126
127 public AuditEntryComboBox(Object component, String instanceName, String name) {
128 super(component, instanceName, name);
129 }
130
131
132 protected Class getEntityClass() {
133 return AuditEntry.class;
134 }
135
136
137 protected String getAlias() {
138 return "t1";
139 }
140
141
142 protected String getItemLabel() {
143 return "#{t1.entityName}";
144 }
145
146
147 protected String getOrderBy() {
148 return "t1.entityName";
149 }
150 }
151
152
153
154
155
156
157
158
159 public static class AuditEntryPicker<COMP, SRC> extends
160 Picker<COMP, AuditEntry, SRC> {
161
162
163 public AuditEntryPicker(Object component, String name) {
164 super(component, name);
165 }
166
167
168 public AuditEntryPicker(Object component, String instanceName, String name) {
169 super(component, instanceName, name);
170 }
171
172
173 protected Class getEntityClass() {
174 return AuditEntry.class;
175 }
176
177
178 protected String getAlias() {
179 return "t1";
180 }
181
182
183 protected String getItemLabel() {
184 return "#{t1.entityName}";
185 }
186
187
188 protected String getOrderBy() {
189 return "t1.entityName";
190 }
191
192
193 protected String getFilterRestriction() {
194 return "lower(t1.entityName) like :filter";
195 }
196 }
197 }