ProcessMaker-MA "Dynaforms Resources (endpoints)"

- Se han implementado los siguientes Endpoints:
    GET    /api/1.0/{workspace}/project/{prj_uid}/dynaforms
    GET    /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
    POST   /api/1.0/{workspace}/project/{prj_uid}/dynaform
    PUT    /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
    DELETE /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
This commit is contained in:
Victor Saisa Lopez
2013-12-23 17:14:04 -04:00
parent 97e3660c26
commit defc377061
9 changed files with 1001 additions and 22 deletions

View File

@@ -5219,7 +5219,7 @@ class G
return in_array(strtolower($functionName), $allFunctions['user']);
}
/**
/**
* Constructor for inputFilter class. Only first parameter is required.
* @access constructor
* @data Mixed - input string/array-of-string to be 'cleaned'
@@ -5235,11 +5235,11 @@ class G
$filtro = new InputFilter($tagsArray , $attrArray, $tagsMethod, $attrMethod, $xssAuto);
return $filtro->process($data);
}
/**
* Stores a message in the log file, if the file size exceeds
* Stores a message in the log file, if the file size exceeds
* specified log file is renamed and a new one is created.
*
*
* @param type $message
* @param type $pathData
* @param type $file
@@ -5248,12 +5248,33 @@ class G
{
$config = System::getSystemConfiguration();
G::LoadSystem('logger');
$oLogger =& Logger::getSingleton($pathData, PATH_SEP, $file);
$oLogger->limitFile = $config['number_log_file'];
$oLogger->limitFile = $config['number_log_file'];
$oLogger->limitSize = $config['size_log_file'];
$oLogger->write($message);
}
/**
* Changes all keys in an array and sub-arrays
*
* @param array $arrayData The array to work on
* @param int $case Either CASE_UPPER or CASE_LOWER (default)
*
* return array Returns an array with its keys lower or uppercased, or false if $arrayData is not an array
*/
public static function array_change_key_case2($arrayData, $case = CASE_LOWER)
{
$arrayData = array_change_key_case($arrayData, $case);
foreach ($arrayData as $key => $value) {
if (is_array($value)) {
$arrayData[$key] = self::array_change_key_case2($value, $case);
}
}
return $arrayData;
}
}
/**

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,7 @@ class InputDocument
}
/**
* Checks if the title exists in the InputDocuments of Process
* Verify if the title exists in the InputDocuments of Process
*
* @param string $processUid Unique id of Process
* @param string $title Title
@@ -140,9 +140,9 @@ class InputDocument
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
$arrayData["inp_doc_uid"] = $inputDocumentUid;
unset($arrayData["inp_doc_uid"]);
return $arrayData;
return array_merge(array("inp_doc_uid" => $inputDocumentUid), $arrayData);
} catch (\Exception $e) {
throw $e;
}
@@ -297,6 +297,16 @@ class InputDocument
public function getInputDocumentDataFromRecord($record)
{
try {
$inputdoc = new \InputDocument();
if ($record["INP_DOC_TITLE"] . "" == "") {
//There is no transaltion for this Document name, try to get/regenerate the label
$arrayInputdocData = $inputdoc->load($record["INP_DOC_UID"]);
$record["INP_DOC_TITLE"] = $arrayInputdocData["INP_DOC_TITLE"];
$record["INP_DOC_DESCRIPTION"] = $arrayInputdocData["INP_DOC_DESCRIPTION"];
}
return array(
"inp_doc_uid" => $record["INP_DOC_UID"],
"inp_doc_title" => $record["INP_DOC_TITLE"],
@@ -342,14 +352,6 @@ class InputDocument
$row = $rsCriteria->getRow();
if ($row["INP_DOC_TITLE"] . "" == "") {
//There is no transaltion for this Document name, try to get/regenerate the label
$arrayInputdocData = $inputdoc->load($inputDocumentUid);
$row["INP_DOC_TITLE"] = $arrayInputdocData["INP_DOC_TITLE"];
$row["INP_DOC_DESCRIPTION"] = $arrayInputdocData["INP_DOC_DESCRIPTION"];
}
return $this->getInputDocumentDataFromRecord($row);
} catch (\Exception $e) {
throw $e;

View File

@@ -510,6 +510,48 @@ class Process
}
/**
* Get all DynaForms of a Process
*
* @param string $processUid Unique id of Process
*
* return array Return an array with all DynaForms of a Process
*/
public function getDynaForms($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
$arrayDynaForm = array();
$dynaForm = new \BusinessModel\DynaForm();
$criteria = $dynaForm->getDynaFormCriteria();
$criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
$criteria->addAscendingOrderByColumn("DYN_TITLE");
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayDynaForm[] = $dynaForm->getDynaFormDataFromRecord($row);
}
return $arrayDynaForm;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get all InputDocuments of a Process
*

View File

@@ -4,7 +4,7 @@ namespace BusinessModel;
class Step
{
/**
* Checks if exists the record in table STEP
* Verify if exists the record in table STEP
*
* @param string $taskUid Unique id of Task
* @param string $type Type of Step (DYNAFORM, INPUT_DOCUMENT, OUTPUT_DOCUMENT)
@@ -52,7 +52,7 @@ class Step
}
/**
* Checks if exists the "Object UID" in the corresponding table
* Verify if exists the "Object UID" in the corresponding table
*
* @param string $type Type of Step (DYNAFORM, INPUT_DOCUMENT, OUTPUT_DOCUMENT)
* @param string $objectUid Unique id of Object
@@ -149,9 +149,10 @@ class Step
$arrayData = $this->update($stepUid, $arrayData);
$arrayData["step_uid"] = $stepUid;
//Return
unset($arrayData["step_uid"]);
return $arrayData;
return array_merge(array("step_uid" => $stepUid), $arrayData);
} catch (\Exception $e) {
throw $e;
}

View File

@@ -4,7 +4,7 @@ namespace BusinessModel\Step;
class Trigger
{
/**
* Checks if exists the record in table STEP_TRIGGER
* Verify if exists the record in table STEP_TRIGGER
*
* @param string $stepUid Unique id of Step
* @param string $type Type (BEFORE, AFTER)

View File

@@ -61,6 +61,22 @@ class Project extends Api
}
}
/**
* @url GET /:projectUid/dynaforms
*/
public function doGetDynaForms($projectUid)
{
try {
$process = new \BusinessModel\Process();
$response = $process->getDynaForms($projectUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:projectUid/input-documents
*/

View File

@@ -0,0 +1,135 @@
<?php
namespace Services\Api\ProcessMaker\Project;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Project\DynaForm Api Controller
*
* @protected
*/
class DynaForm extends Api
{
/**
* @url GET /:projectUid/dynaform/:dynaFormUid
*/
public function doGetDynaForm($dynaFormUid, $projectUid)
{
try {
$dynaForm = new \BusinessModel\DynaForm();
$response = $dynaForm->getDynaForm($dynaFormUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url POST /:projectUid/dynaform
*
* @param string $projectUid
* @param DynaFormPostStructure $request_data
*
* @status 201
*/
public function doPostDynaForm($projectUid, DynaFormPostStructure $request_data = null)
{
try {
$dynaForm = new \BusinessModel\DynaForm();
$arrayData = $dynaForm->getArrayDataFromRequestData($request_data);
$arrayData = $dynaForm->defineCreate($projectUid, $arrayData);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url PUT /:projectUid/dynaform/:dynaFormUid
*
* @param string $dynaFormUid
* @param string $projectUid
* @param DynaFormPutStructure $request_data
*/
public function doPutDynaForm($dynaFormUid, $projectUid, DynaFormPutStructure $request_data = null)
{
try {
$dynaForm = new \BusinessModel\DynaForm();
$arrayData = $dynaForm->getArrayDataFromRequestData($request_data);
$arrayData = $dynaForm->update($dynaFormUid, $arrayData);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url DELETE /:projectUid/dynaform/:dynaFormUid
*/
public function doDeleteDynaForm($dynaFormUid, $projectUid)
{
try {
$dynaForm = new \BusinessModel\DynaForm();
$dynaForm->delete($dynaFormUid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}
class DynaFormPostStructure
{
/**
* @var string {@from body}{@required true}
*/
public $dyn_title;
/**
* @var string {@from body}
*/
public $dyn_description;
/**
* @var string {@from body}{@choice xmlform,grid}{@required true}
*/
public $dyn_type;
/**
* @var array {@from body}{@type associative}
*/
public $copy_import;
/**
* @var array {@from body}{@type associative}
*/
public $pmtable;
}
class DynaFormPutStructure
{
/**
* @var string {@from body}
*/
public $dyn_title;
/**
* @var string {@from body}
*/
public $dyn_description;
/**
* @var string {@from body}{@choice xmlform,grid}{@required true}
*/
public $dyn_type;
}

View File

@@ -20,6 +20,7 @@ debug = 1
project = "Services\Api\ProcessMaker\Project"
trigger2 = "Services\Api\ProcessMaker\Project\Trigger"
event = "Services\Api\ProcessMaker\Project\Event"
dynaform = "Services\Api\ProcessMaker\Project\DynaForm"
input-document = "Services\Api\ProcessMaker\Project\InputDocument"
output-documents = "Services\Api\ProcessMaker\Project\OutputDocuments"
supervisors = "Services\Api\ProcessMaker\Project\ProcessSupervisors"