documenting start case endpoint
This commit is contained in:
@@ -2035,22 +2035,44 @@ class Cases
|
||||
}
|
||||
|
||||
/**
|
||||
* This function start a case using the task for the user $usrUid
|
||||
* With this function we can Start a case
|
||||
*
|
||||
* @name startCase
|
||||
* @param string $tasUid
|
||||
* @param string $usrUid
|
||||
* @param bool $isSubprocess
|
||||
* @param array $previousInfo
|
||||
* @param bool $isSelfService
|
||||
* @param string $sequenceType
|
||||
*
|
||||
* @return Fields
|
||||
* @throw Exception
|
||||
* The startCase function is designed to start a new case using a specified task ($tasUid) for a user ($usrUid).
|
||||
* It handles various scenarios, including subprocesses, self-service tasks, and multiple instances of tasks.
|
||||
*
|
||||
* Parameters
|
||||
* - $tasUid: The unique identifier for the task that is being started.
|
||||
* - $usrUid: The unique identifier for the user who is starting the case.
|
||||
* - $isSubprocess: A boolean indicating whether the case is being started as a subprocess.
|
||||
* - $previousInfo: An array containing any previous information related to the case (not used in the provided code).
|
||||
* - $isSelfService: A boolean indicating whether the case is being started in a self-service context.
|
||||
* - $sequenceType: A string indicating the type of sequence for the application (default is AppSequence::APP_TYPE_NORMAL).
|
||||
* Return Value
|
||||
* The function returns an array containing:
|
||||
* - APPLICATION: The unique identifier of the created application.
|
||||
* - INDEX: The delegation index.
|
||||
* - PROCESS: The unique identifier of the process.
|
||||
* - CASE_NUMBER: The case number of the created application.
|
||||
* Exception Handling
|
||||
* The function throws exceptions in various scenarios, such as when the task does not exist or when required parameters are missing.
|
||||
*/
|
||||
public function startCase(string $tasUid, string $usrUid, $isSubprocess = false, $previousInfo = [], $isSelfService = false, $sequenceType = AppSequence::APP_TYPE_NORMAL)
|
||||
{
|
||||
/*
|
||||
1. checks if $tasUid is not empty. If it is, an exception is thrown user or task UID is missing.
|
||||
2. retrieves the task using TaskPeer::retrieveByPK($tasUid) and the user using UsersPeer::retrieveByPK($usrUid).
|
||||
3. checks if the task type is not allowed for self-service and if the user UID is empty. eod throws an exception
|
||||
4. loads the process associated with the task using $task->getProUid() and creates a new Process object.
|
||||
5. creates a new application using the Application class, which is associated with the process and user.
|
||||
6. creates a new application delegation using the newAppDelegation method.
|
||||
7. An application thread is created for the new application.
|
||||
8. If the task is of type "MULTIPLE_INSTANCE", it retrieves all users and creates delegations for each user, excluding the current user.
|
||||
9. The application is updated with the delegation index and other relevant fields.
|
||||
10. An event is created to log the application creation.
|
||||
11. The function adds a new row to the inbox for the user and for each user in the multiple instance scenario.
|
||||
12. A log entry is created to record the case creation, including relevant context information.
|
||||
13. If a specific plugin class exists, it executes triggers related to the case creation.
|
||||
14. The function executes any configured triggers for the case creation process.
|
||||
15. Finally, the function returns an array containing the application UID, delegation index, process UID, and case number.
|
||||
*/
|
||||
if (!empty($tasUid)) {
|
||||
try {
|
||||
$task = TaskPeer::retrieveByPK($tasUid);
|
||||
@@ -7371,12 +7393,12 @@ class Cases
|
||||
{
|
||||
$conn = Propel::getConnection('workflow');
|
||||
|
||||
$sql = 'SELECT TASK.TAS_UID, TASK.TAS_TITLE, TASK.TAS_DESCRIPTION, TASK.TAS_START,
|
||||
TASK.TAS_TYPE, TASK.TAS_DERIVATION, TASK.TAS_ASSIGN_TYPE, APP.USR_UID, USERS.USR_USERNAME,
|
||||
USERS.USR_FIRSTNAME, USERS.USR_LASTNAME
|
||||
FROM TASK LEFT JOIN (SELECT * FROM APP_DELEGATION WHERE APP_DELEGATION.APP_UID = ?) AS APP
|
||||
ON TASK.TAS_UID = APP.TAS_UID LEFT JOIN USERS
|
||||
ON (SELECT USR_UID FROM APP_DELEGATION WHERE APP_UID = ? AND TAS_UID = TASK.TAS_UID ORDER BY DEL_INDEX DESC LIMIT 1) = USERS.USR_UID
|
||||
$sql = 'SELECT TASK.TAS_UID, TASK.TAS_TITLE, TASK.TAS_DESCRIPTION, TASK.TAS_START,
|
||||
TASK.TAS_TYPE, TASK.TAS_DERIVATION, TASK.TAS_ASSIGN_TYPE, APP.USR_UID, USERS.USR_USERNAME,
|
||||
USERS.USR_FIRSTNAME, USERS.USR_LASTNAME
|
||||
FROM TASK LEFT JOIN (SELECT * FROM APP_DELEGATION WHERE APP_DELEGATION.APP_UID = ?) AS APP
|
||||
ON TASK.TAS_UID = APP.TAS_UID LEFT JOIN USERS
|
||||
ON (SELECT USR_UID FROM APP_DELEGATION WHERE APP_UID = ? AND TAS_UID = TASK.TAS_UID ORDER BY DEL_INDEX DESC LIMIT 1) = USERS.USR_UID
|
||||
WHERE TASK.PRO_UID = ?';
|
||||
|
||||
$stmt = $conn->prepareStatement($sql);
|
||||
@@ -7533,4 +7555,3 @@ class Cases
|
||||
return $rsCriteria;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user