Adding Override Methods to Adapter Bpmn->Workflow Projects
This commit is contained in:
@@ -7,5 +7,66 @@ use ProcessMaker\Util\Hash;
|
||||
|
||||
class BpmnWorkflow extends Project\Bpmn
|
||||
{
|
||||
/**
|
||||
* OVERRIDES
|
||||
*/
|
||||
|
||||
public function create($data)
|
||||
{
|
||||
try {
|
||||
parent::create($data);
|
||||
} catch (\Exception $e) {
|
||||
throw new \RuntimeException(sprintf("Can't create Bpmn Project." . PHP_EOL . $e->getMessage()));
|
||||
}
|
||||
|
||||
try {
|
||||
$wpData = array();
|
||||
$wpData["PRO_UID"] = $this->getUid();
|
||||
|
||||
if (array_key_exists("PRJ_NAME", $data)) {
|
||||
$wpData["PRO_TITLE"] = $data["PRJ_NAME"];
|
||||
}
|
||||
if (array_key_exists("PRJ_DESCRIPTION", $data)) {
|
||||
$wpData["PRO_DESCRIPTION"] = $data["PRJ_DESCRIPTION"];
|
||||
}
|
||||
if (array_key_exists("PRJ_AUTHOR", $data)) {
|
||||
$wpData["PRO_CREATE_USER"] = $data["PRJ_AUTHOR"];
|
||||
}
|
||||
|
||||
$wp = new Project\Workflow();
|
||||
$wp->create($wpData);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$prjUid = $this->getUid();
|
||||
$this->remove();
|
||||
|
||||
throw new \RuntimeException(sprintf(
|
||||
"Can't create Bpmn Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage()
|
||||
, $prjUid
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
$bpmnProjects = parent::getList($start, $limit, $filter, $changeCaseTo);
|
||||
$workflowProjects = Project\Workflow::getList($start, $limit, "", "");
|
||||
|
||||
$workflowProjectsUids = array();
|
||||
|
||||
foreach ($workflowProjects as $workflowProject) {
|
||||
$workflowProjectsUids[] = $workflowProject["PRO_UID"];
|
||||
}
|
||||
|
||||
$prjUidKey = $changeCaseTo == CASE_UPPER ? "PRJ_UID" : "prj_uid";
|
||||
$list = array();
|
||||
|
||||
foreach ($bpmnProjects as $bpmnProject) {
|
||||
if (in_array($bpmnProject[$prjUidKey], $workflowProjectsUids)) {
|
||||
$list[] = $bpmnProject;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,11 @@ class Bpmn extends Handler
|
||||
$this->prjUid = $this->project->getPrjUid();
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function remove()
|
||||
{
|
||||
/*
|
||||
@@ -100,20 +105,15 @@ class Bpmn extends Handler
|
||||
foreach ($activities as $activity) {
|
||||
$this->removeActivity($activity["ACT_UID"]);
|
||||
}
|
||||
|
||||
$process = ProcessPeer::retrieveByPK($this->getProcess("object")->getProUid());
|
||||
$process->delete();
|
||||
|
||||
$diagram = DiagramPeer::retrieveByPK($this->getDiagram("object")->getDiaUid());
|
||||
$diagram->delete();
|
||||
|
||||
$project = ProjectPeer::retrieveByPK($this->getUid());
|
||||
$project->delete();
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
if ($process = $this->getProcess("object")) {
|
||||
$process->delete();
|
||||
}
|
||||
if ($diagram = $this->getDiagram("object")) {
|
||||
$diagram->delete();
|
||||
}
|
||||
if ($project = $this->getProject("object")) {
|
||||
$project->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER)
|
||||
|
||||
@@ -73,9 +73,19 @@ class Workflow extends Handler
|
||||
$this->deleteProcess($this->proUid);
|
||||
}
|
||||
|
||||
public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
//return Project::getAll($start, $limit, $filter, $changeCaseTo);
|
||||
$process = new Process();
|
||||
$processes = $process->getAllProcesses( $start, $limit, "", "");
|
||||
//$processes = $process->getAll();
|
||||
|
||||
return $processes;
|
||||
}
|
||||
|
||||
public function getUid()
|
||||
{
|
||||
if (empty($this->project)) {
|
||||
if (empty($this->proUid)) {
|
||||
throw new \RuntimeException("Error: There is not an initialized project.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user