CInbox (Common-Inbox)  0.1
Common functionality for ingesting files for archiving.
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
CITask Class Reference
Inheritance diagram for CITask:
TaskCopy TaskDirListing TaskExec TaskFilesMatch TaskHash TaskLogfileCopy TaskSkeleton TaskCopyRsync TaskRenameTarget TaskDirListCSV TaskPostProcs TaskPreProcs TaskCleanFilenames TaskFilesMustExist TaskFilesValid TaskFilesWait TaskHashGenerate TaskHashOutput TaskHashSearch TaskHashValidate

Public Member Functions

 __construct (&$CIFolder, $label)
 
 getName ()
 
 setLabel ($label)
 
 getLabel ()
 
 setDescription ($description)
 
 getDescription ()
 
 skip ()
 
 skipIt ()
 
 setItemSubDirs ($itemSubDirs)
 
Querying the task status

These methods are related to reading/checking which status the task is currently in.

 getStatus ()
 
 statusUndefined ()
 
 statusRunning ()
 
 statusWait ()
 
 statusDone ()
 
 statusPBCT ()
 
 statusPBC ()
 
 statusSkipped ()
 
 statusError ()
 
 statusConfigError ()
 

Static Public Member Functions

static isRecursive ()
 
static oncePerItem ()
 
static getTaskByName ($taskName, $CIFolder)
 
static getTaskClassName ($taskName)
 

Public Attributes

Task status
const STATUS_UNDEFINED = 0
 Undefined. Default unless task changes it.
 
const STATUS_RUNNING = 1
 Undefined, but indicates that the task is in progress.
 
const STATUS_WAIT = 2
 Task decided that Item is not ready yet and shall be moved back to 'to-do'.
 
const STATUS_DONE = 5
 Success! This means the task completed successfully.
 
const STATUS_PBCT = 6
 There were problems, but the task may continue.
 
const STATUS_PBC = 7
 There were problems, but subsequent task may continue.
 
const STATUS_ERROR = 10
 An error occurred. Abort execution as soon as possible.
 
const STATUS_CONFIG_ERROR = 11
 If a config option was not valid.
 
const STATUS_SKIPPED = 15
 If task was skipped.
 
Task Modes

Different operational modes for a task.

const ONCE_PER_ITEM = false
 True: Run this task only once per item.
 
const IS_RECURSIVE = false
 Default (false): one task = one folder. True: The task performs actions on subfolders too.
 
Task Settings

This setting is defined here, since it affects multiple tasks if files are excluded from copy (HashGenerate, CopyToTarget, HashValidate, etc)

const CONF_COPY_EXCLUDE = 'COPY_EXCLUDE'
 Patterns which files to exclude from copying.
 
Miscellaneous

This setting is defined here, since it affects multiple tasks that need to access the temporary target folder (before TaskRenameTarget has run).

const MASK_TARGET_TEMP = 'temp_%s'
 

Protected Member Functions

 setName ($name)
 
 exclude ($file, $excludePatterns)
 
 optionIsArray ($option, $optionName)
 
 resolveTargetFolderTemp ($CIFolder=null)
 
Setting the task status

These methods are related to writing/setting the task's current status.

 setStatus ($status)
 
 setStatusUndefined ()
 
 setStatusRunning ()
 
 setStatusWait ()
 
 setStatusDone ()
 
 setStatusPBCT ()
 
 setStatusPBC ()
 
 setStatusSkipped ()
 
 setStatusError ()
 
 setStatusConfigError ()
 
Temp folder handling.
 checkTempFolder ()
 
 getTempFolder ()
 
 setTempFolder ($tempFolder=null)
 

Protected Attributes

Basics
 $logger
 Logging handler.
 
 $name
 Class name of this task.
 
 $label
 Human readable Task label.
 
 $description
 Human readable description of Task's purpose/actions.
 
Folder handling
 $CIFolder
 CIFolder object that provides all information needed for this task.
 
 $sourceFolder
 Source folder of this task.
 
 $targetFolder
 Target folder of this task (read from config).
 
 $targetFolderTemp
 Temporary name of Target folder of this task. Used until inbox processing completed successfully.
 
 $itemSubDirs
 Array of Item subfolders: key=foldername, value=CIFolder (initialized with its config).
 
Temp folder handling
 $tempFolder
 Path of the temp folder for this task.
 
Task config options

Variables that contain settings from the config file.

 $copyExclude
 Contains the value of CONF_COPY_EXCLUDE.
 

Status handling

 $skip = false
 True: Skip execution. Default=false (=normal execution).
 
 $status
 Status of this task (=for current item subfolder).
 
static $statusGlobal
 Status of the sum of tasks of this type. // TODO! Implement and use this.
 

Common task functions

 init ()
 
 run ()
 
 finalize ()
 
 loadSettings ()
 

Detailed Description

Base class for Common Inbox tasks.

Author
Peter Bubestinger-Steindl (pb@av.nosp@m.-rd..nosp@m.com)
See also

Member Function Documentation

CITask::checkTempFolder ( )
protected

Tests if the currently set temp-folder of this task's CIFolder exists, and is writeable.

Return values
booleanReturns 'true' if temp folder exists and meets all conditions. If not, then exceptions are thrown.
See also
$tempFolder
CITask::exclude (   $file,
  $excludePatterns 
)
protected

