1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.event.eventtype;
25
26
27 /***
28 * Database EventTypeStrategy class. Provides implementations of the super
29 * class methods for Database events.
30 *
31 * @author Luca Fossato
32 *
33 */
34 public class DatabaseEventTypeStrategy implements EventTypeStrategy {
35
36 /***
37 * Gets the eventGroup attribute of the EventTypeStrategyImpl object
38 *
39 * @param eventString Description of the Parameter
40 *
41 * @return The eventGroup value, or EventType.EVENT_UNDEFINED otherwise
42 */
43 public int getEventGroup(String eventString) {
44 int eventGroup = EventType.EVENT_UNDEFINED;
45
46 if ((eventString.startsWith("ac_insert_"))
47 || (eventString.startsWith("ac_update_"))
48 || (eventString.startsWith("ac_updatear_"))
49 || (eventString.startsWith("ac_delete_"))
50 || (eventString.startsWith("ac_deletear_"))) {
51 eventGroup = EventType.EVENT_GROUP_DATABASE;
52 }
53
54 return eventGroup;
55 }
56
57
58 /***
59 * Gets the eventType attribute of the EventTypeStrategyImpl object
60 *
61 * @param eventString Description of the Parameter
62 *
63 * @return The eventType value
64 */
65 public String getEventType(String eventString) {
66 String eventType = String.valueOf(EventType.EVENT_UNDEFINED);
67
68 if (eventString.startsWith("ac_insert_")) {
69 eventType = EventType.EVENT_DATABASE_INSERT;
70 } else if (eventString.startsWith("ac_update_")
71 || eventString.startsWith("ac_updatear_")) {
72 eventType = EventType.EVENT_DATABASE_UPDATE;
73 } else if (eventString.startsWith("ac_delete_")
74 || eventString.startsWith("ac_deletear_")) {
75 eventType = EventType.EVENT_DATABASE_DELETE;
76 }
77
78 return eventType;
79 }
80
81
82 /***
83 * Gets the EventTypeStrategy identifier.
84 *
85 * @return the EventTypeStrategy identifier
86 */
87 public String getId() {
88 return "DatabaseEventTypeStrategy";
89 }
90 }