|
1 /* |
|
2 * Created on Feb 22, 2005 |
|
3 * |
|
4 * To change the template for this generated file go to |
|
5 * Window>Preferences>Java>Code Generation>Code and Comments |
|
6 */ |
|
7 package isac.util.users; |
|
8 |
|
9 import java.io.FileOutputStream; |
|
10 import java.io.IOException; |
|
11 import java.util.Properties; |
|
12 |
|
13 /** |
|
14 * @author Alan Krempler |
|
15 * |
|
16 * The UserModel is a class to gather statistics about one user's interaction |
|
17 * with the system. Statistis are gathered per user and per interactional |
|
18 * context. |
|
19 */ |
|
20 public class UserModel extends Properties { |
|
21 |
|
22 // special value for retrieving the statistics regardless of the dialog atom |
|
23 // used in the interaction |
|
24 public static final int DIALOG_ATOM_ANY = 0; |
|
25 |
|
26 // counter for identifying pending interactions |
|
27 private static int interaction_nr_ = 1; |
|
28 |
|
29 private String userpath_; |
|
30 |
|
31 private String username_; |
|
32 |
|
33 public UserModel(String userpath, String username) { |
|
34 userpath_ = userpath; |
|
35 username_ = username; |
|
36 //TODO.WN050311 |
|
37 } |
|
38 |
|
39 /** |
|
40 * @param item_id |
|
41 * ID of the item being queried, a tactic for example |
|
42 * @param dialog_atom |
|
43 * ID of the interactional context use DIALOG_ATOM_ANY if asking |
|
44 * for statistics for all dialog atoms |
|
45 * @return count of previously recorded interactions with this item |
|
46 */ |
|
47 public int getTouchedCount(int item_id, int dialog_atom) { |
|
48 // FIXME: returning dummy value in absence of valid statistics |
|
49 return 0; |
|
50 } |
|
51 |
|
52 /** |
|
53 * @param item_id |
|
54 * ID of the item being queried, a tactic for example |
|
55 * @param dialog_atom |
|
56 * ID of the interactional context use DIALOG_ATOM_ANY if asking |
|
57 * for statistics for all dialog atoms |
|
58 * @return count of previously recorded successful interactions with this |
|
59 * item |
|
60 */ |
|
61 public int getSuccessCount(int item_id, int dialog_atom) { |
|
62 // FIXME: returning dummy value in absence of valid statistics |
|
63 return 0; |
|
64 } |
|
65 |
|
66 /** |
|
67 * @param item_id |
|
68 * ID of the item being queried, a tactic for example |
|
69 * @param dialog_atom |
|
70 * ID of the interactional context use DIALOG_ATOM_ANY if asking |
|
71 * for statistics for all dialog atoms |
|
72 * @return time of last recorded interaction with this item |
|
73 */ |
|
74 public java.util.Date getTouchedLast(int item_id, int dialog_atom) { |
|
75 // FIXME: returning dummy value in absence of valid statistics |
|
76 return new java.util.Date(); |
|
77 } |
|
78 |
|
79 /** |
|
80 * @param item_id |
|
81 * ID of the item being queried, a tactic for example |
|
82 * @param dialog_atom |
|
83 * ID of the interactional context use DIALOG_ATOM_ANY if asking |
|
84 * for statistics for all dialog atoms |
|
85 * @return time of last recorded successful interaction with this item |
|
86 */ |
|
87 public java.util.Date getSuccessLast(int item_id, int dialog_atom) { |
|
88 // FIXME: returning dummy value in absence of valid statistics |
|
89 return new java.util.Date(); |
|
90 } |
|
91 |
|
92 /** |
|
93 * @param item_id |
|
94 * ID of the item being queried, a tactic for example |
|
95 * @param dialog_atom |
|
96 * ID of the interactional context use DIALOG_ATOM_ANY if asking |
|
97 * for statistics for all dialog atoms |
|
98 * @return average time (seconds) spent in interactions with this item |
|
99 */ |
|
100 public int getTimeSpentAvg(int item_id, int dialog_atom) { |
|
101 // FIXME: returning dummy value in absence of valid statistics |
|
102 return 0; |
|
103 } |
|
104 |
|
105 /** |
|
106 * @param item_id |
|
107 * ID of the item being queried, a tactic for example |
|
108 * @param dialog_atom |
|
109 * ID of the interactional context use DIALOG_ATOM_ANY if asking |
|
110 * for statistics for all dialog atoms |
|
111 * @return maximum time (seconds) spent in interactions with this item |
|
112 */ |
|
113 public int getTimeSpentMax(int item_id, int dialog_atom) { |
|
114 // FIXME: returning dummy value in absence of valid statistics |
|
115 return 0; |
|
116 } |
|
117 |
|
118 /** |
|
119 * @param item_id |
|
120 * ID of the item being queried, a tactic for example |
|
121 * @param dialog_atom |
|
122 * ID of the interactional context use DIALOG_ATOM_ANY if asking |
|
123 * for statistics for all dialog atoms |
|
124 * @return standard deviation of time spent in interactions with this item |
|
125 */ |
|
126 public float getTimeSpentStddev(int item_id, int dialog_atom) { |
|
127 // FIXME: returning dummy value in absence of valid statistics |
|
128 return 0; |
|
129 } |
|
130 |
|
131 /** |
|
132 * Mark the beginning of an interaction with an item. |
|
133 * |
|
134 * @param item_id |
|
135 * ID of the item being acted upon, a tactic for example |
|
136 * @param dialog_atom |
|
137 * ID of the interactional context |
|
138 * @return unique number to indentify the end of the transaction |
|
139 */ |
|
140 public int startInteraction(int item_id, int dialog_atom) { |
|
141 // FIXME: insert code to record statistics |
|
142 |
|
143 // record timestamp |
|
144 // new java.util.Date(); ... |
|
145 |
|
146 // save in static vector of currently open interactions |
|
147 // ... |
|
148 |
|
149 return interaction_nr_++; |
|
150 } |
|
151 |
|
152 /** |
|
153 * Mark the end of an interaction with an item. |
|
154 * |
|
155 * @param interaction_id |
|
156 * ID of the interaction returned from the call to |
|
157 * {@link # startInteraction() } |
|
158 * @param success |
|
159 * information about the success of the interaction |
|
160 * @return false in case of failure - no matching start could be found, true |
|
161 * in case of success |
|
162 */ |
|
163 public boolean endInteraction(int interaction_id, int success) { |
|
164 // FIXME: insert code to record statistics |
|
165 |
|
166 // record end timestamp |
|
167 // new java.util.Date(); ... |
|
168 |
|
169 // add to statistics |
|
170 |
|
171 // delete from static vector of currently open interactions |
|
172 // ... |
|
173 |
|
174 return true; |
|
175 } |
|
176 |
|
177 //WN050311 just for creation of the first file |
|
178 //beware of the fix path ! |
|
179 public static void main(String[] args) { |
|
180 UserModel a = new UserModel("isac/xmldata/users", "x"); |
|
181 a.setProperty("TODO-key", "TODO-value"); |
|
182 |
|
183 String filename = "isac/xmldata/users/x_model.txt"; |
|
184 try { |
|
185 FileOutputStream propOutFile = new FileOutputStream(filename); |
|
186 a.store(propOutFile, "dynamic dialog data of user 'x'"); |
|
187 |
|
188 } catch (IOException e) { |
|
189 System.err.println("I/O failed."); |
|
190 } |
|
191 |
|
192 } |
|
193 } |