com.bits.mainserver
Class DAL

java.lang.Object
  extended by com.bits.mainserver.DAL

public class DAL
extends java.lang.Object

Data Access Layer to communicate with the DB

Author:
sophirha

Constructor Summary
DAL()
           
 
Method Summary
static boolean addTaskToExperiment(java.lang.String expName, java.lang.String taskName)
          Adds a task to the experiment
static boolean changeUserPassword(UserInfo u, java.lang.String newPassword)
          Replaces the user's password with the new one
static boolean checkConnection()
          This method returns true if a connection to the Database is available, and false otherwise
static boolean checkPassword(java.lang.String userID, java.lang.String givenPassword)
          Validates if the user's password matches the given one
static void clearGameProperties()
          removes all games from the DB
static boolean createExperiment(java.lang.String expname)
          Creates a new experiment
static boolean createTask(java.lang.String tName, java.lang.String tScript)
          creates a new task
static void deleteExperiment(java.lang.String expName)
          deletes an experiment (the tasks are not deleted)
static void deleteTask(java.lang.String taskName)
          Deletes a task from the DB, the script is not recoverable
static boolean deleteTaskFromExperiment(java.lang.String expName, java.lang.String taskName)
          removes a task from an experiment
static java.util.ArrayList<Experiment> getAllExperiments()
           
static java.util.ArrayList<Task> getAllTasks()
           
static java.util.ArrayList<Task> getExperimentTasks(java.lang.String expName)
           
static java.util.LinkedList<standards3.games.game.GameProperties> getGamePropertiesByFilter(java.lang.String filterExpression)
          lists game properties that match a filter criteria
static java.util.LinkedList<GameResult> getGameResultArray(java.lang.String userID, java.util.UUID gameID)
           
static java.util.LinkedList<GameResult> getGameResultsForUser(java.lang.String userID)
          gets all game results for the user
static java.util.LinkedList<UserInfo> getPatients(UserInfo doctor)
          list patients for the doctor
static RecommendedSession getRecommendedSession(UserInfo ui)
          retrieves the session saved for the user
static java.util.HashMap<standards3.games.game.GameProperties,java.util.LinkedList<GameResult>> getResultsForUser(UserInfo ui)
          gets all results for user mapped with the properties
static java.lang.String getTask(java.lang.String taskName)
          gets a task's script
static java.util.LinkedList<GameResult> getTPResultsByFunc(java.util.UUID tpid, standards3.games.categories.Functionality func)
          gets the training program results for a specific functionality
static UserInfo getUserInfo(java.lang.String userID)
          gets userinfo by name (id)
static TrainingProgram getUserTrainingProgram(UserInfo ui)
           
static java.lang.String LoadRecordedTask()
          Deprecated. 
static java.lang.String LoadScript()
          Deprecated. 
static boolean saveGameProperties(standards3.games.game.GameProperties props)
          saves a property to the DB, updates if exists
static boolean SaveRecordedTask(java.lang.String taskToSave)
          Deprecated. 
static boolean SaveScript(java.lang.String scriptToSave)
          Deprecated. 
static boolean setRecommendedSession(UserInfo ui, RecommendedSession rs, boolean overwrite)
           
static boolean setUserInfo(UserInfo userInfo)
          updates or inserts user info
static boolean setUserTrainingProgram(UserInfo ui, TrainingProgram tp)
          updates or inserts a training program for a user
static boolean updateResults(standards3.games.interfaces.IGameResult gameResult, UserInfo user, java.util.UUID gameId, java.util.UUID trainingProgramID)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DAL

public DAL()
Method Detail

addTaskToExperiment

public static boolean addTaskToExperiment(java.lang.String expName,
                                          java.lang.String taskName)
Adds a task to the experiment

Parameters:
expName - the name of the experiment
taskName - the name of the task
Returns:
true if successful, false otherwise

changeUserPassword

public static boolean changeUserPassword(UserInfo u,
                                         java.lang.String newPassword)
Replaces the user's password with the new one

Parameters:
u - the userinfo of the user
newPassword - the new password
Returns:
success status

checkConnection

public static boolean checkConnection()
This method returns true if a connection to the Database is available, and false otherwise


checkPassword

public static boolean checkPassword(java.lang.String userID,
                                    java.lang.String givenPassword)
Validates if the user's password matches the given one

Parameters:
userID - the username to check for
givenPassword - the password to check
Returns:
true if the passwords match, false otherwise

clearGameProperties

public static void clearGameProperties()
removes all games from the DB


createExperiment

public static boolean createExperiment(java.lang.String expname)
Creates a new experiment

Parameters:
expname - the experiment's name
Returns:
success status

createTask

public static boolean createTask(java.lang.String tName,
                                 java.lang.String tScript)
creates a new task

Parameters:
tName - name of the task
tScript - the task's script
Returns:
success status

deleteExperiment

public static void deleteExperiment(java.lang.String expName)
deletes an experiment (the tasks are not deleted)

