From 9f7c33c1c03959c7df08aaa367293d29c4ea90aa Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Tue, 7 Jan 2014 12:29:16 -0400 Subject: [PATCH 01/10] Se adiciona available Process supervisor para dynaform e inputdocuments --- .../src/BusinessModel/ProcessSupervisor.php | 104 +++++++++++++++++- .../Project/ProcessSupervisors.php | 84 ++++++++++---- 2 files changed, 162 insertions(+), 26 deletions(-) diff --git a/workflow/engine/src/BusinessModel/ProcessSupervisor.php b/workflow/engine/src/BusinessModel/ProcessSupervisor.php index 2f9f7cf88..d7ee89793 100644 --- a/workflow/engine/src/BusinessModel/ProcessSupervisor.php +++ b/workflow/engine/src/BusinessModel/ProcessSupervisor.php @@ -186,7 +186,7 @@ class ProcessSupervisor } /** - * Return output documents of a project + * Return dynaform supervisor * @param string $sProcessUID * * @return array @@ -228,15 +228,63 @@ class ProcessSupervisor 'step_position' => $aRow['STEP_POSITION'], 'title' => $aRow['DYN_TITLE']); $oDataset->next(); - } - return $aResp; + } + return $aResp; } catch (Exception $e) { throw $e; } } /** - * Return output documents of a project + * Return available dynaform supervisor + * @param string $sProcessUID + * + * @return array + * + * @access public + */ + public function getAvailableDynaformSupervisors($sProcessUID = '') + { + try { + $oCriteria = $this->getDynaformSupervisor($sProcessUID); + $aUIDS = array(); + foreach ($oCriteria as $oCriteria => $value) { + $aUIDS[] = $value["step_uid_obj"]; + } + $sDelimiter = \DBAdapter::getStringDelimiter(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\DynaformPeer::DYN_UID); + $oCriteria->addSelectColumn(\DynaformPeer::PRO_UID); + $oCriteria->addAsColumn('DYN_TITLE', 'C.CON_VALUE'); + $oCriteria->addAlias('C', 'CONTENT'); + $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(\DynaformPeer::PRO_UID, $sProcessUID); + $oCriteria->add(\DynaformPeer::DYN_TYPE, 'xmlform'); + $oCriteria->add(\DynaformPeer::DYN_UID, $aUIDS, \Criteria::NOT_IN); + $oDataset = \StepSupervisorPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + $oDataset = \StepSupervisorPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aResp[] = array('pro_uid' => $aRow['PRO_UID'], + 'dyn_uid' => $aRow['DYN_UID'], + 'title' => $aRow['DYN_TITLE']); + $oDataset->next(); + } + return $aResp; + } catch (Exception $e) { + throw $e; + } + } + + /** + * Return input documents supervisor * @param string $sProcessUID * * @return array @@ -285,6 +333,54 @@ class ProcessSupervisor } } + /** + * Return available inputdocuments supervisor + * @param string $sProcessUID + * + * @return array + * + * @access public + */ + public function getAvailableInputDocumentSupervisor($sProcessUID = '') + { + try { + $oCriteria = $this->getInputDocumentSupervisor($sProcessUID); + $aUIDS = array(); + foreach ($oCriteria as $oCriteria => $value) { + $aUIDS[] = $value["step_uid_obj"]; + } + $sDelimiter = \DBAdapter::getStringDelimiter(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID); + $oCriteria->addSelectColumn(\InputDocumentPeer::PRO_UID); + $oCriteria->addAsColumn('INP_DOC_TITLE', 'C.CON_VALUE'); + $oCriteria->addAlias('C', 'CONTENT'); + $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(\InputDocumentPeer::PRO_UID, $sProcessUID); + $oCriteria->add(\InputDocumentPeer::INP_DOC_UID, $aUIDS, \Criteria::NOT_IN); + $oDataset = \StepSupervisorPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + $oDataset = \StepSupervisorPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aResp[] = array('pro_uid' => $aRow['PRO_UID'], + 'inp_doc_uid' => $aRow['INP_DOC_UID'], + 'title' => $aRow['INP_DOC_TITLE']); + $oDataset->next(); + } + return $aResp; + } catch (Exception $e) { + throw $e; + } + } + + /** * Remove a supervisor of an activity * diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php index c128d7219..192381d8d 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php @@ -33,28 +33,6 @@ class ProcessSupervisors extends Api return $response; } - /** - * @param string $prjUid {@min 32} {@max 32} - * @param string $filter - * @param int $start - * @param int $limit - * - * @url GET /:prjUid/available-supervisors - */ - public function doGetAvailableSupervisors($prjUid, $filter = '', $start = null, $limit = null) - { - try { - $supervisor = new \BusinessModel\ProcessSupervisor(); - $arrayData = $supervisor->getAvailableSupervisors($prjUid, $filter, $start, $limit); - //Response - $response = $arrayData; - } catch (\Exception $e) { - //response - throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); - } - return $response; - } - /** * @param string $prjUid {@min 32} {@max 32} * @@ -93,6 +71,68 @@ class ProcessSupervisors extends Api return $response; } + /** + * @param string $prjUid {@min 32} {@max 32} + * @param string $filter + * @param int $start + * @param int $limit + * + * @url GET /:prjUid/available-supervisors + */ + public function doGetAvailableSupervisors($prjUid, $filter = '', $start = null, $limit = null) + { + try { + $supervisor = new \BusinessModel\ProcessSupervisor(); + $arrayData = $supervisor->getAvailableSupervisors($prjUid, $filter, $start, $limit); + //Response + $response = $arrayData; + } catch (\Exception $e) { + //response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + + /** + * @param string $prjUid {@min 32} {@max 32} + * + * @url GET /:prjUid/available-dynaform-supervisor + */ + public function doGetAvailableDynaformSupervisor($prjUid) + { + try { + $supervisor = new \BusinessModel\ProcessSupervisor(); + $arrayData = $supervisor->getAvailableDynaformSupervisors($prjUid); + //Response + $response = $arrayData; + } catch (\Exception $e) { + //response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + + /** + * @param string $prjUid {@min 32} {@max 32} + * + * @url GET /:prjUid/available-inputdocument-supervisor + */ + public function doGetAvailableInputDocumentSupervisor($prjUid) + + { + try { + $supervisor = new \BusinessModel\ProcessSupervisor(); + $arrayData = $supervisor->getAvailableInputDocumentSupervisor($prjUid); + //Response + $response = $arrayData; + } catch (\Exception $e) { + //response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + + /** * @url DELETE /:prjUid/supervisor/:supUid * From ebd341d5dfae102c532d7cd82919cce21d0618b2 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 12:34:39 -0400 Subject: [PATCH 02/10] Pruebas de behat para events --- behat.yml.dist | 2 +- features/bootstrap/RestContext.php | 24 +++++++++++ features/processmaker/event.feature | 61 +++++++++++++++++++++++++++ features/processmaker/trigger.feature | 23 ++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 features/processmaker/event.feature create mode 100644 features/processmaker/trigger.feature diff --git a/behat.yml.dist b/behat.yml.dist index c22acdb95..a8869196e 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -3,4 +3,4 @@ default: context: parameters: base_url: http://192.168.11.181/api/1.0/michelangelo/ - access_token: ff4bdec9e8e2e3b2fa3fb03bc3a7d287fd0dcf26 + access_token: cd5cff9b2e3ebabf49e276e47e977fab5988c00e diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 8f80c1487..48a90d813 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -173,6 +173,26 @@ class RestContext extends BehatContext $this->_restObjectMethod = 'get'; } + /** + * @Given /^that I want to find a resource with the key "([^"]*)" stored in session array$/ + */ + public function thatIWantToFindAResourceWithTheKeyStoredInSessionArray($varName) + { + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = array(); + } + if (!isset($sessionData->$varName) ) { + $varValue = ''; + } else { + $varValue = $sessionData->$varName; + } + + $this->_restFindQueryStringSuffix = "/" . $varValue; + $this->_restObjectMethod = 'get'; + } + /** * @Given /^that I want to delete a "([^"]*)"$/ * @Given /^that I want to delete an "([^"]*)"$/ @@ -331,6 +351,10 @@ class RestContext extends BehatContext $this->_response = $this->_request->send(); break; case 'GET': + if (isset($this->_restFindQueryStringSuffix) && + $this->_restFindQueryStringSuffix != '') { + $url .= $this->_restFindQueryStringSuffix; + } $this->_request = $this->_client ->get($url, $this->_headers); $this->_response = $this->_request->send(); diff --git a/features/processmaker/event.feature b/features/processmaker/event.feature new file mode 100644 index 000000000..e20147b75 --- /dev/null +++ b/features/processmaker/event.feature @@ -0,0 +1,61 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Testing triggers + + @1: TEST FOR POST EVENT /---------------------------------------------------------------------- + Scenario: Create a event + Given that I have a valid access_token + And POST this data: + """ + { + "evn_description": "DE BEHAT", + "evn_status": "ACTIVE", + "evn_action": "SEND_MESSAGE", + "evn_related_to": "SINGLE", + "tas_uid": "97192372152a5c78f04a794095806311", + "evn_tas_uid_from": "97192372152a5c78f04a794095806311", + "evn_tas_estimated_duration": 1, + "evn_time_unit": "DAYS", + "evn_when": 1, + "evn_when_occurs": "AFTER_TIME", + "tri_uid": "95325847552af0c07792c15098680510" + } + """ + And I request "project/251815090529619a99a2bf4013294414/event" + Then the response status code should be 201 + And store "evn_uid" in session array + + @2: TEST FOR PUT EVENT /----------------------------------------------------------------------- + Scenario: Update a event + Given that I have a valid access_token + And PUT this data: + """ + { + "evn_description": "change description", + "evn_status": "ACTIVE", + "evn_action": "SEND_MESSAGE", + "evn_related_to": "SINGLE", + "tas_uid": "97192372152a5c78f04a794095806311", + "evn_tas_uid_from": "97192372152a5c78f04a794095806311", + "evn_tas_estimated_duration": 1, + "evn_time_unit": "DAYS", + "evn_when": 1, + "evn_when_occurs": "AFTER_TIME", + "tri_uid": "95325847552af0c07792c15098680510" + } + """ + And that I want to update 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" + + + @3: TEST FOR GET EVENT /----------------------------------------------------------------------- + Scenario: Get a event + Given that I have a valid access_token + And that I want to find 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" + And that "evn_description" is set to "change description" \ No newline at end of file diff --git a/features/processmaker/trigger.feature b/features/processmaker/trigger.feature new file mode 100644 index 000000000..edfd62a31 --- /dev/null +++ b/features/processmaker/trigger.feature @@ -0,0 +1,23 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Testing triggers + Scenario: List triggers of an project + Given that I have a valid access_token + And I request "project/534152995521df6bb5986c4062665559/triggers" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + + + Scenario: Create a trigger + Given that I have a valid access_token + And POST this data: + """ + { + "tri_title": "nuevo triggerr", + "tri_description": "descripcion" + } + """ + And I request "project/534152995521df6bb5986c4062665559/trigger" + Then the response status code should be 201 \ No newline at end of file From a96cbb2a8d5482dd30dcbd5286237e638d821fab Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Tue, 7 Jan 2014 12:50:22 -0400 Subject: [PATCH 03/10] ProcessMaker-MA "Dynaforms Resources (behat)" - Se han implementado los siguientes features: GET /api/1.0/{workspace}/project/{prj_uid}/dynaforms GET /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid} POST /api/1.0/{workspace}/project/{prj_uid}/dynaform - Creation normal of a DynaForm - Copy/Import a DynaForm - Creation of a DynaForm based in a PMTable PUT /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid} DELETE /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid} --- .../dynaforms_resources/dynaforms.feature | 191 ++++++++++++++++-- 1 file changed, 172 insertions(+), 19 deletions(-) diff --git a/features/backend/dynaforms_resources/dynaforms.feature b/features/backend/dynaforms_resources/dynaforms.feature index b0c7b98cc..0b945c876 100644 --- a/features/backend/dynaforms_resources/dynaforms.feature +++ b/features/backend/dynaforms_resources/dynaforms.feature @@ -1,23 +1,176 @@ @ProcessMakerMichelangelo @RestAPI -Feature: Dynaforms Resources +Feature: DynaForms Resources + #GET /api/1.0/{workspace}/project/{prj_uid}/dynaforms + # Get a List DynaForms of a Project + Scenario: Get a List DynaForms of a Project + Given that I have a valid access_token + And I request "project/14414793652a5d718b65590036026581/dynaforms" + 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 - Background: - Given that I have a valid access_token + #POST /api/1.0/{workspace}/project/{prj_uid}/dynaform + # Create a new DynaForm for a Project + # Creation normal of a DynaForm + Scenario: Create "My DynaForm1" for a Project (Creation normal of a DynaForm) + Given that I have a valid access_token + And POST this data: + """ + { + "dyn_title": "My DynaForm1", + "dyn_description": "My DynaForm1 DESCRIPTION", + "dyn_type": "xmlform" + } + """ + And I request "project/14414793652a5d718b65590036026581/dynaform" + And the content type is "application/json" + Then the response status code should be 201 + And the response charset is "UTF-8" + And the type is "object" + And store "dyn_uid" in session array as variable "dynaForm1" - Scenario: Get a List of dynaforms of a project - Given this scenario is not implemented yet - - Scenario: Get a single dynaform of a project - Given this scenario is not implemented yet - - Scenario: Create a new dynaform for a project - Given this scenario is not implemented yet - - Scenario: Create a copy of a dynaform and import it to another project - Given this scenario is not implemented yet - - Scenario: Update a dynaform of a project - Given this scenario is not implemented yet + #POST /api/1.0/{workspace}/project/{prj_uid}/dynaform + # Create a new DynaForm for a Project + # Copy/Import a DynaForm + Scenario: Create "DynaForm Demo" for a Project (Copy/Import a DynaForm) + Given that I have a valid access_token + And POST this data: + """ + { + "dyn_title": "DynaForm Demo", + "dyn_description": "Description", + "dyn_type": "xmlform", + "copy_import": + { + "prj_uid": "48207364252cc27894ca354020290166", + "dyn_uid": "68268455252cc27cb463d76013645722" + } + } + """ + And I request "project/14414793652a5d718b65590036026581/dynaform" + And the content type is "application/json" + Then the response status code should be 201 + And the response charset is "UTF-8" + And the type is "object" + And store "dyn_uid" in session array as variable "dynaForm2" + + #POST /api/1.0/{workspace}/project/{prj_uid}/dynaform + # Create a new DynaForm for a Project + # Creation of a DynaForm based in a PMTable + Scenario: Create "My DynaForm3" for a Project (Creation of a DynaForm based in a PMTable) + Given that I have a valid access_token + And POST this data: + """ + { + "dyn_title": "My DynaForm3", + "dyn_description": "My DynaForm3 DESCRIPTION", + "dyn_type": "xmlform", + "pmtable": + { + "tab_uid": "65193158852cc1a93a5a535084878044", + "fields": [ + { + "fld_name": "DYN_UID", + "pro_variable": "@#APPLICATION" + } + ] + } + } + """ + And I request "project/14414793652a5d718b65590036026581/dynaform" + And the content type is "application/json" + Then the response status code should be 201 + And the response charset is "UTF-8" + And the type is "object" + And store "dyn_uid" in session array as variable "dynaForm3" + + #PUT /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid} + # Update a DynaForm for a Project + Scenario: Update a DynaForm for a Project + Given that I have a valid access_token + And PUT this data: + """ + { + "dyn_title": "My DynaForm1 Modified", + "dyn_description": "My DynaForm1 DESCRIPTION Modified", + "dyn_type": "xmlform" + } + """ + And that I want to update a resource with the key "dynaForm1" stored in session array + And I request "project/14414793652a5d718b65590036026581/dynaform" + 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 "dyn_title" is set to "My DynaForm1 Modified" + + #GET /api/1.0/{workspace}/project/{prj_uid}/dynaforms + # Get a List DynaForms of a Project + Scenario: Get a List DynaForms of a Project + Given that I have a valid access_token + And I request "project/14414793652a5d718b65590036026581/dynaforms" + 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 "dyn_title" property in row 0 equals "DynaForm Demo" + And the "dyn_description" property in row 0 equals "Description" + And the "dyn_type" property in row 0 equals "xmlform" + + #GET /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid} + # Get a single DynaForm of a Project + Scenario: Get a single DynaForm of a Project + Given that I have a valid access_token + And that I want to get a resource with the key "dynaForm3" stored in session array + And I request "project/14414793652a5d718b65590036026581/dynaform" + 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 "dyn_title" is set to "My DynaForm3" + And that "dyn_description" is set to "My DynaForm3 DESCRIPTION" + And that "dyn_type" is set to "xmlform" + + #DELETE /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid} + # Delete a DynaForm of a Project + Scenario: Delete a previously created DynaForms + Given that I have a valid access_token + And that I want to delete a resource with the key "dynaForm1" stored in session array + And I request "project/14414793652a5d718b65590036026581/dynaform" + 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}/dynaform/{dyn_uid} + # Delete a DynaForm of a Project + Scenario: Delete a previously created DynaForms + Given that I have a valid access_token + And that I want to delete a resource with the key "dynaForm2" stored in session array + And I request "project/14414793652a5d718b65590036026581/dynaform" + 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}/dynaform/{dyn_uid} + # Delete a DynaForm of a Project + Scenario: Delete a previously created DynaForms + Given that I have a valid access_token + And that I want to delete a resource with the key "dynaForm3" stored in session array + And I request "project/14414793652a5d718b65590036026581/dynaform" + 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}/dynaforms + # Get a List DynaForms of a Project + Scenario: Get a List DynaForms of a Project + Given that I have a valid access_token + And I request "project/14414793652a5d718b65590036026581/dynaforms" + 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 - Scenario: Delete a dynaform of a project - Given this scenario is not implemented yet From 9abed301de9a9d31a3fa92119520159261f9ebef Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 14:50:37 -0400 Subject: [PATCH 04/10] Arreglo de conflictos --- features/bootstrap/RestContext.php | 85 ++++++++++++++++++------------ 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 48a90d813..bdabc845d 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -173,26 +173,6 @@ class RestContext extends BehatContext $this->_restObjectMethod = 'get'; } - /** - * @Given /^that I want to find a resource with the key "([^"]*)" stored in session array$/ - */ - public function thatIWantToFindAResourceWithTheKeyStoredInSessionArray($varName) - { - if (file_exists("session.data")) { - $sessionData = json_decode(file_get_contents("session.data")); - } else { - $sessionData = array(); - } - if (!isset($sessionData->$varName) ) { - $varValue = ''; - } else { - $varValue = $sessionData->$varName; - } - - $this->_restFindQueryStringSuffix = "/" . $varValue; - $this->_restObjectMethod = 'get'; - } - /** * @Given /^that I want to delete a "([^"]*)"$/ * @Given /^that I want to delete an "([^"]*)"$/ @@ -244,6 +224,26 @@ class RestContext extends BehatContext $this->_restObjectMethod = 'put'; } + /** + * @Given /^that I want to get a resource with the key "([^"]*)" stored in session array$/ + */ + public function thatIWantToGetAResourceWithTheKeyStoredInSessionArray($varName) + { + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = array(); + } + if (!isset($sessionData->$varName) ) { + $varValue = ''; + } else { + $varValue = $sessionData->$varName; + } + + $this->_restGetQueryStringSuffix = "/" . $varValue; + $this->_restObjectMethod = 'get'; + } + /** * @Given /^that "([^"]*)" header is set to "([^"]*)"$/ * @Given /^that "([^"]*)" header is set to (\d+)$/ @@ -351,9 +351,9 @@ class RestContext extends BehatContext $this->_response = $this->_request->send(); break; case 'GET': - if (isset($this->_restFindQueryStringSuffix) && - $this->_restFindQueryStringSuffix != '') { - $url .= $this->_restFindQueryStringSuffix; + if (isset($this->_restGetQueryStringSuffix) && + $this->_restGetQueryStringSuffix != '') { + $url .= $this->_restGetQueryStringSuffix; } $this->_request = $this->_client ->get($url, $this->_headers); @@ -961,8 +961,8 @@ class RestContext extends BehatContext $this->_headers['Content-Type'] = 'application/json; charset=UTF-8'; $this->_requestBody = $string; } - - + + /** @@ -999,7 +999,25 @@ class RestContext extends BehatContext $sessionData->$varName = $varValue; file_put_contents("session.data", json_encode($sessionData)); } - + + /** + * @Given /^store "([^"]*)" in session array as variable "([^"]*)"$/ + */ + public function storeInAsVariable($varName, $sessionVarName) + { + if (!isset($this->_data->$varName)) { + throw new \Exception("JSON Response does not have '$varName' property\n\n" ); + } + + $varValue = $this->_data->$varName; + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = new StdClass(); + } + $sessionData->$sessionVarName = $varValue; + file_put_contents("session.data", json_encode($sessionData)); + } /** * @Then /^echo last response$/ @@ -1008,17 +1026,17 @@ class RestContext extends BehatContext { $this->printDebug("$this->_request\n$this->_response"); } - - + + //*********** WEN - + /** * @Given /^POST data from file "([^"]*)"$/ */ public function postDataFromFile($jsonFile) { $filePath = __DIR__ . "/../json/" . $jsonFile; - + if(file_exists($filePath)) { $fileData = file_get_contents($filePath); @@ -1030,14 +1048,14 @@ class RestContext extends BehatContext } // throw new PendingException(); } - + /** * @Given /^PUT data from file "([^"]*)"$/ */ public function putDataFromFile($jsonFile) { $filePath = __DIR__ . "/../json/" . $jsonFile; - + if(file_exists($filePath)) { $fileData = file_get_contents($filePath); @@ -1057,6 +1075,5 @@ class RestContext extends BehatContext { throw new PendingException(); } - -} +} From 8aa5a67f4c21baa8fffa25b69b8e39a3cb7cab2a Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 14:58:59 -0400 Subject: [PATCH 05/10] arreglo conflicto --- features/bootstrap/RestContext.php | 1 - 1 file changed, 1 deletion(-) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index bdabc845d..24d7a85f3 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1075,5 +1075,4 @@ class RestContext extends BehatContext { throw new PendingException(); } - } From 28ced8f1a067e3e75986b29441eb18c0b7283804 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 15:14:17 -0400 Subject: [PATCH 06/10] arreglo de conflicto --- features/bootstrap/RestContext.php | 1 - 1 file changed, 1 deletion(-) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index b498ca832..bdabc845d 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1077,4 +1077,3 @@ class RestContext extends BehatContext } } - From 67b5c681ab317cc05f0595e96cd7f5fad1500e5e Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 15:19:04 -0400 Subject: [PATCH 07/10] Arreglo de llamado a funcion en behat --- features/processmaker/event.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/processmaker/event.feature b/features/processmaker/event.feature index e20147b75..235806870 100644 --- a/features/processmaker/event.feature +++ b/features/processmaker/event.feature @@ -53,7 +53,7 @@ Feature: Testing triggers @3: TEST FOR GET EVENT /----------------------------------------------------------------------- Scenario: Get a event Given that I have a valid access_token - And that I want to find a resource with the key "evn_uid" stored in session array + And that I want to get 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" From 8de51893f16be6449576d9d73afc28ad1d70eaf4 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 15:22:16 -0400 Subject: [PATCH 08/10] Arreglo para RestContext.php --- features/bootstrap/RestContext.php | 1 + 1 file changed, 1 insertion(+) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index bdabc845d..b498ca832 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1077,3 +1077,4 @@ class RestContext extends BehatContext } } + From 2c4faa92686eda95c9d5a735d18a0f96a8a272d4 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 16:41:52 -0400 Subject: [PATCH 09/10] Arreglos y adicion de behat --- .../events_resources}/event.feature | 15 +++- .../triggers_resources/triggers.feature | 70 ++++++++++++++----- features/processmaker/trigger.feature | 23 ------ 3 files changed, 65 insertions(+), 43 deletions(-) rename features/{processmaker => backend/events_resources}/event.feature (84%) delete mode 100644 features/processmaker/trigger.feature diff --git a/features/processmaker/event.feature b/features/backend/events_resources/event.feature similarity index 84% rename from features/processmaker/event.feature rename to features/backend/events_resources/event.feature index 235806870..65163cd6e 100644 --- a/features/processmaker/event.feature +++ b/features/backend/events_resources/event.feature @@ -1,5 +1,5 @@ @ProcessMakerMichelangelo @RestAPI -Feature: Testing triggers +Feature: Testing events @1: TEST FOR POST EVENT /---------------------------------------------------------------------- Scenario: Create a event @@ -24,6 +24,7 @@ Feature: Testing triggers Then the response status code should be 201 And store "evn_uid" in session array + @2: TEST FOR PUT EVENT /----------------------------------------------------------------------- Scenario: Update a event Given that I have a valid access_token @@ -58,4 +59,14 @@ Feature: Testing triggers Then the response status code should be 200 And the response charset is "UTF-8" And the type is "object" - And that "evn_description" is set to "change description" \ No newline at end of file + And that "evn_description" is set to "change description" + + + @4: 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 diff --git a/features/backend/triggers_resources/triggers.feature b/features/backend/triggers_resources/triggers.feature index 7fb8499fc..c137e9be4 100644 --- a/features/backend/triggers_resources/triggers.feature +++ b/features/backend/triggers_resources/triggers.feature @@ -1,21 +1,55 @@ @ProcessMakerMichelangelo @RestAPI -Feature: Triggers Resources - - Background: - Given that I have a valid access_token - - Scenario: Get a List of triggers of a project - Given this scenario is not implemented yet - - Scenario: Get a single trigger of a project - Given this scenario is not implemented yet - - Scenario: Create a new trigger for a project - Given this scenario is not implemented yet - - Scenario: Update a trigger of a project - Given this scenario is not implemented yet +Feature: Testing triggers - Scenario: Delete a trigger of a project - Given this scenario is not implemented yet + @1: TEST FOR POST TRIGGER /-------------------------------------------------------------------- + Scenario: Create a trigger + Given that I have a valid access_token + And POST this data: + """ + { + "tri_title": "nuevo trigger", + "tri_description": "descripcion" + } + """ + And I request "project/251815090529619a99a2bf4013294414/trigger" + Then the response status code should be 201 + And store "tri_uid" in session array + + @2: TEST FOR PUT TRIGGER /----------------------------------------------------------------------- + Scenario: Update a trigger + Given that I have a valid access_token + And PUT this data: + """ + { + "tri_title": "trigger editado", + "tri_description": "descripcion editada" + } + """ + And that I want to update 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" + + + @3: 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 + 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" + And that "tri_title" is set to "trigger editado" + And that "tri_description" is set to "descripcion editada" + + + @4: 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 diff --git a/features/processmaker/trigger.feature b/features/processmaker/trigger.feature deleted file mode 100644 index edfd62a31..000000000 --- a/features/processmaker/trigger.feature +++ /dev/null @@ -1,23 +0,0 @@ -@ProcessMakerMichelangelo @RestAPI -Feature: Testing triggers - Scenario: List triggers of an project - Given that I have a valid access_token - And I request "project/534152995521df6bb5986c4062665559/triggers" - Then the response status code should be 200 - And the response charset is "UTF-8" - And the content type is "application/json" - And the type is "array" - - - - Scenario: Create a trigger - Given that I have a valid access_token - And POST this data: - """ - { - "tri_title": "nuevo triggerr", - "tri_description": "descripcion" - } - """ - And I request "project/534152995521df6bb5986c4062665559/trigger" - Then the response status code should be 201 \ No newline at end of file From da3b7769886b715a306e78f318a103a12f2b1c1b Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Tue, 7 Jan 2014 16:42:11 -0400 Subject: [PATCH 10/10] Se adiciona POST para Process supervisor dynaform e inputdocuments --- .../src/BusinessModel/ProcessSupervisor.php | 71 +++++++++++++------ .../Project/ProcessSupervisors.php | 38 ++++++++++ 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/workflow/engine/src/BusinessModel/ProcessSupervisor.php b/workflow/engine/src/BusinessModel/ProcessSupervisor.php index d7ee89793..14b47a4a2 100644 --- a/workflow/engine/src/BusinessModel/ProcessSupervisor.php +++ b/workflow/engine/src/BusinessModel/ProcessSupervisor.php @@ -382,7 +382,7 @@ class ProcessSupervisor /** - * Remove a supervisor of an activity + * Remove a supervisor * * @param string $sProcessUID * @param string $sUserUID @@ -418,7 +418,7 @@ class ProcessSupervisor } /** - * Remove a dynaform supervisor of an activity + * Remove a dynaform supervisor * * @param string $sProcessUID * @param string $sDynaformUID @@ -454,7 +454,7 @@ class ProcessSupervisor } /** - * Remove a dynaform supervisor of an activity + * Remove a input document supervisor * * @param string $sProcessUID * @param string $sInputDocumentUID @@ -504,29 +504,56 @@ class ProcessSupervisor if ($sTypeUID == 'Group') { $puType = 'GROUP_SUPERVISOR'; } - $oTypeAssigneeG = \GroupwfPeer::retrieveByPK( $sUsrUID ); $oTypeAssigneeU = \UsersPeer::retrieveByPK( $sUsrUID ); - - if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { - throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID )); - } - if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) { - $type = "user"; - if ( $type != $assType ) { - throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID )); - } - } - if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { - $type = "group"; - if ( $type != $assType ) { - throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID )); - } - } - - + if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { + throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID )); + } + if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) { + $type = "User"; + if ( $type != $sTypeUID ) { + throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID )); + } + } + if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { + $type = "Group"; + if ( $type != $sTypeUID ) { + throw (new \Exception( 'This id: '. $sUsrUID .' do not correspond to a registered ' .$sTypeUID )); + } + } $oProcessUser->create(array('PU_UID' => \G::generateUniqueID(), 'PRO_UID' => $sProcessUID, 'USR_UID' => $sUsrUID, 'PU_TYPE' => $puType)); } + /** + * Assign a dynaform supervisor of a process + * + * @param string $sProcessUID + * @param string $sDynUID + * @access public + */ + public function addDynaformSupervisor($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"))); + } + + /** + * Assign a inputdocument supervisor of a process + * + * @param string $sProcessUID + * @param string $sInputDocumentUID + * @access public + */ + public function addInputDocumentSupervisor($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"))); + } } diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php index 192381d8d..58a123456 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php @@ -212,6 +212,44 @@ class ProcessSupervisors extends Api return $response; } + /** + * @url POST /:prjUid/dynaform-supervisor + * + * @param string $prjUid + * @param string $dyn_uid + * + * @status 201 + */ + public function doPostDynaformSupervisors($prjUid, $dyn_uid) + { + try { + $supervisor = new \BusinessModel\ProcessSupervisor(); + $arrayData = $supervisor->addDynaformSupervisor($prjUid, $dyn_uid); + } catch (\Exception $e) { + //Response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + /** + * @url POST /:prjUid/inputdocument-supervisor + * + * @param string $prjUid + * @param string $inp_doc_uid + * + * @status 201 + */ + public function doPostInputDocumentSupervisors($prjUid, $inp_doc_uid) + { + try { + $supervisor = new \BusinessModel\ProcessSupervisor(); + $arrayData = $supervisor->addInputDocumentSupervisor($prjUid, $inp_doc_uid); + } catch (\Exception $e) { + //Response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } }