From 97d0a61aa248c9dadd802390414c4bc630899c98 Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Thu, 9 Jan 2014 15:57:01 -0400 Subject: [PATCH 1/9] Validaciones para el metodo POST para PROCESS SUPERVISOR --- .../src/BusinessModel/ProcessSupervisor.php | 175 ++++++++++++++---- 1 file changed, 140 insertions(+), 35 deletions(-) diff --git a/workflow/engine/src/BusinessModel/ProcessSupervisor.php b/workflow/engine/src/BusinessModel/ProcessSupervisor.php index f80cf453d..adce6ce20 100644 --- a/workflow/engine/src/BusinessModel/ProcessSupervisor.php +++ b/workflow/engine/src/BusinessModel/ProcessSupervisor.php @@ -550,13 +550,53 @@ class ProcessSupervisor throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID )); } } - $sPuUID = \G::generateUniqueID(); - $oProcessUser->create(array('PU_UID' => $sPuUID, - 'PRO_UID' => $sProcessUID, - 'USR_UID' => $sUsrUID, - 'PU_TYPE' => $sTypeUID)); - $oCriteria = $this->getProcessSupervisor($sProcessUID, $sPuUID); - return $oCriteria; + // validate Groups + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\ProcessUserPeer::PU_UID); + $oCriteria->addSelectColumn(\ProcessUserPeer::USR_UID); + $oCriteria->addAsColumn('GRP_TITLE', \ContentPeer::CON_VALUE); + $aConditions [] = array(\ProcessUserPeer::USR_UID, \ContentPeer::CON_ID); + $aConditions [] = array(\ContentPeer::CON_CATEGORY, \DBAdapter::getStringDelimiter().'GRP_TITLE'.\DBAdapter::getStringDelimiter()); + $aConditions [] = array(\ContentPeer::CON_LANG, \DBAdapter::getStringDelimiter().SYS_LANG.\DBAdapter::getStringDelimiter()); + $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); + $oCriteria->add(\ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR'); + $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID); + $oCriteria->add(\ProcessUserPeer::USR_UID, $sUsrUID); + $oCriteria->addAscendingOrderByColumn(\ContentPeer::CON_VALUE); + $oDataset = \ProcessUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $sPuUIDT = $aRow['PU_UID']; + $oDataset->next(); + } + // validate Users + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\ProcessUserPeer::USR_UID); + $oCriteria->addSelectColumn(\ProcessUserPeer::PU_UID); + $oCriteria->addJoin(\ProcessUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); + $oCriteria->add(\ProcessUserPeer::PU_TYPE, 'SUPERVISOR'); + $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID); + $oCriteria->add(\ProcessUserPeer::USR_UID, $sUsrUID); + $oCriteria->addAscendingOrderByColumn(\UsersPeer::USR_FIRSTNAME); + $oDataset = \ProcessUserPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $sPuUIDT = $aRow['PU_UID']; + $oDataset->next(); + } + if (is_null($sPuUIDT)) { + $sPuUID = \G::generateUniqueID(); + $oProcessUser->create(array('PU_UID' => $sPuUID, + 'PRO_UID' => $sProcessUID, + 'USR_UID' => $sUsrUID, + 'PU_TYPE' => $sTypeUID)); + $oCriteria = $this->getProcessSupervisor($sProcessUID, $sPuUID); + return $oCriteria; + } else { + throw (new \Exception('This relation already exist!')); + } } /** @@ -568,18 +608,13 @@ class ProcessSupervisor */ public function addProcessSupervisorDynaform($sProcessUID, $sDynUID) { - $oStepSupervisor = new \StepSupervisor(); - $oStepSupervisor->create(array('PRO_UID' => $sProcessUID, - 'STEP_TYPE_OBJ' => "DYNAFORM", - 'STEP_UID_OBJ' => $sDynUID, - 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "DYNAFORM"))); + $oTypeDynaform = \DynaformPeer::retrieveByPK($sDynUID); + if (is_null( $oTypeDynaform )) { + throw (new \Exception( 'This id: '. $sDynUID .' do not correspond to a registered Dynaform')); + } $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID); - $oCriteria->addSelectColumn(\StepSupervisorPeer::PRO_UID); - $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_TYPE_OBJ); - $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID_OBJ); - $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_POSITION); $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); @@ -599,13 +634,50 @@ class ProcessSupervisor $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { - $aResp = array('pud_uid' => $aRow['STEP_UID'], - 'pud_position' => $aRow['STEP_POSITION'], - 'dyn_uid' => $aRow['STEP_UID_OBJ'], - 'dyn_title' => $aRow['DYN_TITLE']); + $sPuUIDT = $aRow['STEP_UID']; $oDataset->next(); } - return $aResp; + if (is_null($sPuUIDT)) { + $oStepSupervisor = new \StepSupervisor(); + $oStepSupervisor->create(array('PRO_UID' => $sProcessUID, + 'STEP_TYPE_OBJ' => "DYNAFORM", + 'STEP_UID_OBJ' => $sDynUID, + 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "DYNAFORM"))); + $sDelimiter = \DBAdapter::getStringDelimiter(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID); + $oCriteria->addSelectColumn(\StepSupervisorPeer::PRO_UID); + $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID_OBJ); + $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_POSITION); + $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE'); + $oCriteria->addAlias('C', 'CONTENT'); + $aConditions = array(); + $aConditions[] = array(\StepSupervisorPeer::STEP_UID_OBJ, \DynaformPeer::DYN_UID ); + $aConditions[] = array(\StepSupervisorPeer::STEP_TYPE_OBJ, $sDelimiter . 'DYNAFORM' . $sDelimiter ); + $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); + $aConditions = array(); + $aConditions[] = array(\DynaformPeer::DYN_UID, 'C.CON_ID' ); + $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'DYN_TITLE' . $sDelimiter ); + $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter ); + $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); + $oCriteria->add(\StepSupervisorPeer::PRO_UID, $sProcessUID); + $oCriteria->add(\StepSupervisorPeer::STEP_UID_OBJ, $sDynUID); + $oCriteria->add(\StepSupervisorPeer::STEP_TYPE_OBJ, 'DYNAFORM'); + $oCriteria->addAscendingOrderByColumn(\StepSupervisorPeer::STEP_POSITION); + $oDataset = \StepSupervisorPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aResp = array('pud_uid' => $aRow['STEP_UID'], + 'pud_position' => $aRow['STEP_POSITION'], + 'dyn_uid' => $aRow['STEP_UID_OBJ'], + 'dyn_title' => $aRow['DYN_TITLE']); + $oDataset->next(); + } + return $aResp; + } else { + throw (new \Exception('This relation already exist!')); + } } /** @@ -617,18 +689,13 @@ class ProcessSupervisor */ public function addProcessSupervisorInputDocument($sProcessUID, $sInputDocumentUID) { - $oStepSupervisor = new \StepSupervisor(); - $oStepSupervisor->create(array('PRO_UID' => $sProcessUID, - 'STEP_TYPE_OBJ' => "INPUT_DOCUMENT", - 'STEP_UID_OBJ' => $sInputDocumentUID, - 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "DYNAFORM"))); + $oTypeInputDocument= \InputDocumentPeer::retrieveByPK($sInputDocumentUID); + if (is_null( $oTypeInputDocument )) { + throw (new \Exception( 'This id: '. $sInputDocumentUID .' do not correspond to a registered InputDocument')); + } $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID); - $oCriteria->addSelectColumn(\StepSupervisorPeer::PRO_UID); - $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_TYPE_OBJ); - $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID_OBJ); - $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_POSITION); $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); @@ -648,13 +715,51 @@ class ProcessSupervisor $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { - $aResp = array('pui_uid' => $aRow['STEP_UID'], - 'pui_position' => $aRow['STEP_POSITION'], - 'input_doc_uid' => $aRow['STEP_UID_OBJ'], - 'input_doc_title' => $aRow['INP_DOC_TITLE']); + $sPuUIDT = $aRow['STEP_UID']; $oDataset->next(); } - return $aResp; + if (is_null($sPuUIDT)) { + $oStepSupervisor = new \StepSupervisor(); + $oStepSupervisor->create(array('PRO_UID' => $sProcessUID, + 'STEP_TYPE_OBJ' => "INPUT_DOCUMENT", + 'STEP_UID_OBJ' => $sInputDocumentUID, + 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "DYNAFORM"))); + $sDelimiter = \DBAdapter::getStringDelimiter(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID); + $oCriteria->addSelectColumn(\StepSupervisorPeer::PRO_UID); + $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_TYPE_OBJ); + $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID_OBJ); + $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_POSITION); + $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE'); + $oCriteria->addAlias('C', 'CONTENT'); + $aConditions = array(); + $aConditions[] = array(\StepSupervisorPeer::STEP_UID_OBJ, \InputDocumentPeer::INP_DOC_UID); + $aConditions[] = array(\StepSupervisorPeer::STEP_TYPE_OBJ, $sDelimiter . 'INPUT_DOCUMENT' . $sDelimiter); + $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); + $aConditions = array(); + $aConditions[] = array(\InputDocumentPeer::INP_DOC_UID, 'C.CON_ID'); + $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'INP_DOC_TITLE' . $sDelimiter); + $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); + $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); + $oCriteria->add(\StepSupervisorPeer::PRO_UID, $sProcessUID); + $oCriteria->add(\StepSupervisorPeer::STEP_UID_OBJ, $sInputDocumentUID); + $oCriteria->add(\StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT'); + $oCriteria->addAscendingOrderByColumn(\StepSupervisorPeer::STEP_POSITION); + $oDataset = \StepSupervisorPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aResp = array('pui_uid' => $aRow['STEP_UID'], + 'pui_position' => $aRow['STEP_POSITION'], + 'input_doc_uid' => $aRow['STEP_UID_OBJ'], + 'input_doc_title' => $aRow['INP_DOC_TITLE']); + $oDataset->next(); + } + return $aResp; + } else { + throw (new \Exception('This relation already exist!')); + } } /** From daaa1f1a81378d540f57e23e350178bf8fc28681 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Thu, 9 Jan 2014 16:33:07 -0400 Subject: [PATCH 2/9] Get para ProcessPermissions --- .../src/BusinessModel/ProcessPermissions.php | 161 ++++++++++++++++++ .../Project/ProcessPermissions.php | 39 +++++ workflow/engine/src/Services/api.ini | 1 + 3 files changed, 201 insertions(+) create mode 100644 workflow/engine/src/BusinessModel/ProcessPermissions.php create mode 100644 workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php diff --git a/workflow/engine/src/BusinessModel/ProcessPermissions.php b/workflow/engine/src/BusinessModel/ProcessPermissions.php new file mode 100644 index 000000000..308905ba5 --- /dev/null +++ b/workflow/engine/src/BusinessModel/ProcessPermissions.php @@ -0,0 +1,161 @@ + + * @copyright Colosa - Bolivia + */ +class ProcessPermissions +{ + /** + * Get list for ProcessPermissions + * @var string $sProcessUID. Uid for Process + * @var string $filter. + * @var string $sEventUID. Uid for Process + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return array + */ + public function getProcessPermissions($sProcessUID) + { + G::LoadClass('case'); + Cases::verifyTable(); + $aObjectsPermissions = array(); + //$aObjectsPermissions[] = array('OP_UID' => 'char', 'TASK_TARGET' => 'char', 'GROUP_USER' => 'char', 'TASK_SOURCE' => 'char', 'OBJECT_TYPE' => 'char', 'OBJECT' => 'char', 'PARTICIPATED' => 'char', 'ACTION' => 'char', 'OP_CASE_STATUS' => 'char'); + $oCriteria = new \Criteria('workflow'); + $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID); + $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + //Obtain task target + if (($aRow['TAS_UID'] != '') && ($aRow['TAS_UID'] != '0')) { + try { + $oTask = new \Task(); + $aFields = $oTask->load($aRow['TAS_UID']); + $sTaskTarget = $aFields['TAS_TITLE']; + } catch (\Exception $oError) { + $sTaskTarget = 'All Tasks'; + } + } else { + $sTaskTarget = G::LoadTranslation('ID_ANY_TASK'); + } + //Obtain user or group + if ($aRow['OP_USER_RELATION'] == 1) { + $oUser = new \Users(); + $aFields = $oUser->load($aRow['USR_UID']); + $sUserGroup = $aFields['USR_FIRSTNAME'] . ' ' . $aFields['USR_LASTNAME'] . ' (' . $aFields['USR_USERNAME'] . ')'; + } else { + $oGroup = new \Groupwf(); + if ($aRow['USR_UID'] != '') { + try { + $aFields = $oGroup->load($aRow['USR_UID']); + $sUserGroup = $aFields['GRP_TITLE']; + } catch (\Exception $oError) { + $sUserGroup = '(GROUP DELETED)'; + } + } else { + $sUserGroup = G::LoadTranslation('ID_ANY'); + } + } + //Obtain task source + if (($aRow['OP_TASK_SOURCE'] != '') && ($aRow['OP_TASK_SOURCE'] != '0')) { + try { + $oTask = new \Task(); + $aFields = $oTask->load($aRow['OP_TASK_SOURCE']); + $sTaskSource = $aFields['TAS_TITLE']; + } catch (\Exception $oError) { + $sTaskSource = 'All Tasks'; + } + } else { + $sTaskSource = G::LoadTranslation('ID_ANY_TASK'); + } + //Obtain object and type + switch ($aRow['OP_OBJ_TYPE']) { + case 'ALL': + $sObjectType = G::LoadTranslation('ID_ALL'); + $sObject = G::LoadTranslation('ID_ALL'); + break; + case 'ANY': //For backward compatibility (some process with ANY instead of ALL + $sObjectType = G::LoadTranslation('ID_ALL'); + $sObject = G::LoadTranslation('ID_ALL'); + break; + /* case 'ANY_DYNAFORM': + $sObjectType = G::LoadTranslation('ID_ANY_DYNAFORM'); + $sObject = G::LoadTranslation('ID_ALL'); + break; + case 'ANY_INPUT': + $sObjectType = G::LoadTranslation('ID_ANY_INPUT'); + $sObject = G::LoadTranslation('ID_ALL'); + break; + case 'ANY_OUTPUT': + $sObjectType = G::LoadTranslation('ID_ANY_OUTPUT'); + $sObject = G::LoadTranslation('ID_ALL'); + break; */ + case 'DYNAFORM': + $sObjectType = G::LoadTranslation('ID_DYNAFORM'); + if (($aRow['OP_OBJ_UID'] != '') && ($aRow['OP_OBJ_UID'] != '0')) { + $oDynaform = new \Dynaform(); + $aFields = $oDynaform->load($aRow['OP_OBJ_UID']); + $sObject = $aFields['DYN_TITLE']; + } else { + $sObject = G::LoadTranslation('ID_ALL'); + } + break; + case 'INPUT': + $sObjectType = G::LoadTranslation('ID_INPUT_DOCUMENT'); + if (($aRow['OP_OBJ_UID'] != '') && ($aRow['OP_OBJ_UID'] != '0')) { + $oInputDocument = new \InputDocument(); + $aFields = $oInputDocument->load($aRow['OP_OBJ_UID']); + $sObject = $aFields['INP_DOC_TITLE']; + } else { + $sObject = G::LoadTranslation('ID_ALL'); + } + break; + case 'OUTPUT': + $sObjectType = G::LoadTranslation('ID_OUTPUT_DOCUMENT'); + if (($aRow['OP_OBJ_UID'] != '') && ($aRow['OP_OBJ_UID'] != '0')) { + $oOutputDocument = new \OutputDocument(); + $aFields = $oOutputDocument->load($aRow['OP_OBJ_UID']); + $sObject = $aFields['OUT_DOC_TITLE']; + } else { + $sObject = G::LoadTranslation('ID_ALL'); + } + break; + case 'CASES_NOTES': + $sObjectType = G::LoadTranslation('ID_CASES_NOTES'); + $sObject = 'N/A'; + break; + case 'MSGS_HISTORY': + $sObjectType = G::LoadTranslation('MSGS_HISTORY'); + $sObject = G::LoadTranslation('ID_ALL'); + break; + default: + $sObjectType = G::LoadTranslation('ID_ALL'); + $sObject = G::LoadTranslation('ID_ALL'); + break; + } + //Participated + if ($aRow['OP_PARTICIPATE'] == 0) { + $sParticipated = G::LoadTranslation('ID_NO'); + } else { + $sParticipated = G::LoadTranslation('ID_YES'); + } + //Obtain action (permission) + $sAction = G::LoadTranslation('ID_' . $aRow['OP_ACTION']); + //Add to array + $aObjectsPermissions[] = array_merge($aRow, array('OP_UID' => $aRow['OP_UID'], 'TASK_TARGET' => $sTaskTarget, 'GROUP_USER' => $sUserGroup, 'TASK_SOURCE' => $sTaskSource, 'OBJECT_TYPE' => $sObjectType, 'OBJECT' => $sObject, 'PARTICIPATED' => $sParticipated, 'ACTION' => $sAction, 'OP_CASE_STATUS' => $aRow['OP_CASE_STATUS'])); + $oDataset->next(); + } + return $aObjectsPermissions; + } +} + diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php new file mode 100644 index 000000000..b56cce121 --- /dev/null +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php @@ -0,0 +1,39 @@ + + * @copyright Colosa - Bolivia + * + * @protected + */ +class ProcessPermissions extends Api +{ + /** + * @param string $projectUid {@min 1} {@max 32} + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return array + * + * @url GET /:projectUid/process-permissions + */ + public function doGetProcessPermissions($projectUid) + { + try { + $processPermissions = new \BusinessModel\ProcessPermissions(); + $response = $processPermissions->getProcessPermissions($projectUid); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } +} + diff --git a/workflow/engine/src/Services/api.ini b/workflow/engine/src/Services/api.ini index 3956165ba..2bae1b34d 100644 --- a/workflow/engine/src/Services/api.ini +++ b/workflow/engine/src/Services/api.ini @@ -24,6 +24,7 @@ debug = 1 input-document = "Services\Api\ProcessMaker\Project\InputDocument" output-documents = "Services\Api\ProcessMaker\Project\OutputDocuments" supervisors = "Services\Api\ProcessMaker\Project\ProcessSupervisors" + process-permissions = "Services\Api\ProcessMaker\Project\ProcessPermissions" [alias: projects] project = "Services\Api\ProcessMaker\Project" From a883b5bdf610ae2833016691cc21f40bd918efc1 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Thu, 9 Jan 2014 17:40:56 -0400 Subject: [PATCH 3/9] adding behat scenario outline test file --- features/test/test_scenario_outline.feature | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 features/test/test_scenario_outline.feature diff --git a/features/test/test_scenario_outline.feature b/features/test/test_scenario_outline.feature new file mode 100644 index 000000000..fad79a619 --- /dev/null +++ b/features/test/test_scenario_outline.feature @@ -0,0 +1,23 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Project Properties - Assignee Resources + + Background: + Given that I have a valid access_token + +Scenario Outline: Get a list of available users and groups to be assigned to an activity with filter + Given that I want to make a new "test" + And his "name" is "" + And his "lastname" is "" + When I request "test" + Then the response status code should be 200 + And the response should be JSON + #And that "id" is set to "" + And the "id" property equals "" + + Examples: + | name | lastname | age | id | + | erik | sample1 | 7 | 2 | + | wendy | sample2 | 15 | 3 | + | wendy2 | sample22 | 15 | 4 | + | wendy3 | sample23 | 15 | 5 | + From 1edc5b8f4126a185cb3f99d225e4bb0eb062bfe0 Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Fri, 10 Jan 2014 14:16:16 -0400 Subject: [PATCH 4/9] BEHAT para OUTPUTDOCUMENTS --- .../output_document.feature | 84 +++++++++++++++++-- .../Project/ProcessSupervisors.php | 4 - 2 files changed, 77 insertions(+), 11 deletions(-) diff --git a/features/backend/output_documents_resources/output_document.feature b/features/backend/output_documents_resources/output_document.feature index 43c9a2950..d3f7d5569 100644 --- a/features/backend/output_documents_resources/output_document.feature +++ b/features/backend/output_documents_resources/output_document.feature @@ -18,11 +18,81 @@ Feature: Output Documents Resources And the type is "object" Scenario: Create a new output document for a project - Given this scenario is not implemented yet - - Scenario: Update a output document for a project - Given this scenario is not implemented yet - - Scenario: Delete a output document of a project - Given this scenario is not implemented yet + Given POST this data: + """ + { + "out_doc_title": "Output doc #1", + "out_doc_description": "Output doc #1 - Desc", + "out_doc_filename": "od_generated_1", + "out_doc_template": "", + "out_doc_report_generator": "HTML2PDF", + "out_doc_landscape": 0, + "out_doc_media": "Letter", + "out_doc_left_margin": 0, + "out_doc_right_margin": 0, + "out_doc_top_margin": 0, + "out_doc_bottom_margin": 0, + "out_doc_generate": "BOTH", + "out_doc_type": "HTML", + "out_doc_current_revision": 0, + "out_doc_field_mapping": "", + "out_doc_versioning": 0, + "out_doc_destination_path": "", + "out_doc_tags": "", + "out_doc_pdf_security_enabled": 0, + "out_doc_pdf_security_open_password": "", + "out_doc_pdf_security_owner_password": "", + "out_doc_pdf_security_permissions": "" + } + """ + And I request "project/4224292655297723eb98691001100052/output-document" + Then the response status code should be 201 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "object" + And store "out_doc_uid" in session array as variable "out_doc_uid" + + Scenario: Update a output document for a project + Given PUT this data: + """ + { + "out_doc_title": "Output doc #1", + "out_doc_description": "Output doc #1 - Desc DESCRIPTION Modified", + "out_doc_filename": "od_generated_1", + "out_doc_template": "", + "out_doc_report_generator": "HTML2PDF", + "out_doc_landscape": 0, + "out_doc_media": "Letter", + "out_doc_left_margin": 0, + "out_doc_right_margin": 0, + "out_doc_top_margin": 0, + "out_doc_bottom_margin": 0, + "out_doc_generate": "BOTH", + "out_doc_type": "HTML", + "out_doc_current_revision": 0, + "out_doc_field_mapping": "", + "out_doc_versioning": 0, + "out_doc_destination_path": "", + "out_doc_tags": "", + "out_doc_pdf_security_enabled": 0, + "out_doc_pdf_security_open_password": "", + "out_doc_pdf_security_owner_password": "", + "out_doc_pdf_security_permissions": "" + } + """ + And that I want to update a resource with the key "out_doc_uid" stored in session array + And I request "project/4224292655297723eb98691001100052/output-document" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And that "out_doc_description": "Output doc #1 - Desc DESCRIPTION Modified" + + Scenario: Delete a output document of a project + Given that I want to delete a resource with the key "out_doc_uid" stored in session array + And I request "project/4224292655297723eb98691001100052/output-document" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php index 3c9b680c9..2d7202fd6 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php @@ -311,8 +311,4 @@ class ProcessSupervisors extends Api } return $response; } - - - - } From d8d5d1d44f33ffd1f41659bcbca611ac998958f3 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Fri, 10 Jan 2014 15:32:14 -0400 Subject: [PATCH 5/9] Arreglo a behat para events --- .../backend/events_resources/event.feature | 40 +++++++++++++++---- features/bootstrap/RestContext.php | 13 +++--- workflow/engine/src/BusinessModel/Event.php | 11 +++++ .../src/BusinessModel/ProcessPermissions.php | 14 +++++-- .../Project/ProcessPermissions.php | 23 +++++++++++ 5 files changed, 82 insertions(+), 19 deletions(-) diff --git a/features/backend/events_resources/event.feature b/features/backend/events_resources/event.feature index 183bc91f3..10808acc7 100644 --- a/features/backend/events_resources/event.feature +++ b/features/backend/events_resources/event.feature @@ -1,8 +1,17 @@ @ProcessMakerMichelangelo @RestAPI -Feature: Testing events +Feature: Events Resources - @1: TEST FOR POST EVENT /---------------------------------------------------------------------- - Scenario: Create a event + @1: TEST FOR GET EVENTS /---------------------------------------------------------------------- + Scenario: List all the events (result 0 events) + Given that I have a valid access_token + And I request "project/251815090529619a99a2bf4013294414/events" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the response has 0 record + + + @2: TEST FOR POST EVENT /---------------------------------------------------------------------- + Scenario: Create a new event Given that I have a valid access_token And POST this data: """ @@ -24,8 +33,15 @@ Feature: Testing events Then the response status code should be 201 And store "evn_uid" in session array + @3: TEST FOR GET EVENTS /---------------------------------------------------------------------- + Scenario: List all the events (result 1 event) + Given that I have a valid access_token + And I request "project/251815090529619a99a2bf4013294414/events" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the response has 1 record - @2: TEST FOR PUT EVENT /----------------------------------------------------------------------- + @4: TEST FOR PUT EVENT /----------------------------------------------------------------------- Scenario: Update a event Given that I have a valid access_token And PUT this data: @@ -51,8 +67,8 @@ Feature: Testing events And the type is "object" - @3: TEST FOR GET EVENT /----------------------------------------------------------------------- - Scenario: Get a event + @5: TEST FOR GET EVENT /----------------------------------------------------------------------- + Scenario: Get a event (with change in "evn_description") Given that I have a valid access_token And that I want to get a resource with the key "evn_uid" stored in session array And I request "project/251815090529619a99a2bf4013294414/event" @@ -62,11 +78,19 @@ Feature: Testing events And that "evn_description" is set to "change description" - @4: TEST FOR DELETE EVENT /----------------------------------------------------------------------- + @6: TEST FOR DELETE EVENT /----------------------------------------------------------------------- Scenario: Delete a event Given that I have a valid access_token And that I want to delete a resource with the key "evn_uid" stored in session array And I request "project/251815090529619a99a2bf4013294414/event" Then the response status code should be 200 And the response charset is "UTF-8" - And the type is "object" \ No newline at end of file + And the type is "object" + + @7: TEST FOR GET EVENTS /---------------------------------------------------------------------- + Scenario: List all the events (result 0 events) + Given that I have a valid access_token + And I request "project/251815090529619a99a2bf4013294414/events" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the response has 0 record \ No newline at end of file diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index faa40a073..95c2fc495 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1100,13 +1100,12 @@ class RestContext extends BehatContext public function theResponseHasRecords($quantityOfRecords) { $data = $this->_data; - if (!is_array($data)) { - throw new Exception("the Response data is not an array!\n\n" ); - } - $currentRecordsCount=count($data); - if($currentRecordsCount!=$quantityOfRecords){ + if (!is_array($data)) { + throw new Exception("the Response data is not an array!\n\n" ); + } + $currentRecordsCount=count($data); + if($currentRecordsCount!=$quantityOfRecords){ throw new Exception('Records quantity not match ' . $quantityOfRecords . ' (actual: ' . $currentRecordsCount . ")\n\n"); - } + } } - } diff --git a/workflow/engine/src/BusinessModel/Event.php b/workflow/engine/src/BusinessModel/Event.php index db552640d..c5dfa7b96 100644 --- a/workflow/engine/src/BusinessModel/Event.php +++ b/workflow/engine/src/BusinessModel/Event.php @@ -21,6 +21,11 @@ class Event */ public function getEvents($sProcessUID, $filter = '', $sEventUID = '') { + $oProcess = new \Process(); + if (!($oProcess->processExists($sProcessUID))) { + throw (new \Exception( 'This process doesn\'t exist!' )); + } + $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn(\EventPeer::EVN_UID); @@ -88,6 +93,12 @@ class Event if ( ($sProcessUID == '') || (count($dataEvent) == 0) ) { return false; } + + $oProcess = new \Process(); + if (!($oProcess->processExists($sProcessUID))) { + throw (new \Exception( 'This process doesn\'t exist!' )); + } + $dataEvent = array_change_key_case($dataEvent, CASE_UPPER); if ( $create && (isset($dataEvent['ENV_UID'])) ) { diff --git a/workflow/engine/src/BusinessModel/ProcessPermissions.php b/workflow/engine/src/BusinessModel/ProcessPermissions.php index 308905ba5..930c30a45 100644 --- a/workflow/engine/src/BusinessModel/ProcessPermissions.php +++ b/workflow/engine/src/BusinessModel/ProcessPermissions.php @@ -15,8 +15,6 @@ class ProcessPermissions /** * Get list for ProcessPermissions * @var string $sProcessUID. Uid for Process - * @var string $filter. - * @var string $sEventUID. Uid for Process * * @access public * @author Brayan Pereyra (Cochalo) @@ -24,14 +22,16 @@ class ProcessPermissions * * @return array */ - public function getProcessPermissions($sProcessUID) + public function getProcessPermissions($sProcessUID, $sPermissionUid = '') { G::LoadClass('case'); Cases::verifyTable(); $aObjectsPermissions = array(); - //$aObjectsPermissions[] = array('OP_UID' => 'char', 'TASK_TARGET' => 'char', 'GROUP_USER' => 'char', 'TASK_SOURCE' => 'char', 'OBJECT_TYPE' => 'char', 'OBJECT' => 'char', 'PARTICIPATED' => 'char', 'ACTION' => 'char', 'OP_CASE_STATUS' => 'char'); $oCriteria = new \Criteria('workflow'); $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID); + if ($sPermissionUid != '') { + $oCriteria->add(ObjectPermissionPeer::OP_UID, $sPermissionUid); + } $oDataset = ObjectPermissionPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); @@ -155,6 +155,12 @@ class ProcessPermissions $aObjectsPermissions[] = array_merge($aRow, array('OP_UID' => $aRow['OP_UID'], 'TASK_TARGET' => $sTaskTarget, 'GROUP_USER' => $sUserGroup, 'TASK_SOURCE' => $sTaskSource, 'OBJECT_TYPE' => $sObjectType, 'OBJECT' => $sObject, 'PARTICIPATED' => $sParticipated, 'ACTION' => $sAction, 'OP_CASE_STATUS' => $aRow['OP_CASE_STATUS'])); $oDataset->next(); } + + if ($sPermissionUid != '' && empty($aObjectsPermissions)) { + throw (new \Exception( 'This row doesn\'t exist!' )); + } else if ($sPermissionUid != '' && !empty($aObjectsPermissions)) { + return current($aObjectsPermissions); + } return $aObjectsPermissions; } } diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php index b56cce121..0553f949d 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessPermissions.php @@ -35,5 +35,28 @@ class ProcessPermissions extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + /** + * @param string $projectUid {@min 1} {@max 32} + * @param string $objectPermissionUid {@min 1} {@max 32} + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return array + * + * @url GET /:projectUid/process-permission/:objectPermissionUid + */ + public function doGetProcessPermission($projectUid, $objectPermissionUid) + { + try { + $processPermissions = new \BusinessModel\ProcessPermissions(); + $response = $processPermissions->getProcessPermissions($projectUid, $objectPermissionUid); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } } From 50c237fc905472578866e5a774a195c7778a1003 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Fri, 10 Jan 2014 15:57:57 -0400 Subject: [PATCH 6/9] Correcion en los behats de Activity y Triggers --- .../activity.feature | 3 +- .../triggers_resources/triggers.feature | 39 ++++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/features/backend/project_activity_resources/activity.feature b/features/backend/project_activity_resources/activity.feature index cf81cef31..990819bd7 100644 --- a/features/backend/project_activity_resources/activity.feature +++ b/features/backend/project_activity_resources/activity.feature @@ -1,5 +1,6 @@ @ProcessMakerMichelangelo @RestAPI -Feature: Testing activity +Feature: Activity Resources + @1: TEST FOR GET ACTIVITY /----------------------------------------------------------------------- Scenario: Get a activity Given that I have a valid access_token diff --git a/features/backend/triggers_resources/triggers.feature b/features/backend/triggers_resources/triggers.feature index c137e9be4..126ee2c35 100644 --- a/features/backend/triggers_resources/triggers.feature +++ b/features/backend/triggers_resources/triggers.feature @@ -1,7 +1,16 @@ @ProcessMakerMichelangelo @RestAPI -Feature: Testing triggers +Feature: Triggers Resources - @1: TEST FOR POST TRIGGER /-------------------------------------------------------------------- + @1: TEST FOR GET TRIGGERS /-------------------------------------------------------------------- + Scenario: List all the events (result 1 trigger) + Given that I have a valid access_token + And I request "project/251815090529619a99a2bf4013294414/triggers" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the response has 1 record + + + @2: TEST FOR POST TRIGGER /-------------------------------------------------------------------- Scenario: Create a trigger Given that I have a valid access_token And POST this data: @@ -16,7 +25,7 @@ Feature: Testing triggers And store "tri_uid" in session array - @2: TEST FOR PUT TRIGGER /----------------------------------------------------------------------- + @3: TEST FOR PUT TRIGGER /--------------------------------------------------------------------- Scenario: Update a trigger Given that I have a valid access_token And PUT this data: @@ -33,7 +42,7 @@ Feature: Testing triggers And the type is "object" - @3: TEST FOR GET TRIGGER /----------------------------------------------------------------------- + @4: TEST FOR GET TRIGGER /--------------------------------------------------------------------- Scenario: Get a trigger Given that I have a valid access_token And that I want to get a resource with the key "tri_uid" stored in session array @@ -45,11 +54,29 @@ Feature: Testing triggers And that "tri_description" is set to "descripcion editada" - @4: TEST FOR DELETE TRIGGER /----------------------------------------------------------------------- + @5: TEST FOR GET TRIGGERS /-------------------------------------------------------------------- + Scenario: List all the events (result 2 trigger) + Given that I have a valid access_token + And I request "project/251815090529619a99a2bf4013294414/triggers" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the response has 2 record + + + @6: TEST FOR DELETE TRIGGER /----------------------------------------------------------------------- Scenario: Get a trigger Given that I have a valid access_token And that I want to delete a resource with the key "tri_uid" stored in session array And I request "project/251815090529619a99a2bf4013294414/trigger" Then the response status code should be 200 And the response charset is "UTF-8" - And the type is "object" \ No newline at end of file + And the type is "object" + + + @7: TEST FOR GET TRIGGERS /-------------------------------------------------------------------- + Scenario: List all the events (result 1 trigger) + Given that I have a valid access_token + And I request "project/251815090529619a99a2bf4013294414/triggers" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the response has 1 record \ No newline at end of file From 20ad79e7258e6cbf5e684436e2467ee0cbe5c89f Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Fri, 10 Jan 2014 16:18:46 -0400 Subject: [PATCH 7/9] ProcessMaker-MA "Project Properties - Step R. - Assign Task (endpoints & behat)" - Se han implementado los siguientes Endpoints y sus correspondientes features (behat): GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/triggers GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/available-triggers/{type} GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type} POST /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger PUT /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid} DELETE /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type} --- .../step.feature | 147 ++++++++++++++++ workflow/engine/src/BusinessModel/Step.php | 92 ++++++++-- .../engine/src/BusinessModel/Step/Trigger.php | 161 +++++++++++++----- .../ProcessMaker/Project/Activity/Step.php | 38 +++++ .../Project/Activity/Step/Trigger.php | 134 ++++++++++++++- 5 files changed, 518 insertions(+), 54 deletions(-) diff --git a/features/backend/project_properties_step_resources/step.feature b/features/backend/project_properties_step_resources/step.feature index ce23727fc..e10e6113e 100644 --- a/features/backend/project_properties_step_resources/step.feature +++ b/features/backend/project_properties_step_resources/step.feature @@ -301,3 +301,150 @@ Feature: Project Properties - Step Resources And the type is "array" And the json data is an empty array + #TRIGGERS OF STEP "ASSIGN TASK" + + #GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/triggers + # List assigned Triggers to a Step + Scenario: List Triggers assigned to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/triggers" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And the json data is an empty array + + #POST /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger + # Assign a Trigger to a Step + Scenario: Assign "Trigger Demo1" to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And POST this data: + """ + { + "tri_uid": "81919273152cd636c665080083928728", + "st_type": "BEFORE_ASSIGNMENT", + "st_condition": "", + "st_position": 1 + } + """ + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger" + And the content type is "application/json" + Then the response status code should be 201 + And the response charset is "UTF-8" + + #POST /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger + # Assign a Trigger to a Step + Scenario: Assign "Trigger Demo2" to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And POST this data: + """ + { + "tri_uid": "56359776552cd6378b38e47080912028", + "st_type": "BEFORE_ASSIGNMENT", + "st_condition": "", + "st_position": 2 + } + """ + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger" + And the content type is "application/json" + Then the response status code should be 201 + And the response charset is "UTF-8" + + #PUT /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid} + # Update a Trigger assignation of a Step + Scenario: Update "Trigger Demo1" assigned to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And PUT this data: + """ + { + "st_type": "BEFORE_ASSIGNMENT", + "st_condition": "@@FIELD2 == 2" + } + """ + And that I want to update a resource with the key "tgr1" stored in session array + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/81919273152cd636c665080083928728" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And that "st_condition" is set to "@@FIELD2 == 2" + + #GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/triggers + # List assigned Triggers to a Step + Scenario: List Triggers assigned to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/triggers" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And the "tri_uid" property in row 1 equals "56359776552cd6378b38e47080912028" + And the "tri_title" property in row 1 equals "Trigger Demo2" + And the "tri_description" property in row 1 equals "Description" + And the "st_type" property in row 1 equals "BEFORE_ASSIGNMENT" + And the "st_condition" property in row 1 equals "" + And the "st_position" property in row 1 equals "2" + + #GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/available-triggers/{type} + # List available Triggers to assign to a Step + Scenario: List available Triggers to assign to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/available-triggers/before-assignment" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And the "tri_uid" property in row 0 equals "57401970252cd6393531551040242546" + And the "tri_title" property in row 0 equals "Trigger Demo3" + And the "tri_description" property in row 0 equals "Description" + And the "tri_type" property in row 0 equals "SCRIPT" + And the "tri_webbot" property in row 0 equals "" + And the "tri_param" property in row 0 equals "" + + #GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type} + # Get a single Trigger assigned to a Step + Scenario: Get a single Trigger "Trigger Demo1" assigned to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/81919273152cd636c665080083928728/before-assignment" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And that "tri_uid" is set to "81919273152cd636c665080083928728" + And that "tri_title" is set to "Trigger Demo1" + And that "tri_description" is set to "Description" + And that "st_type" is set to "BEFORE_ASSIGNMENT" + And that "st_condition" is set to "@@FIELD2 == 2" + And that "st_position" is set to "1" + + #DELETE /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type} + # Remove a Trigger assignation of a Step + Scenario: Remove "Trigger Demo1" assigned to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And that I want to delete a resource with the key "tgr1" stored in session array + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/81919273152cd636c665080083928728/before-assignment" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + + #DELETE /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type} + # Remove a Trigger assignation of a Step + Scenario: Remove "Trigger Demo2" assigned to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And that I want to delete a resource with the key "tgr2" stored in session array + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/56359776552cd6378b38e47080912028/before-assignment" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + + #GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/triggers + # List assigned Triggers to a Step + Scenario: List Triggers assigned to Step "Assign Task" of "Task2" + Given that I have a valid access_token + And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/triggers" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "array" + And the json data is an empty array + diff --git a/workflow/engine/src/BusinessModel/Step.php b/workflow/engine/src/BusinessModel/Step.php index 926bb72a7..5cff40c2d 100644 --- a/workflow/engine/src/BusinessModel/Step.php +++ b/workflow/engine/src/BusinessModel/Step.php @@ -381,9 +381,11 @@ class Step $rsCriteria = \StepPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); - $rsCriteria->next(); - - return $rsCriteria->getRow(); + if ($rsCriteria->next()) { + return $rsCriteria->getRow(); + } else { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); + } } catch (\Exception $e) { throw $e; } @@ -393,20 +395,60 @@ class Step * Get available triggers of a Step * * @param string $stepUid Unique id of Step - * @param string $type Type (BEFORE, AFTER) + * @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING) + * @param string $taskUid Unique id of Task * * return array */ - public function getAvailableTriggers($stepUid, $type) + public function getAvailableTriggers($stepUid, $type, $taskUid = "") { try { + //Verify data + $step = new \Step(); + + if ($stepUid != "" && !$step->StepExists($stepUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); + } + + $task = new \Task(); + + if ($stepUid == "" && !$task->taskExists($taskUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" doesn't exist in table {1}"))); + } + + //Get data $arrayAvailableTrigger = array(); $trigger = new \BusinessModel\Trigger(); - $arrayDataUid = $this->getDataUids($stepUid); + $flagStepAssignTask = 0; - $processUid = $arrayDataUid["PRO_UID"]; + if ($stepUid != "") { + $arrayDataUid = $this->getDataUids($stepUid); + + $processUid = $arrayDataUid["PRO_UID"]; + } else { + $arrayData = $task->load($taskUid); + + $processUid = $arrayData["PRO_UID"]; + + $flagStepAssignTask = 1; + + switch ($type) { + case "BEFORE_ASSIGNMENT": + $stepUid = "-1"; + $type = "BEFORE"; + break; + case "BEFORE_ROUTING": + $stepUid = "-2"; + $type = "BEFORE"; + break; + case "AFTER_ROUTING": + $stepUid = "-2"; + $type = "AFTER"; + break; + } + } //Get Uids $arrayUid = array(); @@ -415,6 +457,11 @@ class Step $criteria->addSelectColumn(\StepTriggerPeer::TRI_UID); $criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL); + + if ($flagStepAssignTask == 1) { + $criteria->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL); + } + $criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL); $rsCriteria = \StepTriggerPeer::doSelectRS($criteria); @@ -459,21 +506,37 @@ class Step * Get all triggers of a Step * * @param string $stepUid Unique id of Step + * @param string $taskUid Unique id of Task * * return array */ - public function getTriggers($stepUid) + public function getTriggers($stepUid, $taskUid = "") { try { + //Verify data + $step = new \Step(); + + if ($stepUid != "" && !$step->StepExists($stepUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); + } + + $task = new \Task(); + + if ($stepUid == "" && !$task->taskExists($taskUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" doesn't exist in table {1}"))); + } + //Get data $arrayTrigger = array(); $bmTrigger = new \BusinessModel\Trigger(); $bmStepTrigger = new \BusinessModel\Step\Trigger(); - $arrayDataUid = $this->getDataUids($stepUid); + if ($stepUid != "") { + $arrayDataUid = $this->getDataUids($stepUid); - $taskUid = $arrayDataUid["TAS_UID"]; + $taskUid = $arrayDataUid["TAS_UID"]; + } $processMap = new \ProcessMap(); $stepTrigger = new \StepTrigger(); @@ -495,15 +558,20 @@ class Step $triggerType = $index; $type = $value; + $flagStepAssignTask = 0; + switch ($triggerType) { case "BEFORE_ASSIGNMENT": $stepUid = "-1"; + $flagStepAssignTask = 1; break; case "BEFORE_ROUTING": $stepUid = "-2"; + $flagStepAssignTask = 1; break; case "AFTER_ROUTING": $stepUid = "-2"; + $flagStepAssignTask = 1; break; } @@ -527,6 +595,10 @@ class Step while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); + if ($flagStepAssignTask == 1) { + $row["ST_TYPE"] = $triggerType; + } + $arrayTrigger[] = $bmStepTrigger->getTriggerDataFromRecord($row); } } diff --git a/workflow/engine/src/BusinessModel/Step/Trigger.php b/workflow/engine/src/BusinessModel/Step/Trigger.php index c22b91dfc..ac96d71d3 100644 --- a/workflow/engine/src/BusinessModel/Step/Trigger.php +++ b/workflow/engine/src/BusinessModel/Step/Trigger.php @@ -8,13 +8,14 @@ class Trigger * * @param string $stepUid Unique id of Step * @param string $type Type (BEFORE, AFTER) + * @param string $taskUid Unique id of Task * @param string $triggerUid Unique id of Trigger * @param int $position Position * @param string $triggerUidExclude Unique id of Trigger to exclude * * return bool Return true if exists the record in table STEP_TRIGGER, false otherwise */ - public function existsRecord($stepUid, $type, $triggerUid, $position = 0, $triggerUidExclude = "") + public function existsRecord($stepUid, $type, $taskUid, $triggerUid, $position = 0, $triggerUidExclude = "") { try { $criteria = new \Criteria("workflow"); @@ -22,6 +23,7 @@ class Trigger $criteria->addSelectColumn(\StepTriggerPeer::STEP_UID); $criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL); $criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL); + $criteria->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL); if ($triggerUid != "") { $criteria->add(\StepTriggerPeer::TRI_UID, $triggerUid, \Criteria::EQUAL); @@ -52,26 +54,53 @@ class Trigger * Assign Trigger to a Step * * @param string $stepUid Unique id of Step - * @param string $type Type (BEFORE, AFTER) + * @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING) + * @param string $taskUid Unique id of Task * @param string $triggerUid Unique id of Trigger * @param array $arrayData Data * * return array Data of the Trigger assigned to a Step */ - public function create($stepUid, $type, $triggerUid, $arrayData) + public function create($stepUid, $type, $taskUid, $triggerUid, $arrayData) { try { - $step = new \BusinessModel\Step(); + $stepUidIni = $stepUid; + $typeIni = $type; - $arrayDataUid = $step->getDataUids($stepUid); + $flagStepAssignTask = 0; - $taskUid = $arrayDataUid["TAS_UID"]; + if ($stepUid == "") { + $flagStepAssignTask = 1; + + switch ($type) { + case "BEFORE_ASSIGNMENT": + $stepUid = "-1"; + $type = "BEFORE"; + break; + case "BEFORE_ROUTING": + $stepUid = "-2"; + $type = "BEFORE"; + break; + case "AFTER_ROUTING": + $stepUid = "-2"; + $type = "AFTER"; + break; + } + } //Verify data - $step = new \Step(); + if ($flagStepAssignTask == 0) { + $step = new \Step(); - if (!$step->StepExists($stepUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); + if (!$step->StepExists($stepUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); + } + } + + $task = new \Task(); + + if (!$task->taskExists($taskUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" doesn't exist in table {1}"))); } $trigger = new \Triggers(); @@ -80,12 +109,12 @@ class Trigger throw (new \Exception(str_replace(array("{0}", "{1}"), array($triggerUid, "TRIGGERS"), "The UID \"{0}\" doesn't exist in table {1}"))); } - if ($this->existsRecord($stepUid, $type, $triggerUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", exists in table {1}"))); + if ($this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", exists in table {1}"))); } - if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, "", $arrayData["st_position"])) { - throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}"))); + if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, $taskUid, "", $arrayData["st_position"])) { + throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $taskUid . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}"))); } //Create @@ -97,7 +126,7 @@ class Trigger $arrayData["st_position"] = $stepTrigger->getNextPosition($stepUid, $type, $taskUid) - 1; } - $arrayData = $this->update($stepUid, $type, $triggerUid, $arrayData); + $arrayData = $this->update($stepUidIni, $typeIni, $taskUid, $triggerUid, $arrayData); return $arrayData; } catch (\Exception $e) { @@ -109,26 +138,44 @@ class Trigger * Update Trigger of a Step * * @param string $stepUid Unique id of Step - * @param string $type Type (BEFORE, AFTER) + * @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING) + * @param string $taskUid Unique id of Task * @param string $triggerUid Unique id of Trigger * @param array $arrayData Data * * return array Data updated of the Trigger assigned to a Step */ - public function update($stepUid, $type, $triggerUid, $arrayData) + public function update($stepUid, $type, $taskUid, $triggerUid, $arrayData) { try { - $step = new \BusinessModel\Step(); + $flagStepAssignTask = 0; - $arrayDataUid = $step->getDataUids($stepUid); + if ($stepUid == "") { + $flagStepAssignTask = 1; - $taskUid = $arrayDataUid["TAS_UID"]; + switch ($type) { + case "BEFORE_ASSIGNMENT": + $stepUid = "-1"; + $type = "BEFORE"; + break; + case "BEFORE_ROUTING": + $stepUid = "-2"; + $type = "BEFORE"; + break; + case "AFTER_ROUTING": + $stepUid = "-2"; + $type = "AFTER"; + break; + } + } //Verify data - $step = new \Step(); + if ($flagStepAssignTask == 0) { + $step = new \Step(); - if (!$step->StepExists($stepUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); + if (!$step->StepExists($stepUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); + } } $trigger = new \Triggers(); @@ -137,8 +184,8 @@ class Trigger throw (new \Exception(str_replace(array("{0}", "{1}"), array($triggerUid, "TRIGGERS"), "The UID \"{0}\" doesn't exist in table {1}"))); } - if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, "", $arrayData["st_position"], $triggerUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}"))); + if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, $taskUid, "", $arrayData["st_position"], $triggerUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $taskUid . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}"))); } //Update @@ -171,23 +218,35 @@ class Trigger * Delete Trigger of a Step * * @param string $stepUid Unique id of Step - * @param string $type Type (BEFORE, AFTER) + * @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING) + * @param string $taskUid Unique id of Task * @param string $triggerUid Unique id of Trigger * * return void */ - public function delete($stepUid, $type, $triggerUid) + public function delete($stepUid, $type, $taskUid, $triggerUid) { try { - $step = new \BusinessModel\Step(); - - $arrayDataUid = $step->getDataUids($stepUid); - - $taskUid = $arrayDataUid["TAS_UID"]; + if ($stepUid == "") { + switch ($type) { + case "BEFORE_ASSIGNMENT": + $stepUid = "-1"; + $type = "BEFORE"; + break; + case "BEFORE_ROUTING": + $stepUid = "-2"; + $type = "BEFORE"; + break; + case "AFTER_ROUTING": + $stepUid = "-2"; + $type = "AFTER"; + break; + } + } //Verify data - if (!$this->existsRecord($stepUid, $type, $triggerUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}"))); + if (!$this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}"))); } //Get position @@ -234,23 +293,41 @@ class Trigger * Get data of a Trigger * * @param string $stepUid Unique id of Step - * @param string $type Type (BEFORE, AFTER) + * @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING) + * @param string $taskUid Unique id of Task * @param string $triggerUid Unique id of Trigger * * return array Return an array with data of a Trigger */ - public function getTrigger($stepUid, $type, $triggerUid) + public function getTrigger($stepUid, $type, $taskUid, $triggerUid) { try { - $step = new \BusinessModel\Step(); + $typeIni = $type; - $arrayDataUid = $step->getDataUids($stepUid); + $flagStepAssignTask = 0; - $taskUid = $arrayDataUid["TAS_UID"]; + if ($stepUid == "") { + $flagStepAssignTask = 1; + + switch ($type) { + case "BEFORE_ASSIGNMENT": + $stepUid = "-1"; + $type = "BEFORE"; + break; + case "BEFORE_ROUTING": + $stepUid = "-2"; + $type = "BEFORE"; + break; + case "AFTER_ROUTING": + $stepUid = "-2"; + $type = "AFTER"; + break; + } + } //Verify data - if (!$this->existsRecord($stepUid, $type, $triggerUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}"))); + if (!$this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}"))); } //Get data @@ -274,6 +351,10 @@ class Trigger $row = $rsCriteria->getRow(); + if ($flagStepAssignTask == 1) { + $row["ST_TYPE"] = $typeIni; + } + return $this->getTriggerDataFromRecord($row); } catch (\Exception $e) { throw $e; diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step.php index 88d7e7f00..051be1dec 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step.php @@ -124,6 +124,44 @@ class Step extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + //Step "Assign Task" + + /** + * @url GET /:projectUid/activity/:activityUid/step/triggers + */ + public function doGetActivityStepAssignTaskTriggers($activityUid, $projectUid) + { + try { + $step = new \BusinessModel\Step(); + + $response = $step->getTriggers("", $activityUid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url GET /:projectUid/activity/:activityUid/step/available-triggers/:type + * + * @param string $activityUid + * @param string $projectUid + * @param string $type {@from body}{@choice before-assignment,before-routing,after-routing} + */ + public function doGetActivityStepAssignTaskAvailableTriggers($activityUid, $projectUid, $type) + { + try { + $step = new \BusinessModel\Step(); + + $response = $step->getAvailableTriggers("", strtoupper(str_replace("-", "_", $type)), $activityUid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } } class StepPostStructure diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step/Trigger.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step/Trigger.php index c8f988dec..5a9a063bf 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step/Trigger.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Step/Trigger.php @@ -25,7 +25,7 @@ class Trigger extends Api try { $stepTrigger = new \BusinessModel\Step\Trigger(); - $response = $stepTrigger->getTrigger($stepUid, strtoupper($type), $triggerUid); + $response = $stepTrigger->getTrigger($stepUid, strtoupper($type), $activityUid, $triggerUid); return $response; } catch (\Exception $e) { @@ -50,7 +50,7 @@ class Trigger extends Api $stepTrigger = new \BusinessModel\Step\Trigger(); - $arrayData = $stepTrigger->create($stepUid, $request_data["st_type"], $request_data["tri_uid"], $request_data); + $arrayData = $stepTrigger->create($stepUid, $request_data["st_type"], $activityUid, $request_data["tri_uid"], $request_data); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } @@ -72,7 +72,7 @@ class Trigger extends Api $stepTrigger = new \BusinessModel\Step\Trigger(); - $arrayData = $stepTrigger->update($stepUid, $request_data["st_type"], $triggerUid, $request_data); + $arrayData = $stepTrigger->update($stepUid, $request_data["st_type"], $activityUid, $triggerUid, $request_data); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } @@ -92,7 +92,92 @@ class Trigger extends Api try { $stepTrigger = new \BusinessModel\Step\Trigger(); - $stepTrigger->delete($stepUid, strtoupper($type), $triggerUid); + $stepTrigger->delete($stepUid, strtoupper($type), $activityUid, $triggerUid); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + //Step "Assign Task" + + /** + * @url GET /:projectUid/activity/:activityUid/step/trigger/:triggerUid/:type + * + * @param string $triggerUid + * @param string $activityUid + * @param string $projectUid + * @param string $type {@from body}{@choice before-assignment,before-routing,after-routing} + */ + public function doGetActivityStepAssignTaskTrigger($triggerUid, $activityUid, $projectUid, $type) + { + try { + $stepTrigger = new \BusinessModel\Step\Trigger(); + + $response = $stepTrigger->getTrigger("", strtoupper(str_replace("-", "_", $type)), $activityUid, $triggerUid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url POST /:projectUid/activity/:activityUid/step/trigger + * + * @param string $activityUid + * @param string $projectUid + * @param StepAssignTaskTriggerPostStructure $request_data + * + * @status 201 + */ + public function doPostActivityStepAssignTaskTrigger($activityUid, $projectUid, StepAssignTaskTriggerPostStructure $request_data = null) + { + try { + $request_data = (array)($request_data); + + $stepTrigger = new \BusinessModel\Step\Trigger(); + + $arrayData = $stepTrigger->create("", $request_data["st_type"], $activityUid, $request_data["tri_uid"], $request_data); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url PUT /:projectUid/activity/:activityUid/step/trigger/:triggerUid + * + * @param string $triggerUid + * @param string $activityUid + * @param string $projectUid + * @param StepAssignTaskTriggerPutStructure $request_data + */ + public function doPutActivityStepAssignTaskTrigger($triggerUid, $activityUid, $projectUid, StepAssignTaskTriggerPutStructure $request_data = null) + { + try { + $request_data = (array)($request_data); + + $stepTrigger = new \BusinessModel\Step\Trigger(); + + $arrayData = $stepTrigger->update("", $request_data["st_type"], $activityUid, $triggerUid, $request_data); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url DELETE /:projectUid/activity/:activityUid/step/trigger/:triggerUid/:type + * + * @param string $triggerUid + * @param string $activityUid + * @param string $projectUid + * @param string $type {@from body}{@choice before-assignment,before-routing,after-routing} + */ + public function doDeleteActivityStepAssignTaskTrigger($triggerUid, $activityUid, $projectUid, $type) + { + try { + $stepTrigger = new \BusinessModel\Step\Trigger(); + + $stepTrigger->delete("", strtoupper(str_replace("-", "_", $type)), $activityUid, $triggerUid); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } @@ -140,3 +225,44 @@ class StepTriggerPutStructure public $st_position; } +class StepAssignTaskTriggerPostStructure +{ + /** + * @var string {@from body}{@choice BEFORE_ASSIGNMENT,BEFORE_ROUTING,AFTER_ROUTING}{@required true} + */ + public $st_type; + + /** + * @var string {@from body}{@min 32}{@max 32}{@required true} + */ + public $tri_uid; + + /** + * @var string + */ + public $st_condition; + + /** + * @var int {@from body}{@min 1} + */ + public $st_position; +} + +class StepAssignTaskTriggerPutStructure +{ + /** + * @var string {@from body}{@choice BEFORE_ASSIGNMENT,BEFORE_ROUTING,AFTER_ROUTING}{@required true} + */ + public $st_type; + + /** + * @var string + */ + public $st_condition; + + /** + * @var int {@from body}{@min 1} + */ + public $st_position; +} + From 6d820a2420e6c255abad3475491249075b142518 Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Mon, 13 Jan 2014 10:00:16 -0400 Subject: [PATCH 8/9] Se cambia nombre de parametros para assignee adhoc --- .../ProcessMaker/Project/Activity/Assignee.php | 16 ++++++++-------- workflow/engine/src/Services/api.ini | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php index b251bebf7..ecb806369 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php @@ -89,16 +89,16 @@ class Assignee extends Api * * @param string $prjUid * @param string $actUid - * @param string $ass_uid - * @param string $ass_type {@choice user,group} + * @param string $aas_uid + * @param string $aas_type {@choice user,group} * * @status 201 */ - public function doPostActivityAssignee($prjUid, $actUid, $ass_uid, $ass_type) + public function doPostActivityAssignee($prjUid, $actUid, $aas_uid, $aas_type) { try { $task = new \BusinessModel\Task(); - $arrayData = $task->addTaskAssignee($prjUid, $actUid, $ass_uid, $ass_type); + $arrayData = $task->addTaskAssignee($prjUid, $actUid, $aas_uid, $aas_type); } catch (\Exception $e) { //Response throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); @@ -107,18 +107,18 @@ class Assignee extends Api } /** - * @url DELETE /:prjUid/activity/:actUid/assignee/:assUid + * @url DELETE /:prjUid/activity/:actUid/assignee/:aasUid * * @param string $prjUid * @param string $actUid - * @param string $assUid + * @param string $aasUid * */ - public function doDeleteActivityAssignee($prjUid, $actUid, $assUid) + public function doDeleteActivityAssignee($prjUid, $actUid, $aasUid) { try { $task = new \BusinessModel\Task(); - $arrayData = $task->removeTaskAssignee($prjUid, $actUid, $assUid); + $arrayData = $task->removeTaskAssignee($prjUid, $actUid, $aasUid); } catch (\Exception $e) { //response throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); diff --git a/workflow/engine/src/Services/api.ini b/workflow/engine/src/Services/api.ini index 2bae1b34d..d2cbd8ffe 100644 --- a/workflow/engine/src/Services/api.ini +++ b/workflow/engine/src/Services/api.ini @@ -25,6 +25,7 @@ debug = 1 output-documents = "Services\Api\ProcessMaker\Project\OutputDocuments" supervisors = "Services\Api\ProcessMaker\Project\ProcessSupervisors" process-permissions = "Services\Api\ProcessMaker\Project\ProcessPermissions" + case-scheduler = "Services\Api\ProcessMaker\Project\CaseScheduler" [alias: projects] project = "Services\Api\ProcessMaker\Project" From 0a023659626a17191bc4041b5f5208b5b6d69abc Mon Sep 17 00:00:00 2001 From: erik Date: Mon, 13 Jan 2014 13:56:13 -0400 Subject: [PATCH 9/9] typo fix in bootstrap, vendors validation messages & validation that vendors/autoload.php exists --- gulliver/system/class.bootstrap.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index e5f027af3..069791c1c 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -3088,6 +3088,14 @@ class Bootstrap "$>php composer.phar install" ); } + } + + if (! file_exists(PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php")) { + throw new Exception( + "ERROR: Problems with Verdors!" . PHP_EOL . + "Please execute the following command to repare vendors:" .PHP_EOL.PHP_EOL. + "$>php composer.phar update" + ); } require_once PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php";