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:
@@ -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 |
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -3,16 +3,103 @@ namespace BusinessModel;
|
||||
|
||||
class InputDocument
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"INP_DOC_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "inputDocumentUid"),
|
||||
|
||||
"INP_DOC_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "inputDocumentTitle"),
|
||||
"INP_DOC_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentDescription"),
|
||||
"INP_DOC_FORM_NEEDED" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("VIRTUAL", "REAL", "VREAL"), "fieldNameAux" => "inputDocumentFormNeeded"),
|
||||
"INP_DOC_ORIGINAL" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("ORIGINAL", "COPY", "COPYLEGAL"), "fieldNameAux" => "inputDocumentOriginal"),
|
||||
"INP_DOC_PUBLISHED" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("PRIVATE"), "fieldNameAux" => "inputDocumentPublished"),
|
||||
"INP_DOC_VERSIONING" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "inputDocumentVersioning"),
|
||||
"INP_DOC_DESTINATION_PATH" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentDestinationPath"),
|
||||
"INP_DOC_TAGS" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentTags")
|
||||
);
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
|
||||
private $arrayFieldNameForException = array(
|
||||
"processUid" => "PRO_UID"
|
||||
);
|
||||
|
||||
/**
|
||||
* Verify if the title exists in the InputDocuments of Process
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $title Title
|
||||
* return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the format of the fields name (uppercase, lowercase)
|
||||
*
|
||||
* @param bool $flag Value that set the format
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setFormatFieldNameInUppercase($flag)
|
||||
{
|
||||
try {
|
||||
$this->formatFieldNameInUppercase = $flag;
|
||||
|
||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set exception messages for fields
|
||||
*
|
||||
* @param array $arrayData Data with the fields
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setArrayFieldNameForException($arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the field according to the format
|
||||
*
|
||||
* @param string $fieldName Field name
|
||||
*
|
||||
* return string Return the field name according the format
|
||||
*/
|
||||
public function getFieldNameByFormatFieldName($fieldName)
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if exists the title of a InputDocument
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $inputDocumentTitle Title
|
||||
* @param string $inputDocumentUidExclude Unique id of InputDocument to exclude
|
||||
*
|
||||
* return bool Return true if the title exists in the InputDocuments of Process, false otherwise
|
||||
* return bool Return true if exists the title of a InputDocument, false otherwise
|
||||
*/
|
||||
public function titleExists($processUid, $title, $inputDocumentUidExclude = "")
|
||||
public function existsTitle($processUid, $inputDocumentTitle, $inputDocumentUidExclude = "")
|
||||
{
|
||||
try {
|
||||
$delimiter = \DBAdapter::getStringDelimiter();
|
||||
@@ -35,10 +122,9 @@ class InputDocument
|
||||
$criteria->add(\InputDocumentPeer::INP_DOC_UID, $inputDocumentUidExclude, \Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add("CT.CON_VALUE", $title, \Criteria::EQUAL);
|
||||
$criteria->add("CT.CON_VALUE", $inputDocumentTitle, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \InputDocumentPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
return true;
|
||||
@@ -50,6 +136,63 @@ class InputDocument
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the InputDocument in table INPUT_DOCUMENT
|
||||
*
|
||||
* @param string $inputDocumentUid Unique id of InputDocument
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the InputDocument in table INPUT_DOCUMENT
|
||||
*/
|
||||
public function throwExceptionIfNotExistsInputDocument($inputDocumentUid, $processUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID);
|
||||
|
||||
if ($processUid != "") {
|
||||
$criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\InputDocumentPeer::INP_DOC_UID, $inputDocumentUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \InputDocumentPeer::doSelectRS($criteria);
|
||||
|
||||
if (!$rsCriteria->next()) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentUid), "The InputDocument with {0}: {1}, does not exist");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if exists the title of a InputDocument
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $inputDocumentTitle Title
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
* @param string $inputDocumentUidExclude Unique id of InputDocument to exclude
|
||||
*
|
||||
* return void Throw exception if exists the title of a InputDocument
|
||||
*/
|
||||
public function throwExceptionIfExistsTitle($processUid, $inputDocumentTitle, $fieldNameForException, $inputDocumentUidExclude = "")
|
||||
{
|
||||
try {
|
||||
if ($this->existsTitle($processUid, $inputDocumentTitle, $inputDocumentUidExclude)) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentTitle), "The InputDocument title with {0}: \"{1}\", already exists");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create InputDocument for a Process
|
||||
*
|
||||
@@ -66,23 +209,13 @@ class InputDocument
|
||||
unset($arrayData["INP_DOC_UID"]);
|
||||
|
||||
//Verify data
|
||||
$process = new \Process();
|
||||
$process = new \BusinessModel\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}")));
|
||||
}
|
||||
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
|
||||
if (!isset($arrayData["INP_DOC_TITLE"])) {
|
||||
throw (new \Exception(str_replace(array("{0}"), array(strtolower("INP_DOC_TITLE")), "The \"{0}\" attribute is not defined")));
|
||||
}
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
||||
|
||||
if (isset($arrayData["INP_DOC_TITLE"]) && trim($arrayData["INP_DOC_TITLE"]) == "") {
|
||||
throw (new \Exception(str_replace(array("{0}"), array(strtolower("INP_DOC_TITLE")), "The \"{0}\" attribute is empty")));
|
||||
}
|
||||
|
||||
if (isset($arrayData["INP_DOC_TITLE"]) && $this->titleExists($processUid, $arrayData["INP_DOC_TITLE"])) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INPUT_NOT_SAVE")));
|
||||
}
|
||||
$this->throwExceptionIfExistsTitle($processUid, $arrayData["INP_DOC_TITLE"], $this->arrayFieldNameForException["inputDocumentTitle"]);
|
||||
|
||||
//Flags
|
||||
$flagDataDestinationPath = (isset($arrayData["INP_DOC_DESTINATION_PATH"]))? 1 : 0;
|
||||
@@ -109,11 +242,13 @@ class InputDocument
|
||||
unset($arrayData["INP_DOC_TAGS"]);
|
||||
}
|
||||
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
$arrayData = array_merge(array("INP_DOC_UID" => $inputDocumentUid), $arrayData);
|
||||
|
||||
unset($arrayData["inp_doc_uid"]);
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
return array_merge(array("inp_doc_uid" => $inputDocumentUid), $arrayData);
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -132,24 +267,23 @@ class InputDocument
|
||||
try {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
//Verify data
|
||||
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
|
||||
|
||||
//Load InputDocument
|
||||
$inputDocument = new \InputDocument();
|
||||
|
||||
$arrayInputDocumentData = $inputDocument->load($inputDocumentUid);
|
||||
|
||||
//Uids
|
||||
$processUid = $arrayInputDocumentData["PRO_UID"];
|
||||
|
||||
//Verify data
|
||||
if (!$inputDocument->InputExists($inputDocumentUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($inputDocumentUid, "INPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
$process = new \BusinessModel\Process();
|
||||
|
||||
if (isset($arrayData["INP_DOC_TITLE"]) && trim($arrayData["INP_DOC_TITLE"]) == "") {
|
||||
throw (new \Exception(str_replace(array("{0}"), array(strtolower("INP_DOC_TITLE")), "The \"{0}\" attribute is empty")));
|
||||
}
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
|
||||
|
||||
if (isset($arrayData["INP_DOC_TITLE"]) && $this->titleExists($processUid, $arrayData["INP_DOC_TITLE"], $inputDocumentUid)) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INPUT_NOT_SAVE")));
|
||||
if (isset($arrayData["INP_DOC_TITLE"])) {
|
||||
$this->throwExceptionIfExistsTitle($processUid, $arrayData["INP_DOC_TITLE"], $this->arrayFieldNameForException["inputDocumentTitle"], $inputDocumentUid);
|
||||
}
|
||||
|
||||
//Update
|
||||
@@ -160,7 +294,11 @@ class InputDocument
|
||||
//Return
|
||||
unset($arrayData["INP_DOC_UID"]);
|
||||
|
||||
return array_change_key_case($arrayData, CASE_LOWER);
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -177,11 +315,7 @@ class InputDocument
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$inputDocument = new \InputDocument();
|
||||
|
||||
if (!$inputDocument->InputExists($inputDocumentUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($inputDocumentUid, "INPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
|
||||
|
||||
//Delete
|
||||
//StepSupervisor
|
||||
@@ -266,31 +400,32 @@ class InputDocument
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* return array Return an array with data of an InputDocument
|
||||
* return array Return an array with data InputDocument
|
||||
*/
|
||||
public function getInputDocumentDataFromRecord($record)
|
||||
{
|
||||
try {
|
||||
if ($record["INP_DOC_TITLE"] . "" == "") {
|
||||
//Load InputDocument
|
||||
$inputDocument = new \InputDocument();
|
||||
|
||||
//There is no transaltion for this Document name, try to get/regenerate the label
|
||||
$arrayInputdocData = $inputDocument->load($record["INP_DOC_UID"]);
|
||||
$arrayInputDocumentData = $inputDocument->load($record["INP_DOC_UID"]);
|
||||
|
||||
$record["INP_DOC_TITLE"] = $arrayInputdocData["INP_DOC_TITLE"];
|
||||
$record["INP_DOC_DESCRIPTION"] = $arrayInputdocData["INP_DOC_DESCRIPTION"];
|
||||
//There is no transaltion for this Document name, try to get/regenerate the label
|
||||
$record["INP_DOC_TITLE"] = $arrayInputDocumentData["INP_DOC_TITLE"];
|
||||
$record["INP_DOC_DESCRIPTION"] = $arrayInputDocumentData["INP_DOC_DESCRIPTION"];
|
||||
}
|
||||
|
||||
return array(
|
||||
"inp_doc_uid" => $record["INP_DOC_UID"],
|
||||
"inp_doc_title" => $record["INP_DOC_TITLE"],
|
||||
"inp_doc_description" => $record["INP_DOC_DESCRIPTION"] . "",
|
||||
"inp_doc_form_needed" => $record["INP_DOC_FORM_NEEDED"],
|
||||
"inp_doc_original" => $record["INP_DOC_ORIGINAL"],
|
||||
"inp_doc_published" => $record["INP_DOC_PUBLISHED"],
|
||||
"inp_doc_versioning" => (int)($record["INP_DOC_VERSIONING"]),
|
||||
"inp_doc_destination_path" => $record["INP_DOC_DESTINATION_PATH"] . "",
|
||||
"inp_doc_tags" => $record["INP_DOC_TAGS"] . ""
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_UID") => $record["INP_DOC_UID"],
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_TITLE") => $record["INP_DOC_TITLE"],
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_DESCRIPTION") => $record["INP_DOC_DESCRIPTION"] . "",
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_FORM_NEEDED") => $record["INP_DOC_FORM_NEEDED"] . "",
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_ORIGINAL") => $record["INP_DOC_ORIGINAL"] . "",
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_PUBLISHED") => $record["INP_DOC_PUBLISHED"] . "",
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_VERSIONING") => (int)($record["INP_DOC_VERSIONING"]),
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_DESTINATION_PATH") => $record["INP_DOC_DESTINATION_PATH"] . "",
|
||||
$this->getFieldNameByFormatFieldName("INP_DOC_TAGS") => $record["INP_DOC_TAGS"] . ""
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
@@ -308,11 +443,7 @@ class InputDocument
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$inputDocument = new \InputDocument();
|
||||
|
||||
if (!$inputDocument->InputExists($inputDocumentUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($inputDocumentUid, "INPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
|
||||
|
||||
//Get data
|
||||
$criteria = $this->getInputDocumentCriteria();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user