CInbox (Common-Inbox)  0.1
Common functionality for ingesting files for archiving.
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
CIItem Class Reference
Inheritance diagram for CIItem:
CIFolder

List of all members.

Public Member Functions

 __construct ($itemId, &$logger, $folderName, $baseFolder=null)
 isInitialized ()
 isConfigured ()
 setStatus ($status)
 getStatus ()
 setItemId ($itemId)
 getItemId ()
 isItemIdValid ($itemId, $itemIdValidRegEx)
 initItemSettings ()
 initItem ()
 callBucketScript ($script, &$bucket)
 getDefaultValues ()
 runTask ($folder, $taskName, $itemSubDirs)
 process ()
 finalize ()
 canStart ()
 setTempFolder ($tempFolder)
 removeTempFolder ()
 getAge ()
 updateTimestamp ()

Public Attributes

 $tryAgain = false
Config options
const CONF_SECTION_ITEM = '__INBOX__'
const CONF_MAX_FOLDER_DEPTH = 'MAX_FOLDER_DEPTH'
const CONF_ITEM_ID_VALID = 'ITEM_ID_VALID'
const CONF_BUCKET_SCRIPT = 'BUCKET_SCRIPT'
const CONF_COOLOFF_TIME = 'COOLOFF_TIME'
const CONF_TASKLIST = 'TASKLIST'

Protected Member Functions

 initItemSubFolders ($folderName, $depth=null, $parent=null)
 initItemSubFolder ($folderName, $baseFolder, $parent)

Protected Attributes

 $itemId
 $initialized = false
 $configured = false

Item states

const STATUS_TODO = 'TODO'
const STATUS_IN_PROGRESS = 'IN_PROGRESS'
const STATUS_DONE = 'DONE'
const STATUS_ERROR = 'ERROR'
static $itemStates

Detailed Description

This class is a logical representation of an CInbox Item. Each Item represents an archival package to regard as one.

Therefore, each Item requires a unique identifier (Item ID), which is also known in archival terms as "object identifier", "archive signature" or similar.

The list of tasks to be processed for each Item is handled in here.

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

Member Function Documentation

CIItem::callBucketScript ( script,
&$  bucket 
)

This calls an external script with the ItemID as argument.

The output of that script will be used as-is and resolves the placeholder "[@BUCKET@]". This can be used to have a custom subfolder structure for each Item at the target destination.

For example: ItemID = VX-00815 Bucket = VX/00/VX-00815

As you can see in the example, the resulting subfolder structure creates something like "buckets" which divides the amount of ItemIDs over several subfolders, following a custom syntax (which would be in the external script).

Returns 'true' if start condition for this item is fulfilled. False if item is not ready for processing yet.

Do whatever things are to-be-done to finalize an item in order to proceed to the next one.

Returns the "age" of an item.

Every change to a file/folder in the item resets the age. Can be used to determine if the item is still being written/changed or if it is safe to process it.

If the item's folder is empty, the modification time of the folder itself will be used.

Return values:
numericAge of the youngest file/folder in $folder. In minutes.
See also:
Helper::getYoungest()

Set default values for Item settings. This must be loaded before 'loadSettings()' in order to have default values instead of empty values where no setting was configured in config file.

Returns the current status of this Item.

See also:
$itemStates

Initialize an Item, so that everything's ready to begin processing the tasklist.

NOTE: initItemSettings() must have been run before!

The ItemID is checked against CONF_ITEM_ID_VALID. The bucket script is executed.

Load item configuration from INI file. It makes sure that placeholders are resolved and default values are loaded.

It sets the property $configured to true, to indicate that the item has been configured properly.

Return values:
boolean'true' if successful, 'false' if not.
CIItem::initItemSubFolders ( folderName,
depth = null,
parent = null 
) [protected]

Recursion through subfolder structure of current item. Returns a flat array with: keys: foldernames (absolute) values: CIFolder (initialized with config and parent set)

CIItem::isItemIdValid ( itemId,
itemIdValidRegEx 
)

Checks if itemId is valid, according to Regular Expressions in config file: #ITEM_ID_VALID

Parameters:
stringitemId The itemId (=object identifier = archive signature)
stringitemIdValidRegEx Array of RegEx (string) from config file: #ITEM_ID_VALID
Returns:
True if valid, False if not.

Deletes the item's temporary folder (including subfolders and files)

CIItem::runTask ( folder,
taskName,
itemSubDirs 
)

Instantiates and runs the task defined by $taskName on the given $folder. $folder must be an object of class type "CIFolder" and must already be initialized properly before.

$subDirs must be supplied with the output of "initItemSubFolders()".

The return value is the task instance itself, which allows the calling function to access all information to decide how to proceed. See "CITask" for details about Task statuses.

CIItem::setStatus ( status)

Sets the current status of this Item to $status.

See also:
$itemStates
CIItem::setTempFolder ( tempFolder)

Set where temporary files are to be stored in.

Folder must already exist, be writable - and subfolders there must follow naming conventions of Common Inbox, so data can be exchanged in temporary files between different tasks - and Inbox runs.

Reimplemented from CIFolder.

Updates the item's source timestamp to now.


Member Data Documentation

CIItem::$itemStates [static]
Initial value:
 array(            
            self::STATUS_TODO,
            self::STATUS_IN_PROGRESS,
            self::STATUS_DONE,
            self::STATUS_ERROR,
            )

The documentation for this class was generated from the following file:
 All Classes Functions Variables