diff --git a/features/backend/pm_user/basic_sequence_pm_user.feature b/features/backend/pm_user/basic_sequence_pm_user.feature index 401c38747..7337af3be 100644 --- a/features/backend/pm_user/basic_sequence_pm_user.feature +++ b/features/backend/pm_user/basic_sequence_pm_user.feature @@ -35,7 +35,7 @@ Feature: User #GET /api/1.0/{workspace}/user/{usr_uid} # Upload a image Scenario: Upload a image - Given POST I want to upload the image "/home/daniel/pic3.jpg" to user "00000000000000000000000000000001". Url "user/" + Given POST I want to upload the image "/home/wendy/photo/pic3.jpg" to user "00000000000000000000000000000001". Url "user/" #POST /api/1.0/{workspace}/user # Create new User diff --git a/features/backend/pm_user/main_tests_pm_user.feature b/features/backend/pm_user/main_tests_pm_user.feature index eebf7ea45..e3b4e4d71 100644 --- a/features/backend/pm_user/main_tests_pm_user.feature +++ b/features/backend/pm_user/main_tests_pm_user.feature @@ -95,14 +95,6 @@ Feature: User Main Tests | Create user Vacation | 5 | micaela | sanchez | micaela | micaela@gmail.com | sancjh #544 | 555-6652 | US | FL | MIA | 555-6655-555 | Gerencia | | 2016-02-15 | | VACATION | PROCESSMAKER_OPERATOR | sample | sample | - #Para que funcione este test, debe existir el archivo que se quiere subir - #GET /api/1.0/{workspace}/user/{usr_uid} - # Upload a image - Scenario: Upload a image - Given POST I want to upload the image "/home/daniel/pic3.jpg" to user "00000000000000000000000000000001". Url "user/" - - - # Upload a image Scenario Outline: Upload a image Given POST I want to upload the image "" to user with the key "usr_uid" stored in session array as variable "usr_uid_". Url "user/" @@ -149,7 +141,7 @@ Feature: User Main Tests "usr_phone": "", "usr_position": "", "usr_replaced_by": "", - "usr_due_date": "", + "usr_due_date": "", "usr_calendar": "", "usr_status": "", "usr_role": "", @@ -167,8 +159,8 @@ Feature: User Main Tests Examples: | Test_description | usr_number | usr_firstname | usr_lastname | usr_username | usr_email | usr_address | usr_zip_code | usr_country | usr_city | usr_location | usr_phone | usr_position | usr_replaced_by | usr_due_date | usr_calendar | usr_status | usr_role | usr_new_pass | usr_cnf_pass | - | Update usr_calendar, usr_role | 1 | jhoohan | smith | jhoohan | jhon@gmail.com | grenn #344 | 555-6555 | US | FL | MIA | 555-6655-555 | Gerencia | | 2016-02-15 | 99159704252f501c63f8c58025859967 | ACTIVE | PROCESSMAKER_ADMIN | sample | sample | - | Update usr_firstname, usr_lastname, usr_username | 2 | william | carters | william | will@gmail.com | saim #45 | 555-6522 | BO | L | LPB | 23344444 | Adminsitracion | 44811996752d567110634a1013636964 | 2014-12-12 | | ACTIVE | PROCESSMAKER_MANAGER | sample | sample | + | Update usr_calendar, usr_role | 1 | jhoohan | smith | jhoohan | jhon@gmail.com | grenn #344 | 555-6555 | US | FL | MIA | 555-6655-555 | Gerencia | | 2014-02-15 | 99159704252f501c63f8c58025859967 | ACTIVE | PROCESSMAKER_ADMIN | sample | sample | + | Update usr_firstname, usr_lastname, usr_username | 2 | wilian | carters | wilian | will@gmail.com | saim #45 | 555-6522 | BO | L | LPB | 23344444 | Adminsitracion | 44811996752d567110634a1013636964 | 2014-12-12 | | ACTIVE | PROCESSMAKER_MANAGER | sample | sample | | Update usr_status | 3 | sarita | sandler | sarita | saraah@gmail.com | laberh #985 | 555-9999 | AR | B | BUE | 2353643644 | Desarrollo | 61364466452d56711adb378002702791 | 2014-12-12 | 99159704252f501c63f8c58025859967 | INACTIVE | PROCESSMAKER_ADMIN | admin | admin | @@ -202,7 +194,7 @@ Feature: User Main Tests | Test_description | usr_number | usr_firstname | usr_lastname | usr_username | usr_email | usr_address | usr_zip_code | usr_country | usr_city | usr_location | usr_phone | usr_position | usr_replaced_by | usr_due_date | usr_calendar | usr_status | usr_role | usr_new_pass | usr_cnf_pass | | Update usr_calendar, usr_role | 1 | jhoohan | smith | jhoohan | jhon@gmail.com | grenn #344 | 555-6555 | US | FL | MIA | 555-6655-555 | Gerencia | | 2016-02-15 | 99159704252f501c63f8c58025859967 | ACTIVE | PROCESSMAKER_ADMIN | sample | sample | - | Update usr_firstname, usr_lastname, usr_username | 2 | william | carters | william | will@gmail.com | saim #45 | 555-6522 | BO | L | LPB | 23344444 | Adminsitracion | 44811996752d567110634a1013636964 | 2014-12-12 | | ACTIVE | PROCESSMAKER_MANAGER | sample | sample | + | Update usr_firstname, usr_lastname, usr_username | 2 | wilian | carters | wilian | will@gmail.com | saim #45 | 555-6522 | BO | L | LPB | 23344444 | Adminsitracion | 44811996752d567110634a1013636964 | 2014-12-12 | | ACTIVE | PROCESSMAKER_MANAGER | sample | sample | | Update usr_status | 3 | sarita | sandler | sarita | saraah@gmail.com | laberh #985 | 555-9999 | AR | B | BUE | 2353643644 | Desarrollo | 61364466452d56711adb378002702791 | 2014-12-12 | 99159704252f501c63f8c58025859967 | INACTIVE | PROCESSMAKER_ADMIN | admin | admin | diff --git a/features/backend/step/basic_sequence_step.feature b/features/backend/step/basic_sequence_step.feature index e10e6113e..47850235f 100644 --- a/features/backend/step/basic_sequence_step.feature +++ b/features/backend/step/basic_sequence_step.feature @@ -100,7 +100,7 @@ Feature: Project Properties - Step Resources Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the "obj_uid" property in row 1 equals "32743823452cd63105006e1076595203" + And the "obj_uid" property in row 1 equals "6869969705306aaae049a62048840877" And the "obj_title" property in row 1 equals "OutputDocument Demo" And the "obj_description" property in row 1 equals "Description" And the "obj_type" property in row 1 equals "OUTPUT_DOCUMENT" diff --git a/features/backend/step/main_tests_step.feature b/features/backend/step/main_tests_step.feature index 4f1e6c657..167cc08f4 100644 --- a/features/backend/step/main_tests_step.feature +++ b/features/backend/step/main_tests_step.feature @@ -39,7 +39,7 @@ Feature: Project Properties - Step Resources Main Tests 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"git + And the type is "object" And store "step_uid" in session array as variable "step_uid_" Examples: @@ -112,7 +112,7 @@ Feature: Project Properties - Step Resources Main Tests | test_description | project | activity | records | step_type_obj | step_uid_obj | | 3 steps in task 1 - verify that the first record is the first position | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | DYNAFORM | 50332332752cd9b9a7cc989003652905 | - | 2 steps in task 2 - verify that the first record is the first position | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 2 | DYNAFORM | 63293140052cd61b29e21a9056770986 | + | 2 steps in task 2 - verify that the first record is the first position | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 3 | DYNAFORM | 63293140052cd61b29e21a9056770986 | #STEP TRIGGERS @@ -174,24 +174,24 @@ Feature: Project Properties - Step Resources Main Tests Examples: | test_description | project | activity | step_number | tri_uid_number | tri_uid | st_type | st_condition | st_position | - | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 1 | 81919273152cd636c665080083928728 | BEFORE | | 1 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 2 | 56359776552cd6378b38e47080912028 | BEFORE | | 2 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 3 | 57401970252cd6393531551040242546 | BEFORE | | 3 | - | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 4 | 81919273152cd636c665080083928728 | AFTER | | 1 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 5 | 56359776552cd6378b38e47080912028 | AFTER | | 2 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 6 | 57401970252cd6393531551040242546 | AFTER | | 3 | - | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 7 | 81919273152cd636c665080083928728 | BEFORE | | 1 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 8 | 56359776552cd6378b38e47080912028 | BEFORE | | 2 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 9 | 57401970252cd6393531551040242546 | BEFORE | | 3 | - | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 10 | 81919273152cd636c665080083928728 | AFTER | | 1 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 11 | 56359776552cd6378b38e47080912028 | AFTER | | 2 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 12 | 57401970252cd6393531551040242546 | AFTER | | 3 | - | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 13 | 81919273152cd636c665080083928728 | BEFORE | | 1 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 14 | 56359776552cd6378b38e47080912028 | BEFORE | | 2 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 15 | 57401970252cd6393531551040242546 | BEFORE | | 3 | - | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 16 | 81919273152cd636c665080083928728 | AFTER | | 1 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 17 | 56359776552cd6378b38e47080912028 | AFTER | | 2 | - | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 18 | 57401970252cd6393531551040242546 | AFTER | | 3 | + | Trigger assigned to Task 1 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 1 | 81919273152cd636c665080083928728 | BEFORE | | 1 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 2 | 56359776552cd6378b38e47080912028 | BEFORE | | 2 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 3 | 57401970252cd6393531551040242546 | BEFORE | | 3 | + | Trigger assigned to Task 1 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 4 | 81919273152cd636c665080083928728 | AFTER | | 1 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 5 | 56359776552cd6378b38e47080912028 | AFTER | | 2 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 1 | 6 | 57401970252cd6393531551040242546 | AFTER | | 3 | + | Trigger assigned to Task 1 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 7 | 81919273152cd636c665080083928728 | BEFORE | | 1 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 8 | 56359776552cd6378b38e47080912028 | BEFORE | | 2 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 9 | 57401970252cd6393531551040242546 | BEFORE | | 3 | + | Trigger assigned to Task 1 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 10 | 81919273152cd636c665080083928728 | AFTER | | 1 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 11 | 56359776552cd6378b38e47080912028 | AFTER | | 2 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | 12 | 57401970252cd6393531551040242546 | AFTER | | 3 | + | Trigger assigned to Task 1 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 13 | 81919273152cd636c665080083928728 | BEFORE | | 1 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 14 | 56359776552cd6378b38e47080912028 | BEFORE | | 2 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 15 | 57401970252cd6393531551040242546 | BEFORE | | 3 | + | Trigger assigned to Task 1 in type before | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 16 | 81919273152cd636c665080083928728 | AFTER | | 1 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 17 | 56359776552cd6378b38e47080912028 | AFTER | | 2 | + | Trigger assigned to Task 1 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | 18 | 57401970252cd6393531551040242546 | AFTER | | 3 | | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 4 | 19 | 81919273152cd636c665080083928728 | BEFORE | | 1 | | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 4 | 20 | 56359776552cd6378b38e47080912028 | BEFORE | | 2 | | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 4 | 21 | 57401970252cd6393531551040242546 | BEFORE | | 3 | @@ -200,6 +200,21 @@ Feature: Project Properties - Step Resources Main Tests | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 4 | 24 | 57401970252cd6393531551040242546 | AFTER | | 3 | + +Scenario Outline: Delete all Triggers created previously in this script + Given that I want to delete a "trigger" + And I request "project//trigger/" + Then the response status code should be 400 + And the response charset is "UTF-8" + And the type is "object" + + Examples: + + | project | tri_uid | + | 16062437052cd6141881e06088349078 | 81919273152cd636c665080083928728 | + | 16062437052cd6141881e06088349078 | 57401970252cd6393531551040242546 | + + Scenario Outline: List available Triggers for each assigned step Given I request "project//activity//step/step_uid/available-triggers/before" with the key "step_uid" stored in session array as variable "step_uid_" And the content type is "application/json" @@ -328,7 +343,7 @@ Feature: Project Properties - Step Resources Main Tests | Trigger assigned to External in type before | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 5 | 0 | - Scenario Outline: Unassign all"DynaForm Demo1" from "Task1" + Scenario Outline: Unassign all "DynaForm Demo1" from "Task1" and "Task 2" Given that I have a valid access_token And that I want to delete a resource with the key "step1" stored in session array Given that I want to delete a resource with the key "step_uid" stored in session array as variable "step_uid_" @@ -344,6 +359,8 @@ Feature: Project Properties - Step Resources Main Tests | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 2 | | Trigger assigned to Task 2 in type After | 16062437052cd6141881e06088349078 | 10163687452cd6234e0dd25086954968 | 3 | | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 4 | + | Trigger assigned to Task 2 in type before | 16062437052cd6141881e06088349078 | 89706843252cd9decdcf9b3047762708 | 5 | + Scenario Outline: List assigned Steps to "Task1" & "Task2" (empty) (verify if everithing was deleted) diff --git a/features/backend/trigger_wizard/main_tests_trigger_wizards.feature b/features/backend/trigger_wizard/main_tests_trigger_wizards.feature index 15030ad55..153ab1e5a 100644 --- a/features/backend/trigger_wizard/main_tests_trigger_wizards.feature +++ b/features/backend/trigger_wizard/main_tests_trigger_wizards.feature @@ -144,6 +144,43 @@ Scenario Outline: Create new Trigger: createDWS Examples: | i | lib_name | fn_name | tri_title | tri_description | tri_type | tri_params.input.sharepointServer | tri_params.input.auth | tri_params.input.name | tri_params.input.users | tri_params.input.title | tri_params.input.documents | tri_params.output.tri_answer | | 1 | pmTrSharepoint | createDWS | Sharepoint 1 | | SCRIPT | @@SERVER | username:password | Test DWS | @@users | Test DWS | /files/test.doc | $respuesta | + + +Scenario Outline: Create new Trigger: createDWS (no enviar campos no requeridos) + Given POST this data: + """ + { + "tri_title": "", + "tri_description": "", + "tri_type": "", + "tri_params": { + "input": { + + "sharepointServer": "", + "auth": "", + "name": "", + "users": "", + "title": "", + "documents": "" + + }, + "output": { + "tri_answer": "" + } + } + } + """ + And I request "project/14414793652a5d718b65590036026581/trigger-wizard//" + 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 "tri_uid" in session array as variable "tri_uid" + + Examples: + | i | lib_name | fn_name | tri_title | tri_description | tri_type | tri_params.input.sharepointServer | tri_params.input.auth | tri_params.input.name | tri_params.input.users | tri_params.input.title | tri_params.input.documents | tri_params.output.tri_answer | + | 2 | pmTrSharepoint | createDWS | Sharepoint 1 | | SCRIPT | @@SERVER | username:password | Test DWS | @@users | Test DWS | /files/test.doc | $respuesta | + Scenario Outline: Update Trigger Given PUT this data: diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 2a18f6846..328603c94 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1259,7 +1259,7 @@ class RestContext extends BehatContext $pageUrl = str_replace($varName, $varValue, $pageUrl); - $this->printDebug("URL: $pageUrl\n$varName = $varValue\n"); + //$this->printDebug("URL: $pageUrl\n$varName = $varValue\n"); $this->iRequest($pageUrl, $urlType); @@ -1333,7 +1333,7 @@ class RestContext extends BehatContext $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); - curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => null)); + curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path)); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); diff --git a/workflow/engine/src/BusinessModel/FilesManager.php b/workflow/engine/src/BusinessModel/FilesManager.php index a2da64444..d2cd7a0e2 100644 --- a/workflow/engine/src/BusinessModel/FilesManager.php +++ b/workflow/engine/src/BusinessModel/FilesManager.php @@ -67,7 +67,6 @@ class FilesManager } \G::verifyPath($sDirectory, true); $aTheFiles = array(); - $aDirectories = array(); $aFiles = array(); $oDirectory = dir($sDirectory); while ($sObject = $oDirectory->read()) { @@ -127,7 +126,7 @@ class FilesManager } } return $aTheFiles; - } catch (Exception $e) { + } catch (\Exception $e) { throw $e; } } @@ -184,6 +183,12 @@ class FilesManager $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectory . $aData['prf_filename']; break; } + $content = $aData['prf_content']; + if (is_string($content)) { + if (file_exists(PATH_SEP.$sDirectory)) { + throw (new \Exception( 'The file: '.$sMainDirectory. PATH_SEP . $sSubDirectory . $aData['prf_filename'] . ' already exists.')); + } + } if (!file_exists($sCheckDirectory)) { $sPkProcessFiles = \G::generateUniqueID(); $oProcessFiles = new \ProcessFiles(); diff --git a/workflow/engine/src/BusinessModel/ProcessSupervisor.php b/workflow/engine/src/BusinessModel/ProcessSupervisor.php index 571d4a9e4..86a212075 100644 --- a/workflow/engine/src/BusinessModel/ProcessSupervisor.php +++ b/workflow/engine/src/BusinessModel/ProcessSupervisor.php @@ -624,9 +624,10 @@ class ProcessSupervisor * * @param string $sProcessUID * @param string $sDynUID + * @param int $sPudPosition * @access public */ - public function addProcessSupervisorDynaform($sProcessUID, $sDynUID) + public function addProcessSupervisorDynaform($sProcessUID, $sDynUID, $sPudPosition) { $oTypeDynaform = \DynaformPeer::retrieveByPK($sDynUID); if (is_null( $oTypeDynaform )) { @@ -692,9 +693,10 @@ class ProcessSupervisor 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']); + 'dyn_uid' => $aRow['STEP_UID_OBJ']); $oDataset->next(); + $aRespPosition = $this->updateProcessSupervisorDynaform($sProcessUID ,$aRow['STEP_UID'], $sPudPosition); + $aResp = array_merge(array('dyn_title' => $aRow['DYN_TITLE']), $aRespPosition); } return $aResp; } else { @@ -707,9 +709,11 @@ class ProcessSupervisor * * @param string $sProcessUID * @param string $sInputDocumentUID + * @param int $sPuiPosition * @access public */ - public function addProcessSupervisorInputDocument($sProcessUID, $sInputDocumentUID) + + public function addProcessSupervisorInputDocument($sProcessUID, $sInputDocumentUID, $sPuiPosition) { $oTypeInputDocument= \InputDocumentPeer::retrieveByPK($sInputDocumentUID); if (is_null( $oTypeInputDocument )) { @@ -747,7 +751,7 @@ class ProcessSupervisor $oStepSupervisor->create(array('PRO_UID' => $sProcessUID, 'STEP_TYPE_OBJ' => "INPUT_DOCUMENT", 'STEP_UID_OBJ' => $sInputDocumentUID, - 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "DYNAFORM"))); + 'STEP_POSITION' => $oStepSupervisor->getNextPosition($sProcessUID, "INPUT_DOCUMENT"))); $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn(\StepSupervisorPeer::STEP_UID); @@ -776,9 +780,10 @@ class ProcessSupervisor 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']); + 'input_doc_uid' => $aRow['STEP_UID_OBJ']); $oDataset->next(); + $aRespPosition = $this->updateProcessSupervisorInputDocument($sProcessUID ,$aRow['STEP_UID'], $sPuiPosition); + $aResp = array_merge(array('input_doc_title' => $aRow['INP_DOC_TITLE']), $aRespPosition); } return $aResp; } else { @@ -821,19 +826,15 @@ class ProcessSupervisor */ public function removeDynaformSupervisor($sProcessUID, $sPudUID) { - $oConnection = \Propel::getConnection(\StepSupervisorPeer::DATABASE_NAME); try { $oDynaformSupervidor = \StepSupervisorPeer::retrieveByPK($sPudUID); if (!is_null($oDynaformSupervidor)) { - $oConnection->begin(); - $iResult = $oDynaformSupervidor->delete(); - $oConnection->commit(); - return $iResult; + $oProcessMap = new \processMap(new \DBConnection()); + $oProcessMap->removeSupervisorStep( $oDynaformSupervidor->getStepUid(), $sProcessUID, 'DYNAFORM', $oDynaformSupervidor->getStepUidObj(), $oDynaformSupervidor->getStepPosition() ); } else { throw (new \Exception('This row does not exist!')); } } catch (Exception $oError) { - $oConnection->rollback(); throw ($oError); } } @@ -851,10 +852,8 @@ class ProcessSupervisor try { $oInputDocumentSupervidor = \StepSupervisorPeer::retrieveByPK($sPuiUID); if (!is_null($oInputDocumentSupervidor)) { - $oConnection->begin(); - $iResult = $oInputDocumentSupervidor->delete(); - $oConnection->commit(); - return $iResult; + $oProcessMap = new \processMap(new \DBConnection()); + $oProcessMap->removeSupervisorStep( $oInputDocumentSupervidor->getStepUid(), $sProcessUID, 'INPUT_DOCUMENT', $oInputDocumentSupervidor->getStepUidObj(), $oInputDocumentSupervidor->getStepPosition() ); } else { throw (new \Exception('This row does not exist!')); } @@ -863,5 +862,174 @@ class ProcessSupervisor throw ($oError); } } -} + /** + * Assign a dynaform supervisor of a process + * + * @param string $sProcessUID + * @param string $sPudUID + * @param string $sPudPosition + * @access public + */ + public function updateProcessSupervisorDynaform($sProcessUID, $sPudUID, $sPudPosition) + { + $oCriteria=\StepSupervisorPeer::retrieveByPK($sPudUID); + $actualPosition = $oCriteria->getStepPosition(); + $tempPosition = (isset($sPudPosition)) ? $sPudPosition : $actualPosition; + if (isset($tempPosition) && ($tempPosition != $actualPosition)) { + $this->moveDynaforms($sProcessUID, $sPudUID, $tempPosition); + } + //Return + unset($sPudPosition); + $sPudPosition = $tempPosition; + $oCriteria->setStepPosition($sPudPosition); + $oCriteria->save(); + $oCriteria=array('pud_uid' => $oCriteria->getStepUid(), + 'pud_position' => $oCriteria->getStepPosition(), + 'dyn_uid' => $oCriteria->getStepUidObj()); + return $oCriteria; + } + + /** + * Assign a InputDocument supervisor of a process + * + * @param string $sProcessUID + * @param string $sPuiUID + * @param string $sPuiPosition + * @access public + */ + public function updateProcessSupervisorInputDocument($sProcessUID, $sPuiUID, $sPuiPosition) + { + $oCriteria=\StepSupervisorPeer::retrieveByPK($sPuiUID); + $actualPosition = $oCriteria->getStepPosition(); + $tempPosition = (isset($sPuiPosition)) ? $sPuiPosition : $actualPosition; + if (isset($tempPosition) && ($tempPosition != $actualPosition)) { + $this->moveInputDocuments($sProcessUID, $sPuiUID, $tempPosition); + } + //Return + unset($sPuiPosition); + $sPuiPosition = $tempPosition; + $oCriteria->setStepPosition($sPuiPosition); + $oCriteria->save(); + $oCriteria=array('pui_uid' => $oCriteria->getStepUid(), + 'pui_position' => $oCriteria->getStepPosition(), + 'inp_doc_uid' => $oCriteria->getStepUidObj()); + return $oCriteria; + } + + /** + * Validate Process Uid + * @var string $pro_uid. Uid for Process + * @var string $pu_uid. Uid for Step + * @var string $pu_pos. Position for Step + * + * @return void + */ + public function moveDynaforms($pro_uid, $pu_uid, $pu_pos) + { + $aSteps = $this->getProcessSupervisorDynaforms($pro_uid); + $step_pos = $pu_pos; + $step_uid = $pu_uid; + foreach ($aSteps as $dataStep) { + if ($dataStep['pud_uid'] == $step_uid) { + $prStepPos = (int)$dataStep['pud_position']; + } + } + $seStepPos = $step_pos; + //Principal Step is up + if ($prStepPos == $seStepPos) { + return true; + } elseif ($prStepPos < $seStepPos) { + $modPos = 'UP'; + $newPos = $seStepPos; + $iniPos = $prStepPos+1; + $finPos = $seStepPos; + } else { + $modPos = 'DOWN'; + $newPos = $seStepPos; + $iniPos = $seStepPos; + $finPos = $prStepPos-1; + } + $range = range($iniPos, $finPos); + foreach ($aSteps as $dataStep) { + if ((in_array($dataStep['pud_position'], $range)) && ($dataStep['pud_uid'] != $step_uid)) { + $stepChangeIds[] = $dataStep['pud_uid']; + $stepChangePos[] = $dataStep['pud_position']; + } + } + foreach ($stepChangeIds as $key => $value) { + if ($modPos == 'UP') { + $tempPos = ((int)$stepChangePos[$key])-1; + $this ->changePosStep($value, $tempPos); + } else { + $tempPos = ((int)$stepChangePos[$key])+1; + $this ->changePosStep($value, $tempPos); + } + } + $this ->changePosStep($value, $tempPos); + } + + /** + * Validate Process Uid + * @var string $pro_uid. Uid for Process + * @var string $pu_uid. Uid for Step + * @var string $pu_pos. Position for Step + * + * @return void + */ + public function moveInputDocuments($pro_uid, $pu_uid, $pu_pos) + { + $aSteps = $this->getProcessSupervisorInputDocuments($pro_uid); + $step_pos = $pu_pos; + $step_uid = $pu_uid; + foreach ($aSteps as $dataStep) { + if ($dataStep['pui_uid'] == $step_uid) { + $prStepPos = (int)$dataStep['pui_position']; + } + } + $seStepPos = $step_pos; + //Principal Step is up + if ($prStepPos == $seStepPos) { + return true; + } elseif ($prStepPos < $seStepPos) { + $modPos = 'UP'; + $newPos = $seStepPos; + $iniPos = $prStepPos+1; + $finPos = $seStepPos; + } else { + $modPos = 'DOWN'; + $newPos = $seStepPos; + $iniPos = $seStepPos; + $finPos = $prStepPos-1; + } + $range = range($iniPos, $finPos); + foreach ($aSteps as $dataStep) { + if ((in_array($dataStep['pui_position'], $range)) && ($dataStep['pui_uid'] != $step_uid)) { + $stepChangeIds[] = $dataStep['pui_uid']; + $stepChangePos[] = $dataStep['pui_position']; + } + } + foreach ($stepChangeIds as $key => $value) { + if ($modPos == 'UP') { + $tempPos = ((int)$stepChangePos[$key])-1; + $this ->changePosStep($value, $tempPos); + } else { + $tempPos = ((int)$stepChangePos[$key])+1; + $this ->changePosStep($value, $tempPos); + } + } + $this ->changePosStep($value, $tempPos); + } + + /** + * Validate Process Uid + * @var string $pro_uid. Uid for process + * + */ + public function changePosStep ($step_uid, $pos) + { + $oCriteria=\StepSupervisorPeer::retrieveByPK($step_uid); + $oCriteria->setStepPosition($pos); + $oCriteria->save(); + } +} diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php index e916c8a8f..351af84be 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php @@ -37,15 +37,17 @@ class FilesManager extends Api /** * @param string $prj_uid {@min 32} {@max 32} - * @param ProcessFilesManagerStructure $request_data + * @param ProcessFilesManagerStructurePost $request_data + * @param string $prf_content * * @url POST /:prj_uid/file-manager */ - public function doPostProcessFilesManager($prj_uid, ProcessFilesManagerStructure $request_data) + public function doPostProcessFilesManager($prj_uid, ProcessFilesManagerStructurePost $request_data, $prf_content=null) { try { $userUid = $this->getUserId(); $request_data = (array)($request_data); + $request_data = array_merge(array('prf_content' => $prf_content ), $request_data); $filesManager = new \BusinessModel\FilesManager(); $arrayData = $filesManager->addProcessFilesManager($prj_uid, $userUid, $request_data); //Response @@ -151,6 +153,18 @@ class FilesManager extends Api } } +class ProcessFilesManagerStructurePost +{ /** + * @var string {@from body} + */ + public $prf_filename; + + /** + * @var string {@from body} + */ + public $prf_path; +} + class ProcessFilesManagerStructure { /** diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php index 11cf7a782..3dff5185e 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProcessSupervisors.php @@ -215,14 +215,15 @@ class ProcessSupervisors extends Api * * @param string $prjUid {@min 32} {@max 32} * @param string $dyn_uid {@min 32} {@max 32} + * @param int $pud_position * * @status 201 */ - public function doPostProcessSupervisorDynaform($prjUid, $dyn_uid) + public function doPostProcessSupervisorDynaform($prjUid, $dyn_uid, $pud_position=null) { try { $supervisor = new \BusinessModel\ProcessSupervisor(); - $objectData = $supervisor->addProcessSupervisorDynaform($prjUid, $dyn_uid); + $objectData = $supervisor->addProcessSupervisorDynaform($prjUid, $dyn_uid, $pud_position); //Response $response = $objectData; } catch (\Exception $e) { @@ -237,14 +238,15 @@ class ProcessSupervisors extends Api * * @param string $prjUid {@min 32} {@max 32} * @param string $inp_doc_uid {@min 32} {@max 32} + * @param int $pui_position * * @status 201 */ - public function doPostProcessSupervisorInputDocument($prjUid, $inp_doc_uid) + public function doPostProcessSupervisorInputDocument($prjUid, $inp_doc_uid, $pui_position=null) { try { $supervisor = new \BusinessModel\ProcessSupervisor(); - $objectData = $supervisor->addProcessSupervisorInputDocument($prjUid, $inp_doc_uid); + $objectData = $supervisor->addProcessSupervisorInputDocument($prjUid, $inp_doc_uid, $pui_position); //Response $response = $objectData; } catch (\Exception $e) { @@ -265,7 +267,7 @@ class ProcessSupervisors extends Api { try { $supervisor = new \BusinessModel\ProcessSupervisor(); - $arrayData = $supervisor->removeProcessSupervisor($prjUid, $puUid); + $supervisor->removeProcessSupervisor($prjUid, $puUid); } catch (\Exception $e) { //response throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); @@ -283,7 +285,7 @@ class ProcessSupervisors extends Api { try { $supervisor = new \BusinessModel\ProcessSupervisor(); - $arrayData = $supervisor->removeDynaformSupervisor($prjUid, $pudUid); + $supervisor->removeDynaformSupervisor($prjUid, $pudUid); } catch (\Exception $e) { //response throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); @@ -301,11 +303,57 @@ class ProcessSupervisors extends Api { try { $supervisor = new \BusinessModel\ProcessSupervisor(); - $arrayData = $supervisor->removeInputDocumentSupervisor($prjUid, $puiUid); + $supervisor->removeInputDocumentSupervisor($prjUid, $puiUid); } catch (\Exception $e) { //response throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } } + + /** + * @url PUT /:prjUid/process-supervisor/dynaform/:pud_uid + * + * @param string $prjUid {@min 32} {@max 32} + * @param string $pud_uid {@min 32} {@max 32} + * @param int $pud_position + * + * @status 201 + */ + public function doPutProcessSupervisorDynaform($prjUid, $pud_uid, $pud_position = null) + { + try { + $supervisor = new \BusinessModel\ProcessSupervisor(); + $objectData = $supervisor->updateProcessSupervisorDynaform($prjUid, $pud_uid, $pud_position); + //Response + $response = $objectData; + } catch (\Exception $e) { + //Response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + + /** + * @url PUT /:prjUid/process-supervisor/input-document/:pui_uid + * + * @param string $prjUid {@min 32} {@max 32} + * @param string $pui_uid {@min 32} {@max 32} + * @param int $pui_position + * + * @status 201 + */ + public function doPutProcessSupervisorInputDocument($prjUid, $pui_uid, $pui_position = null) + { + try { + $supervisor = new \BusinessModel\ProcessSupervisor(); + $objectData = $supervisor->updateProcessSupervisorInputDocument($prjUid, $pui_uid, $pui_position); + //Response + $response = $objectData; + } catch (\Exception $e) { + //Response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } }