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:
@@ -5219,7 +5219,7 @@ class G
|
|||||||
return in_array(strtolower($functionName), $allFunctions['user']);
|
return in_array(strtolower($functionName), $allFunctions['user']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for inputFilter class. Only first parameter is required.
|
* Constructor for inputFilter class. Only first parameter is required.
|
||||||
* @access constructor
|
* @access constructor
|
||||||
* @data Mixed - input string/array-of-string to be 'cleaned'
|
* @data Mixed - input string/array-of-string to be 'cleaned'
|
||||||
@@ -5235,11 +5235,11 @@ class G
|
|||||||
$filtro = new InputFilter($tagsArray , $attrArray, $tagsMethod, $attrMethod, $xssAuto);
|
$filtro = new InputFilter($tagsArray , $attrArray, $tagsMethod, $attrMethod, $xssAuto);
|
||||||
return $filtro->process($data);
|
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.
|
* specified log file is renamed and a new one is created.
|
||||||
*
|
*
|
||||||
* @param type $message
|
* @param type $message
|
||||||
* @param type $pathData
|
* @param type $pathData
|
||||||
* @param type $file
|
* @param type $file
|
||||||
@@ -5248,12 +5248,33 @@ class G
|
|||||||
{
|
{
|
||||||
$config = System::getSystemConfiguration();
|
$config = System::getSystemConfiguration();
|
||||||
G::LoadSystem('logger');
|
G::LoadSystem('logger');
|
||||||
|
|
||||||
$oLogger =& Logger::getSingleton($pathData, PATH_SEP, $file);
|
$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->limitSize = $config['size_log_file'];
|
||||||
$oLogger->write($message);
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
761
workflow/engine/src/BusinessModel/DynaForm.php
Normal file
761
workflow/engine/src/BusinessModel/DynaForm.php
Normal file
@@ -0,0 +1,761 @@
|
|||||||
|
<?php
|
||||||
|
namespace BusinessModel;
|
||||||
|
|
||||||
|
class DynaForm
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get data of unique ids of a DynaForm (Unique id of Process)
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
*
|
||||||
|
* return array
|
||||||
|
*/
|
||||||
|
public function getDataUids($dynaFormUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\DynaformPeer::PRO_UID);
|
||||||
|
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
|
||||||
|
|
||||||
|
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
if ($rsCriteria->next()) {
|
||||||
|
return $rsCriteria->getRow();
|
||||||
|
} else {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($dynaFormUid, "DYNAFORM"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if the title exists in the DynaForms of Process
|
||||||
|
*
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
* @param string $title Title
|
||||||
|
* @param string $dynaFormUidExclude Unique id of DynaForm to exclude
|
||||||
|
*
|
||||||
|
* return bool Return true if the title exists in the DynaForms of Process, false otherwise
|
||||||
|
*/
|
||||||
|
public function titleExists($processUid, $title, $dynaFormUidExclude = "")
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$delimiter = \DBAdapter::getStringDelimiter();
|
||||||
|
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
|
||||||
|
|
||||||
|
$criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
|
||||||
|
|
||||||
|
$arrayCondition = array();
|
||||||
|
$arrayCondition[] = array(\DynaformPeer::DYN_UID, "CT.CON_ID", \Criteria::EQUAL);
|
||||||
|
$arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "DYN_TITLE" . $delimiter, \Criteria::EQUAL);
|
||||||
|
$arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
|
||||||
|
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
||||||
|
|
||||||
|
$criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||||
|
|
||||||
|
if ($dynaFormUidExclude != "") {
|
||||||
|
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUidExclude, \Criteria::NOT_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
$criteria->add("CT.CON_VALUE", $title, \Criteria::EQUAL);
|
||||||
|
|
||||||
|
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
if ($rsCriteria->next()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if a DynaForm belongs to Process
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
*
|
||||||
|
* return bool Return true if a DynaForm belongs to Process, false otherwise
|
||||||
|
*/
|
||||||
|
public function dynaFormBelongsProcess($dynaFormUid, $processUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
|
||||||
|
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
|
||||||
|
$criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||||
|
|
||||||
|
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
if ($rsCriteria->next()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if a DynaForm is assigned some Steps
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
*
|
||||||
|
* return bool Return true if a DynaForm is assigned some Steps, false otherwise
|
||||||
|
*/
|
||||||
|
public function dynaFormAssignedStep($dynaFormUid, $processUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$step = new \Step();
|
||||||
|
|
||||||
|
$arrayData = $step->loadInfoAssigDynaform($processUid, $dynaFormUid);
|
||||||
|
|
||||||
|
if (is_array($arrayData)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if a DynaForm has relation with a Step Supervisor
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
*
|
||||||
|
* return bool Return true if a DynaForm has relation with a Step Supervisor, false otherwise
|
||||||
|
*/
|
||||||
|
public function dynaFormRelationStepSupervisor($dynaFormUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$stepSupervisor = new \StepSupervisor();
|
||||||
|
|
||||||
|
$arrayData = $stepSupervisor->loadInfo($dynaFormUid);
|
||||||
|
|
||||||
|
if (is_array($arrayData)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data from a request data
|
||||||
|
*
|
||||||
|
* @param object $requestData Request data
|
||||||
|
*
|
||||||
|
* return array Return an array with data of request data
|
||||||
|
*/
|
||||||
|
public function getArrayDataFromRequestData($requestData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$arrayData = array();
|
||||||
|
|
||||||
|
$requestData = (array)($requestData);
|
||||||
|
|
||||||
|
foreach ($requestData as $key => $value) {
|
||||||
|
$arrayData[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arrayData;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create DynaForm for a Process
|
||||||
|
*
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Return data of the new DynaForm created
|
||||||
|
*/
|
||||||
|
public function create($processUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
|
unset($arrayData["DYN_UID"]);
|
||||||
|
unset($arrayData["COPY_IMPORT"]);
|
||||||
|
unset($arrayData["PMTABLE"]);
|
||||||
|
|
||||||
|
//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}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["DYN_TITLE"]) && $this->titleExists($processUid, $arrayData["DYN_TITLE"])) {
|
||||||
|
throw (new \Exception(\G::LoadTranslation("ID_EXIST_DYNAFORM")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
$arrayData["PRO_UID"] = $processUid;
|
||||||
|
|
||||||
|
$dynaFormUid = $dynaForm->create($arrayData);
|
||||||
|
|
||||||
|
//Return
|
||||||
|
unset($arrayData["PRO_UID"]);
|
||||||
|
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||||
|
|
||||||
|
unset($arrayData["dyn_uid"]);
|
||||||
|
|
||||||
|
return array_merge(array("dyn_uid" => $dynaFormUid), $arrayData);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update DynaForm
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Return data of the DynaForm updated
|
||||||
|
*/
|
||||||
|
public function update($dynaFormUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
if (!$dynaForm->dynaformExists($dynaFormUid)) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($dynaFormUid, "DYNAFORM"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Uids
|
||||||
|
$arrayDataUid = $this->getDataUids($dynaFormUid);
|
||||||
|
|
||||||
|
$processUid = $arrayDataUid["PRO_UID"];
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if (isset($arrayData["DYN_TITLE"]) && $this->titleExists($processUid, $arrayData["DYN_TITLE"], $dynaFormUid)) {
|
||||||
|
throw (new \Exception(\G::LoadTranslation("ID_EXIST_DYNAFORM")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update
|
||||||
|
$arrayData["DYN_UID"] = $dynaFormUid;
|
||||||
|
|
||||||
|
$result = $dynaForm->update($arrayData);
|
||||||
|
|
||||||
|
//Return
|
||||||
|
unset($arrayData["DYN_UID"]);
|
||||||
|
|
||||||
|
return array_change_key_case($arrayData, CASE_LOWER);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete DynaForm
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
*
|
||||||
|
* return void
|
||||||
|
*/
|
||||||
|
public function delete($dynaFormUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Verify data
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
if (!$dynaForm->dynaformExists($dynaFormUid)) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($dynaFormUid, "DYNAFORM"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Uids
|
||||||
|
$arrayDataUid = $this->getDataUids($dynaFormUid);
|
||||||
|
|
||||||
|
$processUid = $arrayDataUid["PRO_UID"];
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if (!$this->dynaFormAssignedStep($dynaFormUid, $processUid)) {
|
||||||
|
throw (new \Exception("You cannot delete this Dynaform while it is assigned to a step"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Delete
|
||||||
|
//In table DYNAFORM
|
||||||
|
$result = $dynaForm->remove($dynaFormUid);
|
||||||
|
|
||||||
|
//In table STEP
|
||||||
|
$step = new \Step();
|
||||||
|
$step->removeStep("DYNAFORM", $dynaFormUid);
|
||||||
|
|
||||||
|
//In table OBJECT_PERMISSION
|
||||||
|
$objPermission = new \ObjectPermission();
|
||||||
|
$objPermission->removeByObject("DYNAFORM", $dynaFormUid);
|
||||||
|
|
||||||
|
//In table STEP_SUPERVISOR
|
||||||
|
$stepSupervisor = new \StepSupervisor();
|
||||||
|
$stepSupervisor->removeByObject("DYNAFORM", $dynaFormUid);
|
||||||
|
|
||||||
|
//In table CASE_TRACKER_OBJECT
|
||||||
|
$caseTrackerObject = new \CaseTrackerObject();
|
||||||
|
$caseTrackerObject->removeByObject("DYNAFORM", $dynaFormUid);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy/Import a DynaForm
|
||||||
|
*
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Return data of the new DynaForm created
|
||||||
|
*/
|
||||||
|
public function copyImport($processUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if (!isset($arrayData["COPY_IMPORT"]["PRJ_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array("PRJ_UID"), "For the creation the DynaForm, the attribute \"{0}\" doesn't exist")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["COPY_IMPORT"]["DYN_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array("DYN_UID"), "For the creation the DynaForm, the attribute \"{0}\" doesn't exist")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Copy/Import Uids
|
||||||
|
$processUidCopyImport = $arrayData["COPY_IMPORT"]["PRJ_UID"];
|
||||||
|
$dynaFormUidCopyImport = $arrayData["COPY_IMPORT"]["DYN_UID"];
|
||||||
|
|
||||||
|
unset($arrayData["COPY_IMPORT"]);
|
||||||
|
|
||||||
|
//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}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$process->exists($processUidCopyImport)) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($processUidCopyImport, "PROCESS"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
if (!$dynaForm->dynaformExists($dynaFormUidCopyImport)) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($dynaFormUidCopyImport, "DYNAFORM"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->dynaFormBelongsProcess($dynaFormUidCopyImport, $processUidCopyImport)) {
|
||||||
|
throw (new \Exception("The DynaForm for Copy/Import doesn't belongs to the Process"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Copy/Import
|
||||||
|
//Create
|
||||||
|
$arrayData = $this->create($processUid, $arrayData);
|
||||||
|
|
||||||
|
$dynaFormUid = $arrayData["dyn_uid"];
|
||||||
|
|
||||||
|
//Copy files of the DynaForm
|
||||||
|
$umaskOld = umask(0);
|
||||||
|
|
||||||
|
$fileXml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormUidCopyImport . ".xml";
|
||||||
|
|
||||||
|
if (file_exists($fileXml)) {
|
||||||
|
$fileXmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormUid . ".xml";
|
||||||
|
|
||||||
|
$fhXml = fopen($fileXml, "r");
|
||||||
|
$fhXmlCopy = fopen($fileXmlCopy, "w");
|
||||||
|
|
||||||
|
while (!feof($fhXml)) {
|
||||||
|
$strLine = fgets($fhXml, 4096);
|
||||||
|
$strLine = str_replace($processUidCopyImport . "/" . $dynaFormUidCopyImport, $processUid . "/" . $dynaFormUid, $strLine);
|
||||||
|
|
||||||
|
//DynaForm Grid
|
||||||
|
preg_match_all("/<.*type\s*=\s*[\"\']grid[\"\'].*xmlgrid\s*=\s*[\"\']\w{32}\/(\w{32})[\"\'].*\/>/", $strLine, $arrayMatch, PREG_SET_ORDER);
|
||||||
|
|
||||||
|
foreach ($arrayMatch as $value) {
|
||||||
|
$dynaFormGridUidCopyImport = $value[1];
|
||||||
|
|
||||||
|
//Get data
|
||||||
|
$criteria = new \Criteria();
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\ContentPeer::CON_VALUE);
|
||||||
|
$criteria->add(\ContentPeer::CON_ID, $dynaFormGridUidCopyImport);
|
||||||
|
$criteria->add(\ContentPeer::CON_CATEGORY, "DYN_TITLE");
|
||||||
|
$criteria->add(\ContentPeer::CON_LANG, SYS_LANG);
|
||||||
|
|
||||||
|
$rsCriteria = \ContentPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
$rsCriteria->next();
|
||||||
|
$row = $rsCriteria->getRow();
|
||||||
|
|
||||||
|
$dynGrdTitleCopyImport = $row["CON_VALUE"];
|
||||||
|
|
||||||
|
$criteria = new \Criteria();
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\ContentPeer::CON_VALUE);
|
||||||
|
$criteria->add(\ContentPeer::CON_ID, $dynaFormGridUidCopyImport);
|
||||||
|
$criteria->add(\ContentPeer::CON_CATEGORY, "DYN_DESCRIPTION");
|
||||||
|
$criteria->add(\ContentPeer::CON_LANG, SYS_LANG);
|
||||||
|
|
||||||
|
$rsCriteria = \ContentPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
$rsCriteria->next();
|
||||||
|
$row = $rsCriteria->getRow();
|
||||||
|
|
||||||
|
$dynGrdDescriptionCopyImport = $row["CON_VALUE"];
|
||||||
|
|
||||||
|
//Create Grid
|
||||||
|
$arrayDataAux = array(
|
||||||
|
"PRO_UID" => $processUid,
|
||||||
|
"DYN_TITLE" => $dynGrdTitleCopyImport,
|
||||||
|
"DYN_DESCRIPTION" => $dynGrdDescriptionCopyImport,
|
||||||
|
"DYN_TYPE" => "grid"
|
||||||
|
);
|
||||||
|
|
||||||
|
$dynaFormGrid = new \Dynaform();
|
||||||
|
|
||||||
|
$dynaFormGridUid = $dynaFormGrid->create($arrayDataAux);
|
||||||
|
|
||||||
|
//Copy files of the DynaForm Grid
|
||||||
|
$fileGridXml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormGridUidCopyImport . ".xml";
|
||||||
|
|
||||||
|
if (file_exists($fileGridXml)) {
|
||||||
|
$fileGridXmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormGridUid . ".xml";
|
||||||
|
|
||||||
|
$fhGridXml = fopen($fileGridXml, "r");
|
||||||
|
$fhGridXmlCopy = fopen($fileGridXmlCopy, "w");
|
||||||
|
|
||||||
|
while (!feof($fhGridXml)) {
|
||||||
|
$strLineAux = fgets($fhGridXml, 4096);
|
||||||
|
$strLineAux = str_replace($processUidCopyImport . "/" . $dynaFormGridUidCopyImport, $processUid . "/" . $dynaFormGridUid, $strLineAux);
|
||||||
|
|
||||||
|
fwrite($fhGridXmlCopy, $strLineAux);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fhGridXmlCopy);
|
||||||
|
fclose($fhGridXml);
|
||||||
|
|
||||||
|
chmod($fileGridXmlCopy, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileGridHtml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormGridUidCopyImport . ".html";
|
||||||
|
|
||||||
|
if (file_exists($fileGridHtml)) {
|
||||||
|
$fileGridHtmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormGridUid . ".html";
|
||||||
|
|
||||||
|
copy($fileGridHtml, $fileGridHtmlCopy);
|
||||||
|
|
||||||
|
chmod($fileGridHtmlCopy, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
$strLine = str_replace($processUidCopyImport . "/" . $dynaFormGridUidCopyImport, $processUid . "/" . $dynaFormGridUid, $strLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite($fhXmlCopy, $strLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fhXmlCopy);
|
||||||
|
fclose($fhXml);
|
||||||
|
|
||||||
|
chmod($fileXmlCopy, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileHtml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormUidCopyImport . ".html";
|
||||||
|
|
||||||
|
if (file_exists($fileHtml)) {
|
||||||
|
$fileHtmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormUid . ".html";
|
||||||
|
|
||||||
|
copy($fileHtml, $fileHtmlCopy);
|
||||||
|
|
||||||
|
chmod($fileHtmlCopy, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Copy if there are conditions attached to the DynaForm
|
||||||
|
$fieldCondition = new \FieldCondition();
|
||||||
|
|
||||||
|
$arrayCondition = $fieldCondition->getAllByDynUid($dynaFormUidCopyImport);
|
||||||
|
|
||||||
|
foreach ($arrayCondition as $condition) {
|
||||||
|
$condition["FCD_UID"] = "";
|
||||||
|
$condition["FCD_DYN_UID"] = $dynaFormUid;
|
||||||
|
|
||||||
|
$fieldCondition->quickSave($condition);
|
||||||
|
}
|
||||||
|
|
||||||
|
umask($umaskOld);
|
||||||
|
|
||||||
|
//Return
|
||||||
|
return $arrayData;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Dynaform based on a PMTable
|
||||||
|
*
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Return data of the new DynaForm created
|
||||||
|
*/
|
||||||
|
public function createBasedPmTable($processUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
|
unset($arrayData["DYN_UID"]);
|
||||||
|
unset($arrayData["COPY_IMPORT"]);
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if (!isset($arrayData["PMTABLE"]["TAB_UID"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array("TAB_UID"), "For the creation the DynaForm, the attribute \"{0}\" doesn't exist")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["PMTABLE"]["FIELDS"])) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array("FIELDS"), "For the creation the DynaForm, the attribute \"{0}\" doesn't exist")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($arrayData["PMTABLE"]["FIELDS"]) == 0) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array("FIELDS"), "For the creation the DynaForm, the attribute \"{0}\" is empty")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//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}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["DYN_TITLE"]) && $this->titleExists($processUid, $arrayData["DYN_TITLE"])) {
|
||||||
|
throw (new \Exception(\G::LoadTranslation("ID_EXIST_DYNAFORM")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["DYN_TYPE"]) && $arrayData["DYN_TYPE"] == "grid") {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array("DYN_TYPE"), "For the creation the DynaForm, the attribute \"{0}\" is invalid")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null(\AdditionalTablesPeer::retrieveByPK($arrayData["PMTABLE"]["TAB_UID"]))) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayData["PMTABLE"]["TAB_UID"], "ADDITIONAL_TABLES"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set data
|
||||||
|
$tableUid = $arrayData["PMTABLE"]["TAB_UID"];
|
||||||
|
$arrayFields = $arrayData["PMTABLE"]["FIELDS"];
|
||||||
|
|
||||||
|
unset($arrayData["PMTABLE"]);
|
||||||
|
|
||||||
|
//Create
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
$arrayData["PRO_UID"] = $processUid;
|
||||||
|
$arrayData["DYN_TYPE"] = "xmlform";
|
||||||
|
$arrayData["FIELDS"] = $arrayFields;
|
||||||
|
|
||||||
|
$dynaForm->createFromPMTable($arrayData, $tableUid);
|
||||||
|
|
||||||
|
$dynaFormUid = $dynaForm->getDynUid();
|
||||||
|
|
||||||
|
//Return
|
||||||
|
unset($arrayData["PRO_UID"]);
|
||||||
|
unset($arrayData["FIELDS"]);
|
||||||
|
|
||||||
|
$arrayData = \G::array_change_key_case2($arrayData, CASE_LOWER);
|
||||||
|
|
||||||
|
unset($arrayData["dyn_uid"]);
|
||||||
|
|
||||||
|
return array_merge(array("dyn_uid" => $dynaFormUid), $arrayData);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the method for create a DynaForm
|
||||||
|
*
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Return data of the new DynaForm created
|
||||||
|
*/
|
||||||
|
public function defineCreate($processUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$option = "NORMAL";
|
||||||
|
|
||||||
|
//Validate data
|
||||||
|
$count = 0;
|
||||||
|
$msgMethod = "";
|
||||||
|
|
||||||
|
if (isset($arrayData["copy_import"])) {
|
||||||
|
$count = $count + 1;
|
||||||
|
$msgMethod = (($msgMethod != "")? ", " : "") . $msgMethod . "COPY_IMPORT";
|
||||||
|
|
||||||
|
$option = "COPY_IMPORT";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["pmtable"])) {
|
||||||
|
$count = $count + 1;
|
||||||
|
$msgMethod = (($msgMethod != "")? ", " : "") . $msgMethod . "PMTABLE";
|
||||||
|
|
||||||
|
$option = "PMTABLE";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($count <= 1) {
|
||||||
|
$arrayDataAux = array();
|
||||||
|
|
||||||
|
switch ($option) {
|
||||||
|
case "COPY_IMPORT":
|
||||||
|
$arrayDataAux = $this->copyImport($processUid, $arrayData);
|
||||||
|
break;
|
||||||
|
case "PMTABLE":
|
||||||
|
$arrayDataAux = $this->createBasedPmTable($processUid, $arrayData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//NORMAL
|
||||||
|
$arrayDataAux = $this->create($processUid, $arrayData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return
|
||||||
|
return $arrayDataAux;
|
||||||
|
} else {
|
||||||
|
throw (new \Exception(str_replace(array("{0}"), array($msgMethod), "It is trying to create a DynaForm by \"{0}\", please send only one attribute for creation")));
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get criteria for DynaForm
|
||||||
|
*
|
||||||
|
* return object
|
||||||
|
*/
|
||||||
|
public function getDynaFormCriteria()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$delimiter = \DBAdapter::getStringDelimiter();
|
||||||
|
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
|
||||||
|
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
|
||||||
|
$criteria->addAsColumn("DYN_TITLE", "CT.CON_VALUE");
|
||||||
|
$criteria->addAsColumn("DYN_DESCRIPTION", "CD.CON_VALUE");
|
||||||
|
$criteria->addSelectColumn(\DynaformPeer::DYN_TYPE);
|
||||||
|
|
||||||
|
$criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
|
||||||
|
$criteria->addAlias("CD", \ContentPeer::TABLE_NAME);
|
||||||
|
|
||||||
|
$arrayCondition = array();
|
||||||
|
$arrayCondition[] = array(\DynaformPeer::DYN_UID, "CT.CON_ID", \Criteria::EQUAL);
|
||||||
|
$arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "DYN_TITLE" . $delimiter, \Criteria::EQUAL);
|
||||||
|
$arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
|
||||||
|
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
||||||
|
|
||||||
|
$arrayCondition = array();
|
||||||
|
$arrayCondition[] = array(\DynaformPeer::DYN_UID, "CD.CON_ID", \Criteria::EQUAL);
|
||||||
|
$arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "DYN_DESCRIPTION" . $delimiter, \Criteria::EQUAL);
|
||||||
|
$arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
|
||||||
|
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
||||||
|
|
||||||
|
return $criteria;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data of a DynaForm from a record
|
||||||
|
*
|
||||||
|
* @param array $record Record
|
||||||
|
*
|
||||||
|
* return array Return an array with data of a DynaForm
|
||||||
|
*/
|
||||||
|
public function getDynaFormDataFromRecord($record)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($record["DYN_TITLE"] . "" == "") {
|
||||||
|
//There is no transaltion for this Document name, try to get/regenerate the label
|
||||||
|
$record["DYN_TITLE"] = \Content::load("DYN_TITLE", "", $record["DYN_UID"], SYS_LANG);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($record["DYN_DESCRIPTION"] . "" == "") {
|
||||||
|
//There is no transaltion for this Document name, try to get/regenerate the label
|
||||||
|
$record["DYN_DESCRIPTION"] = \Content::load("DYN_DESCRIPTION", "", $record["DYN_UID"], SYS_LANG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"dyn_uid" => $record["DYN_UID"],
|
||||||
|
"dyn_title" => $record["DYN_TITLE"],
|
||||||
|
"dyn_description" => $record["DYN_DESCRIPTION"] . "",
|
||||||
|
"dyn_type" => $record["DYN_TYPE"] . ""
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data of a DynaForm
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
*
|
||||||
|
* return array Return an array with data of a DynaForm
|
||||||
|
*/
|
||||||
|
public function getDynaForm($dynaFormUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Verify data
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
if (!$dynaForm->dynaformExists($dynaFormUid)) {
|
||||||
|
throw (new \Exception(str_replace(array("{0}", "{1}"), array($dynaFormUid, "DYNAFORM"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get data
|
||||||
|
$criteria = $this->getDynaFormCriteria();
|
||||||
|
|
||||||
|
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
|
||||||
|
|
||||||
|
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
$rsCriteria->next();
|
||||||
|
|
||||||
|
$row = $rsCriteria->getRow();
|
||||||
|
|
||||||
|
return $this->getDynaFormDataFromRecord($row);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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 $processUid Unique id of Process
|
||||||
* @param string $title Title
|
* @param string $title Title
|
||||||
@@ -140,9 +140,9 @@ class InputDocument
|
|||||||
|
|
||||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
$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) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
@@ -297,6 +297,16 @@ class InputDocument
|
|||||||
public function getInputDocumentDataFromRecord($record)
|
public function getInputDocumentDataFromRecord($record)
|
||||||
{
|
{
|
||||||
try {
|
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(
|
return array(
|
||||||
"inp_doc_uid" => $record["INP_DOC_UID"],
|
"inp_doc_uid" => $record["INP_DOC_UID"],
|
||||||
"inp_doc_title" => $record["INP_DOC_TITLE"],
|
"inp_doc_title" => $record["INP_DOC_TITLE"],
|
||||||
@@ -342,14 +352,6 @@ class InputDocument
|
|||||||
|
|
||||||
$row = $rsCriteria->getRow();
|
$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);
|
return $this->getInputDocumentDataFromRecord($row);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|||||||
@@ -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
|
* Get all InputDocuments of a Process
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace BusinessModel;
|
|||||||
class Step
|
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 $taskUid Unique id of Task
|
||||||
* @param string $type Type of Step (DYNAFORM, INPUT_DOCUMENT, OUTPUT_DOCUMENT)
|
* @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 $type Type of Step (DYNAFORM, INPUT_DOCUMENT, OUTPUT_DOCUMENT)
|
||||||
* @param string $objectUid Unique id of Object
|
* @param string $objectUid Unique id of Object
|
||||||
@@ -149,9 +149,10 @@ class Step
|
|||||||
|
|
||||||
$arrayData = $this->update($stepUid, $arrayData);
|
$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) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace BusinessModel\Step;
|
|||||||
class Trigger
|
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 $stepUid Unique id of Step
|
||||||
* @param string $type Type (BEFORE, AFTER)
|
* @param string $type Type (BEFORE, AFTER)
|
||||||
|
|||||||
@@ -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
|
* @url GET /:projectUid/input-documents
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ debug = 1
|
|||||||
project = "Services\Api\ProcessMaker\Project"
|
project = "Services\Api\ProcessMaker\Project"
|
||||||
trigger2 = "Services\Api\ProcessMaker\Project\Trigger"
|
trigger2 = "Services\Api\ProcessMaker\Project\Trigger"
|
||||||
event = "Services\Api\ProcessMaker\Project\Event"
|
event = "Services\Api\ProcessMaker\Project\Event"
|
||||||
|
dynaform = "Services\Api\ProcessMaker\Project\DynaForm"
|
||||||
input-document = "Services\Api\ProcessMaker\Project\InputDocument"
|
input-document = "Services\Api\ProcessMaker\Project\InputDocument"
|
||||||
output-documents = "Services\Api\ProcessMaker\Project\OutputDocuments"
|
output-documents = "Services\Api\ProcessMaker\Project\OutputDocuments"
|
||||||
supervisors = "Services\Api\ProcessMaker\Project\ProcessSupervisors"
|
supervisors = "Services\Api\ProcessMaker\Project\ProcessSupervisors"
|
||||||
|
|||||||
Reference in New Issue
Block a user