Enabling to use GET method for Project endpoint -> Request GET: /projects, and some updates
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project\Adapter;
|
||||
|
||||
use ProcessMaker\Project;
|
||||
use ProcessMaker\Util\Hash;
|
||||
|
||||
|
||||
class BpmnWorkflow extends Project\Bpmn
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project\Adapter;
|
||||
|
||||
use ProcessMaker\Project\Adapter\BpmnHandler;
|
||||
use ProcessMaker\Util\Hash;
|
||||
|
||||
|
||||
class BpmnWorkflowProject extends BpmnHandler
|
||||
{
|
||||
|
||||
}
|
||||
@@ -111,6 +111,38 @@ class Bpmn extends Handler
|
||||
$project->delete();
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
return Project::getAll($start, $limit, $filter, $changeCaseTo);
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
if (empty($this->project)) {
|
||||
throw new \RuntimeException("Error: There is not an initialized project.");
|
||||
}
|
||||
|
||||
return $this->prjUid;
|
||||
}
|
||||
|
||||
public function getProject($retType = "array")
|
||||
{
|
||||
if (empty($this->project)) {
|
||||
throw new \RuntimeException("Error: There is not an initialized project.");
|
||||
}
|
||||
|
||||
return $retType == "array" ? $this->project->toArray() : $this->project;
|
||||
}
|
||||
|
||||
/*
|
||||
* Projects elements handlers
|
||||
*/
|
||||
|
||||
public function addDiagram($data = array())
|
||||
{
|
||||
if (empty($this->project)) {
|
||||
@@ -127,6 +159,20 @@ class Bpmn extends Handler
|
||||
$this->diagram->save();
|
||||
}
|
||||
|
||||
public function getDiagram($retType = "array")
|
||||
{
|
||||
if (empty($this->diagram)) {
|
||||
$diagrams = Diagram::findAllByProUid($this->getUid());
|
||||
|
||||
if (! empty($diagrams)) {
|
||||
//NOTICE for ProcessMaker we're just handling a "one to one" relationship between project and process
|
||||
$this->diagram = $diagrams[0];
|
||||
}
|
||||
}
|
||||
|
||||
return $retType == "array" ? $this->diagram->toArray() : $this->diagram;
|
||||
}
|
||||
|
||||
public function addProcess($data = array())
|
||||
{
|
||||
if (empty($this->diagram)) {
|
||||
@@ -144,6 +190,20 @@ class Bpmn extends Handler
|
||||
$this->process->save();
|
||||
}
|
||||
|
||||
public function getProcess($retType = "array")
|
||||
{
|
||||
if (empty($this->process)) {
|
||||
$processes = Process::findAllByProUid($this->getUid());
|
||||
|
||||
if (! empty($processes)) {
|
||||
//NOTICE for ProcessMaker we're just handling a "one to one" relationship between project and process
|
||||
$this->process = $processes[0];
|
||||
}
|
||||
}
|
||||
|
||||
return $retType == "array" ? $this->process->toArray() : $this->process;
|
||||
}
|
||||
|
||||
public function addActivity($data)
|
||||
{
|
||||
if (empty($this->diagram)) {
|
||||
@@ -173,9 +233,21 @@ class Bpmn extends Handler
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function getActivities($retType = 'array')
|
||||
public function getActivities()
|
||||
{
|
||||
return Activity::getAll($this->getUid(), null, null, '', $retType);
|
||||
return Activity::getAll($this->getUid());
|
||||
}
|
||||
|
||||
public function updateActivity($actUid, $data)
|
||||
{
|
||||
$activity = ActivityPeer::retrieveByPk($actUid);
|
||||
|
||||
// fixing data
|
||||
//$data['ELEMENT_UID'] = $data['BOU_ELEMENT_UID'];
|
||||
//unset($data['BOU_ELEMENT_UID']);
|
||||
|
||||
$activity->fromArray($data);
|
||||
$activity->save();
|
||||
}
|
||||
|
||||
public function removeActivity($actUid)
|
||||
@@ -329,50 +401,4 @@ class Bpmn extends Handler
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
}
|
||||
|
||||
|
||||
|
||||
// getters
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
if (empty($this->project)) {
|
||||
throw new \Exception("Error: There is not an initialized project.");
|
||||
}
|
||||
|
||||
return $this->prjUid;
|
||||
}
|
||||
|
||||
public function getProject($retType = "array")
|
||||
{
|
||||
return $retType == "array" ? $this->project->toArray() : $this->project;
|
||||
}
|
||||
|
||||
public function getDiagram($retType = "array")
|
||||
{
|
||||
if (empty($this->diagram)) {
|
||||
$diagrams = Diagram::findAllByProUid($this->getUid());
|
||||
|
||||
if (! empty($diagrams)) {
|
||||
//NOTICE for ProcessMaker we're just handling a "one to one" relationship between project and process
|
||||
$this->diagram = $diagrams[0];
|
||||
}
|
||||
}
|
||||
|
||||
return $retType == "array" ? $this->diagram->toArray() : $this->diagram;
|
||||
}
|
||||
|
||||
public function getProcess($retType = "array")
|
||||
{
|
||||
if (empty($this->process)) {
|
||||
$processes = Process::findAllByProUid($this->getUid());
|
||||
|
||||
if (! empty($processes)) {
|
||||
//NOTICE for ProcessMaker we're just handling a "one to one" relationship between project and process
|
||||
$this->process = $processes[0];
|
||||
}
|
||||
}
|
||||
|
||||
return $retType == "array" ? $this->process->toArray() : $this->process;
|
||||
}
|
||||
}
|
||||
@@ -29,25 +29,21 @@ class Workflow extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function setProperties($properties)
|
||||
public static function load($proUid)
|
||||
{
|
||||
$this->properties = $properties;
|
||||
}
|
||||
$me = new self();
|
||||
|
||||
public function getProcess()
|
||||
{
|
||||
if (empty($this->proUid)) {
|
||||
throw new \Exception("Error: There is not an initialized project.");
|
||||
try {
|
||||
$process = new Process();
|
||||
$processData = $process->load($proUid);
|
||||
} catch (\Exception $e) {
|
||||
throw new Exception\ProjectNotFound($me, $proUid);
|
||||
}
|
||||
|
||||
$process = new Process();
|
||||
$me->process = $processData;
|
||||
$me->proUid = $processData["PRO_UID"];
|
||||
|
||||
return $process->load($this->proUid);
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
return $this->proUid;
|
||||
return $me;
|
||||
}
|
||||
|
||||
public function create($data)
|
||||
@@ -77,21 +73,24 @@ class Workflow extends Handler
|
||||
$this->deleteProcess($this->proUid);
|
||||
}
|
||||
|
||||
public static function load($proUid)
|
||||
public function getUid()
|
||||
{
|
||||
$me = new self();
|
||||
|
||||
try {
|
||||
$process = new Process();
|
||||
$processData = $process->load($proUid);
|
||||
} catch (\Exception $e) {
|
||||
throw new Exception\ProjectNotFound($me, $proUid);
|
||||
if (empty($this->project)) {
|
||||
throw new \RuntimeException("Error: There is not an initialized project.");
|
||||
}
|
||||
|
||||
$me->process = $processData;
|
||||
$me->proUid = $processData["PRO_UID"];
|
||||
return $this->proUid;
|
||||
}
|
||||
|
||||
return $me;
|
||||
public function getProcess()
|
||||
{
|
||||
if (empty($this->proUid)) {
|
||||
throw new \Exception("Error: There is not an initialized project.");
|
||||
}
|
||||
|
||||
$process = new Process();
|
||||
|
||||
return $process->load($this->proUid);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user