Checks if a file shall be excluded from processing, according to file patterns in $excludePatterns.

Return values
booleanReturns 'true' if file shall be excluded, 'false' if it shall be copied.
CITask::finalize ( )

Actions to be performed after run() finished successfully;

Return values
booleanTrue if task shall proceed. False if not.
CITask::getDescription ( )

Returns a multi-line string describing this Task.

See also
$description
CITask::getLabel ( )

Returns the human readable label of this task.

See also
$label
CITask::getName ( )

Returns the name of this task type. This currently equals the class name.

See also
$name
CITask::getStatus ( )

Return the status of processing of this task. Used to determine if task is still running, already finished - and if successful or not.

static CITask::getTaskByName (   $taskName,
  $CIFolder 
)
static

Creates an instance of a Task matching classname returned by getTaskClassName().

static CITask::getTaskClassName (   $taskName)
static

Returns the class name of a task corresponding to "$taskName".

Naming convention is that all task classes start with the word "Task".

CITask::getTempFolder ( )
protected

Returns the current temp folder to use by this task. Please run checkTempFolder() before calling this to make sure we have a valid tempFolder.

Return values
stringPath of the temp folder for this task.
See also
$tempFolder
CITask::init ( )

Prepare everything so it's ready for processing.

Return values
booleanTrue if task shall proceed. False if not.
static CITask::isRecursive ( )
static

Returns 'true' if this task performs recursive actions or 'false' if it only applies actions to the current folder.

CITask::loadSettings ( )
protected

Load settings from config that are relevant for this task.

Return values
booleanTrue if everything went fine. False if not.
static CITask::oncePerItem ( )
static

Returns 'true' if this task is to be run only once per Item.

CITask::optionIsArray (   $option,
  $optionName 
)
protected

Checks if config option is an array and sets task status to STATUS_CONFIG_ERROR if not.

CITask::resolveTargetFolderTemp (   $CIFolder = null)
protected

Constructs the name of the temporary target folder for this CIFolder. Returns the resolved $targetFolderTemp as string, or False if problems occurred.

See also
static::MASK_TARGET_TEMP
$this->targetFolderTemp
CITask::run ( )

Perform the actual steps of this task.

Return values
booleanTrue if task shall proceed. False if not.
CITask::setDescription (   $description)

Set a description for this task. What it's supposed to do, what is good to know, etc.

Can be a multi-line string with linebreaks.

See also
$description
CITask::setItemSubDirs (   $itemSubDirs)

Provide an array with item subfolders and CIFolder objects already initialized for each one.

This is useful/necessary for self-recursive tasks, in order to e.g. access configuration of certain item subfolders, etc.

CITask::setLabel (   $label)

Set human readable label for this task.

See also
$label
CITask::setName (   $name)
protected

Sets the name of this task type.

CITask::setStatus (   $status)
protected

Updates the task's current status to $status. See CITask const definitions about valid task states.

Returns 'true' if status is good and task shall continue, and 'false' if a negative state was set, and task execution shall abort.

Return values
boolean'false' if task was set to a negative/faulty/unsuccessful status, such as STATUS_ERROR or STATUS_CONFIG_ERROR. 'true' for all other states.
CITask::setStatusConfigError ( )
protected

Set task status to STATUS_CONFIG_ERROR

See also
setStatus()
CITask::setStatusDone ( )
protected

Set task status to STATUS_DONE

See also
setStatus()
CITask::setStatusError ( )
protected

Set task status to STATUS_ERROR

See also
setStatus()
CITask::setStatusPBC ( )
protected

Set task status to STATUS_PBC

See also
setStatus()
CITask::setStatusPBCT ( )
protected

Set task status to STATUS_PBCT

See also
setStatus()
CITask::setStatusRunning ( )
protected

Set task status to STATUS_RUNNING

See also
setStatus()
CITask::setStatusSkipped ( )
protected

Set task status to STATUS_SKIPPED

See also
setStatus()
CITask::setStatusUndefined ( )
protected

Set task status to STATUS_UNDEFINED

See also
setStatus()
CITask::setStatusWait ( )
protected

Set task status to STATUS_WAIT

See also
setStatus()
CITask::setTempFolder (   $tempFolder = null)
protected

Sets the temp folder of this task.

See also
$tempFolder
CITask::skip ( )

Returns 'true' if execution of this task is to be skipped.

Used for optional tasks.

See also
$skip
CITask::skipIt ( )

Use this to mark this task as "to be skipped".

CITask::statusConfigError ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_CONFIG_ERROR, 'false' if not.
CITask::statusDone ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_DONE, 'false' if not.
CITask::statusError ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_ERROR, 'false' if not.
CITask::statusPBC ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_PBC, 'false' if not.
CITask::statusPBCT ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_PBCT, 'false' if not.
CITask::statusRunning ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_RUNNING, 'false' if not.
CITask::statusSkipped ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_SKIPPED, 'false' if not.
CITask::statusUndefined ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_UNDEFINED, 'false' if not.
CITask::statusWait ( )

Queries the task's status.

Return values
boolean'true' if task status is STATUS_WAIT, 'false' if not.

The documentation for this class was generated from the following file: