Merged in darojas/processmaker (pull request #414)

Arreglo en errores en BEHAT y adicion de validaciones para inputDocuments and outputDocuments
This commit is contained in:
Erik Amaru Ortiz
2014-04-23 17:29:06 -04:00
4 changed files with 98 additions and 124 deletions

View File

@@ -1,48 +1,44 @@
@ProcessMakerMichelangelo @RestAPI @ProcessMakerMichelangelo @RestAPI
Feature: Output Documents cases Feature: Output Documents cases
Requirements: Requirements:
a workspace with one case of the process "Test Output Document Case" a workspace with one case of the process "Test Output Document Case"
and there are six Output Documents in the process and there are six Output Documents in the process
Background: Background:
Given that I have a valid access_token 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" Given I request "cases/33125846153383cecdf64f1079330191/output-documents"
Then the response status code should be 200 Then the response status code should be 200
And the response charset is "UTF-8" And the response charset is "UTF-8"
And the type is "array" And the type is "array"
And the response has 1 records And the response has 1 records
Scenario: Returns a generated document for a given case Scenario: Generate or regenerates an output documents for a given case
Given I request "cases/33125846153383cecdf64f1079330191/output-document/75468909953383d0bc42f96046736849" 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 Then the response status code should be 200
And the response charset is "UTF-8" And the response charset is "UTF-8"
And the type is "object" And the type is "object"
Scenario: Generate or regenerates an output documents for a given case Scenario: Delete an uploaded or generated document from a case.
Given POST this data: 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
"out_doc_uid": "2087233055331ef4127d238097105696" And the content type is "application/json"
} And the response charset is "UTF-8"
""" And the type is "object"
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"

View File

@@ -1,96 +1,78 @@
@ProcessMakerMichelangelo @RestAPI @ProcessMakerMichelangelo @RestAPI
Feature: Output Documents cases Main Tests Feature: Output Documents cases Main Tests
Requirements: Requirements:
a workspace with one case of the process "Test Output Document Case" a workspace with one case of the process "Test Output Document Case"
and there are six Output Documents in the process and there are six Output Documents in the process
Background: Background:
Given that I have a valid access_token Given that I have a valid access_token
Scenario Outline: Generate or regenerates an output documents for a given case Scenario Outline: Generate or regenerates an output documents for a given case
Given POST this data: Given POST this data:
""" """
{ {
"out_doc_uid": "<out_doc_uid>" "out_doc_uid": "<out_doc_uid>"
} }
""" """
And I request "cases/33125846153383cecdf64f1079330191/output-document" And I request "cases/33125846153383cecdf64f1079330191/output-document"
Then the response status code should be 200 Then the response status code should be 200
And the response charset is "UTF-8" And the response charset is "UTF-8"
And the content type is "application/json" And the content type is "application/json"
And the type is "array" And the type is "array"
And store "app_doc_uid" in session array as variable "app_doc_uid_<app_doc_uid_number>" And store "app_doc_uid" in session array as variable "app_doc_uid_<app_doc_uid_number>"
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 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" Given I request "cases/33125846153383cecdf64f1079330191/output-documents"
Then the response status code should be 200 Then the response status code should be 200
And the response charset is "UTF-8" And the response charset is "UTF-8"
And the type is "array" And the type is "array"
And the response has 6 records 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_<app_doc_uid_number>" 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_<app_doc_uid_number>"
Then the response status code should be 200 Then the response status code should be 200
And the response charset is "UTF-8" And the response charset is "UTF-8"
And the type is "Object" And the type is "array"
And the "app_doc_uid" property equals "<app_doc_uid>"
And the "app_doc_filename" property equals "<app_doc_filename>" And the "app_doc_filename" property equals "<app_doc_filename>"
And the "doc_uid" property equals "<doc_uid>" And the "doc_uid" property equals "<doc_uid>"
And the "app_doc_version" property equals "<app_doc_version>"
And the "app_doc_create_date" property equals "<app_doc_create_date>"
And the "app_doc_create_user" property equals "<app_doc_create_user>" And the "app_doc_create_user" property equals "<app_doc_create_user>"
And the "app_doc_type" property equals "<app_doc_type>" And the "app_doc_type" property equals "<app_doc_type>"
And the "app_doc_index" property equals "<app_doc_index>"
And the "app_doc_link" property equals "<app_doc_link>" 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: Scenario Outline: Delete an uploaded or generated document from a case.
| 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.
Given that I want to delete a resource with the key "app_doc_uid" stored in session array as variable "app_doc_uid_<app_doc_uid_number>" Given that I want to delete a resource with the key "app_doc_uid" stored in session array as variable "app_doc_uid_<app_doc_uid_number>"
And I request "cases/33125846153383cecdf64f1079330191/output-document" And I request "cases/33125846153383cecdf64f1079330191/output-document"
And the response status code should be 200 And the response status code should be 200
And the content type is "application/json" And the content type is "application/json"
And the response charset is "UTF-8" And the response charset is "UTF-8"
And the type is "object" And the type is "object"
Examples: Examples:
| app_doc_uid_number | | app_doc_uid_number |
| 1 | | 1 |
| 2 | | 2 |
| 3 | | 3 |
| 4 | | 4 |
| 5 | | 5 |

View File

@@ -14,10 +14,6 @@ class InputDocument
public function getCasesInputDocuments($applicationUid, $userUid) public function getCasesInputDocuments($applicationUid, $userUid)
{ {
try { try {
$oApplication = \ApplicationPeer::retrieveByPk($applicationUid);
if (!is_object($oApplication)) {
throw (new \Exception("The Application with app_uid: '$applicationUid' doesn't exist!"));
}
$sApplicationUID = $applicationUid; $sApplicationUID = $applicationUid;
$sUserUID = $userUid; $sUserUID = $userUid;
\G::LoadClass('case'); \G::LoadClass('case');
@@ -62,10 +58,6 @@ class InputDocument
public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid) public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid)
{ {
try { 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; $sApplicationUID = $applicationUid;
$sUserUID = $userUid; $sUserUID = $userUid;
\G::LoadClass('case'); \G::LoadClass('case');
@@ -90,6 +82,10 @@ class InputDocument
$docrow['app_doc_index'] = $row['APP_DOC_INDEX']; $docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK']; $docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
if ($docrow['app_doc_uid'] == $inputDocumentUid) { 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; $result = $docrow;
} }
} }
@@ -183,34 +179,34 @@ class InputDocument
//Triggers //Triggers
$arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER");
//Add Input Document //Add Input Document
$_FILES["form"]["name"] = ''; if (empty($_FILES)) {
$_FILES["form"]["error"] = ''; throw (new \Exception('This document filename doesn\'t exist!'));
$_FILES["form"]["tmp_name"] = ''; }
if ($_FILES["form"]["error"] == '') { if (!$_FILES["form"]["error"]) {
$_FILES["form"]["error"] = 0; $_FILES["form"]["error"] = 0;
} }
if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) {
$appDocUid = $case->addInputDocument($inputDocumentUid, $appDocUid = $case->addInputDocument($inputDocumentUid,
$appDocUid, $appDocUid,
$docVersion, $docVersion,
$appDocType, $appDocType,
$appDocComment, $appDocComment,
'', '',
$applicationUid, $applicationUid,
$delIndex, $delIndex,
$taskUid, $taskUid,
$userUid, $userUid,
"xmlform", "xmlform",
$_FILES["form"]["name"], $_FILES["form"]["name"],
$_FILES["form"]["error"], $_FILES["form"]["error"],
$_FILES["form"]["tmp_name"]); $_FILES["form"]["tmp_name"]);
} }
//Trigger - Execute after - Start //Trigger - Execute after - Start
$arrayField["APP_DATA"] = $case->executeTriggers ($taskUid, $arrayField["APP_DATA"] = $case->executeTriggers ($taskUid,
"INPUT_DOCUMENT", "INPUT_DOCUMENT",
$inputDocumentUid, $inputDocumentUid,
"AFTER", "AFTER",
$arrayField["APP_DATA"]); $arrayField["APP_DATA"]);
//Trigger - Execute after - End //Trigger - Execute after - End
//Save data //Save data
$arrayData = array(); $arrayData = array();
@@ -226,4 +222,3 @@ class InputDocument
} }
} }
} }

View File

@@ -104,13 +104,14 @@ class OutputDocument
public function removeOutputDocument($applicationDocumentUid) public function removeOutputDocument($applicationDocumentUid)
{ {
try { 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') { if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!'));
} }
\G::LoadClass('wsBase'); $aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED');
$ws = new \wsBase(); $oAppDocument->update( $aFields );
$ws->removeDocument($applicationDocumentUid);
} catch (\Exception $e) { } catch (\Exception $e) {
throw $e; throw $e;
} }