|
CInbox (Common-Inbox)
0.1
Common functionality for ingesting files for archiving.
|
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 | |
Available status options for task execution. | |
| 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 () | |
Base class for Common Inbox tasks.
|
protected |
Tests if the currently set temp-folder of this task's CIFolder exists, and is writeable.
| boolean | Returns 'true' if temp folder exists and meets all conditions. If not, then exceptions are thrown. |
|
protected |
Checks if a file shall be excluded from processing, according to file patterns in $excludePatterns.
| boolean | Returns 'true' if file shall be excluded, 'false' if it shall be copied. |
| CITask::finalize | ( | ) |
Actions to be performed after run() finished successfully;
| boolean | True if task shall proceed. False if not. |
| CITask::getDescription | ( | ) |
Returns a multi-line string describing this Task.
| CITask::getLabel | ( | ) |
Returns the human readable label of this task.
| CITask::getName | ( | ) |
Returns the name of this task type. This currently equals the class 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 |
Creates an instance of a Task matching classname returned by getTaskClassName().
|
static |
Returns the class name of a task corresponding to "$taskName".
Naming convention is that all task classes start with the word "Task".
|
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.
| string | Path of the temp folder for this task. |
| CITask::init | ( | ) |
Prepare everything so it's ready for processing.
| boolean | True if task shall proceed. False if not. |
|
static |
Returns 'true' if this task performs recursive actions or 'false' if it only applies actions to the current folder.
|
protected |
Load settings from config that are relevant for this task.
| boolean | True if everything went fine. False if not. |
|
static |
Returns 'true' if this task is to be run only once per Item.
|
protected |
Checks if config option is an array and sets task status to STATUS_CONFIG_ERROR if not.
|
protected |
Constructs the name of the temporary target folder for this CIFolder. Returns the resolved $targetFolderTemp as string, or False if problems occurred.
| CITask::run | ( | ) |
Perform the actual steps of this task.
| boolean | True 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.
| 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.
|
protected |
Sets the name of this task type.
|
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.
| 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. |
|
protected |
Set task status to STATUS_CONFIG_ERROR
|
protected |
Set task status to STATUS_DONE
|
protected |
Set task status to STATUS_ERROR
|
protected |
Set task status to STATUS_PBC
|
protected |
Set task status to STATUS_PBCT
|
protected |
Set task status to STATUS_RUNNING
|
protected |
Set task status to STATUS_SKIPPED
|
protected |
Set task status to STATUS_UNDEFINED
|
protected |
Set task status to STATUS_WAIT
|
protected |
Sets the temp folder of this task.
| CITask::skip | ( | ) |
| CITask::skipIt | ( | ) |
Use this to mark this task as "to be skipped".
| CITask::statusConfigError | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_CONFIG_ERROR, 'false' if not. |
| CITask::statusDone | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_DONE, 'false' if not. |
| CITask::statusError | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_ERROR, 'false' if not. |
| CITask::statusPBC | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_PBC, 'false' if not. |
| CITask::statusPBCT | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_PBCT, 'false' if not. |
| CITask::statusRunning | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_RUNNING, 'false' if not. |
| CITask::statusSkipped | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_SKIPPED, 'false' if not. |
| CITask::statusUndefined | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_UNDEFINED, 'false' if not. |
| CITask::statusWait | ( | ) |
Queries the task's status.
| boolean | 'true' if task status is STATUS_WAIT, 'false' if not. |
1.8.11