Detailed Description
BatchController is used to process complex, longer running actions, that need to be divided into several requests to overcome resource limits and provide progress information to the user.
Conceptually the process is divided into sub actions (work packages), that are called sequentially. Depending on the progress, the controller sets different actions on the response as result of one execution.
BatchController only sets up the infrastructure, the concrete process is defined by creating a subclass and implementing the abstract methods (mainly BatchController::getWorkPackage()).
The controller supports the following actions:
Parameter | Description |
---|---|
in oneCall | Boolean whether to accomplish the task in one call (optional, default: false) |
out stepNumber | The current step starting with 1, ending with numberOfSteps+1 |
out numberOfSteps | Total number of steps |
out displayText | The display text for the current step |
out status | The value of the response action |
Response Actions | |
progress | The process is not finished and continue should be called as next action |
download | The process is finished and the next call to continue will trigger the file download |
done | The process is finished |
Parameter | Description |
---|---|
out stepNumber | The current step starting with 1, ending with numberOfSteps+1 |
out numberOfSteps | Total number of steps |
out displayText | The display text for the next step (since the first request) |
out status | The value of the response action |
Response Actions | |
progress | The process is not finished and continue should be called as next action |
download | The process is finished and the next call to continue will trigger the file download |
done | The process is finished |
Definition at line 73 of file BatchController.php.
Public Member Functions | |
initialize (Request $request, Response $response) | |
Public Member Functions inherited from Controller | |
__construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration) | |
execute ($method=null) | |
getRequest () | |
getResponse () | |
Public Attributes | |
const | REQUEST_VAR = 'request' |
const | ONE_CALL_VAR = 'oneCall' |
const | STEP_VAR = 'step' |
const | NUM_STEPS_VAR = 'numSteps' |
const | DOWNLOAD_STEP_VAR = 'downloadStep' |
const | PACKAGES_VAR = 'packages' |
Public Attributes inherited from Controller | |
const | CSRF_TOKEN_PARAM = 'csrf_token' |
Protected Member Functions | |
doExecute ($method=null) | |
getStepNumber () | |
addWorkPackage ($name, $size, array $oids, $callback, $args=null) | |
processPart ($step) | |
getRequestValue ($name) | |
getNumberOfSteps () | |
getDisplayText ($step) | |
getDownloadFile () | |
getWorkPackage ($number) | |
cleanup () | |
Protected Member Functions inherited from Controller | |
validate () | |
executeSubAction ($action) | |
redirect ($location, $key=null, $data=null) | |
getLogger () | |
getSession () | |
getPersistenceFacade () | |
getPermissionManager () | |
getActionMapper () | |
getLocalization () | |
getMessage () | |
getConfiguration () | |
requireTransaction () | |
endTransaction ($commit) | |
isLocalizedRequest () | |
checkLanguageParameter () | |
generateCsrfToken ($name, $refresh=true) | |
validateCsrfToken ($name, $invalidate=true) | |
getLocalSessionValue ($key, $default=null) | |
setLocalSessionValue ($key, $value) | |
clearLocalSessionValues () | |
Member Function Documentation
◆ initialize()
- See also
- Controller::initialize()
Reimplemented from Controller.
Reimplemented in CopyController, XMLExportController, CSVImportController, SearchIndexController, CSVExportController, and BatchDisplayController.
Definition at line 89 of file BatchController.php.
◆ doExecute()
|
protected |
- See also
- Controller::doExecute()
Reimplemented from Controller.
Definition at line 139 of file BatchController.php.
◆ getStepNumber()
|
protected |
Get the number of the current step (1..number of steps).
- Returns
- The number of the current step
Definition at line 195 of file BatchController.php.
◆ addWorkPackage()
|
protected |
Add a work package to session.
This package will be divided into sub packages of given size.
- Parameters
-
$name Display name of the package (will be supplemented by startNumber-endNumber, e.g. '1-7', '8-14', ...) $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) $oids An array of object ids (or other application specific package identifiers) that will be distributed into sub packages of given size $callback The name of method to call for this package type. The callback method must accept the following parameters: - array parameter (the object ids to process in the current call)
- optionally array parameter (the additional arguments)
$args Associative array of additional callback arguments (application specific) (default: null)
Definition at line 210 of file BatchController.php.
◆ processPart()
|
protected |
Process the given step (1-base).
- Parameters
-
$step The step to process
Definition at line 260 of file BatchController.php.
◆ getRequestValue()
|
protected |
Get a value from the initial request.
- Parameters
-
$name The name of the value
- Returns
- Mixed
Definition at line 285 of file BatchController.php.
◆ getNumberOfSteps()
|
protected |
Get the number of steps to process.
- Returns
- Integer
Definition at line 294 of file BatchController.php.
◆ getDisplayText()
|
protected |
Get the text to display for the current step.
- Parameters
-
$step The step number
Definition at line 302 of file BatchController.php.
◆ getDownloadFile()
|
protected |
Get the filename of the file to download at the end of processing.
- Returns
- String of null, if no download is created.
Reimplemented in XMLExportController, and CSVExportController.
Definition at line 312 of file BatchController.php.
◆ getWorkPackage()
|
abstractprotected |
Get definitions of work packages.
- Parameters
-
$number The number of the work package (first number is 0, number is incremented on every call)
- Note
- This function gets called on first initialization run as often until it returns null. This allows to define different static work packages. If you would like to add work packages dynamically on subsequent runs this may be done by directly calling the BatchController::addWorkPackage() method.
- Returns
- A work packages description as associative array with keys 'name', 'size', 'oids', 'callback' as required for BatchController::addWorkPackage() method or null to terminate.
Reimplemented in CopyController, CSVImportController, XMLExportController, CSVExportController, BatchDisplayController, and SearchIndexController.
◆ cleanup()
|
protected |
Clean up after all tasks are finished.
- Note
- Subclasses may override this to do custom clean up, but should call the parent method.
Reimplemented in XMLExportController, CSVImportController, and CSVExportController.
Definition at line 331 of file BatchController.php.
Member Data Documentation
◆ REQUEST_VAR
const REQUEST_VAR = 'request' |
Definition at line 76 of file BatchController.php.
◆ ONE_CALL_VAR
const ONE_CALL_VAR = 'oneCall' |
Definition at line 77 of file BatchController.php.
◆ STEP_VAR
const STEP_VAR = 'step' |
Definition at line 78 of file BatchController.php.
◆ NUM_STEPS_VAR
const NUM_STEPS_VAR = 'numSteps' |
Definition at line 79 of file BatchController.php.
◆ DOWNLOAD_STEP_VAR
const DOWNLOAD_STEP_VAR = 'downloadStep' |
Definition at line 80 of file BatchController.php.
◆ PACKAGES_VAR
const PACKAGES_VAR = 'packages' |
Definition at line 81 of file BatchController.php.