From ce50fa9308b89ebc5c41f52f03950b3ffb20cafa Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Wed, 23 Apr 2014 16:50:31 -0400 Subject: [PATCH] Arreglo en errores en BEHAT y adicion de validaciones para inputDocuments and outputDocuments --- ...asic_sequence_output_document_case.feature | 60 ++++++------ ...main_sequence_output_document_case.feature | 98 ++++++++----------- .../BusinessModel/Cases/InputDocument.php | 55 +++++------ .../BusinessModel/Cases/OutputDocument.php | 9 +- 4 files changed, 98 insertions(+), 124 deletions(-) diff --git a/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature b/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature index 8c1b095e6..1beddfcda 100644 --- a/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature +++ b/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature @@ -1,48 +1,44 @@ @ProcessMakerMichelangelo @RestAPI Feature: Output Documents cases -Requirements: - a workspace with one case of the process "Test Output Document Case" - and there are six Output Documents in the process + Requirements: + a workspace with one case of the process "Test Output Document Case" + and there are six Output Documents in the process -Background: + Background: Given that I have a valid access_token -Scenario: Returns a list of the generated documents for a given cases + Scenario: Returns a list of the generated documents for a given cases Given I request "cases/33125846153383cecdf64f1079330191/output-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" And the response has 1 records - -Scenario: Returns a generated document for a given case - Given I request "cases/33125846153383cecdf64f1079330191/output-document/75468909953383d0bc42f96046736849" + Scenario: Generate or regenerates an output documents for a given case + Given POST this data: + """ + { + "out_doc_uid": "2087233055331ef4127d238097105696" + } + """ + And I request "cases/33125846153383cecdf64f1079330191/output-document" + 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" + And store "app_doc_uid" in session array as variable "app_doc_uid_0" + + Scenario: Returns a generated document for a given case + Given I request "cases/33125846153383cecdf64f1079330191/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_0" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "object" - -Scenario: Generate or regenerates an output documents for a given case - Given POST this data: - """ - { - "out_doc_uid": "2087233055331ef4127d238097105696" - } - """ - And I request "cases/33125846153383cecdf64f1079330191/output-document" - 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" - And store "app_doc_uid" in session array as variable "app_doc_uid_0" - - - -Scenario: Delete an uploaded or generated document from a case. - And that I want to delete a resource with the key "app_doc_uid_0" stored in session array - Given I request "output-document" - Then the response status code should be 200 - And the content type is "application/json" - And the response charset is "UTF-8" - And the type is "object" + Scenario: Delete an uploaded or generated document from a case. + Given that I want to delete a resource with the key "app_doc_uid_0" stored in session array + And I request "cases/33125846153383cecdf64f1079330191/output-document" + Then the response status code should be 200 + And the content type is "application/json" + And the response charset is "UTF-8" + And the type is "object" diff --git a/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature b/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature index 026ab8570..2ebf6a565 100644 --- a/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature +++ b/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature @@ -1,96 +1,78 @@ @ProcessMakerMichelangelo @RestAPI Feature: Output Documents cases Main Tests -Requirements: - a workspace with one case of the process "Test Output Document Case" - and there are six Output Documents in the process + Requirements: + a workspace with one case of the process "Test Output Document Case" + and there are six Output Documents in the process -Background: + Background: Given that I have a valid access_token -Scenario Outline: Generate or regenerates an output documents for a given case - Given POST this data: - """ + Scenario Outline: Generate or regenerates an output documents for a given case + Given POST this data: + """ { - "out_doc_uid": "" + "out_doc_uid": "" } """ - And I request "cases/33125846153383cecdf64f1079330191/output-document" - 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" - And store "app_doc_uid" in session array as variable "app_doc_uid_" - - - Examples: - - | test_description | app_doc_uid_number | out_doc_uid | - | Generate "output document only doc" | 1 | 2087233055331ef4127d238097105696 | - | Generate "output document with versioning" | 2 | 5961108155331efc976cee7011445347 | - | Generate "output document only pdf" | 3 | 7074907425331ef837aa8b2055964905 | - | Generate "output document old version" | 4 | 7385645355331ee70ea6a87029841722 | - | Generate "output document with pdf security" | 5 | 8594478445331eff2d30767061922215 | + And I request "cases/33125846153383cecdf64f1079330191/output-document" + 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" + And store "app_doc_uid" in session array as variable "app_doc_uid_" -Scenario: Returns a list of the generated documents for a given cases + Examples: + + | test_description | app_doc_uid_number | out_doc_uid | + | Generate "output document only doc" | 1 | 2087233055331ef4127d238097105696 | + | Generate "output document with versioning" | 2 | 5961108155331efc976cee7011445347 | + | Generate "output document only pdf" | 3 | 7074907425331ef837aa8b2055964905 | + | Generate "output document old version" | 4 | 7385645355331ee70ea6a87029841722 | + | Generate "output document with pdf security" | 5 | 8594478445331eff2d30767061922215 | + + + Scenario: Returns a list of the generated documents for a given cases Given I request "cases/33125846153383cecdf64f1079330191/output-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" And the response has 6 records - And the "app_doc_filename" property in row 0 equals "output document new version.pdf" - And the "app_doc_filename" property in row 1 equals "output document with pdf security.pdf" - And the "app_doc_filename" property in row 2 equals "output document only pdf.pdf" - And the "app_doc_filename" property in row 3 equals "output document only doc.doc" - And the "app_doc_filename" property in row 4 equals "output document with versioning.pdf" - And the "app_doc_filename" property in row 5 equals "output document old version.pdf" - -Scenario Outline: Returns an generated document for a given case + Scenario Outline: Returns an generated document for a given case Given I request "cases/33125846153383cecdf64f1079330191/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" Then the response status code should be 200 And the response charset is "UTF-8" - And the type is "Object" - And the "app_doc_uid" property equals "" + And the type is "array" And the "app_doc_filename" property equals "" And the "doc_uid" property equals "" - And the "app_doc_version" property equals "" - And the "app_doc_create_date" property equals "" And the "app_doc_create_user" property equals "" And the "app_doc_type" property equals "" - And the "app_doc_index" property equals "" - And the "app_doc_link" property equals "" + + Examples: + + | test_description | app_doc_uid_number | app_doc_filename | doc_uid | app_doc_create_user | app_doc_type | + | Get Output "output document only doc.doc" | 1 | output document only doc.doc | 2087233055331ef4127d238097105696 | , Administrator (admin) | OUTPUT DOC | + | Get Output "output document with versioning.pdf" | 2 | output document with versioning.pdf | 5961108155331efc976cee7011445347 | , Administrator (admin) | OUTPUT BOTH | + | Get Output "output document only pdf.pdf" | 3 | output document only pdf.pdf | 7074907425331ef837aa8b2055964905 | , Administrator (admin) | OUTPUT PDF | + | Get Output "output document old version.pdf" | 4 | output document old version.pdf | 7385645355331ee70ea6a87029841722 | , Administrator (admin) | OUTPUT BOTH | + | Get Output "output document with pdf security.pdf" | 5 | output document with pdf security.pdf| 8594478445331eff2d30767061922215 | , Administrator (admin) | OUTPUT BOTH | - Examples: - - | test_description | app_doc_uid_number | app_doc_filename | doc_uid | app_doc_version | app_doc_create_date | app_doc_create_user | app_doc_type | app_doc_index | app_doc_link | - | Get Output "output document new version.pdf" | 1 | output document new version.pdf | 3391282325331ee81c84715031595672 | 1 | 2014-03-26 12:29:30 | , Administrator (admin) | OUTPUT BOTH | 1 | cases/cases_ShowOutputDocument?a=3000248055333006ab56a01005891659&v=1&ext=pdf&random=1256696859 | - | Get Output "output document old version.pdf" | 2 | output document old version.pdf | 7385645355331ee70ea6a87029841722 | 1 | 2014-03-26 12:29:33 | , Administrator (admin) | OUTPUT BOTH | 2 | cases/cases_ShowOutputDocument?a=8865432395333006d75d824038425476&v=1&ext=pdf&random=1838956992 | - | Get Output "output document only doc.doc" | 3 | output document only doc.doc | 2087233055331ef4127d238097105696 | 1 | 2014-03-26 12:29:35 | , Administrator (admin) | OUTPUT DOC | 3 | cases/cases_ShowOutputDocument?a=4447256265333006fe6fb00061503934&v=1&ext=doc&random=949245639 | - | Get Output "output document only pdf.pdf" | 4 | output document only pdf.pdf | 7074907425331ef837aa8b2055964905 | 1 | 2014-03-26 12:29:38 | , Administrator (admin) | OUTPUT PDF | 4 | cases/cases_ShowOutputDocument?a=828039615533300724fdcb6091842678&v=1&ext=pdf&random=401448562 | - | Get Output "output document with pdf security.pdf" | 5 | output document with pdf security.pdf | 8594478445331eff2d30767061922215 | 1 | 2014-03-26 12:29:40 | , Administrator (admin) | OUTPUT BOTH | 5 | cases/cases_ShowOutputDocument?a=25293137553330074713ab9073501576&v=1&ext=pdf&random=324546362 | - | Get Output "output document with versioning.pdf" | 6 | output document with versioning.pdf | 5961108155331efc976cee7011445347 | 1 | 2014-03-26 12:29:42 | , Administrator (admin) | OUTPUT BOTH | 6 | cases/cases_ShowOutputDocument?a=354826487533300769e65e0027827984&v=1&ext=pdf&random=1682978530 | - - - -Scenario Outline: Delete an uploaded or generated document from a case. + Scenario Outline: Delete an uploaded or generated document from a case. Given that I want to delete a resource with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" And I request "cases/33125846153383cecdf64f1079330191/output-document" And the response status code should be 200 And the content type is "application/json" And the response charset is "UTF-8" - And the type is "object" + And the type is "object" - Examples: + Examples: | app_doc_uid_number | | 1 | | 2 | | 3 | | 4 | - | 5 | - - - \ No newline at end of file + | 5 | diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index f2c55a450..ecf9dddaa 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -14,10 +14,6 @@ class InputDocument public function getCasesInputDocuments($applicationUid, $userUid) { try { - $oApplication = \ApplicationPeer::retrieveByPk($applicationUid); - if (!is_object($oApplication)) { - throw (new \Exception("The Application with app_uid: '$applicationUid' doesn't exist!")); - } $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); @@ -62,10 +58,6 @@ class InputDocument public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid) { try { - $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 ); - if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { - throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!')); - } $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); @@ -90,6 +82,10 @@ class InputDocument $docrow['app_doc_index'] = $row['APP_DOC_INDEX']; $docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK']; if ($docrow['app_doc_uid'] == $inputDocumentUid) { + $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, $row['DOC_VERSION'] ); + if (is_null( $oAppDocument )) { + throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!')); + } $result = $docrow; } } @@ -183,34 +179,34 @@ class InputDocument //Triggers $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Add Input Document - $_FILES["form"]["name"] = ''; - $_FILES["form"]["error"] = ''; - $_FILES["form"]["tmp_name"] = ''; - if ($_FILES["form"]["error"] == '') { + if (empty($_FILES)) { + throw (new \Exception('This document filename doesn\'t exist!')); + } + if (!$_FILES["form"]["error"]) { $_FILES["form"]["error"] = 0; } if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { $appDocUid = $case->addInputDocument($inputDocumentUid, - $appDocUid, - $docVersion, - $appDocType, - $appDocComment, - '', - $applicationUid, - $delIndex, - $taskUid, - $userUid, - "xmlform", - $_FILES["form"]["name"], - $_FILES["form"]["error"], - $_FILES["form"]["tmp_name"]); + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + '', + $applicationUid, + $delIndex, + $taskUid, + $userUid, + "xmlform", + $_FILES["form"]["name"], + $_FILES["form"]["error"], + $_FILES["form"]["tmp_name"]); } //Trigger - Execute after - Start $arrayField["APP_DATA"] = $case->executeTriggers ($taskUid, - "INPUT_DOCUMENT", - $inputDocumentUid, - "AFTER", - $arrayField["APP_DATA"]); + "INPUT_DOCUMENT", + $inputDocumentUid, + "AFTER", + $arrayField["APP_DATA"]); //Trigger - Execute after - End //Save data $arrayData = array(); @@ -226,4 +222,3 @@ class InputDocument } } } - diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index 8237f74dd..5225298dc 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -104,13 +104,14 @@ class OutputDocument public function removeOutputDocument($applicationDocumentUid) { try { - $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 ); + $oAppDocumentVersion = new \AppDocument(); + $lastDocVersion = $oAppDocumentVersion->getLastAppDocVersion($applicationDocumentUid); + $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $lastDocVersion); if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); } - \G::LoadClass('wsBase'); - $ws = new \wsBase(); - $ws->removeDocument($applicationDocumentUid); + $aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED'); + $oAppDocument->update( $aFields ); } catch (\Exception $e) { throw $e; }