1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/java/isac/util/users/UserModel.java Wed Jun 15 18:31:02 2005 +0200
1.3 @@ -0,0 +1,193 @@
1.4 +/*
1.5 + * Created on Feb 22, 2005
1.6 + *
1.7 + * To change the template for this generated file go to
1.8 + * Window>Preferences>Java>Code Generation>Code and Comments
1.9 + */
1.10 +package isac.util.users;
1.11 +
1.12 +import java.io.FileOutputStream;
1.13 +import java.io.IOException;
1.14 +import java.util.Properties;
1.15 +
1.16 +/**
1.17 + * @author Alan Krempler
1.18 + *
1.19 + * The UserModel is a class to gather statistics about one user's interaction
1.20 + * with the system. Statistis are gathered per user and per interactional
1.21 + * context.
1.22 + */
1.23 +public class UserModel extends Properties {
1.24 +
1.25 + // special value for retrieving the statistics regardless of the dialog atom
1.26 + // used in the interaction
1.27 + public static final int DIALOG_ATOM_ANY = 0;
1.28 +
1.29 + // counter for identifying pending interactions
1.30 + private static int interaction_nr_ = 1;
1.31 +
1.32 + private String userpath_;
1.33 +
1.34 + private String username_;
1.35 +
1.36 + public UserModel(String userpath, String username) {
1.37 + userpath_ = userpath;
1.38 + username_ = username;
1.39 + //TODO.WN050311
1.40 + }
1.41 +
1.42 + /**
1.43 + * @param item_id
1.44 + * ID of the item being queried, a tactic for example
1.45 + * @param dialog_atom
1.46 + * ID of the interactional context use DIALOG_ATOM_ANY if asking
1.47 + * for statistics for all dialog atoms
1.48 + * @return count of previously recorded interactions with this item
1.49 + */
1.50 + public int getTouchedCount(int item_id, int dialog_atom) {
1.51 + // FIXME: returning dummy value in absence of valid statistics
1.52 + return 0;
1.53 + }
1.54 +
1.55 + /**
1.56 + * @param item_id
1.57 + * ID of the item being queried, a tactic for example
1.58 + * @param dialog_atom
1.59 + * ID of the interactional context use DIALOG_ATOM_ANY if asking
1.60 + * for statistics for all dialog atoms
1.61 + * @return count of previously recorded successful interactions with this
1.62 + * item
1.63 + */
1.64 + public int getSuccessCount(int item_id, int dialog_atom) {
1.65 + // FIXME: returning dummy value in absence of valid statistics
1.66 + return 0;
1.67 + }
1.68 +
1.69 + /**
1.70 + * @param item_id
1.71 + * ID of the item being queried, a tactic for example
1.72 + * @param dialog_atom
1.73 + * ID of the interactional context use DIALOG_ATOM_ANY if asking
1.74 + * for statistics for all dialog atoms
1.75 + * @return time of last recorded interaction with this item
1.76 + */
1.77 + public java.util.Date getTouchedLast(int item_id, int dialog_atom) {
1.78 + // FIXME: returning dummy value in absence of valid statistics
1.79 + return new java.util.Date();
1.80 + }
1.81 +
1.82 + /**
1.83 + * @param item_id
1.84 + * ID of the item being queried, a tactic for example
1.85 + * @param dialog_atom
1.86 + * ID of the interactional context use DIALOG_ATOM_ANY if asking
1.87 + * for statistics for all dialog atoms
1.88 + * @return time of last recorded successful interaction with this item
1.89 + */
1.90 + public java.util.Date getSuccessLast(int item_id, int dialog_atom) {
1.91 + // FIXME: returning dummy value in absence of valid statistics
1.92 + return new java.util.Date();
1.93 + }
1.94 +
1.95 + /**
1.96 + * @param item_id
1.97 + * ID of the item being queried, a tactic for example
1.98 + * @param dialog_atom
1.99 + * ID of the interactional context use DIALOG_ATOM_ANY if asking
1.100 + * for statistics for all dialog atoms
1.101 + * @return average time (seconds) spent in interactions with this item
1.102 + */
1.103 + public int getTimeSpentAvg(int item_id, int dialog_atom) {
1.104 + // FIXME: returning dummy value in absence of valid statistics
1.105 + return 0;
1.106 + }
1.107 +
1.108 + /**
1.109 + * @param item_id
1.110 + * ID of the item being queried, a tactic for example
1.111 + * @param dialog_atom
1.112 + * ID of the interactional context use DIALOG_ATOM_ANY if asking
1.113 + * for statistics for all dialog atoms
1.114 + * @return maximum time (seconds) spent in interactions with this item
1.115 + */
1.116 + public int getTimeSpentMax(int item_id, int dialog_atom) {
1.117 + // FIXME: returning dummy value in absence of valid statistics
1.118 + return 0;
1.119 + }
1.120 +
1.121 + /**
1.122 + * @param item_id
1.123 + * ID of the item being queried, a tactic for example
1.124 + * @param dialog_atom
1.125 + * ID of the interactional context use DIALOG_ATOM_ANY if asking
1.126 + * for statistics for all dialog atoms
1.127 + * @return standard deviation of time spent in interactions with this item
1.128 + */
1.129 + public float getTimeSpentStddev(int item_id, int dialog_atom) {
1.130 + // FIXME: returning dummy value in absence of valid statistics
1.131 + return 0;
1.132 + }
1.133 +
1.134 + /**
1.135 + * Mark the beginning of an interaction with an item.
1.136 + *
1.137 + * @param item_id
1.138 + * ID of the item being acted upon, a tactic for example
1.139 + * @param dialog_atom
1.140 + * ID of the interactional context
1.141 + * @return unique number to indentify the end of the transaction
1.142 + */
1.143 + public int startInteraction(int item_id, int dialog_atom) {
1.144 + // FIXME: insert code to record statistics
1.145 +
1.146 + // record timestamp
1.147 + // new java.util.Date(); ...
1.148 +
1.149 + // save in static vector of currently open interactions
1.150 + // ...
1.151 +
1.152 + return interaction_nr_++;
1.153 + }
1.154 +
1.155 + /**
1.156 + * Mark the end of an interaction with an item.
1.157 + *
1.158 + * @param interaction_id
1.159 + * ID of the interaction returned from the call to
1.160 + * {@link # startInteraction() }
1.161 + * @param success
1.162 + * information about the success of the interaction
1.163 + * @return false in case of failure - no matching start could be found, true
1.164 + * in case of success
1.165 + */
1.166 + public boolean endInteraction(int interaction_id, int success) {
1.167 + // FIXME: insert code to record statistics
1.168 +
1.169 + // record end timestamp
1.170 + // new java.util.Date(); ...
1.171 +
1.172 + // add to statistics
1.173 +
1.174 + // delete from static vector of currently open interactions
1.175 + // ...
1.176 +
1.177 + return true;
1.178 + }
1.179 +
1.180 + //WN050311 just for creation of the first file
1.181 + //beware of the fix path !
1.182 + public static void main(String[] args) {
1.183 + UserModel a = new UserModel("isac/xmldata/users", "x");
1.184 + a.setProperty("TODO-key", "TODO-value");
1.185 +
1.186 + String filename = "isac/xmldata/users/x_model.txt";
1.187 + try {
1.188 + FileOutputStream propOutFile = new FileOutputStream(filename);
1.189 + a.store(propOutFile, "dynamic dialog data of user 'x'");
1.190 +
1.191 + } catch (IOException e) {
1.192 + System.err.println("I/O failed.");
1.193 + }
1.194 +
1.195 + }
1.196 +}
1.197 \ No newline at end of file