ProcessMaker-MA "InputDocuments and DynaForms (Fixes)"

- Se han mejorado y corregido el nombre de las variables (prj_uid)
- Se han completado validaciones al: Crear y Actualizar un InputDocument
- Se ha corregido el "negative_tests_input.feature" (behat) para el InputDocument, los
  cambios corresponden a nombres de atributos
This commit is contained in:
Victor Saisa Lopez
2014-02-12 12:32:04 -04:00
parent af238b4a9a
commit 5544d8f805
7 changed files with 288 additions and 182 deletions

View File

@@ -27,13 +27,13 @@ Feature: Output Documents Negative Tests
Examples:
| test_description | project | inp_doc_title | inp_doc_description | inp_doc_form_needed | inp_doc_original | inp_doc_published | inp_doc_versioning | inp_doc_destination_path | inp_doc_tags | error_code | error_message |
| Create with project invalid | 14414793652a5d718b65590036 | My InputDocument1 | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | project |
| Create with project invalid | 14414793652a5d718b65590036 | My InputDocument1 | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | prj_uid |
| Invalid inp doc from needed | 14414793652a5d718b65590036026581 | My InputDocument4 | My InputDocument4 DESCRIPTION | VRESAMPLE12334$%#@ | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_form_needed |
| Invalid inp doc original | 14414793652a5d718b65590036026581 | My InputDocument5 | My InputDocument5 DESCRIPTION | VIRTUAL | COORIGI 123@#$%$% | PRIVATE | 1 | | INPUT | 400 | inp_doc_original |
| Invalid inp doc published | 14414793652a5d718b65590036026581 | My InputDocument6 | My InputDocument6 DESCRIPTION | VIRTUAL | ORIGINAL | PRIV123234@##$$%% | 0 | | INPUT | 400 | inp_doc_published |
| Invalid inp doc versioning | 14414793652a5d718b65590036026581 | My InputDocument7 | My InputDocument7 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 87 | | INPUT | 400 | inp_doc_versioning |
| Create without id of project | | My InputDocument10 | My InputDocument10 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | project |
| Create without id of project | | My InputDocument10 | My InputDocument10 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | prj_uid |
| Create without inp doc form needed | 14414793652a5d718b65590036026581 | My InputDocument11 | My InputDocument11 DESCRIPTION | | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_form_needed |
| Create without inp doc original | 14414793652a5d718b65590036026581 | My InputDocument12 | My InputDocument12 DESCRIPTION | REAL | | PRIVATE | 1 | | INPUT | 400 | inp_doc_original |
| Create without inp doc published | 14414793652a5d718b65590036026581 | My InputDocument13 | My InputDocument13 DESCRIPTION | VREAL | ORIGINAL | | 1 | | INPUT | 400 | inp_doc_published |
| Create without inp doc title | 14414793652a5d718b65590036026581 | | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_title |
| Create without inp doc title | 14414793652a5d718b65590036026581 | | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_title |

View File

@@ -180,6 +180,40 @@ class DynaForm
}
}
/**
* Verify if doesn't exist the DynaForm in table DYNAFORM
*
* @param string $dynaFormUid Unique id of DynaForm
* @param string $processUid Unique id of Process
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if doesn't exist the DynaForm in table DYNAFORM
*/
public function throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $fieldNameForException)
{
try {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
if ($processUid != "") {
$criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
}
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist");
throw (new \Exception($msg));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the title of a DynaForm
*
@@ -265,9 +299,7 @@ class DynaForm
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
$this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]);
//Load DynaForm
$dynaForm = new \Dynaform();
@@ -277,6 +309,8 @@ class DynaForm
$processUid = $arrayDynaFormData["PRO_UID"];
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
if (isset($arrayData["DYN_TITLE"])) {
@@ -312,9 +346,7 @@ class DynaForm
{
try {
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
$this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]);
//Load DynaForm
$dynaForm = new \Dynaform();
@@ -408,7 +440,7 @@ class DynaForm
//Verify data
$process->throwExceptionIfNoExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID"));
$process->throwExceptionIfNotExistsDynaForm($processUidCopyImport, $dynaFormUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
$this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
//Copy/Import
//Create
@@ -840,9 +872,7 @@ class DynaForm
{
try {
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
$this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]);
//Get data
$criteria = $this->getDynaFormCriteria();

File diff suppressed because it is too large Load Diff

View File

@@ -420,40 +420,6 @@ class Process
}
}
/**
* Verify if doesn't exist the DynaForm in table DYNAFORM
*
* @param string $processUid Unique id of Process
* @param string $dynaFormUid Unique id of DynaForm
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if doesn't exist the DynaForm in table DYNAFORM
*/
public function throwExceptionIfNotExistsDynaForm($processUid, $dynaFormUid, $fieldNameForException)
{
try {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
if ($processUid != "") {
$criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
}
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist");
throw (new \Exception($msg));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if doesn't exist the Template in Routing Screen Template
*
@@ -553,7 +519,9 @@ class Process
}
if (isset($arrayData["PRO_SUMMARY_DYNAFORM"]) && $arrayData["PRO_SUMMARY_DYNAFORM"] . "" != "") {
$this->throwExceptionIfNotExistsDynaForm($processUid, $arrayData["PRO_SUMMARY_DYNAFORM"], $this->arrayFieldNameForException["processSummaryDynaform"]);
$dynaForm = new \BusinessModel\DynaForm();
$dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["PRO_SUMMARY_DYNAFORM"], $processUid, $this->arrayFieldNameForException["processSummaryDynaform"]);
}
if (isset($arrayData["PRO_DERIVATION_SCREEN_TPL"]) && $arrayData["PRO_DERIVATION_SCREEN_TPL"] . "" != "") {
@@ -1444,19 +1412,17 @@ class Process
public function getInputDocuments($processUid)
{
try {
//Verify data
$process = new \Process();
if (!$process->exists($processUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($processUid, "PROCESS"), "The UID \"{0}\" doesn't exist in table {1}")));
}
//Get data
$arrayInputDocument = array();
$inputdoc = new \BusinessModel\InputDocument();
//Verify data
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$criteria = $inputdoc->getInputDocumentCriteria();
//Get data
$inputDocument = new \BusinessModel\InputDocument();
$inputDocument->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
$inputDocument->setArrayFieldNameForException($this->arrayFieldNameForException);
$criteria = $inputDocument->getInputDocumentCriteria();
$criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
$criteria->addAscendingOrderByColumn("INP_DOC_TITLE");
@@ -1467,9 +1433,10 @@ class Process
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayInputDocument[] = $inputdoc->getInputDocumentDataFromRecord($row);
$arrayInputDocument[] = $inputDocument->getInputDocumentDataFromRecord($row);
}
//Return
return $arrayInputDocument;
} catch (\Exception $e) {
throw $e;

View File

@@ -151,7 +151,9 @@ class WebEntry
}
if ($dynaFormUid != "") {
$process->throwExceptionIfNotExistsDynaForm($processUid, $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
$dynaForm = new \BusinessModel\DynaForm();
$dynaForm->throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
}
//Get data
@@ -293,7 +295,10 @@ class WebEntry
}
$process->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]);
$process->throwExceptionIfNotExistsDynaForm($processUid, $arrayData["DYN_UID"], $this->arrayFieldNameForException["dynaFormUid"]);
$dynaForm = new \BusinessModel\DynaForm();
$dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
$task = new \Task();

View File

