edu.wpi.prc.project
Class Project

java.lang.Object
  extended by edu.wpi.prc.project.Project

public class Project
extends java.lang.Object

The Project class stores information specific to the PRC project.

Author:
James Baldassari

Field Summary
private static java.lang.String clientDir
           
private  int clientPort
           
private static java.lang.String configFilePath
           
private  java.lang.String dbPassword
           
private  java.lang.String dbTypeStr
           
private  java.lang.String dbURI
           
private  java.lang.String dbUserName
           
private  boolean defaultValidator
           
private  java.lang.String failedSpotCheckActionStr
           
private static java.lang.String generatorProgram
           
private  long id
           
private  int minNumResults
           
private  int minNumSpotChecks
           
private  java.lang.String name
           
private  java.lang.String password
           
private static Project project
           
private static java.lang.String resultValidatorProgram
           
private  java.lang.String scienceApp
           
private  int scienceAppPort
           
private static java.lang.String serverDir
           
private  java.lang.String serverURI
           
private  float spotCheckProbability
           
private  java.lang.String transitionerURI
           
private static java.lang.String unixExtension
           
private static java.lang.String winExtension
           
 
Constructor Summary
protected Project()
          Protected constructor because this class is a singleton but needs to be constructed by Hibernate.
 
Method Summary
static Project createProject()
          There is one case in which it is necessary to create a new project without reading project information from the database or from the project.properties file: when creating a new project from the ProjectBuilder.
 java.lang.String getClientDirectoryPath()
          Returns the path to the client directory.
 int getClientPort()
           
 java.lang.String getDbPassword()
           
 DatabaseType getDbType()
           
protected  java.lang.String getDbTypeStr()
           
 java.lang.String getDbURI()
           
 java.lang.String getDbUserName()
           
 boolean getDefaultValidator()
           
protected  java.lang.String getFailedSpotCheckActionStr()
           
 java.lang.String getGeneratorPath()
          Returns the path to the project specific work unit generator program.
protected  long getId()
           
 int getMinNumResults()
           
 int getMinNumSpotChecks()
           
 java.lang.String getName()
           
private static OperatingSystemType getOSType()
          Reads the "os.name" system property and parses it to determine what operating system is being used.
 java.lang.String getPassword()
           
private static java.lang.String getProjectPath()
           
 java.lang.String getResultValidatorPath()
          Returns the path to the project specific result validator program.
 java.lang.String getScienceApp()
           
 java.lang.String getScienceAppPath()
          Returns the path to the project specific science application.
 int getScienceAppPort()
           
private static java.lang.String getScriptExtension()
          Returns the operating system specific file extension for scripts.
 java.lang.String getServerDirectoryPath()
          Returns the path to the server directory.
 java.lang.String getServerURI()
           
 SpotCheckFailureAction getSpotCheckFailureAction()
           
 float getSpotCheckProbability()
           
 java.lang.String getTransitionerURI()
           
static Project instance()
          Retrieves the project information from the database and returns it as a Project object.
static boolean projectFileExists()
          Looks for the project configuration file in the default location.
static Project readFromDatabase()
          Attempts to read the project configuration from the database specified in the project configuration file.
static Project readFromFile()
          Retrieves the project settings from the configuration file rather than the database using the default location for the configuration file.
static Project readFromFile(java.lang.String filePath)
          Retrieves the project settings from the configuration file rather than the database allowing the path of the configuration file to be specified.
 void saveOrUpdate()
          Saves this Project to the database or updates it if it already exists.
 void setClientPort(int clientPort)
           
 void setDbPassword(java.lang.String dbPassword)
           
 void setDbType(DatabaseType dbType)
           
protected  void setDbTypeStr(java.lang.String dbTypeStr)
           
 void setDbURI(java.lang.String dbPath)
           
 void setDbUserName(java.lang.String dbUserName)
           
 void setDefaultValidator(boolean defaultValidator)
           
protected  void setFailedSpotCheckActionStr(java.lang.String failedSpotCheckActionStr)
           
protected  void setId(long id)
           
 void setMinNumResults(int minNumResults)
           
 void setMinNumSpotChecks(int minNumSpotChecks)
           
 void setName(java.lang.String name)
           
 void setPassword(java.lang.String password)
           
 void setScienceApp(java.lang.String scienceApp)
           
 void setScienceAppPort(int scienceAppPort)
           
 void setServerURI(java.lang.String projectURI)
           
 void setSpotCheckFailureAction(SpotCheckFailureAction action)
          Sets the action to take when a user fails a spot check.
 void setSpotCheckProbability(float spotCheckProbability)
           
 void setTransitionerURI(java.lang.String transitionerURI)
           
 void writeClientProjectFile(java.lang.String filePath)
          Writes all configuration information that is necessary for client components to a file.
 void writeServerProjectFile(java.lang.String filePath)
          Writes all configuration information that is necessary for server components to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

