Huygens Remote Manager
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • hrm
    • job
    • param
      • base
    • setting
      • base
    • shell
    • stats
    • user
      • proxy

Classes

  • DatabaseConnection
  • Fileserver
  • FileserverV2
  • HuygensTemplate
  • HuygensTools
  • Log
  • Mail
  • Nav
  • OmeroConnection
  • QueueManager
  • System
  • Util
  • UtilV2
  • Validator

Functions

  • fileButton

Class DatabaseConnection

Manages the database connection through the ADOdb library.

This class abstracts the database back-end and should be used to handle all communication to and from it. Since there are some differences between the databases that still require specialized code, this class officially supports only MySQL and PostgreSQL.

Namespace: hrm
Package: hrm
Located at Database.php

Methods summary

public
# __construct( )

DatabaseConnection constructor: creates a database connection.

DatabaseConnection constructor: creates a database connection.

public boolean
# isReachable( )

Checks whether a connection to the DB is possible.

Checks whether a connection to the DB is possible.

Returns

boolean
True if the connection is possible, false otherwise.
public string
# type( )

Returns the type of the database (mysql, postgres)

Returns the type of the database (mysql, postgres)

Returns

string
The type of the database (e.g. mysql, postgres)
public string
# version( )

Attempts to get the version of the underlying database.

Attempts to get the version of the underlying database.

Returns

string
Version of the database (e.g. 2.2.14).
public string
# host( )

Returns the database host name.

Returns the database host name.

Returns

string
Name of the database host.
public string
# name( )

Returns the database name.

Returns the database name.

Returns

string
Name of the database.
public string
# user( )

Returns the name of the database user.

Returns the name of the database user.

Returns

string
Name of the database user.
public string
# password( )

Returns the password of the database user.

Returns the password of the database user.

Returns

string
Password of the database user.
public ADORecordSet_mysql|ADODB_postgres8|ADODB_postgres9
# connection( )

Returns the ADOConnection object.

Returns the ADOConnection object.

Returns

ADORecordSet_mysql|ADODB_postgres8|ADODB_postgres9
The connection object.
public ADORecordSet_empty|ADORecordSet_mysql|False
# execute( string $query )

Executes an SQL query.

Executes an SQL query.

Parameters

$query
SQL query.

Returns

ADORecordSet_empty|ADORecordSet_mysql|False
Query result.
public array|false
# query( string $queryString )

Executes an SQL query and returns the results.

Executes an SQL query and returns the results.

Parameters

$queryString
SQL query.

Returns

array|false
Result of the query (rows).
public array|false
# queryPrepared( string $sql, array $values )

Executes an SQL query and returns the results.

Executes an SQL query and returns the results.

Parameters

$sql
Prepared SQL query.
$values
Array of values for the prepared query.

Returns

array|false
Result of the query (rows).
public array
# queryLastRow( string $queryString )

Executes an SQL query and returns the last row of the results.

Executes an SQL query and returns the last row of the results.

Parameters

$queryString
SQL query.

Returns

array
Last row of the result of the query.
public string
# queryLastValue( string $queryString )

Executes an SQL query and returns the value in the last column of the last row of the results.

Executes an SQL query and returns the value in the last column of the last row of the results.

Parameters

$queryString
SQL query.

Returns

string

Value of the last column of the last row of the result of the query.

public boolean
# saveParameterSettings( hrm\setting\base\Setting $settings )

Saves the parameter values of the setting object into the database.

Saves the parameter values of the setting object into the database.

If the setting already exists, the old values are overwritten, otherwise a new setting is created.

Parameters

$settings
Settings object to be saved.

Returns

boolean
True if saving was successful, false otherwise.
public boolean
# saveSharedParameterSettings( hrm\setting\base\Setting $settings, string $targetUserName )

Save the parameter values of the setting object into the shared tables.

Save the parameter values of the setting object into the shared tables.

Parameters

$settings
Settings object to be saved.
$targetUserName

User name of the user that the Setting is to be shared with.

Returns

boolean
True if saving was successful, false otherwise.
public hrm\setting\base\Setting
# loadParameterSettings( hrm\setting\base\Setting $settings )

Loads the parameter values for a setting and returns a copy of the setting with the loaded parameter values.

Loads the parameter values for a setting and returns a copy of the setting with the loaded parameter values.

If a value starts with # it is considered to be an array with the first value at the index 0.

Parameters

$settings
Setting object to be loaded.

Returns

hrm\setting\base\Setting
$settings Setting object with loaded values.

Todo

Debug the switch blog (possibly buggy!)
public hrm\setting\base\Setting
# loadSharedParameterSettings( integer $id, string $type )

Loads the parameter values for a setting fro mthe sharead tabled and returns it.

Loads the parameter values for a setting fro mthe sharead tabled and returns it.

Parameters

$id
Setting id.
$type
Setting type (one of "parameter", "task", "analysis").

Returns

hrm\setting\base\Setting
object with loaded values.

Throws

Exception

Todo

Debug the second switch block (probably buggy!)
public array
# getTemplatesSharedWith( string $username, string $table )

Returns the list of shared templates with the given user.

Returns the list of shared templates with the given user.

Parameters

$username

Name of the user for whom to query for shared templates.

$table
Name of the shared table to query.

Returns

array
List of shared jobs.
public array
# getTemplatesSharedBy( string $username, string $table )

Returns the list of shared templates by the given user.

Returns the list of shared templates by the given user.

Parameters

$username

Name of the user for whom to query for shared templates.

$table
Name of the shared table to query.

Returns

array
List of shared jobs.
public boolean
# copySharedTemplate( integer $id, string $sourceSettingTable, string $sourceParameterTable, string $destSettingTable, string $destParameterTable )

Copies the relevant rows from shared- to user- tables.

Copies the relevant rows from shared- to user- tables.

Parameters

$id
ID of the setting to be copied.
$sourceSettingTable
Setting table to copy from.
$sourceParameterTable
Parameter table to copy from.
$destSettingTable
Setting table to copy to.
$destParameterTable
Parameter table to copy to.

Returns

boolean
True if copying was successful; false otherwise.
public boolean
# deleteSharedTemplate( integer $id, string $sourceSettingTable, string $sourceParameterTable )

Delete the relevant rows from the shared tables.

Delete the relevant rows from the shared tables.

Parameters

$id
ID of the setting to be deleted.
$sourceSettingTable
Setting table to copy from.
$sourceParameterTable
Parameter table to copy from.

Returns

boolean
True if deleting was successful; false otherwise.
public array
# updateDefault( hrm\setting\base\Setting $settings )

Updates the default entry in the database according to the default value in the setting.

Updates the default entry in the database according to the default value in the setting.

Parameters

$settings
Settings object to be used to update the default.

Returns

array
query result.
public boolean
# deleteSetting( hrm\setting\base\Setting $settings )

Deletes the setting and all its parameter values from the database.

Deletes the setting and all its parameter values from the database.

Parameters

$settings

Settings object to be used to delete all entries from the database.

Returns

boolean

true if the setting and all parameters were deleted from the database; false otherwise.

public boolean
# existsParametersFor( hrm\setting\base\Setting $settings )

Checks whether parameters are already stored for a given setting.

Checks whether parameters are already stored for a given setting.

Parameters

$settings

Settings object to be used to check for existence in the database.

Returns

boolean
True if the parameters exist in the database; false otherwise.
public boolean
# existsSharedParametersFor( hrm\setting\ParameterSetting|hrm\setting\TaskSetting|hrm\setting\AnalysisSetting $settings )

Checks whether parameters are already stored for a given shared setting.

Checks whether parameters are already stored for a given shared setting.

Parameters

$settings

Settings object to be used to check for existence in the database.

Returns

boolean
True if the parameters exist in the database; false otherwise.
public boolean
# existsSetting( hrm\setting\base\Setting $settings )

Checks whether settings exist in the database for a given owner.

Checks whether settings exist in the database for a given owner.

Parameters

$settings

Settings object to be used to check for existence in the database (the name of the owner must be set in the settings).

Returns

boolean
True if the settings exist in the database; false otherwise.
public boolean
# existsSharedSetting( hrm\setting\ParameterSetting|hrm\setting\TaskSetting|hrm\setting\AnalysisSetting $settings )

Checks whether shared settings exist in the database for a given owner.

Checks whether shared settings exist in the database for a given owner.

Parameters

$settings

$settings Settings object to be used to check for existence in the database (the name of the owner must be set in the settings)

Returns

boolean
True if the settings exist in the database; false otherwise.
public boolean
# saveJobFiles( string $id, string $owner, array $files, boolean $autoseries )

Adds all files for a given job id and user to the database.

Adds all files for a given job id and user to the database.

Parameters

$id
Job id.
$owner
Name of the user that owns the job.
$files
Array of file names.
$autoseries
True if the series is to be loaded automatically, false otherwise.

Returns

boolean

True if the job files could be saved successfully; false otherwise.

public array
# queueJob( string $id, string $username )

Adds a job for a given job id and user to the queue.

Adds a job for a given job id and user to the queue.

Parameters

$id
Job id.
$username
Name of the user that owns the job.

Returns

array
Query result.
public True
# setJobPriorities( )

Assigns priorities to the jobs in the queue.

Assigns priorities to the jobs in the queue.

Returns

True
if assigning priorities was successful.
public
# updateStatistics( hrm\job\Job $job, string $startTime )

Logs job information in the statistics table.

Logs job information in the statistics table.

Parameters

$job

Job object whose information is to be logged in the database.

$startTime
Job start time.
public array
# flatten( array $anArray )

Flattens a multi-dimensional array.

Flattens a multi-dimensional array.

Parameters

$anArray
Multi-dimensional array.

Returns

array
Flattened array.
public array
# readPossibleValues( hrm\param\base\Parameter $parameter )

Returns the possible values for a given parameter.

Returns the possible values for a given parameter.

Parameters

$parameter
Parameter object.

Returns

array
Flattened array of possible values.
public array
# readTranslatedPossibleValues( hrm\param\base\Parameter $parameter )

Returns the translated possible values for a given parameter.

Returns the translated possible values for a given parameter.

Parameters

$parameter
Parameter object.

Returns

array
Flattened array of translated possible values.
public string
# translationFor( string $parameterName, string $value )

Returns the translation of current value for a given parameter.

Returns the translation of current value for a given parameter.

Parameters

$parameterName
Name of the Parameter object.
$value
Value for which a translation should be returned.

Returns

string
Translated value.
public string
# hucoreTranslation( string $parameterName, string $hucorevalue )

Returns the translation of a hucore value.

Returns the translation of a hucore value.

Parameters

$parameterName
Name of the Parameter object.
$hucorevalue
Value name in HuCore.

Returns

string
Expected value by HRM.
public array
# allFileExtensions( )

Returns an array of all file extensions.

Returns an array of all file extensions.

Returns

array
Array of file extensions.
public array
# allMultiFileExtensions( )

Returns an array of all extensions for multi-dataset files.

Returns an array of all extensions for multi-dataset files.

Returns

array
Array of file extensions for multi-dataset files.
public array
# fileExtensions( string $imageFormat )

Returns an array of file extensions associated to a given file format.

Returns an array of file extensions associated to a given file format.

Parameters

$imageFormat
File format.

Returns

array
Array of file extensions.
public array
# readNumericalValueRestrictions( hrm\param\base\Parameter $parameter )

Returns all restrictions for a given numerical parameter.

Returns all restrictions for a given numerical parameter.

Parameters

$parameter
Parameter (object).

Returns

array
Array of restrictions.
public array
# fileFormatsWith( boolean $isSingleChannel, boolean $isVariableChannel, boolean $isFixedGeometry )

Returns the file formats that fit the conditions expressed by the parameters.

Returns the file formats that fit the conditions expressed by the parameters.

Parameters

$isSingleChannel

Set whether the file format must be single channel (True), multi channel (False) or if it doesn't matter (NULL).

$isVariableChannel

Set whether the number of channels must be variable (True), fixed (False) or if it doesn't matter (NULL).

$isFixedGeometry

Set whether the geometry (xyzt) must be fixed (True), variable (False) or if it doesn't matter (NULL).

Returns

array
Array of file formats.

Todo

Check if this method is still used.
public array
# geometriesWith( boolean $isThreeDimensional, boolean $isTimeSeries )

Returns the geometries (XY, XY-time, XYZ, XYZ-time) fit the conditions expressed by the parameters.

Returns the geometries (XY, XY-time, XYZ, XYZ-time) fit the conditions expressed by the parameters.

Parameters

$isThreeDimensional
True if 3D.
$isTimeSeries
True if time-series.

Returns

array
Array of geometries.

Todo

Check if this method is still used.
public array
# retrieveColumnFromTableWhere( string $column, string $table, array $conditions )

Return all values from the column from the table where the condition evaluates to true.

Return all values from the column from the table where the condition evaluates to true.

Parameters

$column
Name of the column from which the values are taken
$table
Name of the table from which the values are taken
$conditions

Array of conditions that the result values must fulfill. This is an array with column names as indices and boolean values as content.

Returns

array
Array of values.
public string
# defaultValue( string $parameterName )

Returns the default value for a given parameter.

Returns the default value for a given parameter.

Parameters

$parameterName
Name of the parameter.

Returns

string
Default value.
public string
# getNextIdFromQueue( )

Returns the id for next job from the queue, sorted by priority.

Returns the id for next job from the queue, sorted by priority.

Returns

string
Job id.
public array
# getQueueJobs( )

Returns all jobs from the queue, both compound and simple, ordered by priority.

Returns all jobs from the queue, both compound and simple, ordered by priority.

Returns

array
All jobs.
public array
# getQueueContents( )

Returns all jobs from the queue, both compound and simple, and the associated file names, ordered by priority.

Returns all jobs from the queue, both compound and simple, and the associated file names, ordered by priority.

Returns

array
All jobs.
public array
# getQueueContentsForId( string $id )

Returns all jobs from the queue for a given id (that must be unique!)

Returns all jobs from the queue for a given id (that must be unique!)

Parameters

$id
Id of the job.

Returns

array
All jobs for the id
public array
# getJobFilesFor( string $id )

Returns all file names associated to a job with given id.

Returns all file names associated to a job with given id.

Parameters

$id
Job id.

Returns

array
Array of file names.
public boolean
# getSeriesModeForId( string $id )

Returns the file series mode of a job with given id.

Returns the file series mode of a job with given id.

Parameters

$id
Job id

Returns

boolean
True if file series, false otherwise.
public string
# userWhoCreatedJob( string $id )

Returns the name of the user who created the job with given id.

Returns the name of the user who created the job with given id.

Parameters

$id
SId of the job.

Returns

string
Name of the user.
public boolean
# deleteJobFromTables( string $id )

Deletes job with specified ID from all job tables.

Deletes job with specified ID from all job tables.

Parameters

$id
Id of the job.

Returns

boolean
True if success, false otherwise.
public string
# huscriptPathOn( string $host )

Returns the path to hucore on given host.

Returns the path to hucore on given host.

Parameters

$host
Host name.

Returns

string
Full path to hucore.

Todo

Better management of multiple hosts.
public string
# freeServer( )

Get the name of a free server.

Get the name of a free server.

Returns

string
Name of the free server.
public string
# statusOfServer( string $name )

Get the status (i.e. free, busy, paused) of server with given name.

Get the status (i.e. free, busy, paused) of server with given name.

Parameters

$name
Name of the server.

Returns

string
Status (one of 'free', 'busy', or 'paused').
public boolean
# isServerBusy( string $name )

Checks whether server is busy.

Checks whether server is busy.

Parameters

$name
Name of the server.

Returns

boolean
True if the server is busy, false otherwise
public boolean
# isSwitchOn( )

Checks whether the switch in the queue manager is 'on'.

Checks whether the switch in the queue manager is 'on'.

Returns

boolean
True if switch is on, false otherwise.
public string
# getSwitchStatus( )

Gets the status of the queue manager's switch.

Gets the status of the queue manager's switch.

Returns

string
'on' or 'off'
public array
# setSwitchStatus( string $status )

Sets the status of the queue manager's switch.

Sets the status of the queue manager's switch.

Parameters

$status
Either 'on' or 'off'

Returns

array
Query result.
public array
# reserveServer( string $name, string $pid )

Sets the state of the server to 'busy' and the pid for a running job.

Sets the state of the server to 'busy' and the pid for a running job.

Parameters

$name
Server name.
$pid
Process identifier associated with a running job.

Returns

array
Query result.
public array
# resetServer( string $name, string $pid )

Sets the state of the server to 'free' and deletes the the pid.

Sets the state of the server to 'free' and deletes the the pid.

Parameters

$name
Server name.
$pid
Process identifier associated with a running job (UNUSED!).

Returns

array
Query result.
public array
# startJob( hrm\job\Job $job )

Starts a job.

Starts a job.

Parameters

$job
Job object.

Returns

array
Query result.
public array
# getRunningJobs( )

Get all running jobs.

Get all running jobs.

Returns

array
Array of Job objects.
public array
# availableServer( )

Get names of all processing servers (independent of their status).

Get names of all processing servers (independent of their status).

Returns

array
Array of server names.
public string
# startTimeOf( hrm\job\Job $job )

Get the starting time of given job object.

Get the starting time of given job object.

Parameters

$job
Job object.

Returns

string
Start time.
public string
# fromUnixTime( string $timestamp )

Returns a formatted time from a unix timestamp.

Returns a formatted time from a unix timestamp.

Parameters

$timestamp
Unix timestamp.

Returns

string
Formatted time string: YYYY-MM-DD hh:mm:ss.
public array
# pauseJob( string $id )

Pauses a job of given id.

Pauses a job of given id.

Parameters

$id
Job id

Returns

array
query result.
public array
# setJobEndTime( string $id, string $date )

Sets the end time of a job.

Sets the end time of a job.

Parameters

$id
Job id.
$date
Formatted date: YYYY-MM-DD hh:mm:ss.

Returns

array
Query result.
public array
# restartPausedJobs( )

Changes status of 'paused' jobs to 'queued'.

Changes status of 'paused' jobs to 'queued'.

Returns

array
Query result
public array
# markJobAsRemoved( string $id )

Marks a job with given id as 'broken' (i.e. to be removed).

Marks a job with given id as 'broken' (i.e. to be removed).

Parameters

$id
Job id.

Returns

array
Query result.
public array
# markServerAsFree( string $server )

Set the server status to free.

Set the server status to free.

Parameters

$server
Server name.

Returns

array
Query result.
public array
# getMarkedJobIds( )

Get all jobs with status 'broken'.

Get all jobs with status 'broken'.

Returns

array
Array of ids for broken jobs.
public array
# getJobIdsToKill( )

Get all jobs with status 'kill' to be killed by the Queue Manager.

Get all jobs with status 'kill' to be killed by the Queue Manager.

Returns

