diff --git a/features/backend/admin_setup/pm_tables/main_tests_pm_tables.feature b/features/backend/admin_setup/pm_tables/main_tests_pm_tables.feature index cc0eecdda..2bc2bf06b 100644 --- a/features/backend/admin_setup/pm_tables/main_tests_pm_tables.feature +++ b/features/backend/admin_setup/pm_tables/main_tests_pm_tables.feature @@ -113,7 +113,7 @@ Scenario Outline: Create new pmtable with type date and char | Create pmtable with type date | 2 | -Scenario Outline: Create a new Data of pm table. +Scenario Outline: Create a new Data of pm table Given POST this data: """ { @@ -132,19 +132,16 @@ Scenario Outline: Create a new Data of pm table. | pmt_uid_number | | 1 | - | 2 | - | 3 | | 4 | | 5 | | 6 | - | 7 | - + Scenario Outline: Update a a data of pm table Given PUT this data: """ { - "UNO" : "UPDATE QA11", + "UNO" : "QA11", "DOS" : "UPDATE QA22", "TRES" : "UPDATE QA33" } @@ -324,20 +321,6 @@ Scenario Outline: Delete a pm table of a pmtable | 7 | -Scenario Outline: Delete a data of a pmtable - Given that I want to delete a resource with the key "pmt_uid" stored in session array as variable "pmt_uid_" - And I request "pmtable//data/CAMPO1/QA" - 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" - - Examples: - - | pmt_uid_number | - | 2 | - - Scenario: Get the PMTABLE List when there are exactly ONE pmtables in this workspace Given I request "pmtable" Then the response status code should be 200 diff --git a/features/backend/admin_setup/pm_tables/negative_tests_pm_tables.feature b/features/backend/admin_setup/pm_tables/negative_tests_pm_tables.feature index 51bf2cac9..17a20f7e2 100644 --- a/features/backend/admin_setup/pm_tables/negative_tests_pm_tables.feature +++ b/features/backend/admin_setup/pm_tables/negative_tests_pm_tables.feature @@ -44,8 +44,8 @@ Scenario Outline: Create news pmtable (Negative Test) "fld_name" : "", "fld_label" : "", "fld_type" : "", - "fld_size" : "" - }, + "fld_size" : + } ] } """ @@ -55,11 +55,31 @@ Scenario Outline: Create news pmtable (Negative Test) Examples: - | test_description | pmt_tab_name | pmt_tab_dsc | fld_name | fld_label | fld_type | fld_size | fld_name | fld_label | fld_type | fld_size | fld_name | fld_label | fld_type | fld_size | error_code | error_message | - | Required pmt_tab_name | | pmt table 1 | UNO | UNO | VARCHAR | 32 | DOS | DOS | BIGINT | | TRES | TRES | BOOLEAN | | 400 | pmt_tab_name | - | Required pmt_tab_dsc | PMT_Test_QA2 | | UNO | UNO | VARCHAR | 32 | DOS | DOS | CHAR | | TRES | TRES | DATE | | 400 | pmt_tab_dsc | - | Required fld_name | PMT_Test_QA3 | pmt table 3 | | UNO | VARCHAR | 32 | DOS | DOS | DATETIME | | TRES | TRES | DECIMAL | | 400 | fld_name | - | Required fld_label | PMT_Test_QA4 | pmt table 4 | UNO | | VARCHAR | 32 | DOS | DOS | DOUBLE | | TRES | TRES | FLOAT | | 400 | fld_label | - | Required fld_type | PMT_Test_QA5 | pmt table 5 | UNO | UNO | VARCHAR | 32 | DOS | DOS | | | TRES | TRES | LONGVARCHAR | | 400 | fld_type | - | Invalid fld_size | PMT_Test_QA6 | pmt table 6 | UNO | UNO | VARCHAR | sample | DOS | DOS | REAL | samke | TRES | TRES | SMALLINT | task | 400 | fld_size | - | Invalid fld_type | PMT_Test_QA7 | pmt table 7 | UNO | UNO | 123 | 32 | DOS | DOS | 1234 | | TRES | TRES | 457,777 | | 400 | fld_type | \ No newline at end of file + | test_description | pmt_tab_name | pmt_tab_dsc | fld_name | fld_label | fld_type | fld_size | error_code | error_message | + | Required pmt_tab_name | | pmt table 1 | UNO | UNO | VARCHAR | 32 | 400 | pmt_tab_name | + | Required fld_name | PMT_Test_QA3 | pmt table 3 | | UNO | VARCHAR | 32 | 400 | fld_name | + | Required fld_label | PMT_Test_QA4 | pmt table 4 | UNO | | VARCHAR | 32 | 400 | fld_label | + | Required fld_type | PMT_Test_QA5 | pmt table 5 | UNO | UNO | | 32 | 400 | fld_type | + | Invalid fld_type | PMT_Test_QA7 | pmt table 7 | UNO | UNO | 123 | 32 | 400 | fld_type | + + +Scenario: Create news pmtable (Negative Test) + Given POST this data: + """ + { + "pmt_tab_name" : "", + "pmt_tab_dsc" : "", + "fields" : [ + { + "fld_key" : 1, + "fld_name" : "UNO", + "fld_label" : "UNO", + "fld_type" : "VARCHAR", + "fld_size" : "sample" + } + ] + } + """ + And I request "pmtable" + Then the response status code should be 400 + And the response status message should have the following text "fld_size" \ No newline at end of file diff --git a/features/backend/projects/project_export_import/main_tests_project_export_import.feature b/features/backend/projects/project_export_import/main_tests_project_export_import.feature index 29f7d6967..1f3fbf1f6 100644 --- a/features/backend/projects/project_export_import/main_tests_project_export_import.feature +++ b/features/backend/projects/project_export_import/main_tests_project_export_import.feature @@ -2,7 +2,7 @@ Feature: Import/Export Process Main Tests Requirements: a workspace without the project 1455892245368ebeb11c1a5001393784 ("Process Complete BPMN") already loaded - there are many activities, steps, triggers, pmtables, asignee, events, etc. in the process + there are many activities, steps, triggers, pmtables, asignee, process supervisor, process permissions, etc. in the process Background: Given that I have a valid access_token @@ -139,15 +139,13 @@ Scenario Outline: Import a process | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | overwrite | 2 | | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | disable | 3 | | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | keep | 4 | - | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | overwrite | 5 | - + #Verificar cantidad de dynaform, output, inputs, triggers, asignacion de usuarios, etc. Scenario Outline: Get a List DynaForms of a Project Process Complete BPMN Given I request "project/prj_uid/dynaforms" with the key "prj_uid" stored in session array as variable "prj_uid_" - And the content type is "application/json" - Then the response status code should be 200 + And the content type is "application/json"se status code should be 200 And the response charset is "UTF-8" And the type is "array" And the response has records @@ -159,6 +157,7 @@ Scenario Outline: Get a List DynaForms of a Project Process Complete BPMN | disable | 3 | 1455892245368ebeb11c1a5001393784 | 26 | | keep | 4 | 1455892245368ebeb11c1a5001393784 | 26 | + Then the respon Scenario Outline: Get the Input Documents List when there are exactly zero input documents Given I request "project/prj_uid/input-documents" with the key "prj_uid" stored in session array as variable "prj_uid_" @@ -227,7 +226,7 @@ Scenario Outline: List assignees of each activity Scenario Outline: Get a List of current process supervisors of a project - Given I request "project/prj_uid/process-supervisors" stored in session array as variable "prj_uid_" + Given I request "project/prj_uid/process-supervisors" with the key "prj_uid" stored in session array as variable "prj_uid_" Then the response status code should be 200 And the response charset is "UTF-8" And the content type is "application/json" @@ -243,7 +242,7 @@ Scenario Outline: Get a List of current process supervisors of a project Scenario Outline: Get a List of current Process Permissions of a project - Given I request "project/prj_uid/process-permissions" stored in session array as variable "prj_uid_" + Given I request "project/prj_uid/process-permissions" with the key "prj_uid" stored in session array as variable "prj_uid_" Then the response status code should be 200 And the response charset is "UTF-8" And the response has records @@ -257,7 +256,7 @@ Scenario Outline: Get a List of current Process Permissions of a project Scenario Outline: Get a list templates folder of process files manager - Given I request "project/prj_uid/file-manager?path=templates" stored in session array as variable "prj_uid_" + Given I request "project/prj_uid/file-manager?path=templates" with the key "prj_uid" stored in session array as variable "prj_uid_" Then the response status code should be 200 And the response charset is "UTF-8" And the content type is "application/json" @@ -368,4 +367,17 @@ Scenario: Get a list of projects 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" \ No newline at end of file + And the type is "array" + + +Scenario Outline: Import a process + Given POST upload a project file "" to "project/import?option=" + 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" + + Examples: + | project_file | import_option | + | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | create | + \ No newline at end of file diff --git a/features/backend/projects/project_export_import/negative_tests_project_export_import.feature b/features/backend/projects/project_export_import/negative_tests_project_export_import.feature index e69de29bb..96cfb2e2c 100644 --- a/features/backend/projects/project_export_import/negative_tests_project_export_import.feature +++ b/features/backend/projects/project_export_import/negative_tests_project_export_import.feature @@ -0,0 +1,16 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Import/Export Process Negative Tests + + Background: + Given that I have a valid access_token + +Scenario Outline: Import a process negative tests + Given POST upload a project file "" to "project/import?option=" + Then the response status code should be + And the response status message should have the following text "" + + + Examples: + | Description | project_file | import_option | error_code | error_message | + | Import process when the process alredy exists | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | create | 400 | already exists | + #| Invalid path | /processmaker/sample/Project_invalido.pmx | create | 400 | invalid | \ No newline at end of file diff --git a/workflow/engine/methods/processes/processes_Export.php b/workflow/engine/methods/processes/processes_Export.php index a7bfabcd9..5c5993eaf 100755 --- a/workflow/engine/methods/processes/processes_Export.php +++ b/workflow/engine/methods/processes/processes_Export.php @@ -30,7 +30,7 @@ try { $exporter = new ProcessMaker\Exporter\XmlExporter($_GET["pro_uid"]); $version = ProcessMaker\Util\Common::getLastVersion($outputDir . $exporter->getProjectName() . "-*.pmx") + 1; - $outputFilename = sprintf("%s-%s.%s", $exporter->getProjectName(), $version, "pmx"); + $outputFilename = sprintf("%s-%s.%s", str_replace(" ", "_", $exporter->getProjectName()), $version, "pmx"); $exporter->saveExport($outputDir . $outputFilename); } else { $oProcess = new Processes(); @@ -134,3 +134,4 @@ echo json_encode($response); // $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); // G::RenderPage( 'publish', 'raw' ); //} + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 2a04fbb03..93b18a1a9 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -700,16 +700,22 @@ class Cases Validator::appUid($app_uid, '$app_uid'); Validator::usrUid($usr_uid, '$usr_uid'); + $case = new \Cases(); + $fields = $case->loadCase($app_uid); + if ($fields['APP_STATUS'] == 'CANCELLED') { + throw (new \Exception("The case '$app_uid' is canceled")); + } + if ($del_index === false) { $del_index = \AppDelegation::getCurrentIndex($app_uid); } + Validator::isInteger($del_index, '$del_index'); if ($unpaused_date != null) { Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date'); } - $case = new \Cases(); $case->pauseCase( $app_uid, $del_index, $usr_uid, $unpaused_date ); } @@ -1515,4 +1521,232 @@ class Cases $appNote = new \AppNotes(); $appNote->addCaseNote($app_uid, $usr_uid, $note_content, intval($send_mail)); } + + /** + * Get data Task Case + * + * @param string $sApplicationUID Unique id of Case + * + * return array Return an array with Task Case + */ + public function getTasks($sApplicationUID) + { + try { + $iDelegation = \AppDelegation::getCurrentIndex($sApplicationUID); + $case = new \Cases(); + $caseLoad = $case->loadCase($sApplicationUID); + $sProcessUID = $caseLoad['PRO_UID']; + $sTask = ''; + $bCT = true; + $oProcess = new \Process(); + $oPM = array(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\TaskPeer::PRO_UID); + $oCriteria->addSelectColumn(\TaskPeer::TAS_UID); + $oCriteria->addSelectColumn(\ContentPeer::CON_VALUE); + $oCriteria->addSelectColumn(\TaskPeer::TAS_START); + $oCriteria->addSelectColumn(\TaskPeer::TAS_TYPE); + $aConditions = array(); + $aConditions[] = array(0 => \TaskPeer::TAS_UID, 1 => \ContentPeer::CON_ID); + $aConditions[] = array(0 => \ContentPeer::CON_CATEGORY, 1 => \DBAdapter::getStringDelimiter() . 'TAS_TITLE' . \DBAdapter::getStringDelimiter() ); + $aConditions[] = array(0 => \ContentPeer::CON_LANG, 1 => \DBAdapter::getStringDelimiter() . SYS_LANG . \DBAdapter::getStringDelimiter() ); + $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); + $oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID); + $oDataset = \TaskPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + while ($aRow1 = $oDataset->getRow()) { + $oTask = new \StdClass(); + $oTask->tas_uid = $aRow1['TAS_UID']; + $oTask->tas_type = $aRow1['TAS_TYPE']; + if ($aRow1['TAS_TYPE'] == 'NORMAL') { + if (($aRow1['CON_VALUE'] == "")) { + //There is no Label in Current SYS_LANG language so try to find in English - by default + $oTask1 = new \Task(); + $aRow1['CON_VALUE'] = $oTask1->getTasTitle(); + } + $oTask->tas_title = htmlentities($aRow1['CON_VALUE'], ENT_QUOTES, 'UTF-8'); + } else { + $oCriteria = new \Criteria('workflow'); + $del = \DBAdapter::getStringDelimiter(); + $oCriteria->add(\SubProcessPeer::PRO_PARENT, $aRow1['PRO_UID']); + $oCriteria->add(\SubProcessPeer::TAS_PARENT, $aRow1['TAS_UID']); + + $oCriteria->addAsColumn('TAS_TITLE', 'C1.CON_VALUE'); + $oCriteria->addAlias("C1", 'CONTENT'); + $tasTitleConds = array(); + $tasTitleConds[] = array(\SubProcessPeer::TAS_PARENT, 'C1.CON_ID'); + $tasTitleConds[] = array('C1.CON_CATEGORY', $del . 'TAS_TITLE' . $del); + $tasTitleConds[] = array('C1.CON_LANG', $del . SYS_LANG . $del); + $oCriteria->addJoinMC($tasTitleConds, \Criteria::LEFT_JOIN); + + $oDatasetX = \SubProcessPeer::doSelectRS($oCriteria); + $oDatasetX->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDatasetX->next(); + $aRowx = $oDatasetX->getRow(); + if ($oProcess->exists($aRowx['PRO_UID'])) { + $oTask->tas_title = htmlentities($aRowx['TAS_TITLE'], ENT_QUOTES, 'UTF-8'); + } else { + $oTask->tas_title = htmlentities($aRow1['CON_VALUE'], ENT_QUOTES, 'UTF-8'); + } + } + $oTask->routing = new \StdClass(); + $oTask->routing->rou_type = ''; + $oTask->routing->to = array(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn(\RoutePeer::ROU_TYPE); + $oCriteria->addSelectColumn(\RoutePeer::ROU_NEXT_TASK); + $oCriteria->addSelectColumn(\RoutePeer::ROU_CONDITION); + $oCriteria->addSelectColumn(\RoutePeer::ROU_TO_LAST_USER); + $oCriteria->addSelectColumn(\RoutePeer::ROU_OPTIONAL); + $oCriteria->addSelectColumn(\UsersPeer::USR_UID); + $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); + $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME); + $oCriteria->addSelectColumn(\AppDelegationPeer::DEL_INIT_DATE); + $oCriteria->addSelectColumn(\AppDelegationPeer::DEL_TASK_DUE_DATE); + $oCriteria->addSelectColumn(\AppDelegationPeer::DEL_FINISH_DATE); + $oCriteria->addJoin(\AppDelegationPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); + $oCriteria->addJoin(\AppDelegationPeer::PRO_UID, \RoutePeer::PRO_UID, \Criteria::LEFT_JOIN); + $oCriteria->add(\RoutePeer::PRO_UID, $sProcessUID); + $oCriteria->add(\RoutePeer::TAS_UID, $aRow1['TAS_UID']); + $oCriteria->add(\AppDelegationPeer::APP_UID, $sApplicationUID); + $oCriteria->add(\AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); + $oCriteria->addDescendingOrderByColumn(\AppDelegationPeer::DEL_INDEX); + $oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria); + $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset2->next(); + while ($aRow2 = $oDataset2->getRow()) { + switch ($aRow2['ROU_TYPE']) { + case 'SEQUENTIAL': + $aRow2['ROU_TYPE'] = 0; + break; + case 'SELECT': + $aRow2['ROU_TYPE'] = 1; + break; + case 'EVALUATE': + $aRow2['ROU_TYPE'] = 2; + break; + case 'PARALLEL': + $aRow2['ROU_TYPE'] = 3; + break; + case 'PARALLEL-BY-EVALUATION': + $aRow2['ROU_TYPE'] = 4; + break; + case 'SEC-JOIN': + $aRow2['ROU_TYPE'] = 5; + break; + case 'DISCRIMINATOR': + $aRow2['ROU_TYPE'] = 8; + break; + } + $iDiff = strtotime($aRow2['DEL_FINISH_DATE']) - strtotime($aRow2['DEL_INIT_DATE']); + $oTo = new \StdClass(); + $oTo->rou_next_task = $aRow2['ROU_NEXT_TASK']; + $oTo->rou_condition = $aRow2['ROU_CONDITION']; + $oTo->rou_to_last_user = $aRow2['ROU_TO_LAST_USER']; + $oTo->rou_optional = $aRow2['ROU_OPTIONAL']; + $oTo->usr_uid = ($aRow2['USR_UID'] != null ? $aRow2['USR_FIRSTNAME'] . ' ' . $aRow2['USR_LASTNAME'] : \G::LoadTranslation('ID_NONE')); + $oTo->usr_firstname = $aRow2['USR_FIRSTNAME']; + $oTo->usr_lastname = $aRow2['USR_LASTNAME']; + $oTo->del_init_date = ($aRow2['DEL_INIT_DATE'] != null ? $aRow2['DEL_INIT_DATE'] : \G::LoadTranslation('ID_CASE_NOT_YET_STARTED')); + $oTo->del_task_due_date = ($aRow2['DEL_TASK_DUE_DATE'] != null ? $aRow2['DEL_TASK_DUE_DATE'] : \G::LoadTranslation('ID_CASE_NOT_YET_STARTED')); + $oTo->del_finish_date = ($aRow2['DEL_FINISH_DATE'] != null ? $aRow2['DEL_FINISH_DATE'] : \G::LoadTranslation('ID_NOT_FINISHED')); + $oTo->duration = ($aRow2['DEL_FINISH_DATE'] != null ? (int) ($iDiff / 3600) . ' ' . ((int) ($iDiff / 3600) == 1 ? \G::LoadTranslation('ID_HOUR') : \G::LoadTranslation('ID_HOURS')) . ' ' . (int) (($iDiff % 3600) / 60) . ' ' . ((int) (($iDiff % 3600) / 60) == 1 ? \G::LoadTranslation('ID_MINUTE') : \G::LoadTranslation('ID_MINUTES')) . ' ' . (int) (($iDiff % 3600) % 60) . ' ' . ((int) (($iDiff % 3600) % 60) == 1 ? \G::LoadTranslation('ID_SECOND') : \G::LoadTranslation('ID_SECONDS')) : \G::LoadTranslation('ID_NOT_FINISHED')); + $oTask->routing->rou_type = $aRow2['ROU_TYPE']; + $oTask->routing->to[] = $oTo; + $oDataset2->next(); + } + if ($bCT) { + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn('COUNT(*) AS CANT'); + $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH'); + $oCriteria->add(\AppDelegationPeer::APP_UID, $sApplicationUID); + $oCriteria->add(\AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); + $oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria); + $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset2->next(); + $aRow2 = $oDataset2->getRow(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn('DEL_FINISH_DATE'); + $oCriteria->add(\AppDelegationPeer::APP_UID, $sApplicationUID); + $oCriteria->add(\AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); + $oCriteria->add(\AppDelegationPeer::DEL_FINISH_DATE, null); + $oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria); + $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset2->next(); + $aRow3 = $oDataset2->getRow(); + if ($aRow3) { + $aRow2['FINISH'] = ''; + } + if (empty($aRow2["FINISH"]) && $aRow1["TAS_UID"] == $sTask) { + $oTask->color = "#FF0000"; //Red + } else { + if (!empty($aRow2["FINISH"])) { + $oTask->color = "#006633"; //Green + } else { + if ($oTask->routing->rou_type != 5) { + if ($aRow2["CANT"] != 0) { + $oTask->color = "#FF0000"; //Red + } else { + $oTask->color = "#939598"; //Gray + } + } else { + if ($aRow3) { + $oTask->color = "#FF0000"; //Red + } else { + $oTask->color = "#939598"; //Gray + } + } + } + } + } else { + if (($sApplicationUID != '') && ($iDelegation > 0) && ($sTask != '')) { + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn('COUNT(*) AS CANT'); + $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH'); + $oCriteria->add(\AppDelegationPeer::APP_UID, $sApplicationUID); + $oCriteria->add(\AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); + $oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria); + $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset2->next(); + $aRow2 = $oDataset2->getRow(); + $oCriteria = new \Criteria('workflow'); + $oCriteria->addSelectColumn('DEL_FINISH_DATE'); + $oCriteria->add(\AppDelegationPeer::APP_UID, $sApplicationUID); + $oCriteria->add(\AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); + $oCriteria->add(\AppDelegationPeer::DEL_FINISH_DATE, null); + $oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria); + $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $oDataset2->next(); + $aRow3 = $oDataset2->getRow(); + if ($aRow3) { + $aRow2['FINISH'] = ''; + } + if (empty($aRow2["FINISH"]) && $aRow1["TAS_UID"] == $sTask) { + $oTask->color = "#FF0000"; //Red + } else { + if (!empty($aRow2["FINISH"])) { + $oTask->color = "#006633"; //Green + } else { + if ($oTask->routing->rou_type != 5) { + if ($aRow2["CANT"] != 0) { + $oTask->color = "#FF0000"; //Red + } else { + $oTask->color = "#939598"; //Gray + } + } else { + $oTask->color = "#FF9900"; //Yellow + } + } + } + } + } + $oPM[] = $oTask; + $oDataset->next(); + } + return $oPM; + } catch (\Exception $e) { + throw $e; + } + } } \ No newline at end of file diff --git a/workflow/engine/src/ProcessMaker/Importer/Importer.php b/workflow/engine/src/ProcessMaker/Importer/Importer.php index b390234fc..5bfeafde0 100644 --- a/workflow/engine/src/ProcessMaker/Importer/Importer.php +++ b/workflow/engine/src/ProcessMaker/Importer/Importer.php @@ -401,7 +401,7 @@ abstract class Importer $arrayFieldNameForException = $arrayFieldName; if (isset($_FILES[$arrayFieldName["projectFile"]])) { - $_FILES["filepmx"] = $_FILES[$arrayFieldName["projectFile"]]; + $_FILES["filePmx"] = $_FILES[$arrayFieldName["projectFile"]]; } if (isset($arrayData[$arrayFieldName["projectFile"]]) && @@ -418,7 +418,6 @@ abstract class Importer $process = new \ProcessMaker\BusinessModel\Process(); $validator = new \ProcessMaker\BusinessModel\Validator(); - $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayFieldDefinition, $arrayFieldNameForException, true); @@ -433,7 +432,7 @@ abstract class Importer } } - if ((isset($_FILES["filepmx"]) && pathinfo($_FILES["filepmx"]["name"], PATHINFO_EXTENSION) != "pmx") || + if ((isset($_FILES["filePmx"]) && pathinfo($_FILES["filePmx"]["name"], PATHINFO_EXTENSION) != "pmx") || (isset($arrayData[$arrayFieldName["projectFile"]]) && pathinfo($arrayData[$arrayFieldName["projectFile"]], PATHINFO_EXTENSION) != "pmx") ) { throw (new \Exception("The file extension not is \"pmx\"")); @@ -456,12 +455,13 @@ abstract class Importer $option = $opt; - if (isset($_FILES["filepmx"])) { - $this->setSaveDir(PATH_DOCUMENT . "input"); - $this->setSourceFromGlobals("filepmx"); + if (isset($_FILES["filePmx"])) { + $this->setSourceFromGlobals("filePmx"); } else { - if (isset($arrayData[$arrayFieldName["projectFile"]]) && file_exists(PATH_DOCUMENT . "input" . PATH_SEP . $arrayData[$arrayFieldName["projectFile"]])) { - $this->setSourceFile(PATH_DOCUMENT . "input" . PATH_SEP . $arrayData[$arrayFieldName["projectFile"]]); + $filePmx = rtrim($this->getSaveDir(), PATH_SEP) . PATH_SEP . $arrayData[$arrayFieldName["projectFile"]]; + + if (isset($arrayData[$arrayFieldName["projectFile"]]) && file_exists($filePmx)) { + $this->setSourceFile($filePmx); } else { throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayFieldNameForException["projectFile"], $arrayData[$arrayFieldName["projectFile"]]), "The file with {0}: \"{1}\" does not exist."))); } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php index 0e215b64e..a5b00d123 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php @@ -989,5 +989,22 @@ class Cases extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + /** + * @url GET /:app_uid/tasks + * + * @param string $app_uid {@min 32}{@max 32} + */ + public function doGetTasks($app_uid) + { + try { + $cases = new \ProcessMaker\BusinessModel\Cases(); + $oData = $cases->getTasks($app_uid); + return $oData; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project.php b/workflow/engine/src/ProcessMaker/Services/Api/Project.php index 685222964..eae11b29e 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project.php @@ -133,6 +133,7 @@ class Project extends Api try { $importer = new \ProcessMaker\Importer\XmlImporter(); + $importer->setSaveDir(PATH_DOCUMENT . "input"); $importer->setData("usr_uid", $this->getUserId()); $arrayData = $importer->importPostFile($request_data, $option, array("projectFile" => "project_file", "option" => "option")); diff --git a/workflow/engine/src/Tests/ProcessMaker/Exporter/XmlExporterTest.php b/workflow/engine/src/Tests/ProcessMaker/Exporter/XmlExporterTest.php index 2abb95c62..0f05168de 100644 --- a/workflow/engine/src/Tests/ProcessMaker/Exporter/XmlExporterTest.php +++ b/workflow/engine/src/Tests/ProcessMaker/Exporter/XmlExporterTest.php @@ -15,8 +15,7 @@ class XmlExporterTest extends \PHPUnit_Framework_TestCase { protected static $exporter; protected static $projectUid = ""; - protected static $projectName = ""; - protected static $fileXml = ""; + protected static $filePmx = ""; /** * Set class for test @@ -25,11 +24,9 @@ class XmlExporterTest extends \PHPUnit_Framework_TestCase */ public static function setUpBeforeClass() { - self::$projectName = \ProcessMaker\Util\Common::generateUID(); - $json = " { - \"prj_name\": \"" . self::$projectName . "\", + \"prj_name\": \"" . \ProcessMaker\Util\Common::generateUID() . "\", \"prj_author\": \"00000000000000000000000000000001\", \"diagrams\": [ { @@ -49,7 +46,7 @@ class XmlExporterTest extends \PHPUnit_Framework_TestCase $arrayResult = \ProcessMaker\Project\Adapter\BpmnWorkflow::createFromStruct(json_decode($json, true)); self::$projectUid = $arrayResult[0]["new_uid"]; - self::$fileXml = PATH_DOCUMENT . "output" . PATH_SEP . self::$projectUid . ".xml"; + self::$filePmx = PATH_DOCUMENT . "output" . PATH_SEP . self::$projectUid . ".pmx"; self::$exporter = new \ProcessMaker\Exporter\XmlExporter(self::$projectUid); } @@ -62,10 +59,9 @@ class XmlExporterTest extends \PHPUnit_Framework_TestCase public static function tearDownAfterClass() { $bpmnWf = \ProcessMaker\Project\Adapter\BpmnWorkflow::load(self::$projectUid); - $bpmnWf->remove(); - unlink(self::$fileXml); + unlink(self::$filePmx); } /** @@ -127,7 +123,7 @@ class XmlExporterTest extends \PHPUnit_Framework_TestCase $node = $value; if ($node->hasAttribute("class")) { - $this->assertTrue(in_array($node->getAttribute("class"), array("BPMN", "workflow"))); + $this->assertContains($node->getAttribute("class"), array("BPMN", "workflow")); } } } @@ -139,9 +135,9 @@ class XmlExporterTest extends \PHPUnit_Framework_TestCase */ public function testSaveExport() { - self::$exporter->saveExport(self::$fileXml); + self::$exporter->saveExport(self::$filePmx); - $this->assertTrue(file_exists(self::$fileXml)); + $this->assertTrue(file_exists(self::$filePmx)); } /** diff --git a/workflow/engine/src/Tests/ProcessMaker/Importer/XmlImporterTest.php b/workflow/engine/src/Tests/ProcessMaker/Importer/XmlImporterTest.php new file mode 100644 index 000000000..9b54a5a10 --- /dev/null +++ b/workflow/engine/src/Tests/ProcessMaker/Importer/XmlImporterTest.php @@ -0,0 +1,216 @@ +saveExport(self::$filePmx); + + $bpmnWf = \ProcessMaker\Project\Adapter\BpmnWorkflow::load(self::$projectUid); + $bpmnWf->remove(); + + self::$importer = new \ProcessMaker\Importer\XmlImporter(); + self::$importer->setSourceFile(self::$filePmx); + } + + /** + * Delete projects + * + * @coversNothing + */ + public static function tearDownAfterClass() + { + foreach (self::$arrayPrjUid as $value) { + $prjUid = $value; + + $bpmnWf = \ProcessMaker\Project\Adapter\BpmnWorkflow::load($prjUid); + $bpmnWf->remove(); + } + + unlink(self::$filePmx); + } + + /** + * Test load + * + * @covers \ProcessMaker\Importer\XmlImporter::load + */ + public function testLoad() + { + $arrayData = self::$importer->load(); + + $this->assertTrue(is_array($arrayData)); + $this->assertNotEmpty($arrayData); + + $this->assertArrayHasKey("tables", $arrayData); + $this->assertArrayHasKey("files", $arrayData); + + $this->assertEquals($arrayData["tables"]["bpmn"]["project"][0]["prj_uid"], self::$projectUid); + $this->assertEquals($arrayData["tables"]["workflow"]["process"][0]["PRO_UID"], self::$projectUid); + } + + /** + * Test getTextNode + * + * @covers \ProcessMaker\Importer\XmlImporter::getTextNode + */ + public function testGetTextNode() + { + //Is not implemented. Method getTextNode() is private + } + + /** + * Test import + * + * @covers \ProcessMaker\Importer\XmlImporter::import + */ + public function testImport() + { + $prjUid = self::$importer->import(); + self::$arrayPrjUid[] = $prjUid; + + $this->assertNotNull(\BpmnProjectPeer::retrieveByPK($prjUid)); + } + + /** + * Test importPostFile + * + * @covers \ProcessMaker\Importer\XmlImporter::importPostFile + */ + public function testImportPostFile() + { + self::$importer->setSaveDir(PATH_DOCUMENT . "input"); + + $arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => self::$projectUid . ".pmx"), "KEEP"); + self::$arrayPrjUid[] = $arrayData["PRJ_UID"]; + + $this->assertNotNull(\BpmnProjectPeer::retrieveByPK($arrayData["PRJ_UID"])); + } + + /** + * Test exception when the project exists + * + * @covers \ProcessMaker\Importer\XmlImporter::import + * + * @expectedException Exception + * @expectedExceptionMessage Project already exists, you need set an action to continue. Available actions: [project.import.create_new|project.import.override|project.import.disable_and_create_new|project.import.keep_without_changing_and_create_new]. + */ + public function testImportExceptionProjectExists() + { + $prjUid = self::$importer->import(); + } + + /** + * Test exception for empty data + * + * @covers \ProcessMaker\Importer\XmlImporter::importPostFile + * + * @expectedException Exception + * @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty. + */ + public function testImportPostFileExceptionEmptyData() + { + $arrayData = self::$importer->importPostFile(array()); + } + + /** + * Test exception for invalid extension + * + * @covers \ProcessMaker\Importer\XmlImporter::importPostFile + * + * @expectedException Exception + * @expectedExceptionMessage The file extension not is "pmx" + */ + public function testImportPostFileExceptionInvalidExtension() + { + $arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => "file.pm")); + } + + /** + * Test exception for file does not exist + * + * @covers \ProcessMaker\Importer\XmlImporter::importPostFile + * + * @expectedException Exception + * @expectedExceptionMessage The file with PROJECT_FILE: "file.pmx" does not exist. + */ + public function testImportPostFileExceptionFileNotExists() + { + $arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => "file.pmx")); + } + + /** + * Test exception for invalid option + * + * @covers \ProcessMaker\Importer\XmlImporter::importPostFile + * + * @expectedException Exception + * @expectedExceptionMessage Invalid value for "OPTION", it only accepts values: "CREATE|OVERWRITE|DISABLE|KEEP". + */ + public function testImportPostFileExceptionInvalidOption() + { + $arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => "file.pmx"), "CREATED"); + } + + /** + * Test exception when the project exists + * + * @covers \ProcessMaker\Importer\XmlImporter::importPostFile + * + * @expectedException Exception + * @expectedExceptionMessage Project already exists, you need set an action to continue. Available actions: [CREATE|OVERWRITE|DISABLE|KEEP]. + */ + public function testImportPostFileExceptionProjectExists() + { + self::$importer->setSaveDir(PATH_DOCUMENT . "input"); + + $arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => self::$projectUid . ".pmx")); + } +} +