project

private static Project project

configFilePath

private static final java.lang.String configFilePath

clientDir

private static final java.lang.String clientDir
See Also:
Constant Field Values

serverDir

private static final java.lang.String serverDir
See Also:
Constant Field Values

generatorProgram

private static final java.lang.String generatorProgram
See Also:
Constant Field Values

resultValidatorProgram

private static final java.lang.String resultValidatorProgram
See Also:
Constant Field Values

unixExtension

private static final java.lang.String unixExtension
See Also:
Constant Field Values

winExtension

private static final java.lang.String winExtension
See Also:
Constant Field Values

id

private long id

name

private java.lang.String name

password

private java.lang.String password

serverURI

private java.lang.String serverURI

clientPort

private int clientPort

scienceApp

private java.lang.String scienceApp

scienceAppPort

private int scienceAppPort

transitionerURI

private java.lang.String transitionerURI

defaultValidator

private boolean defaultValidator

dbTypeStr

private java.lang.String dbTypeStr

dbURI

private java.lang.String dbURI

dbUserName

private java.lang.String dbUserName

dbPassword

private java.lang.String dbPassword

minNumResults

private int minNumResults

spotCheckProbability

private float spotCheckProbability

minNumSpotChecks

private int minNumSpotChecks

failedSpotCheckActionStr

private java.lang.String failedSpotCheckActionStr
Constructor Detail

Project

protected Project()
Protected constructor because this class is a singleton but needs to be constructed by Hibernate.

Method Detail

getId

protected long getId()
Returns:
Returns the id.

setId

protected void setId(long id)
Parameters:
id - The id to set.

getName

public java.lang.String getName()
Returns:
Returns the name.

setName

public void setName(java.lang.String name)
Parameters:
name - The name to set.

getPassword

public java.lang.String getPassword()
Returns:
Returns the password.

setPassword

public void setPassword(java.lang.String password)
Parameters:
password - The password to set.

getDbTypeStr

protected java.lang.String getDbTypeStr()
Returns:
Returns the dbTypeStr.

setDbTypeStr

protected void setDbTypeStr(java.lang.String dbTypeStr)
Parameters:
dbTypeStr - The dbTypeStr to set.

getDbType

public DatabaseType getDbType()
Returns:
Returns the type of database used by the project, or null if no database type was defined.

setDbType

public void setDbType(DatabaseType dbType)
Parameters:
dbType - The dbType to set.

getServerURI

public java.lang.String getServerURI()
Returns:
Returns the serverURI.

setServerURI

public void setServerURI(java.lang.String projectURI)
Parameters:
projectURI - The serverURI to set.

getClientPort

public int getClientPort()
Returns:
Returns the clientPort.

setClientPort

public void setClientPort(int clientPort)
Parameters:
clientPort - The clientPort to set.

getScienceApp

public java.lang.String getScienceApp()
Returns:
Returns the scienceApp.

setScienceApp

public void setScienceApp(java.lang.String scienceApp)
Parameters:
scienceApp - The scienceApp to set.

getScienceAppPort

public int getScienceAppPort()
Returns:
Returns the scienceAppPort.

setScienceAppPort

public void setScienceAppPort(int scienceAppPort)
Parameters:
scienceAppPort - The scienceAppPort to set.

getTransitionerURI

public java.lang.String getTransitionerURI()
Returns:
Returns the transitionerURI.

setTransitionerURI

public void setTransitionerURI(java.lang.String transitionerURI)
Parameters:
transitionerURI - The transitionerURI to set.

getDefaultValidator

public boolean getDefaultValidator()
Returns:
Returns the defaultValidator.

setDefaultValidator

public void setDefaultValidator(boolean defaultValidator)
Parameters:
defaultValidator - The defaultValidator to set.

getDbURI

public java.lang.String getDbURI()
Returns:
Returns the dbPath.

setDbURI

public void setDbURI(java.lang.String dbPath)
Parameters:
dbPath - The dbPath to set.

getDbUserName

public java.lang.String getDbUserName()
Returns:
Returns the dbUserName.

setDbUserName

public void setDbUserName(java.lang.String dbUserName)
Parameters:
dbUserName - The dbUserName to set.

getDbPassword

public java.lang.String getDbPassword()
Returns:
Returns the dbPassword.

setDbPassword

public void setDbPassword(java.lang.String dbPassword)
Parameters:
dbPassword - The dbPassword to set.

getMinNumResults

public int getMinNumResults()
Returns:
Returns the minNumResults.

setMinNumResults

