2013-12-05 20:41:21 -04:00
|
|
|
<?php
|
2014-04-02 17:02:02 -04:00
|
|
|
namespace ProcessMaker\Services\Api;
|
2013-12-05 20:41:21 -04:00
|
|
|
|
|
|
|
|
use Luracast\Restler\RestException;
|
|
|
|
|
use ProcessMaker\Services\Api;
|
2014-02-20 10:50:52 -04:00
|
|
|
use \ProcessMaker\Project\Adapter;
|
|
|
|
|
use \ProcessMaker\Util;
|
2015-11-20 18:57:26 -04:00
|
|
|
use \ProcessMaker\Util\DateTime;
|
|
|
|
|
use \ProcessMaker\BusinessModel\Validator;
|
2016-03-18 15:17:00 -04:00
|
|
|
use \ProcessMaker\BusinessModel\Migrator\GranularExporter;
|
|
|
|
|
use \ProcessMaker\BusinessModel\Migrator\ExportObjects;
|
|
|
|
|
use \ProcessMaker\Util\IO\HttpStream;
|
2013-12-05 20:41:21 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Project
|
|
|
|
|
*
|
|
|
|
|
* @package Services\Api\ProcessMaker
|
|
|
|
|
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class Project extends Api
|
|
|
|
|
{
|
2015-11-20 18:57:26 -04:00
|
|
|
private $arrayFieldIso8601 = [
|
|
|
|
|
"prj_create_date",
|
|
|
|
|
"prj_update_date",
|
|
|
|
|
"pro_update_date",
|
|
|
|
|
"pro_create_date",
|
|
|
|
|
"dyn_update_date"
|
|
|
|
|
];
|
|
|
|
|
|
2014-04-24 16:05:42 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET
|
|
|
|
|
*/
|
|
|
|
|
public function doGetProjects()
|
2013-12-05 23:01:02 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-02-05 12:33:36 -04:00
|
|
|
$start = null;
|
|
|
|
|
$limit = null;
|
|
|
|
|
$filter = "";
|
2013-12-05 23:01:02 -04:00
|
|
|
|
2014-02-20 10:50:52 -04:00
|
|
|
$projects = Adapter\BpmnWorkflow::getList($start, $limit, $filter, CASE_LOWER);
|
2014-02-05 14:09:48 -04:00
|
|
|
|
2015-11-20 18:57:26 -04:00
|
|
|
return DateTime::convertUtcToIso8601($projects, $this->arrayFieldIso8601);
|
2013-12-05 23:01:02 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 20:41:21 -04:00
|
|
|
|
2014-04-24 16:05:42 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetProject($prj_uid)
|
2014-01-28 17:01:26 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2015-11-20 18:57:26 -04:00
|
|
|
$project = Adapter\BpmnWorkflow::getStruct($prj_uid);
|
|
|
|
|
|
2017-04-24 10:23:07 -04:00
|
|
|
$userProperty = new \UsersProperties();
|
|
|
|
|
$property = $userProperty->loadOrCreateIfNotExists($this->getUserId());
|
|
|
|
|
$project['usr_setting_designer'] = isset($property['USR_SETTING_DESIGNER']) ? \G::json_decode($property['USR_SETTING_DESIGNER']) : null;
|
2015-11-20 18:57:26 -04:00
|
|
|
return DateTime::convertUtcToIso8601($project, $this->arrayFieldIso8601);
|
2014-01-28 17:01:26 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-17 11:24:37 -04:00
|
|
|
/**
|
2014-05-07 15:55:51 -04:00
|
|
|
* Post Project
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_name
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @url POST
|
2013-12-17 11:24:37 -04:00
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-05-07 16:49:58 -04:00
|
|
|
public function post($prj_name, $request_data)
|
2013-12-05 20:41:21 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-05-14 15:56:05 -04:00
|
|
|
if (!isset($request_data['prj_author'])) {
|
|
|
|
|
$request_data['prj_author'] = $this->getUserId();
|
|
|
|
|
}
|
2015-11-20 18:57:26 -04:00
|
|
|
Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
|
|
|
|
|
return Adapter\BpmnWorkflow::createFromStruct(DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
|
2013-12-05 20:41:21 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-25 14:47:00 -04:00
|
|
|
/**
|
|
|
|
|
* @url PUT /:prj_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doPutProject($prj_uid, $request_data)
|
2013-12-23 17:17:01 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2017-04-21 15:12:34 -04:00
|
|
|
if (array_key_exists('usr_setting_designer', $request_data)) {
|
2017-04-24 15:36:22 -04:00
|
|
|
$oUserProperty = new \UsersProperties();
|
|
|
|
|
$property = $oUserProperty->loadOrCreateIfNotExists($this->getUserId());
|
2017-04-24 10:23:07 -04:00
|
|
|
$propertyArray = isset($property['USR_SETTING_DESIGNER']) ? \G::json_decode($property['USR_SETTING_DESIGNER'], true) : [];
|
|
|
|
|
$usrSettingDesigner = array_merge($propertyArray, $request_data['usr_setting_designer']);
|
2017-04-24 10:11:16 -04:00
|
|
|
$property['USR_SETTING_DESIGNER'] = \G::json_encode($usrSettingDesigner);
|
|
|
|
|
$oUserProperty->update($property);
|
2017-04-21 15:12:34 -04:00
|
|
|
unset($request_data['usr_setting_designer']);
|
2017-04-21 14:52:57 -04:00
|
|
|
}
|
|
|
|
|
|
2015-11-20 18:57:26 -04:00
|
|
|
Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
|
|
|
|
|
return Adapter\BpmnWorkflow::updateFromStruct($prj_uid, DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
|
2013-12-05 20:44:28 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
2013-12-05 20:41:21 -04:00
|
|
|
}
|
2013-12-13 12:57:02 -04:00
|
|
|
|
2014-04-25 11:38:53 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $prj_uid {@min 1}{@max 32}
|
|
|
|
|
* @url DELETE /:prj_uid
|
|
|
|
|
*/
|
|
|
|
|
public function delete($prj_uid)
|
2014-01-24 17:55:42 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-25 11:38:53 -04:00
|
|
|
$oBpmnWf = Adapter\BpmnWorkflow::load($prj_uid);
|
|
|
|
|
$oBpmnWf->remove();
|
2014-01-24 17:55:42 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 15:17:00 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid/export/listObjects
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
* @return mixed|string
|
|
|
|
|
* @throws RestException
|
|
|
|
|
*/
|
|
|
|
|
public function objectList($prj_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$exportProcess= new ExportObjects();
|
|
|
|
|
$result = $exportProcess->objectList($prj_uid);
|
|
|
|
|
return $result;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid/export-granular
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
* @param string $objects
|
|
|
|
|
*/
|
|
|
|
|
public function exportGranular($prj_uid, $objects)
|
|
|
|
|
{
|
2016-03-18 17:41:38 -04:00
|
|
|
$objects = \G::json_decode($objects);
|
2016-03-18 15:17:00 -04:00
|
|
|
$granularExporter = new GranularExporter($prj_uid);
|
2016-03-21 18:05:02 -04:00
|
|
|
$outputFilename = $granularExporter->export($objects);
|
|
|
|
|
$outputFilename = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'files' . PATH_SEP . 'output' .
|
2016-03-21 15:55:35 -04:00
|
|
|
PATH_SEP . $outputFilename;
|
2016-03-18 15:17:00 -04:00
|
|
|
$httpStream = new HttpStream();
|
|
|
|
|
$fileExtension = pathinfo($outputFilename, PATHINFO_EXTENSION);
|
2017-06-06 15:21:42 -04:00
|
|
|
|
|
|
|
|
\G::auditLog('ExportProcess','Export process "' . $granularExporter->getProjectName() . '"');
|
|
|
|
|
|
2016-03-18 15:17:00 -04:00
|
|
|
$httpStream->loadFromFile($outputFilename);
|
|
|
|
|
$httpStream->setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
|
|
|
$httpStream->send();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-28 12:57:55 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid/export
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function export($prj_uid)
|
|
|
|
|
{
|
|
|
|
|
$exporter = new \ProcessMaker\Exporter\XmlExporter($prj_uid);
|
2015-11-20 18:57:26 -04:00
|
|
|
$getProjectName = $exporter->truncateName($exporter->getProjectName(), false);
|
2014-03-28 12:57:55 -04:00
|
|
|
|
|
|
|
|
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
2015-05-25 09:22:48 -04:00
|
|
|
$version = \ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
|
|
|
|
|
$outputFilename = $outputDir . sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
2014-03-28 12:57:55 -04:00
|
|
|
|
2014-05-07 09:24:46 -04:00
|
|
|
$exporter->setMetadata("export_version", $version);
|
2015-05-25 12:07:40 -04:00
|
|
|
$outputFilename = $outputDir . $exporter->saveExport($outputFilename);
|
2014-03-28 12:57:55 -04:00
|
|
|
|
|
|
|
|
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
|
|
|
|
$fileExtension = pathinfo($outputFilename, PATHINFO_EXTENSION);
|
|
|
|
|
|
2017-06-06 15:21:42 -04:00
|
|
|
\G::auditLog('ExportProcess','Export process "' . $exporter->getProjectName() . '"');
|
|
|
|
|
|
2014-03-28 12:57:55 -04:00
|
|
|
$httpStream->loadFromFile($outputFilename);
|
2014-05-09 16:49:31 -04:00
|
|
|
$httpStream->setHeader("Content-Type", "application/xml; charset=UTF-8");
|
2014-03-28 12:57:55 -04:00
|
|
|
$httpStream->send();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-05 12:19:20 -04:00
|
|
|
/**
|
|
|
|
|
* @url POST /import
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
*
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-05-16 11:22:53 -04:00
|
|
|
public function doPostImport(array $request_data, $option = null, $option_group = null)
|
2014-05-05 12:19:20 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$importer = new \ProcessMaker\Importer\XmlImporter();
|
|
|
|
|
|
2014-05-12 15:24:19 -04:00
|
|
|
$importer->setSaveDir(PATH_DOCUMENT . "input");
|
2014-05-05 12:19:20 -04:00
|
|
|
$importer->setData("usr_uid", $this->getUserId());
|
|
|
|
|
|
2014-05-16 11:22:53 -04:00
|
|
|
$arrayData = $importer->importPostFile(
|
|
|
|
|
$request_data,
|
|
|
|
|
$option,
|
|
|
|
|
$option_group,
|
|
|
|
|
array("projectFile" => "project_file", "option" => "option", "optionGroup" => "option_group")
|
|
|
|
|
);
|
2014-05-05 12:19:20 -04:00
|
|
|
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-19 17:59:00 -04:00
|
|
|
|
2015-07-09 17:21:01 -04:00
|
|
|
/**
|
|
|
|
|
* @url POST /save-as
|
2016-08-19 17:59:00 -04:00
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@from body}
|
|
|
|
|
* @param string $prj_name {@from body}
|
|
|
|
|
* @param string $prj_description {@from body}
|
|
|
|
|
* @param string $prj_category {@from body}
|
2015-07-09 17:21:01 -04:00
|
|
|
*/
|
2016-08-19 17:59:00 -04:00
|
|
|
public function doSaveAs($prj_uid, $prj_name, $prj_description = null, $prj_category = null)
|
2015-07-09 17:21:01 -04:00
|
|
|
{
|
|
|
|
|
$importer = new \ProcessMaker\Importer\XmlImporter();
|
2017-04-11 14:57:56 -04:00
|
|
|
return $importer->saveAs($prj_uid, $prj_name, $prj_description, $prj_category, $this->getUserId());
|
2015-07-09 17:21:01 -04:00
|
|
|
}
|
2014-05-05 12:19:20 -04:00
|
|
|
|
2014-02-04 17:34:29 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid/process
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetProcess($prj_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
2014-02-04 17:34:29 -04:00
|
|
|
$process->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
|
|
|
|
|
|
|
|
|
$response = $process->getProcess($prj_uid);
|
|
|
|
|
|
2015-11-20 18:57:26 -04:00
|
|
|
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
|
|
|
|
|
2014-02-04 17:34:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url PUT /:prj_uid/process
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
*/
|
|
|
|
|
public function doPutProcess($prj_uid, $request_data)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2015-11-20 18:57:26 -04:00
|
|
|
Validator::throwExceptionIfDataNotMetIso8601Format($request_data, $this->arrayFieldIso8601);
|
2014-04-02 17:02:02 -04:00
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
2014-02-04 17:34:29 -04:00
|
|
|
$process->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
|
|
|
|
|
2015-11-20 18:57:26 -04:00
|
|
|
$arrayData = $process->update($prj_uid, DateTime::convertDataToUtc($request_data, $this->arrayFieldIso8601));
|
2014-02-04 17:34:29 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 17:18:48 -04:00
|
|
|
/**
|
2014-07-29 16:10:58 -04:00
|
|
|
* @url POST /generate-bpmn
|
2014-07-24 17:18:48 -04:00
|
|
|
*
|
2014-07-29 16:10:58 -04:00
|
|
|
* @param array $request_data
|
2014-07-24 17:18:48 -04:00
|
|
|
*
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-07-29 16:10:58 -04:00
|
|
|
public function doPostGenerateBpmn(array $request_data)
|
2014-07-24 17:18:48 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-07-29 16:10:58 -04:00
|
|
|
//Set data
|
|
|
|
|
$request_data = array_change_key_case($request_data, CASE_UPPER);
|
|
|
|
|
|
|
|
|
|
//Verify data
|
|
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
|
|
|
|
|
|
|
|
|
$process->throwExceptionIfDataNotMetFieldDefinition(
|
|
|
|
|
$request_data,
|
|
|
|
|
array("PRO_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "processUid")),
|
|
|
|
|
array("processUid" => "pro_uid"),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Generate BPMN
|
2014-07-24 17:18:48 -04:00
|
|
|
$workflowBpmn = new \ProcessMaker\Project\Adapter\WorkflowBpmn();
|
|
|
|
|
|
2014-07-29 16:10:58 -04:00
|
|
|
$projectUid = $workflowBpmn->generateBpmn($request_data["PRO_UID"], "pro_uid", $this->getUserId());
|
2014-07-24 17:18:48 -04:00
|
|
|
|
2014-07-29 16:10:58 -04:00
|
|
|
$arrayData = array_change_key_case(array_merge(array("PRJ_UID" => $projectUid), $request_data), CASE_LOWER);
|
2014-07-24 17:18:48 -04:00
|
|
|
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-23 17:14:04 -04:00
|
|
|
/**
|
2014-02-06 15:35:49 -04:00
|
|
|
* @url GET /:prj_uid/dynaforms
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
2013-12-23 17:14:04 -04:00
|
|
|
*/
|
2014-02-06 15:35:49 -04:00
|
|
|
public function doGetDynaForms($prj_uid)
|
2013-12-23 17:14:04 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
2014-02-06 15:35:49 -04:00
|
|
|
$process->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
2013-12-23 17:14:04 -04:00
|
|
|
|
2014-02-06 15:35:49 -04:00
|
|
|
$response = $process->getDynaForms($prj_uid);
|
2013-12-23 17:14:04 -04:00
|
|
|
|
2015-11-20 18:57:26 -04:00
|
|
|
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
2013-12-23 17:14:04 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 12:57:02 -04:00
|
|
|
/**
|
2014-02-06 15:35:49 -04:00
|
|
|
* @url GET /:prj_uid/input-documents
|
2014-01-17 15:20:11 -04:00
|
|
|
*
|
2014-02-06 15:35:49 -04:00
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
2013-12-13 12:57:02 -04:00
|
|
|
*/
|
2014-02-06 15:35:49 -04:00
|
|
|
public function doGetInputDocuments($prj_uid)
|
2013-12-13 12:57:02 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
2014-02-12 12:32:04 -04:00
|
|
|
$process->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
2013-12-13 12:57:02 -04:00
|
|
|
|
2014-02-06 15:35:49 -04:00
|
|
|
$response = $process->getInputDocuments($prj_uid);
|
2013-12-13 12:57:02 -04:00
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-22 17:18:33 -04:00
|
|
|
|
2014-02-13 17:18:17 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid/variables
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetVariables($prj_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
2014-02-13 17:18:17 -04:00
|
|
|
$process->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
|
|
|
|
|
|
|
|
|
$response = $process->getVariables("ALL", $prj_uid);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid/grid/variables
|
|
|
|
|
* @url GET /:prj_uid/grid/:grid_uid/variables
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
2014-02-20 17:16:00 -04:00
|
|
|
* @param string $grid_uid
|
2014-02-13 17:18:17 -04:00
|
|
|
*/
|
2014-02-14 11:53:49 -04:00
|
|
|
public function doGetGridVariables($prj_uid, $grid_uid = "")
|
2014-02-13 17:18:17 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
2014-02-13 17:18:17 -04:00
|
|
|
$process->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
|
|
|
|
|
|
|
|
|
$response = ($grid_uid == "")? $process->getVariables("GRID", $prj_uid) : $process->getVariables("GRIDVARS", $prj_uid, $grid_uid);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-20 17:16:00 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:prj_uid/trigger-wizards
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetTriggerWizards($prj_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
2014-02-20 17:16:00 -04:00
|
|
|
$process->setFormatFieldNameInUppercase(false);
|
|
|
|
|
$process->setArrayFieldNameForException(array("processUid" => "prj_uid", "libraryName" => "lib_name", "methodName" => "fn_name"));
|
|
|
|
|
|
|
|
|
|
$response = $process->getLibraries($prj_uid);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-19 17:59:00 -04:00
|
|
|
|
2015-09-25 21:24:21 -04:00
|
|
|
/**
|
|
|
|
|
* @url PUT /:prj_uid/update-route-order
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doPutUpdateRouteOrder($prj_uid, $request_data)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oRoute = new \Route();
|
|
|
|
|
$result = $oRoute->updateRouteOrder($request_data);
|
|
|
|
|
return $result;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-19 17:59:00 -04:00
|
|
|
|
2015-09-25 21:24:21 -04:00
|
|
|
/**
|
|
|
|
|
* @url PUT /:prj_uid/update-route-order-from-project
|
|
|
|
|
*
|
|
|
|
|
* @param string $prj_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doPutUpdateRouteOrderFromProject($prj_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oRoute = new \Route();
|
|
|
|
|
$result = $oRoute->updateRouteOrderFromProject($prj_uid);
|
|
|
|
|
return $result;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 23:01:02 -04:00
|
|
|
}
|