2013-12-02 17:36:37 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
require_once 'classes/model/om/BaseBpmnActivity.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Skeleton subclass for representing a row from the 'BPMN_ACTIVITY' table.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* You should add additional methods to this class to meet the
|
|
|
|
|
* application requirements. This class will only be generated as
|
|
|
|
|
* long as it does not already exist in the output directory.
|
|
|
|
|
*
|
|
|
|
|
* @package classes.model
|
|
|
|
|
*/
|
2013-12-23 17:17:01 -04:00
|
|
|
class BpmnActivity extends BaseBpmnActivity
|
|
|
|
|
{
|
2014-01-17 13:37:15 -04:00
|
|
|
private $bound;
|
|
|
|
|
|
|
|
|
|
public function __construct($generateUid = true)
|
|
|
|
|
{
|
|
|
|
|
$this->bound = new BpmnBound();
|
2014-01-27 17:09:32 -04:00
|
|
|
$this->setBoundDefaults();
|
2014-01-17 13:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
public function getBound()
|
2013-12-23 17:17:01 -04:00
|
|
|
{
|
2014-01-23 21:29:03 -04:00
|
|
|
return $this->bound;
|
|
|
|
|
}
|
2013-12-02 17:36:37 -04:00
|
|
|
|
2014-01-27 17:09:32 -04:00
|
|
|
private function setBoundDefaults()
|
|
|
|
|
{
|
|
|
|
|
$this->bound->setBouElementType(lcfirst(str_replace(__NAMESPACE__, '', __CLASS__)));
|
|
|
|
|
$this->bound->setBouElement('pm_canvas');
|
|
|
|
|
$this->bound->setBouContainer('bpmnDiagram');
|
|
|
|
|
|
|
|
|
|
$this->bound->setPrjUid($this->getPrjUid());
|
|
|
|
|
$this->bound->setElementUid($this->getActUid());
|
|
|
|
|
|
|
|
|
|
$process = BpmnProcessPeer::retrieveByPK($this->getProUid());
|
|
|
|
|
|
|
|
|
|
if (is_object($process)) {
|
|
|
|
|
$this->bound->setDiaUid($process->getDiaUid());
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-23 17:17:01 -04:00
|
|
|
|
2014-02-04 20:50:18 -04:00
|
|
|
public static function findOneBy($field, $value)
|
|
|
|
|
{
|
|
|
|
|
$rows = self::findAllBy($field, $value);
|
|
|
|
|
|
|
|
|
|
return empty($rows) ? null : $rows[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function findAllBy($field, $value)
|
|
|
|
|
{
|
|
|
|
|
$c = new Criteria('workflow');
|
|
|
|
|
$c->add($field, $value, Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
return BpmnActivityPeer::doSelect($c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getAll($prjUid = null, $start = null, $limit = null, $filter = '', $returnType = null, $changeCaseTo=CASE_UPPER)
|
|
|
|
|
{
|
|
|
|
|
$c = new Criteria('workflow');
|
|
|
|
|
$c->addSelectColumn("BPMN_ACTIVITY.*");
|
|
|
|
|
$c->addSelectColumn("BPMN_BOUND.*");
|
|
|
|
|
$c->addJoin(BpmnActivityPeer::ACT_UID, BpmnBoundPeer::ELEMENT_UID, Criteria::LEFT_JOIN);
|
|
|
|
|
|
|
|
|
|
if (! is_null($prjUid)) {
|
|
|
|
|
$c->add(BpmnActivityPeer::PRJ_UID, $prjUid, Criteria::EQUAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$returnType = ($returnType != 'array' && $returnType != 'object') ? 'array' : $returnType;
|
|
|
|
|
$activities = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($returnType) {
|
|
|
|
|
case 'object':
|
|
|
|
|
$activities = BpmnActivityPeer::doSelect($c);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'array':
|
|
|
|
|
$rs = BpmnActivityPeer::doSelectRS($c);
|
|
|
|
|
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
while ($rs->next()) {
|
|
|
|
|
$activities[] = $changeCaseTo !== CASE_UPPER ? array_change_key_case($rs->getRow(), CASE_LOWER) : $rs->getRow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $activities;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
// OVERRIDES
|
2013-12-23 17:17:01 -04:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
public function setActUid($actUid)
|
|
|
|
|
{
|
|
|
|
|
parent::setActUid($actUid);
|
|
|
|
|
$this->bound->setElementUid($this->getActUid());
|
|
|
|
|
}
|
2013-12-23 17:17:01 -04:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
public function setPrjUid($prjUid)
|
|
|
|
|
{
|
|
|
|
|
parent::setPrjUid($prjUid);
|
|
|
|
|
$this->bound->setPrjUid($this->getPrjUid());
|
|
|
|
|
}
|
2013-12-23 17:17:01 -04:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
public function setProUid($proUid)
|
|
|
|
|
{
|
|
|
|
|
parent::setProUid($proUid);
|
2013-12-23 17:17:01 -04:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
$process = BpmnProcessPeer::retrieveByPK($this->getProUid());
|
|
|
|
|
$this->bound->setDiaUid($process->getDiaUid());
|
|
|
|
|
}
|
2014-01-17 13:37:15 -04:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
public function save($con = null)
|
|
|
|
|
{
|
|
|
|
|
parent::save($con);
|
2014-01-17 13:37:15 -04:00
|
|
|
|
2014-01-27 17:09:32 -04:00
|
|
|
$this->setBoundDefaults();
|
2014-02-04 20:50:18 -04:00
|
|
|
|
|
|
|
|
if ($this->bound->getBouUid() == "") {
|
|
|
|
|
$this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID());
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-27 17:09:32 -04:00
|
|
|
$this->bound->save($con);
|
2014-01-23 21:29:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function delete($con = null)
|
|
|
|
|
{
|
|
|
|
|
// first, delete the related bound object
|
2014-02-04 20:50:18 -04:00
|
|
|
if (! is_object($this->bound) || $this->bound->getBouUid() == "") {
|
2014-01-24 17:55:42 -04:00
|
|
|
$this->bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_object($this->bound)) {
|
2014-01-23 21:29:03 -04:00
|
|
|
$this->bound->delete($con);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parent::delete($con);
|
|
|
|
|
}
|
2014-01-17 13:37:15 -04:00
|
|
|
|
2014-02-03 19:37:50 -04:00
|
|
|
public function fromArray($data, $type = BasePeer::TYPE_FIELDNAME)
|
2014-01-17 13:37:15 -04:00
|
|
|
{
|
2014-02-03 19:37:50 -04:00
|
|
|
parent::fromArray($data, $type);
|
2014-01-17 13:37:15 -04:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
$bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
2014-01-17 13:37:15 -04:00
|
|
|
|
2014-01-23 21:29:03 -04:00
|
|
|
if (is_object($bound)) {
|
|
|
|
|
$this->bound = $bound;
|
2014-01-27 17:09:32 -04:00
|
|
|
} else {
|
|
|
|
|
$this->bound = new BpmnBound();
|
|
|
|
|
$this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID());
|
2014-01-17 13:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
2013-12-23 17:17:01 -04:00
|
|
|
}
|
|
|
|
|
|
2014-02-03 19:37:50 -04:00
|
|
|
public function toArray($type = BasePeer::TYPE_FIELDNAME)
|
2014-01-17 13:37:15 -04:00
|
|
|
{
|
2014-02-03 19:37:50 -04:00
|
|
|
$data = parent::toArray($type);
|
|
|
|
|
$bouUid = $this->bound->getBouUid();
|
|
|
|
|
|
2014-02-04 20:50:18 -04:00
|
|
|
if (! empty($bouUid)) {
|
2014-02-03 19:37:50 -04:00
|
|
|
$bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
2014-01-17 13:37:15 -04:00
|
|
|
|
2014-02-03 19:37:50 -04:00
|
|
|
if (is_object($bound)) {
|
|
|
|
|
$this->bound = $bound;
|
|
|
|
|
$data = array_merge($data, $this->bound->toArray($type));
|
|
|
|
|
}
|
2014-01-17 13:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data;
|
2013-12-23 17:17:01 -04:00
|
|
|
}
|
2014-01-17 13:37:15 -04:00
|
|
|
|
2013-12-02 17:36:37 -04:00
|
|
|
} // BpmnActivity
|