BatchController.php
40 * | _in_ `oneCall` | Boolean whether to accomplish the task in one call (optional, default: _false_)
46 * | `download` | The process is finished and the next call to `continue` will trigger the file download
62 * | `download` | The process is finished and the next call to `continue` will trigger the file download
75 const DOWNLOAD_STEP = 'BatchController.downloadStep'; // signals that the next continue action triggers the download
94 throw new ApplicationException($request, $response, ApplicationError::getGeneral("Current step undefined."));
101 throw new ApplicationException($request, $response, ApplicationError::getGeneral("Work packages undefined."));
118 throw new ApplicationException($request, $response, ApplicationError::getGeneral("Incomplete work package description."));
122 $this->addWorkPackage($workPackage['name'], $workPackage['size'], $workPackage['oids'], $workPackage['callback'], $args);
127 throw new ApplicationException($request, $response, ApplicationError::getGeneral("No work packages."));
191 * @param $name Display name of the package (will be supplemented by startNumber-endNumber, e.g. '1-7', '8-14', ...)
192 * @param $size Size of one sub package. This defines how many of the oids will be passed to the callback in one call (e.g. '7' means pass 7 oids per call)
193 * @param $oids An array of object ids (or other application specific package identifiers) with _at least one value_ that will be distributed into sub packages of given size
198 * @param $args Assoziative array of additional callback arguments (application specific) (default: _null_)
205 ApplicationError::getGeneral("Wrong work package description '".$name."': Size must be at least 1."));
213 ApplicationError::getGeneral("Wrong work package description '".$name."': No callback given."));
261 throw new ApplicationException($request, $response, ApplicationError::getGeneral("Empty callback name."));
266 ApplicationError::getGeneral("Method '".$curWorkPackageDef['callback']."' must be implemented by ".get_class($this)));
269 call_user_func(array($this, $curWorkPackageDef['callback']), $curWorkPackageDef['oids'], $curWorkPackageDef['args']);
287 return $this->getMessage()->getText("Processing")." ".$this->_workPackages[$step-1]['name']." ...";
300 * @param $number The number of the work package (first number is 0, number is incremented on every call)
302 * This allows to define different static work packages. If you would like to add work packages dynamically on
303 * subsequent runs this may be done by directly calling the BatchController::addWorkPackage() method.
304 * @return A work packages description as assoziative array with keys 'name', 'size', 'oids', 'callback'
Response holds the response values that are used as output from Controller instances.
Definition: Response.php:20
const DOWNLOAD_STEP
Definition: BatchController.php:75
static getGeneral($message)
Factory method for creating a general error instance.
Definition: ApplicationError.php:135
Controller is the base class of all controllers.
Definition: Controller.php:48
getDisplayText($step)
Get the text to display for the current step.
Definition: BatchController.php:286
addWorkPackage($name, $size, $oids, $callback, $args=null)
Add a work package to session.
Definition: BatchController.php:200
const ONE_CALL_SESSION_VARNAME
Definition: BatchController.php:72
getStepNumber()
Get the number of the current step (1..number of steps).
Definition: BatchController.php:183
const STEP_SESSION_VARNAME
Definition: BatchController.php:73
getBooleanValue($name, $default=false)
Get a value as boolean.
Request holds the request values that are used as input to Controller instances.
Definition: Request.php:20
BatchController is used to process complex, longer running actions, that need to be divided into seve...
Definition: BatchController.php:69
getWorkPackage($number)
Get definitions of work packages.
const NUM_STEPS_VARNAME
Definition: BatchController.php:74
initialize(Request $request, Response $response)
Definition: BatchController.php:84
const WORK_PACKAGES_VARNAME
Definition: BatchController.php:76
getDownloadFile()
Get the filename of the file to download at the end of processing.
Definition: BatchController.php:294
ApplicationException signals a general application exception.
Definition: ApplicationException.php:22