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