@@ -237,7 +237,7 @@ class Project extends Api
if ($mappedUid !== false) {
$flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid;
}
$mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result);
if ($mappedUid !== false) {
$flowData["FLO_ELEMENT_DEST"] = $mappedUid;
@@ -358,6 +358,8 @@ class Project extends Api
{
try {
$process = new \BusinessModel\Process();
$process->setFormatFieldNameInUppercase(false);
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$response = $process->getInputDocuments($prj_uid);

View File

@@ -12,17 +12,19 @@ use \Luracast\Restler\RestException;
class InputDocument extends Api
{
/**
* @url GET /:projectUid/input-document/:inputDocumentUid
* @url GET /:prj_uid/input-document/:inp_doc_uid
*
* @param string $inputDocumentUid {@min 32}{@max 32}
* @param string $projectUid {@min 32}{@max 32}
* @param string $inp_doc_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
*/
public function doGetInputDocument($inputDocumentUid, $projectUid)
public function doGetInputDocument($inp_doc_uid, $prj_uid)
{
try {
$inputdoc = new \BusinessModel\InputDocument();
$inputDocument = new \BusinessModel\InputDocument();
$inputDocument->setFormatFieldNameInUppercase(false);
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$response = $inputdoc->getInputDocument($inputDocumentUid);
$response = $inputDocument->getInputDocument($inp_doc_uid);
return $response;
} catch (\Exception $e) {
@@ -31,37 +33,21 @@ class InputDocument extends Api
}
/**
* @url POST /:projectUid/input-document
* @url POST /:prj_uid/input-document
*
* @param string $projectUid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
* @param array $request_data
* @param string $inp_doc_title {@from body}{@required true}
* @param string $inp_doc_description {@from body}
* @param string $inp_doc_form_needed {@from body}{@choice VIRTUAL,REAL,VREAL}
* @param string $inp_doc_original {@from body}{@choice ORIGINAL,COPY,COPYLEGAL}
* @param string $inp_doc_published {@from body}{@choice PRIVATE}
* @param int $inp_doc_versioning {@from body}{@choice 0,1}
* @param string $inp_doc_destination_path {@from body}
* @param string $inp_doc_tags {@from body}
*
* @status 201
*/
public function doPostInputDocument(
$projectUid,
$request_data,
$inp_doc_title = "",
$inp_doc_description = "",
$inp_doc_form_needed = "VIRTUAL",
$inp_doc_original = "ORIGINAL",
$inp_doc_published = "PRIVATE",
$inp_doc_versioning = 0,
$inp_doc_destination_path = "",
$inp_doc_tags = ""
) {
public function doPostInputDocument($prj_uid, $request_data)
{
try {
$inputdoc = new \BusinessModel\InputDocument();
$inputDocument = new \BusinessModel\InputDocument();
$inputDocument->setFormatFieldNameInUppercase(false);
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$arrayData = $inputdoc->create($projectUid, $request_data);
$arrayData = $inputDocument->create($prj_uid, $request_data);
$response = $arrayData;
@@ -72,54 +58,39 @@ class InputDocument extends Api
}
/**
* @url PUT /:projectUid/input-document/:inputDocumentUid
* @url PUT /:prj_uid/input-document/:inp_doc_uid
*
* @param string $inputDocumentUid {@min 32}{@max 32}
* @param string $projectUid {@min 32}{@max 32}
* @param string $inp_doc_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
* @param array $request_data
* @param string $inp_doc_title {@from body}
* @param string $inp_doc_description {@from body}
* @param string $inp_doc_form_needed {@from body}{@choice VIRTUAL,REAL,VREAL}
* @param string $inp_doc_original {@from body}{@choice ORIGINAL,COPY,COPYLEGAL}
* @param string $inp_doc_published {@from body}{@choice PRIVATE}
* @param int $inp_doc_versioning {@from body}{@choice 0,1}
* @param string $inp_doc_destination_path {@from body}
* @param string $inp_doc_tags {@from body}
*/
public function doPutInputDocument(
$inputDocumentUid,
$projectUid,
$request_data,
$inp_doc_title = "",
$inp_doc_description = "",
$inp_doc_form_needed = "VIRTUAL",
$inp_doc_original = "ORIGINAL",
$inp_doc_published = "PRIVATE",
$inp_doc_versioning = 0,
$inp_doc_destination_path = "",
$inp_doc_tags = ""
) {
public function doPutInputDocument($inp_doc_uid, $prj_uid, $request_data)
{
try {
$inputdoc = new \BusinessModel\InputDocument();
$inputDocument = new \BusinessModel\InputDocument();
$inputDocument->setFormatFieldNameInUppercase(false);
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$arrayData = $inputdoc->update($inputDocumentUid, $request_data);
$arrayData = $inputDocument->update($inp_doc_uid, $request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url DELETE /:projectUid/input-document/:inputDocumentUid
* @url DELETE /:prj_uid/input-document/:inp_doc_uid
*
* @param string $inputDocumentUid {@min 32}{@max 32}
* @param string $projectUid {@min 32}{@max 32}
* @param string $inp_doc_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
*/
public function doDeleteInputDocument($inputDocumentUid, $projectUid)
public function doDeleteInputDocument($inp_doc_uid, $prj_uid)
{
try {
$inputdoc = new \BusinessModel\InputDocument();
$inputDocument = new \BusinessModel\InputDocument();
$inputDocument->setFormatFieldNameInUppercase(false);
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
$inputdoc->delete($inputDocumentUid);
$inputDocument->delete($inp_doc_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}