Parameters:
expName - name of experiment to delete

deleteTask

public static void deleteTask(java.lang.String taskName)
Deletes a task from the DB, the script is not recoverable

Parameters:
taskName - name of task to delete

deleteTaskFromExperiment

public static boolean deleteTaskFromExperiment(java.lang.String expName,
                                               java.lang.String taskName)
removes a task from an experiment

Parameters:
expName - name of expermient
taskName - name of
Returns:
true if deletion was successful

getAllExperiments

public static java.util.ArrayList<Experiment> getAllExperiments()
Returns:
a list of all currently available experiments

getAllTasks

public static java.util.ArrayList<Task> getAllTasks()
Returns:
a list of all currently available tasks

getExperimentTasks

public static java.util.ArrayList<Task> getExperimentTasks(java.lang.String expName)
Parameters:
expName - the name of experiment to get tasks for
Returns:
list of that expermient tasks, can be empty

getGamePropertiesByFilter

public static java.util.LinkedList<standards3.games.game.GameProperties> getGamePropertiesByFilter(java.lang.String filterExpression)
lists game properties that match a filter criteria

Parameters:
filterExpression - the expression to be inserted in the where clause, can be empty to get all properties
Returns:
list of matching properties

getGameResultArray

public static java.util.LinkedList<GameResult> getGameResultArray(java.lang.String userID,
                                                                  java.util.UUID gameID)
Parameters:
userID - username to get results for
gameID - gameid to list results of
Returns:
list of game results

getGameResultsForUser

public static java.util.LinkedList<GameResult> getGameResultsForUser(java.lang.String userID)
gets all game results for the user

Parameters:
userID - the user to list results for
Returns:
list of game results

getPatients

public static java.util.LinkedList<UserInfo> getPatients(UserInfo doctor)
list patients for the doctor

Parameters:
doctor - the userinfo of the doctor
Returns:
list of users that are the doctors patients

getRecommendedSession

public static RecommendedSession getRecommendedSession(UserInfo ui)
retrieves the session saved for the user

Parameters:
ui - the user to get the session for
Returns:
the session that is saved, null if not found

getResultsForUser

public static java.util.HashMap<standards3.games.game.GameProperties,java.util.LinkedList<GameResult>> getResultsForUser(UserInfo ui)
gets all results for user mapped with the properties

Parameters:
ui - the user to get results for
Returns:
mapping for each game properties that exists

getTask

public static java.lang.String getTask(java.lang.String taskName)
gets a task's script

Parameters:
taskName - the name of the task
Returns:
the script that is saved, null if not exists

getTPResultsByFunc

public static java.util.LinkedList<GameResult> getTPResultsByFunc(java.util.UUID tpid,
                                                                  standards3.games.categories.Functionality func)
gets the training program results for a specific functionality

Parameters:
tpid - the id of the training program
func - the functionality
Returns:
list of results

getUserInfo

public static UserInfo getUserInfo(java.lang.String userID)
gets userinfo by name (id)

Parameters:
userID - name of user
Returns:
userinfo

getUserTrainingProgram

public static TrainingProgram getUserTrainingProgram(UserInfo ui)
Parameters:
ui - user to get the training program for
Returns:
the training program

LoadRecordedTask

@Deprecated
public static java.lang.String LoadRecordedTask()
Deprecated. 

not needed

Returns:
saved task from database

LoadScript

@Deprecated
public static java.lang.String LoadScript()
Deprecated. 

not needed

Returns:
saved script from DB

saveGameProperties

public static boolean saveGameProperties(standards3.games.game.GameProperties props)
saves a property to the DB, updates if exists

Parameters:
props -
Returns:
success status

SaveRecordedTask

@Deprecated
public static boolean SaveRecordedTask(java.lang.String taskToSave)
Deprecated. 

not needed

Parameters:
taskToSave -
Returns:

SaveScript

@Deprecated
public static boolean SaveScript(java.lang.String scriptToSave)
Deprecated. 

not needed

Parameters:
scriptToSave -
Returns:

setRecommendedSession

public static boolean setRecommendedSession(UserInfo ui,
                                            RecommendedSession rs,
                                            boolean overwrite)
Parameters:
ui - user to save session for
rs - the session to save
overwrite - flag that allows overwriting
Returns:
success status

setUserInfo

public static boolean setUserInfo(UserInfo userInfo)
updates or inserts user info

Parameters:
userInfo -
Returns:
success status

setUserTrainingProgram

public static boolean setUserTrainingProgram(UserInfo ui,
                                             TrainingProgram tp)
updates or inserts a training program for a user

Parameters:
ui - user
tp - training program
Returns:
success status

updateResults

public static boolean updateResults(standards3.games.interfaces.IGameResult gameResult,
                                    UserInfo user,
                                    java.util.UUID gameId,
                                    java.util.UUID trainingProgramID)
Parameters:
gameResult - result to save
user - user that played
gameId - game that was played
trainingProgramID - if was part of training program, can be null
Returns: