2013-12-05 20:41:21 -04:00
|
|
|
<?php
|
|
|
|
|
namespace Services\Api\ProcessMaker;
|
|
|
|
|
|
|
|
|
|
use Luracast\Restler\RestException;
|
|
|
|
|
use ProcessMaker\Services\Api;
|
|
|
|
|
use ProcessMaker\Adapter\Bpmn\Model as BpmnModel;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Project
|
|
|
|
|
*
|
|
|
|
|
* @package Services\Api\ProcessMaker
|
|
|
|
|
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class Project extends Api
|
|
|
|
|
{
|
2013-12-05 23:01:02 -04:00
|
|
|
function index()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$projects = BpmnModel::loadProjects();
|
|
|
|
|
|
|
|
|
|
return $projects;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 20:41:21 -04:00
|
|
|
|
2013-12-17 11:24:37 -04:00
|
|
|
/**
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
2013-12-05 20:41:21 -04:00
|
|
|
function post($request_data)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$bpmnModel = new BpmnModel();
|
2013-12-09 10:42:01 -04:00
|
|
|
$uids = $bpmnModel->createProject($request_data);
|
2013-12-10 20:36:51 -04:00
|
|
|
|
|
|
|
|
$wfProcess = \ProcessMaker\Adapter\Workflow::loadFromBpmnProject($uids[0]['new_uid']);
|
|
|
|
|
|
2013-12-09 10:42:01 -04:00
|
|
|
$process = new \BusinessModel\Process();
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$data = array('process' => $wfProcess);
|
|
|
|
|
$process->createProcess($userUid, $data);
|
2013-12-05 20:41:21 -04:00
|
|
|
|
2013-12-09 10:42:01 -04:00
|
|
|
return $uids;
|
2013-12-05 20:41:21 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get($prjUid)
|
|
|
|
|
{
|
2013-12-05 20:44:28 -04:00
|
|
|
try {
|
|
|
|
|
$project = BpmnModel::loadProject($prjUid);
|
2013-12-05 20:41:21 -04:00
|
|
|
|
2013-12-10 20:36:51 -04:00
|
|
|
//$WorkflowProces = \ProcessMaker\Adapter\Workflow::loadFromBpmnProject($prjUid);
|
2013-12-09 09:58:23 -04:00
|
|
|
//return $WorkflowProces;
|
2013-12-05 20:44:28 -04:00
|
|
|
return $project;
|
|
|
|
|
} 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
|
|
|
|
2013-12-23 17:14:04 -04:00
|
|
|
/**
|
|
|
|
|
* @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()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 12:57:02 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET /:projectUid/input-documents
|
|
|
|
|
*/
|
|
|
|
|
public function doGetInputDocuments($projectUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$process = new \BusinessModel\Process();
|
|
|
|
|
|
|
|
|
|
$response = $process->getInputDocuments($projectUid);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-05 23:01:02 -04:00
|
|
|
}
|
2013-12-13 12:57:02 -04:00
|
|
|
|