public void setMinNumResults(int minNumResults)
Parameters:
minNumResults - The minNumResults to set.

getSpotCheckProbability

public float getSpotCheckProbability()
Returns:
Returns the spotCheckProbability.

setSpotCheckProbability

public void setSpotCheckProbability(float spotCheckProbability)
Parameters:
spotCheckProbability - The spotCheckProbability to set.

getMinNumSpotChecks

public int getMinNumSpotChecks()
Returns:
Returns the minNumSpotChecks.

setMinNumSpotChecks

public void setMinNumSpotChecks(int minNumSpotChecks)
Parameters:
minNumSpotChecks - The minNumSpotChecks to set.

getFailedSpotCheckActionStr

protected java.lang.String getFailedSpotCheckActionStr()
Returns:
Returns the failedSpotCheckActionStr.

setFailedSpotCheckActionStr

protected void setFailedSpotCheckActionStr(java.lang.String failedSpotCheckActionStr)
Parameters:
failedSpotCheckActionStr - The failedSpotCheckActionStr to set.

getSpotCheckFailureAction

public SpotCheckFailureAction getSpotCheckFailureAction()
Returns:
Returns the action to take when a user fails a spot check.

setSpotCheckFailureAction

public void setSpotCheckFailureAction(SpotCheckFailureAction action)
Sets the action to take when a user fails a spot check.

Parameters:
action - The action to take.

getOSType

private static OperatingSystemType getOSType()
Reads the "os.name" system property and parses it to determine what operating system is being used.

Returns:
The type of operating system used.

getScriptExtension

private static java.lang.String getScriptExtension()
Returns the operating system specific file extension for scripts.

Returns:
The file extension for scripts.

getProjectPath

private static java.lang.String getProjectPath()
Returns:
Returns the absolute path to the current working directory, which is assumed to be the project directory.

getClientDirectoryPath

public java.lang.String getClientDirectoryPath()
Returns the path to the client directory.

Returns:
The path to the client directory.

getServerDirectoryPath

public java.lang.String getServerDirectoryPath()
Returns the path to the server directory.

Returns:
The path to the server directory.

getGeneratorPath

public java.lang.String getGeneratorPath()
Returns the path to the project specific work unit generator program.

Returns:
The path to the work unit generator program.

getResultValidatorPath

public java.lang.String getResultValidatorPath()
Returns the path to the project specific result validator program.

Returns:
The path to the result validator program.

getScienceAppPath

public java.lang.String getScienceAppPath()
Returns the path to the project specific science application.

Returns:
The path to the science application.

saveOrUpdate

public void saveOrUpdate()
                  throws org.hibernate.HibernateException
Saves this Project to the database or updates it if it already exists.

Throws:
org.hibernate.HibernateException

projectFileExists

public static boolean projectFileExists()
Looks for the project configuration file in the default location.

Returns:
Returns true if the file exists, false otherwise.

readFromFile

public static Project readFromFile()
                            throws MissingConfigurationFileException
Retrieves the project settings from the configuration file rather than the database using the default location for the configuration file.

Returns:
Returns a new project with values read from the configuration file.
Throws:
MissingConfigurationFileException

writeServerProjectFile

public void writeServerProjectFile(java.lang.String filePath)
                            throws java.io.IOException
Writes all configuration information that is necessary for server components to a file.

Parameters:
filePath - Path to the file that should be written.
Throws:
java.io.IOException

writeClientProjectFile

public void writeClientProjectFile(java.lang.String filePath)
                            throws java.io.IOException
Writes all configuration information that is necessary for client components to a file.

Parameters:
filePath - Path to the file that should be written.
Throws:
java.io.IOException

readFromFile

public static Project readFromFile(java.lang.String filePath)
                            throws MissingConfigurationFileException
Retrieves the project settings from the configuration file rather than the database allowing the path of the configuration file to be specified.

Parameters:
filePath - The path to the project configuration file.
Returns:
Returns a new project with values read from the configuration file.
Throws:
MissingConfigurationFileException

readFromDatabase

public static Project readFromDatabase()
                                throws org.hibernate.HibernateException
Attempts to read the project configuration from the database specified in the project configuration file.

Returns:
Returns the project that was stored in the database, or null if no project was found.
Throws:
org.hibernate.HibernateException

createProject

public static Project createProject()
There is one case in which it is necessary to create a new project without reading project information from the database or from the project.properties file: when creating a new project from the ProjectBuilder. It is only for this reason that the createNewProject() method is available. All other code should use Project.instance() or Project.readFromFile().

Returns:
Returns a new Project initialized with default values.

instance

public static Project instance()
Retrieves the project information from the database and returns it as a Project object.

Returns:
Project object containing project information from the database.