Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
379
workflow/engine/src/ProcessMaker/Adapter/Bpmn/Model.php
Normal file
379
workflow/engine/src/ProcessMaker/Adapter/Bpmn/Model.php
Normal file
@@ -0,0 +1,379 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Adapter\Bpmn;
|
||||
|
||||
use \BpmnProject as Project;
|
||||
use \BpmnProcess as Process;
|
||||
use \BpmnDiagram as Diagram;
|
||||
use \BpmnLaneset as Laneset;
|
||||
use \BpmnLane as Lane;
|
||||
use \BpmnActivity as Activity;
|
||||
use \BpmnBound as Bound;
|
||||
use \BpmnEvent as Event;
|
||||
use \BpmnGateway as Gateway;
|
||||
use \BpmnFlow as Flow;
|
||||
use \BpmnArtifact as Artifact;
|
||||
|
||||
use \BpmnProjectPeer as ProjectPeer;
|
||||
use \BpmnProcessPeer as ProcessPeer;
|
||||
use \BpmnDiagramPeer as DiagramPeer;
|
||||
use \BpmnLanesetPeer as LanesetPeer;
|
||||
use \BpmnLanePeer as LanePeer;
|
||||
use \BpmnActivityPeer as ActivityPeer;
|
||||
use \BpmnBoundPeer as BoundPeer;
|
||||
use \BpmnEventPeer as EventPeer;
|
||||
use \BpmnGatewayPeer as GatewayPeer;
|
||||
use \BpmnFlowPeer as FlowPeer;
|
||||
use \BpmnArtifactPeer as ArtifactPeer;
|
||||
|
||||
use \ProcessMaker\Util\Hash;
|
||||
use \BasePeer;
|
||||
|
||||
/**
|
||||
* Class Model
|
||||
*
|
||||
* @package ProcessMaker\Adapter\Bpmn
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class Model
|
||||
{
|
||||
public function createProject($data)
|
||||
{
|
||||
$data = array_change_key_case($data, CASE_UPPER);
|
||||
$uids = array();
|
||||
$oldPrjUid = $data['PRJ_UID'];
|
||||
$diagrams = $data['DIAGRAMS'];
|
||||
|
||||
unset($data['PRJ_UID']);
|
||||
|
||||
/*
|
||||
* 1. Create a project record
|
||||
* 2. Create a default diagram record
|
||||
* 3. Create a default process record
|
||||
*/
|
||||
|
||||
$project = new Project();
|
||||
$project->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$project->setPrjUid(Hash::generateUID());
|
||||
$project->setPrjCreateDate(date("Y-m-d H:i:s"));
|
||||
$project->save();
|
||||
$prjUid = $project->getPrjUid();
|
||||
$prjName = $project->getPrjName();
|
||||
$uids[] = array('old_uid' => $oldPrjUid, 'new_uid' => $prjUid, 'object' => 'project');
|
||||
|
||||
// By now, is thought create only one diagram for each project (1:1)
|
||||
$diagramData = (array) $diagrams[0];
|
||||
$oldDiaUid = $diagramData['dia_uid'];
|
||||
|
||||
$diagram = new Diagram();
|
||||
$diagram->setDiaUid(Hash::generateUID());
|
||||
$diagram->setPrjUid($prjUid);
|
||||
$diagram->setDiaName($prjName);
|
||||
$diagram->save();
|
||||
$diaUid = $diagram->getDiaUid();
|
||||
$uids[] = array('old_uid' => $oldDiaUid, 'new_uid' => $diaUid, 'object' => 'diagram');
|
||||
|
||||
$process = new Process();
|
||||
$process->setProUid(Hash::generateUID());
|
||||
$process->setPrjUid($prjUid);
|
||||
$process->setDiaUid($diaUid);
|
||||
$process->setProName($prjName);
|
||||
$process->save();
|
||||
$proUid = $process->getProUid();
|
||||
|
||||
$uids = array_merge($uids, $this->createDiagram($prjUid, $proUid, $diaUid, $diagramData));
|
||||
|
||||
return $uids;
|
||||
}
|
||||
|
||||
private function createDiagram($prjUid, $proUid, $diaUid, $diagramData)
|
||||
{
|
||||
$uids = array();
|
||||
|
||||
/*
|
||||
* 1. ensure that all related data of objects are defined, if not we define them as empty
|
||||
* 2. create all related objects
|
||||
*/
|
||||
|
||||
$lanesets = array_key_exists('laneset', $diagramData) ? $diagramData['laneset'] : array();
|
||||
$lanes = array_key_exists('lane', $diagramData) ? $diagramData['lanes'] : array();
|
||||
$activities = array_key_exists('activities', $diagramData) ? $diagramData['activities'] : array();
|
||||
$events = array_key_exists('events', $diagramData) ? $diagramData['events'] : array();
|
||||
$gateways = array_key_exists('gateways', $diagramData) ? $diagramData['gateways'] : array();
|
||||
$flows = array_key_exists('flows', $diagramData) ? $diagramData['flows'] : array();
|
||||
$artifacts = array_key_exists('artifacts', $diagramData) ? $diagramData['artifacts'] : array();
|
||||
|
||||
foreach($lanesets as $lanesetData) {
|
||||
$lanesetData = array_change_key_case((array) $lanesetData, CASE_UPPER);
|
||||
|
||||
$laneset = new Laneset();
|
||||
$laneset->fromArray($lanesetData, BasePeer::TYPE_FIELDNAME);
|
||||
$laneset->setLnsUid(Hash::generateUID());
|
||||
$laneset->setPrjUid($prjUid);
|
||||
$laneset->setProUid($proUid);
|
||||
$laneset->save();
|
||||
$lnsUid = $laneset->getLnsUid();
|
||||
$oldLnsUid = $lanesetData['LNS_UID'];
|
||||
|
||||
$uids[] = array('old_uid' => $oldLnsUid, 'new_uid' => $lnsUid, 'object' => 'laneset');
|
||||
}
|
||||
|
||||
foreach($lanes as $laneData) {
|
||||
$laneData = array_change_key_case((array) $laneData, CASE_UPPER);
|
||||
|
||||
$lane = new Lane();
|
||||
$lane->fromArray($laneData, BasePeer::TYPE_FIELDNAME);
|
||||
$lane->setLanUid(Hash::generateUID());
|
||||
$lane->setPrjUid($prjUid);
|
||||
$lane->save();
|
||||
$lanUid = $lane->getLanUid();
|
||||
$oldLanUid = $laneData['LNS_UID'];
|
||||
|
||||
$uids[] = array('old_uid' => $oldLanUid, 'new_uid' => $lanUid, 'object' => 'lane');
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. crate project related object
|
||||
* 2. crate bound record for each object created previously
|
||||
*/
|
||||
|
||||
foreach($activities as $activityData) {
|
||||
$activityData = array_change_key_case((array) $activityData, CASE_UPPER);
|
||||
|
||||
|
||||
$activity = new Activity();
|
||||
$activity->fromArray($activityData, BasePeer::TYPE_FIELDNAME);
|
||||
$activity->setActUid(Hash::generateUID());
|
||||
$activity->setPrjUid($prjUid);
|
||||
$activity->setProUid($proUid);
|
||||
$activity->save();
|
||||
|
||||
$actUid = $activity->getActUid();
|
||||
$oldActUid = $activityData['ACT_UID'];
|
||||
$uids[] = array('old_uid' => $oldActUid, 'new_uid' => $actUid, 'object' => 'activity');
|
||||
|
||||
|
||||
$bound = new Bound();
|
||||
$bound->fromArray($activityData, BasePeer::TYPE_FIELDNAME);
|
||||
$bound->setBouUid(Hash::generateUID());
|
||||
$bound->setPrjUid($prjUid);
|
||||
$bound->setDiaUid($diaUid);
|
||||
$bound->setElementUid($activity->getActUid());
|
||||
$bound->setBouElementType(get_class($activity));
|
||||
$bound->setBouElement('pm_canvas');
|
||||
$bound->setBouContainer('bpmnDiagram');
|
||||
$bound->save();
|
||||
}
|
||||
|
||||
foreach($events as $eventData) {
|
||||
$eventData = array_change_key_case((array) $eventData, CASE_UPPER);
|
||||
|
||||
$event = new Event();
|
||||
$event->fromArray($eventData, BasePeer::TYPE_FIELDNAME);
|
||||
$event->setEvnUid(Hash::generateUID());
|
||||
$event->setPrjUid($prjUid);
|
||||
$event->setProUid($proUid);
|
||||
$event->save();
|
||||
|
||||
$evnUid = $event->getEvnUid();
|
||||
$oldEvnUid = $eventData['EVN_UID'];
|
||||
$uids[] = array('old_uid' => $oldEvnUid, 'new_uid' => $evnUid, 'object' => 'event');
|
||||
|
||||
$bound = new Bound();
|
||||
$bound->fromArray($eventData, BasePeer::TYPE_FIELDNAME);
|
||||
$bound->setBouUid(Hash::generateUID());
|
||||
$bound->setPrjUid($prjUid);
|
||||
$bound->setDiaUid($diaUid);
|
||||
$bound->setElementUid($event->getEvnUid());
|
||||
$bound->setBouElementType(get_class($event));
|
||||
$bound->setBouElement('pm_canvas');
|
||||
$bound->setBouContainer('bpmnDiagram');
|
||||
$bound->save();
|
||||
}
|
||||
|
||||
foreach($gateways as $gatewayData) {
|
||||
$gatewayData = array_change_key_case((array) $gatewayData, CASE_UPPER);
|
||||
|
||||
$gateway = new Gateway();
|
||||
$gateway->fromArray($gatewayData, BasePeer::TYPE_FIELDNAME);
|
||||
$gateway->setGatUid(Hash::generateUID());
|
||||
$gateway->setPrjUid($prjUid);
|
||||
$gateway->setProUid($proUid);
|
||||
$gateway->save();
|
||||
|
||||
$gatUid = $gateway->getGatUid();
|
||||
$oldGatUid = $gatewayData['GAT_UID'];
|
||||
$uids[] = array('old_uid' => $oldGatUid, 'new_uid' => $gatUid, 'object' => 'gateway');
|
||||
|
||||
$bound = new Bound();
|
||||
$bound->fromArray($gatewayData, BasePeer::TYPE_FIELDNAME);
|
||||
$bound->setBouUid(Hash::generateUID());
|
||||
$bound->setPrjUid($prjUid);
|
||||
$bound->setDiaUid($diaUid);
|
||||
$bound->setElementUid($gateway->getGatUid());
|
||||
$bound->setBouElementType(get_class($gateway));
|
||||
$bound->setBouElement('pm_canvas');
|
||||
$bound->setBouContainer('bpmnDiagram');
|
||||
$bound->save();
|
||||
}
|
||||
|
||||
foreach($flows as $flowData) {
|
||||
$flowData = array_change_key_case((array) $flowData, CASE_UPPER);
|
||||
|
||||
$floState = json_encode($flowData['FLO_STATE']);
|
||||
unset($flowData['FLO_STATE']);
|
||||
|
||||
$flow = new Flow();
|
||||
$flow->fromArray($flowData, BasePeer::TYPE_FIELDNAME);
|
||||
$flow->setFloUid(Hash::generateUID());
|
||||
$flow->setPrjUid($prjUid);
|
||||
$flow->setDiaUid($diaUid);
|
||||
$flow->setFloState($floState);
|
||||
$flow->save();
|
||||
|
||||
$floUid = $flow->getFloUid();
|
||||
$oldFloUid = $flowData['FLO_UID'];
|
||||
$uids[] = array('old_uid' => $oldFloUid, 'new_uid' => $floUid, 'object' => 'flow');
|
||||
}
|
||||
|
||||
foreach($artifacts as $artifactData) {
|
||||
$artifactData = array_change_key_case((array) $artifactData, CASE_UPPER);
|
||||
|
||||
$artifact = new Artifact();
|
||||
$artifact->fromArray($artifactData, BasePeer::TYPE_FIELDNAME);
|
||||
$artifact->setArtUid(Hash::generateUID());
|
||||
$artifact->setPrjUid($prjUid);
|
||||
$artifact->setProUid($proUid);
|
||||
$artifact->save();
|
||||
|
||||
$artUid = $artifact->getFloUid();
|
||||
$oldArtUid = $artifactData['ART_UID'];
|
||||
$uids[] = array('old_uid' => $oldArtUid, 'new_uid' => $artUid, 'object' => 'artifact');
|
||||
}
|
||||
|
||||
return $uids;
|
||||
}
|
||||
|
||||
public function loadProject($prjUid)
|
||||
{
|
||||
/*
|
||||
* 1. load object of project
|
||||
* 2. load object of process
|
||||
* 3. load object of diagram
|
||||
* 4. load collection of lanesets
|
||||
* 5. load collection of lanes
|
||||
* 6. load collection of activities
|
||||
* 7. load collection of events
|
||||
* 8. load collection of gateways
|
||||
* 9. load collection of flows
|
||||
* 10. load collection of artifacts
|
||||
* 11. compose project data structure
|
||||
*/
|
||||
|
||||
$project = self::getBpmnObjectBy('Project', ProjectPeer::PRJ_UID, $prjUid, true);
|
||||
$process = self::getBpmnObjectBy('Process', ProcessPeer::PRJ_UID, $prjUid, true);
|
||||
$diagram = self::getBpmnObjectBy('Diagram', DiagramPeer::DIA_UID, $process['dia_uid'], true);
|
||||
$lanesets = self::getBpmnCollectionBy('Laneset', LanesetPeer::PRJ_UID, $prjUid, true);
|
||||
$lanes = self::getBpmnCollectionBy('Lane', LanePeer::PRJ_UID, $prjUid, true);
|
||||
$activities = self::getBpmnCollectionBy('Activity', ActivityPeer::PRJ_UID, $prjUid, true);
|
||||
$events = self::getBpmnCollectionBy('Event', EventPeer::PRJ_UID, $prjUid, true);
|
||||
$gateways = self::getBpmnCollectionBy('Gateway', GatewayPeer::PRJ_UID, $prjUid, true);
|
||||
$flows = self::getBpmnCollectionBy('Flow', FlowPeer::PRJ_UID, $prjUid, true);
|
||||
$artifacts = self::getBpmnCollectionBy('Artifact', ArtifactPeer::PRJ_UID, $prjUid, true);
|
||||
|
||||
// getting activity bound data
|
||||
foreach ($activities as $i => $activity) {
|
||||
$activities[$i] = array_merge(
|
||||
$activities[$i],
|
||||
self::getBpmnObjectBy('Bound', BoundPeer::ELEMENT_UID, $activity['act_uid'], true)
|
||||
);
|
||||
}
|
||||
|
||||
// getting event bound data
|
||||
foreach ($events as $i => $event) {
|
||||
$events[$i] = array_merge(
|
||||
$events[$i],
|
||||
self::getBpmnObjectBy('Bound', BoundPeer::ELEMENT_UID, $event['evn_uid'], true)
|
||||
);
|
||||
}
|
||||
|
||||
// getting gateway bound data
|
||||
foreach ($gateways as $i => $gateway) {
|
||||
$gateways[$i] = array_merge(
|
||||
$gateways[$i],
|
||||
self::getBpmnObjectBy('Bound', BoundPeer::ELEMENT_UID, $gateway['gat_uid'], true)
|
||||
);
|
||||
}
|
||||
|
||||
$project = array_change_key_case($project);
|
||||
$project['diagrams'] = array($diagram);
|
||||
$project['diagrams'][0]['lanesets'] = $lanesets;
|
||||
$project['diagrams'][0]['lanes'] = $lanes;
|
||||
$project['diagrams'][0]['activities'] = $activities;
|
||||
$project['diagrams'][0]['events'] = $events;
|
||||
$project['diagrams'][0]['gateways'] = $gateways;
|
||||
$project['diagrams'][0]['flows'] = $flows;
|
||||
$project['diagrams'][0]['artifacts'] = $artifacts;
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
public static function loadProjects()
|
||||
{
|
||||
$projectsList = self::getAllBpmnCollectionFrom('Project', true);
|
||||
$projects = array();
|
||||
|
||||
foreach ($projectsList as $project) {
|
||||
$projects[] = self::loadProject($project['prj_uid']);
|
||||
}
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
||||
/*** Private Functions ***/
|
||||
|
||||
private static function getAllBpmnCollectionFrom($class, $changeCase = false)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$c = new \Criteria('workflow');
|
||||
//$c->add($field, $value);
|
||||
|
||||
$classPeer = 'Bpmn' . $class . 'Peer';
|
||||
$rs = $classPeer::doSelectRS($c);
|
||||
|
||||
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rs->next()) {
|
||||
$data[] = $changeCase ? array_change_key_case($rs->getRow(), CASE_LOWER) : $rs->getRow();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function getBpmnCollectionBy($class, $field, $value, $changeCase = false)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$c = new \Criteria('workflow');
|
||||
$c->add($field, $value);
|
||||
|
||||
$classPeer = 'Bpmn' . $class . 'Peer';
|
||||
$rs = $classPeer::doSelectRS($c);
|
||||
|
||||
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rs->next()) {
|
||||
$data[] = $changeCase ? array_change_key_case($rs->getRow(), CASE_LOWER) : $rs->getRow();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function getBpmnObjectBy($class, $field, $value, $changeCase = false)
|
||||
{
|
||||
$record = self::getBpmnCollectionBy($class, $field, $value, $changeCase);
|
||||
|
||||
return empty($record) ? null : $record[0];
|
||||
}
|
||||
}
|
||||
|
||||
48
workflow/engine/src/ProcessMaker/Adapter/Bpmn/Port.php
Normal file
48
workflow/engine/src/ProcessMaker/Adapter/Bpmn/Port.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Adapter\Bpmn;
|
||||
|
||||
use \Process;
|
||||
|
||||
/**
|
||||
* Class Port
|
||||
*
|
||||
* @package ProcessMaker\Adapter\Bpmn
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class Port
|
||||
{
|
||||
public function convertBpmnProjectToPmWorkflow($bpmnProject)
|
||||
{
|
||||
$proUid = $bpmnProject['prj_uid'];
|
||||
|
||||
$process = array();
|
||||
$process['PRO_UID'] = $proUid;
|
||||
$process['PRO_TITLE'] = $bpmnProject['prj_name'];
|
||||
$process['PRO_DESCRIPTION'] = '';
|
||||
$process['PRO_CATEGORY'] = '';
|
||||
$process['PRO_UID'] = $proUid;
|
||||
$process['PRO_UID'] = $proUid;
|
||||
$process['tasks'] = array();
|
||||
|
||||
$diagram = $bpmnProject['prj_name']['diagrams'][0];
|
||||
|
||||
foreach ($diagram['activities'] as $activity) {
|
||||
$process['tasks'][] = array(
|
||||
'TAS_UID' => $activity['act_uid'],
|
||||
'TAS_TITLE' => $activity['act_name'],
|
||||
'TAS_DESCRIPTION' => $activity['act_name'],
|
||||
'TAS_POSX' => $activity['bou_x'],
|
||||
'TAS_POSY' => $activity['bou_y'],
|
||||
'TAS_START' => ''
|
||||
);
|
||||
}
|
||||
|
||||
$process['routes'][] = array(
|
||||
'ROU_UID' => '',
|
||||
'TAS_UID' => '',
|
||||
'ROU_NEXT_TASK' => '',
|
||||
'ROU_TYPE' => ''
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,15 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Services;
|
||||
|
||||
class Api
|
||||
/**
|
||||
* Abstract Class Api
|
||||
*
|
||||
* Api class be be extended by Restler Classes
|
||||
*
|
||||
* @package ProcessMaker\Services
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
abstract class Api
|
||||
{
|
||||
private static $workspace;
|
||||
private static $userId;
|
||||
|
||||
68
workflow/engine/src/ProcessMaker/Util/Hash.php
Normal file
68
workflow/engine/src/ProcessMaker/Util/Hash.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Util;
|
||||
|
||||
class Hash
|
||||
{
|
||||
/**
|
||||
* Generate random number
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function generateUID()
|
||||
{
|
||||
do {
|
||||
$sUID = str_replace('.', '0', uniqid(rand(0, 999999999), true));
|
||||
} while (strlen( $sUID ) != 32);
|
||||
|
||||
return $sUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a numeric or alphanumeric code
|
||||
*
|
||||
* @author Julio Cesar Laura Avendaño <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param int $iDigits
|
||||
* @param string $sType
|
||||
* @return string
|
||||
*/
|
||||
public function generateCode($iDigits = 4, $sType = 'NUMERIC')
|
||||
{
|
||||
if (($iDigits < 4) || ($iDigits > 50)) {
|
||||
$iDigits = 4;
|
||||
}
|
||||
if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) {
|
||||
$sType = 'NUMERIC';
|
||||
}
|
||||
|
||||
$aValidCharacters = array(
|
||||
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H',
|
||||
'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
|
||||
);
|
||||
|
||||
switch ($sType) {
|
||||
case 'NUMERIC':
|
||||
$iMin = 0;
|
||||
$iMax = 9;
|
||||
break;
|
||||
case 'ALPHA':
|
||||
$iMin = 10;
|
||||
$iMax = 35;
|
||||
break;
|
||||
case 'ALPHANUMERIC':
|
||||
$iMin = 0;
|
||||
$iMax = 35;
|
||||
break;
|
||||
}
|
||||
|
||||
$sCode = '';
|
||||
for ($i = 0; $i < $iDigits; $i ++) {
|
||||
$sCode .= $aValidCharacters[rand($iMin, $iMax)];
|
||||
}
|
||||
|
||||
return $sCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Util;
|
||||
|
||||
/**
|
||||
* Singleton Class Logger
|
||||
*
|
||||
* This Utility is usefull to log local messages
|
||||
* @package ProcessMaker\Util
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class Logger
|
||||
{
|
||||
private static $instance;
|
||||
|
||||
52
workflow/engine/src/Services/Api/ProcessMaker/Project.php
Normal file
52
workflow/engine/src/Services/Api/ProcessMaker/Project.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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
|
||||
{
|
||||
function index()
|
||||
{
|
||||
//return \BusinessModel\Process::loadProcess('647625648528d91278a87f5076732980');
|
||||
|
||||
try {
|
||||
$projects = BpmnModel::loadProjects();
|
||||
|
||||
return $projects;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
function post($request_data)
|
||||
{
|
||||
try {
|
||||
$bpmnModel = new BpmnModel();
|
||||
|
||||
return $bpmnModel->createProject($request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
function get($prjUid)
|
||||
{
|
||||
try {
|
||||
$project = BpmnModel::loadProject($prjUid);
|
||||
|
||||
return $project;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user