array
Array of ids for jobs to be killed.
public array
# getUserList( string $name )

Return the list of known users (without the administrator).

Return the list of known users (without the administrator).

Parameters

$name
User name to filter out from the list (optional).

Returns

array
Filtered array of users.
public string
# getJobOwner( string $id )

Get the name of the user who owns a job with given id.

Get the name of the user who owns a job with given id.

Parameters

$id
Job id.

Returns

string
Name of the user who owns the job.
public string
# now( )

Returns current database (!) date and time.

Returns current database (!) date and time.

Returns

string
formatted date (YYYY-MM-DD hh:mm:ss).
public string
# getGroup( string $userName )

Returns the group to which the user belongs.

Returns the group to which the user belongs.

Parameters

$userName
Name of the user

Returns

string
Group name.
public array
# updateMail( string $userName, string $email )

Updates the e-mail address of a user.

Updates the e-mail address of a user.

Parameters

$userName
Name of the user.
$email
E-mail address.

Returns

array
Query result.
public integer
# getMaxChanCnt( )

Gets the maximum number of channels from the database.

Gets the maximum number of channels from the database.

Returns

integer
The number of channels.
public array
# getSettingList( string $username, string $table )

Get the list of settings for the user with given name from the given settings table.

Get the list of settings for the user with given name from the given settings table.

The Parameter values are not loaded.

Parameters

$username
Name of the user.
$table
Name of the settings table.

Returns

array
Array of settings
public string
# getParameterConfidenceLevel( string $fileFormat, string $parameterName )

Get the parameter confidence level for given file format.

Get the parameter confidence level for given file format.

Parameters

$fileFormat

File format for which the Parameter confidence level is queried (not strictly necessary for the Parameters with confidence level 'Provide', could be set to '' for those).

$parameterName

Name of the Parameter the confidence level should be returned.

Returns

string
Parameter confidence level.
public boolean
# hasLicense( string $feature )

Finds out whether a Huygens module is supported by the license.

Finds out whether a Huygens module is supported by the license.

Parameters

$feature

The module to find out about. It can use (SQL) wildcards.

Returns

boolean

True if the module is supported by the license, false otherwise.

public boolean
# hucoreHasValidLicense( )

Checks whether Huygens Core has a valid license.

Checks whether Huygens Core has a valid license.

Returns

boolean
True if the license is valid, false otherwise.
public string
# hucoreServerType( )

Gets the licensed server type for Huygens Core.

Gets the licensed server type for Huygens Core.

Returns

string
One of desktop, small, medium, large, extreme.
public boolean
# storeLicenseDetails( string $licDetails )

Updates the database with the current HuCore license details.

Updates the database with the current HuCore license details.

Parameters

$licDetails
A string with the supported license features.

Returns

boolean

True if the license details were successfully saved, false otherwise.

public boolean
# storeConfidenceLevels( array $confidenceLevels )

Store the confidence levels returned by huCore into the database for faster retrieval.

Store the confidence levels returned by huCore into the database for faster retrieval.

This is a rather low-level function that creates the table if needed.

Parameters

$confidenceLevels

Array of confidence levels with file formats as keys.

Returns

boolean

True if storing (or updating) the database was successful, false otherwise.

public string
# getGPUID( $server )

Get the state of GPU acceleration (as string).

Get the state of GPU acceleration (as string).

Returns

string
One "true" or "false".
public integer
# addServer( $serverName, $huPath, $gpuId )

Add a server (including GPU info) to the list of processing machines for the queue manager.

Add a server (including GPU info) to the list of processing machines for the queue manager.

Returns

integer

0 on failure; 0 on success.

public integer
# removeServer( $serverName )

Remove a server from the list of processing machines for the queue manager.

Remove a server from the list of processing machines for the queue manager.

Returns

integer

0 on failure; 0 on success.

public
# getAllServers( $server )
Huygens Remote Manager API documentation generated by ApiGen