Refactoring Bpmn/Workflow handling layer (4th commit) - adding unit test for BpmnActivity class that is handling transparently its Bound object
This commit is contained in:
@@ -45,48 +45,19 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
}
|
||||
}
|
||||
|
||||
// OVERRIDES
|
||||
|
||||
public function setActUid($actUid)
|
||||
public static function findOneBy($field, $value)
|
||||
{
|
||||
parent::setActUid($actUid);
|
||||
$this->bound->setElementUid($this->getActUid());
|
||||
$rows = self::findAllBy($field, $value);
|
||||
|
||||
return empty($rows) ? null : $rows[0];
|
||||
}
|
||||
|
||||
public function setPrjUid($prjUid)
|
||||
public static function findAllBy($field, $value)
|
||||
{
|
||||
parent::setPrjUid($prjUid);
|
||||
$this->bound->setPrjUid($this->getPrjUid());
|
||||
}
|
||||
$c = new Criteria('workflow');
|
||||
$c->add($field, $value, Criteria::EQUAL);
|
||||
|
||||
public function setProUid($proUid)
|
||||
{
|
||||
parent::setProUid($proUid);
|
||||
|
||||
$process = BpmnProcessPeer::retrieveByPK($this->getProUid());
|
||||
$this->bound->setDiaUid($process->getDiaUid());
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
parent::save($con);
|
||||
|
||||
$this->setBoundDefaults();
|
||||
$this->bound->save($con);
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
// first, delete the related bound object
|
||||
if (! is_object($this->bound)) {
|
||||
$this->bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
||||
}
|
||||
|
||||
if (is_object($this->bound)) {
|
||||
$this->bound->delete($con);
|
||||
}
|
||||
|
||||
parent::delete($con);
|
||||
return BpmnActivityPeer::doSelect($c);
|
||||
}
|
||||
|
||||
public static function getAll($prjUid = null, $start = null, $limit = null, $filter = '', $returnType = null, $changeCaseTo=CASE_UPPER)
|
||||
@@ -118,10 +89,59 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $activities;
|
||||
}
|
||||
|
||||
// OVERRIDES
|
||||
|
||||
public function setActUid($actUid)
|
||||
{
|
||||
parent::setActUid($actUid);
|
||||
$this->bound->setElementUid($this->getActUid());
|
||||
}
|
||||
|
||||
public function setPrjUid($prjUid)
|
||||
{
|
||||
parent::setPrjUid($prjUid);
|
||||
$this->bound->setPrjUid($this->getPrjUid());
|
||||
}
|
||||
|
||||
public function setProUid($proUid)
|
||||
{
|
||||
parent::setProUid($proUid);
|
||||
|
||||
$process = BpmnProcessPeer::retrieveByPK($this->getProUid());
|
||||
$this->bound->setDiaUid($process->getDiaUid());
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
parent::save($con);
|
||||
|
||||
$this->setBoundDefaults();
|
||||
|
||||
if ($this->bound->getBouUid() == "") {
|
||||
$this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID());
|
||||
}
|
||||
|
||||
$this->bound->save($con);
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
// first, delete the related bound object
|
||||
if (! is_object($this->bound) || $this->bound->getBouUid() == "") {
|
||||
$this->bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
||||
}
|
||||
|
||||
if (is_object($this->bound)) {
|
||||
$this->bound->delete($con);
|
||||
}
|
||||
|
||||
parent::delete($con);
|
||||
}
|
||||
|
||||
public function fromArray($data, $type = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
parent::fromArray($data, $type);
|
||||
@@ -143,7 +163,7 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
$data = parent::toArray($type);
|
||||
$bouUid = $this->bound->getBouUid();
|
||||
|
||||
if (empty($bouUid)) {
|
||||
if (! empty($bouUid)) {
|
||||
$bound = BpmnBound::findByElement('Activity', $this->getActUid());
|
||||
|
||||
if (is_object($bound)) {
|
||||
|
||||
@@ -17,16 +17,18 @@ require_once 'classes/model/om/BaseBpmnBound.php';
|
||||
class BpmnBound extends BaseBpmnBound
|
||||
{
|
||||
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);
|
||||
|
||||
$c->add($field, $value, CRITERIA::EQUAL );
|
||||
|
||||
$rs = ContentPeer::doSelectRS($c);
|
||||
//$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
|
||||
return $rs->getRow();
|
||||
return BpmnBoundPeer::doSelect($c);
|
||||
}
|
||||
|
||||
public static function findByElement($type, $uid)
|
||||
|
||||
Reference in New Issue
Block a user