Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -86,7 +86,7 @@ Feature: Files Manager Resources
|
||||
|
||||
#Para que funcione este test, debe existir el archivo que se quiere subir
|
||||
Scenario: Post files
|
||||
Given POST I want to upload the file "/home/daniel/test.txt" to path "public". Url to create prf_uid "project/1265557095225ff5c688f46031700471/file-manager" and updload "project/1265557095225ff5c688f46031700471/file-manager/upload"
|
||||
Given POST I want to upload the file "/home/daniel/test.txt" to path "public". Url to create prf_uid "project/1265557095225ff5c688f46031700471/file-manager" and updload "project/1265557095225ff5c688f46031700471/file-manager"
|
||||
|
||||
Scenario: Delete file
|
||||
Given that I want to delete a "public/test.txt"
|
||||
|
||||
@@ -209,7 +209,7 @@ Requirements:
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"dyn_uid": "<92562207752ceef36c7d874048012431>"
|
||||
"dyn_uid": "92562207752ceef36c7d874048012431"
|
||||
}
|
||||
"""
|
||||
And I request "project/85794888452ceeef3675164057928956/process-supervisor/dynaform"
|
||||
|
||||
@@ -1329,18 +1329,22 @@ class RestContext extends BehatContext
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL,$postUrl);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => ""));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => NULL));
|
||||
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$postResult = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$aResult = explode(",",$postResult);
|
||||
$aFileUid = explode(":",$aResult[0]);
|
||||
$prfUid = trim(str_replace('"','',$aFileUid[1]));
|
||||
$postResult = (array)json_decode($postResult);
|
||||
if (sizeof($postResult) > 2) {
|
||||
$prfUid = $postResult["prf_uid"];
|
||||
} else {
|
||||
var_dump($postResult["error"]);
|
||||
}
|
||||
$url = $url.$prfUid."/upload";
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL,$url);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, array('my_file'=>'@'.$prfFile, 'prf_uid' => $prfUid));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_file'=>'@'.$prfFile));
|
||||
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$postResult = curl_exec($ch);
|
||||
@@ -1398,4 +1402,4 @@ class RestContext extends BehatContext
|
||||
$this->postIWantToUploadTheImageToUser($imageFile, $usrUid, $url);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ class BpmnEvent extends BaseBpmnEvent
|
||||
|
||||
// OVERRIDES
|
||||
|
||||
public function setActUid($actUid)
|
||||
public function setActUid($evnUid)
|
||||
{
|
||||
parent::setActUid($actUid);
|
||||
parent::setEvnUid($evnUid);
|
||||
$this->bound->setElementUid($this->getEvnUid());
|
||||
}
|
||||
|
||||
@@ -165,4 +165,12 @@ class BpmnEvent extends BaseBpmnEvent
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function exists($evnUid)
|
||||
{
|
||||
$c = new Criteria("workflow");
|
||||
$c->add(BpmnEventPeer::EVN_UID, $evnUid);
|
||||
|
||||
return BpmnEventPeer::doCount($c) > 0 ? true : false;
|
||||
}
|
||||
} // BpmnEvent
|
||||
|
||||
@@ -16,22 +16,50 @@ require_once 'classes/model/om/BaseBpmnFlow.php';
|
||||
*/
|
||||
class BpmnFlow extends BaseBpmnFlow
|
||||
{
|
||||
public static function removeAllRelated($elementUid)
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
|
||||
$c1 = $c->getNewCriterion(BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $elementUid);
|
||||
$c2 = $c->getNewCriterion(BpmnFlowPeer::FLO_ELEMENT_DEST, $elementUid);
|
||||
|
||||
$c1->addOr($c2);
|
||||
$c->add($c1);
|
||||
|
||||
$flows = BpmnFlowPeer::doSelect($c);
|
||||
|
||||
foreach ($flows as $flow) {
|
||||
$flow->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $field string coming from \BpmnFlowPeer::<FIELD_NAME>
|
||||
* @param $value string
|
||||
* @return \BpmnFlow|null
|
||||
*/
|
||||
public static function findOneBy($field, $value)
|
||||
public static function findOneBy($field, $value = null)
|
||||
{
|
||||
$rows = self::findAllBy($field, $value);
|
||||
|
||||
return empty($rows) ? null : $rows[0];
|
||||
}
|
||||
|
||||
public static function findAllBy($field, $value)
|
||||
/**
|
||||
* @param $field
|
||||
* @param null $value
|
||||
* @return \BpmnFlow[]
|
||||
*/
|
||||
public static function findAllBy($field, $value = null)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field => $value);
|
||||
|
||||
$c = new Criteria('workflow');
|
||||
$c->add($field, $value, Criteria::EQUAL);
|
||||
|
||||
foreach ($field as $key => $value) {
|
||||
$c->add($key, $value, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
return BpmnFlowPeer::doSelect($c);
|
||||
}
|
||||
@@ -83,4 +111,35 @@ class BpmnFlow extends BaseBpmnFlow
|
||||
return $flow;
|
||||
}
|
||||
|
||||
/*public static function select($select, $where = array())
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$c = new Criteria('workflow');
|
||||
if ($select !== '*') {
|
||||
if (is_array($select)) {
|
||||
foreach ($select as $column) {
|
||||
$c->addSelectColumn($column);
|
||||
}
|
||||
} else {
|
||||
$c->addSelectColumn($select);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($where)) {
|
||||
foreach ($where as $column => $value) {
|
||||
$c->add($column, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$rs = BpmnFlowPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rs->next()) {
|
||||
$data[] = $rs->getRow();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}*/
|
||||
|
||||
} // BpmnFlow
|
||||
|
||||
@@ -45,6 +45,11 @@ class BpmnGateway extends BaseBpmnGateway
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @return \BpmnGateway|null
|
||||
*/
|
||||
public static function findOneBy($field, $value)
|
||||
{
|
||||
$rows = self::findAllBy($field, $value);
|
||||
@@ -87,8 +92,8 @@ class BpmnGateway extends BaseBpmnGateway
|
||||
|
||||
public function setActUid($actUid)
|
||||
{
|
||||
parent::setActUid($actUid);
|
||||
$this->bound->setElementUid($this->getActUid());
|
||||
parent::setGatUid($actUid);
|
||||
$this->bound->setElementUid($this->getGatUid());
|
||||
}
|
||||
|
||||
public function setPrjUid($prjUid)
|
||||
@@ -166,4 +171,12 @@ class BpmnGateway extends BaseBpmnGateway
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function exists($gatUid)
|
||||
{
|
||||
$c = new Criteria("workflow");
|
||||
$c->add(BpmnGatewayPeer::GAT_UID, $gatUid);
|
||||
|
||||
return BpmnGatewayPeer::doCount($c) > 0 ? true : false;
|
||||
}
|
||||
|
||||
} // BpmnGateway
|
||||
|
||||
@@ -238,5 +238,25 @@ class Route extends BaseRoute
|
||||
|
||||
return RoutePeer::doSelect($c);
|
||||
}
|
||||
|
||||
public static function getAll($proUid = null, $start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn("ROUTE.*");
|
||||
|
||||
if (! is_null($proUid)) {
|
||||
$c->add(RoutePeer::PRO_UID, $proUid, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$rs = RoutePeer::doSelectRS($c);
|
||||
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$routes = array();
|
||||
while ($rs->next()) {
|
||||
$routes[] = $changeCaseTo !== CASE_UPPER ? array_change_key_case($rs->getRow(), CASE_LOWER) : $rs->getRow();
|
||||
}
|
||||
|
||||
return $routes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,17 +82,25 @@ class FilesManager
|
||||
}
|
||||
foreach ($aFiles as $aFile) {
|
||||
$arrayFileUid = $this->getFileManagerUid($sDirectory.$aFile['FILE']);
|
||||
$fcontent = file_get_contents($sDirectory.$aFile['FILE']);
|
||||
$fileUid = $arrayFileUid["PRF_UID"];
|
||||
if ($fileUid) {
|
||||
$oProcessFiles = \ProcessFilesPeer::retrieveByPK($fileUid);
|
||||
$editable = $oProcessFiles->getPrfEditable();
|
||||
if ($editable == 1){
|
||||
$editable = 'true';
|
||||
} else {
|
||||
$editable = 'false';
|
||||
}
|
||||
$aTheFiles[] = array( 'prf_filename' => $aFile['FILE'],
|
||||
'usr_uid' => $oProcessFiles->getUsrUid(),
|
||||
'prf_update_usr_uid' => $oProcessFiles->getPrfUpdateUsrUid(),
|
||||
'prf_path' => $sMainDirectory. PATH_SEP .$sSubDirectory,
|
||||
'prf_type' => $oProcessFiles->getPrfType(),
|
||||
'prf_editable' => $oProcessFiles->getPrfEditable(),
|
||||
'prf_editable' => $editable,
|
||||
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
|
||||
'prf_update_date' => $oProcessFiles->getPrfUpdateDate());
|
||||
'prf_update_date' => $oProcessFiles->getPrfUpdateDate(),
|
||||
'prf_content' => $fcontent);
|
||||
|
||||
} else {
|
||||
$aTheFiles[] = array('prf_filename' => $aFile['FILE'],
|
||||
@@ -100,9 +108,10 @@ class FilesManager
|
||||
'prf_update_usr_uid' => '',
|
||||
'prf_path' => $sMainDirectory. PATH_SEP .$sSubDirectory,
|
||||
'prf_type' => 'file',
|
||||
'prf_editable' => '',
|
||||
'prf_editable' => $editable,
|
||||
'prf_create_date' => '',
|
||||
'prf_update_date' => '');
|
||||
'prf_update_date' => '',
|
||||
'prf_content' => $fcontent);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,6 +136,9 @@ class FilesManager
|
||||
{
|
||||
try {
|
||||
$aData['prf_path'] = rtrim($aData['prf_path'], '/') . '/';
|
||||
if (!$aData['prf_filename']){
|
||||
throw (new \Exception( 'invalid value specified for `prf_filename`.'));
|
||||
}
|
||||
$sMainDirectory = current(explode("/", $aData['prf_path']));
|
||||
if ($sMainDirectory != 'public' && $sMainDirectory != 'templates') {
|
||||
throw (new \Exception( 'invalid value specified for `prf_path`. Expecting `templates/` or `public/`'));
|
||||
@@ -184,7 +196,8 @@ class FilesManager
|
||||
'prf_type' => $oProcessFiles->getPrfType(),
|
||||
'prf_editable' => $oProcessFiles->getPrfEditable(),
|
||||
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
|
||||
'prf_update_date' => $oProcessFiles->getPrfUpdateDate());
|
||||
'prf_update_date' => $oProcessFiles->getPrfUpdateDate(),
|
||||
'prf_content' => $content);
|
||||
return $oProcessFile;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
@@ -195,15 +208,14 @@ class FilesManager
|
||||
* Return the Process Files Manager
|
||||
*
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param array $aData
|
||||
* @param string $prfUid {@min 32} {@max 32}
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function uploadProcessFilesManager($prjUid, $aData)
|
||||
public function uploadProcessFilesManager($prjUid, $prfUid)
|
||||
{
|
||||
try {
|
||||
$prfUid = $aData['prf_uid'];
|
||||
$path = '';
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH);
|
||||
@@ -220,10 +232,14 @@ class FilesManager
|
||||
}
|
||||
$file = end(explode("/",$path));
|
||||
$path = str_replace($file,'',$path);
|
||||
if ($_FILES['my_file']['error'] != 1) {
|
||||
if ($_FILES['my_file']['tmp_name'] != '') {
|
||||
\G::uploadFile($_FILES['my_file']['tmp_name'],$path , $_FILES['my_file']['name']);
|
||||
}
|
||||
if ($file == $_FILES['prf_file']['name']) {
|
||||
if ($_FILES['prf_file']['error'] != 1) {
|
||||
if ($_FILES['prf_file']['tmp_name'] != '') {
|
||||
\G::uploadFile($_FILES['prf_file']['tmp_name'],$path , $_FILES['prf_file']['name']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
@@ -320,7 +336,8 @@ class FilesManager
|
||||
'prf_type' => $oProcessFiles->getPrfType(),
|
||||
'prf_editable' => $sEditable,
|
||||
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
|
||||
'prf_update_date' => $oProcessFiles->getPrfUpdateDate());
|
||||
'prf_update_date' => $oProcessFiles->getPrfUpdateDate(),
|
||||
'prf_content' => $content);
|
||||
return $oProcessFile;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
|
||||
@@ -321,17 +321,17 @@ class Step
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid . ", " . $arrayData["STEP_TYPE_OBJ"] . ", " . $arrayData["STEP_UID_OBJ"], "STEP"), "The record \"{0}\", exists in table {1}")));
|
||||
}
|
||||
|
||||
if (isset($arrayData["STEP_POSITION"]) && $this->existsRecord($taskUid, "", "", $arrayData["STEP_POSITION"])) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["STEP_POSITION"], $taskUid . ", " . $arrayData["STEP_POSITION"], "STEP"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
|
||||
}
|
||||
|
||||
//Create
|
||||
$step = new \Step();
|
||||
|
||||
$stepUid = $step->create(array("PRO_UID" => $processUid, "TAS_UID" => $taskUid));
|
||||
$stepUid = $step->create(array(
|
||||
"PRO_UID" => $processUid,
|
||||
"TAS_UID" => $taskUid,
|
||||
"STEP_POSITION" => $step->getNextPosition($taskUid)
|
||||
));
|
||||
|
||||
if (!isset($arrayData["STEP_POSITION"]) || $arrayData["STEP_POSITION"] == "") {
|
||||
$arrayData["STEP_POSITION"] = $step->getNextPosition($taskUid) - 1;
|
||||
unset($arrayData["STEP_POSITION"]);
|
||||
}
|
||||
|
||||
$arrayData = $this->update($stepUid, $arrayData);
|
||||
@@ -369,7 +369,6 @@ class Step
|
||||
|
||||
//Load Step
|
||||
$step = new \Step();
|
||||
|
||||
$arrayStepData = $step->load($stepUid);
|
||||
|
||||
$taskUid = $arrayStepData["TAS_UID"];
|
||||
@@ -428,19 +427,21 @@ class Step
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayData["STEP_POSITION"]) && ($arrayData["STEP_POSITION"] != $arrayStepData["STEP_POSITION"])) {
|
||||
$this->moveSteps($proUid, $taskUid, $stepUid, $arrayData["STEP_POSITION"]);
|
||||
}
|
||||
|
||||
//Update
|
||||
$step = new \Step();
|
||||
|
||||
$arrayData["STEP_UID"] = $stepUid;
|
||||
|
||||
$tempPosition = (isset($arrayData["STEP_POSITION"])) ? $arrayData["STEP_POSITION"] : $arrayStepData["STEP_POSITION"];
|
||||
$arrayData["STEP_POSITION"] = $arrayStepData["STEP_POSITION"];
|
||||
$result = $step->update($arrayData);
|
||||
|
||||
if (isset($tempPosition) && ($tempPosition != $arrayStepData["STEP_POSITION"])) {
|
||||
$this->moveSteps($proUid, $taskUid, $stepUid, $tempPosition);
|
||||
}
|
||||
|
||||
//Return
|
||||
unset($arrayData["STEP_UID"]);
|
||||
$arrayData["STEP_POSITION"] = $tempPosition;
|
||||
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
@@ -875,7 +876,9 @@ class Step
|
||||
$seStepPos = $step_pos;
|
||||
|
||||
//Principal Step is up
|
||||
if ($prStepPos < $seStepPos) {
|
||||
if ($prStepPos == $seStepPos) {
|
||||
return true;
|
||||
} elseif ($prStepPos < $seStepPos) {
|
||||
$modPos = 'UP';
|
||||
$newPos = $seStepPos;
|
||||
$iniPos = $prStepPos+1;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace BusinessModel\Step;
|
||||
|
||||
use \BusinessModel\Step;
|
||||
|
||||
class Trigger
|
||||
{
|
||||
/**
|
||||
@@ -184,10 +186,6 @@ class Trigger
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($triggerUid, "TRIGGERS"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, $taskUid, "", $arrayData["st_position"], $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $taskUid . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
|
||||
}
|
||||
|
||||
//Update
|
||||
$stepTrigger = new \StepTrigger();
|
||||
|
||||
@@ -203,10 +201,13 @@ class Trigger
|
||||
}
|
||||
|
||||
if (isset($arrayData["st_position"]) && $arrayData["st_position"] != "") {
|
||||
$arrayUpdateData["ST_POSITION"] = (int)($arrayData["st_position"]);
|
||||
$tempPos = (int)($arrayData["st_position"]);
|
||||
}
|
||||
|
||||
$stepTrigger->update($arrayUpdateData);
|
||||
if (isset($tempPos)) {
|
||||
$this->moveStepTriggers($taskUid, $stepUid, $triggerUid, $type, $tempPos);
|
||||
}
|
||||
|
||||
return array_change_key_case($arrayUpdateData, CASE_LOWER);
|
||||
} catch (\Exception $e) {
|
||||
@@ -360,5 +361,84 @@ class Trigger
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Process Uid
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $tas_uid. Uid for Task
|
||||
* @var string $step_uid. Uid for Step
|
||||
* @var string $step_pos. Position for Step
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function moveStepTriggers($tasUid, $stepUid, $triUid, $type, $newPos) {
|
||||
$stepTrigger = new \BusinessModel\Step();
|
||||
$aStepTriggers = $stepTrigger->getTriggers($stepUid, $tasUid);
|
||||
foreach ($aStepTriggers as $dataStep) {
|
||||
if (($dataStep['st_type'] == $type) && ($dataStep['tri_uid'] == $triUid)) {
|
||||
$prStepPos = (int)$dataStep['st_position'];
|
||||
}
|
||||
}
|
||||
$seStepPos = $newPos;
|
||||
|
||||
//Principal Step is up
|
||||
if ($prStepPos == $seStepPos) {
|
||||
return true;
|
||||
} elseif ($prStepPos < $seStepPos) {
|
||||
$modPos = 'UP';
|
||||
$newPos = $seStepPos;
|
||||
$iniPos = $prStepPos+1;
|
||||
$finPos = $seStepPos;
|
||||
} else {
|
||||
$modPos = 'DOWN';
|
||||
$newPos = $seStepPos;
|
||||
$iniPos = $seStepPos;
|
||||
$finPos = $prStepPos-1;
|
||||
}
|
||||
|
||||
$range = range($iniPos, $finPos);
|
||||
foreach ($aStepTriggers as $dataStep) {
|
||||
if (($dataStep['st_type'] == $type) && (in_array($dataStep['st_position'], $range)) && ($dataStep['tri_uid'] != $triUid)) {
|
||||
$stepChangeIds[] = $dataStep['tri_uid'];
|
||||
$stepChangePos[] = $dataStep['st_position'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($stepChangeIds as $key => $value) {
|
||||
if ($modPos == 'UP') {
|
||||
$tempPos = ((int)$stepChangePos[$key])-1;
|
||||
$this->changePosStep($stepUid, $tasUid, $value, $type, $tempPos);
|
||||
} else {
|
||||
$tempPos = ((int)$stepChangePos[$key])+1;
|
||||
$this->changePosStep($stepUid, $tasUid, $value, $type, $tempPos);
|
||||
}
|
||||
}
|
||||
$this->changePosStep($stepUid, $tasUid, $triUid, $type, $newPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Process Uid
|
||||
* @var string $pro_uid. Uid for process
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function changePosStep ($stepUid, $tasUid, $triUid, $type, $pos)
|
||||
{
|
||||
$data = array(
|
||||
'STEP_UID' => $stepUid,
|
||||
'TAS_UID' => $tasUid,
|
||||
'TRI_UID' => $triUid,
|
||||
'ST_TYPE' => $type,
|
||||
'ST_POSITION' => $pos
|
||||
);
|
||||
$StepTrigger = new \StepTrigger();
|
||||
$StepTrigger->update($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
{
|
||||
$taskData = array();
|
||||
|
||||
$taskData["TAS_UID"] = parent::addActivity($data);
|
||||
$actUid = parent::addActivity($data);
|
||||
$taskData["TAS_UID"] = $actUid;
|
||||
|
||||
if (array_key_exists("ACT_NAME", $data)) {
|
||||
$taskData["TAS_TITLE"] = $data["ACT_NAME"];
|
||||
@@ -118,6 +119,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
|
||||
$this->wp->addTask($taskData);
|
||||
|
||||
return $actUid;
|
||||
}
|
||||
|
||||
public function updateActivity($actUid, $data)
|
||||
@@ -145,55 +148,73 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$this->wp->removeTask($actUid);
|
||||
}
|
||||
|
||||
public function addFlow($data, $diagram)
|
||||
public function removeGateway($gatUid)
|
||||
{
|
||||
$flows = $diagram["flows"];
|
||||
$gateways = $diagram["gateways"];
|
||||
$events = $diagram["events"];
|
||||
$gatewayData = $this->getGateway($gatUid);
|
||||
$flowsDest = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid);
|
||||
|
||||
parent::addFlow($data);
|
||||
foreach ($flowsDest as $flowDest) {
|
||||
switch ($flowDest->getFloElementOriginType()) {
|
||||
case "bpmnActivity":
|
||||
$actUid = $flowDest->getFloElementOrigin();
|
||||
$flowsOrigin = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid);
|
||||
|
||||
foreach ($flowsOrigin as $flowOrigin) {
|
||||
switch ($flowOrigin->getFloElementDestType()) {
|
||||
case "bpmnActivity":
|
||||
$toActUid = $flowOrigin->getFloElementDest();
|
||||
$this->wp->removeRouteFromTo($actUid, $toActUid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
parent::removeGateway($gatUid);
|
||||
}
|
||||
|
||||
// public function addFlow($data)
|
||||
// {
|
||||
// parent::addFlow($data);
|
||||
|
||||
// to add a workflow route
|
||||
// - activity -> activity ==> route
|
||||
// - activity -> gateway -> activity ==> selection, evaluation, parallel or parallel by evaluation route
|
||||
$routes = self::mapBpmnFlowsToWorkflowRoute($data, $flows, $gateways, $events);
|
||||
// $routes = self::mapBpmnFlowsToWorkflowRoute($data, $flows);
|
||||
//
|
||||
// if ($routes !== null) {
|
||||
// foreach ($routes as $routeData) {
|
||||
// $this->wp->addRoute($routeData["from"], $routeData["to"], $routeData["type"]);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// // to add start event->activity as initial or end task
|
||||
// switch ($data["FLO_ELEMENT_ORIGIN_TYPE"]) {
|
||||
// case "bpmnEvent":
|
||||
// switch ($data["FLO_ELEMENT_DEST_TYPE"]) {
|
||||
// case "bpmnActivity":
|
||||
// $event = \BpmnEventPeer::retrieveByPK($data["FLO_ELEMENT_ORIGIN"]);
|
||||
//
|
||||
// switch ($event && $event->getEvnType()) {
|
||||
// case "START":
|
||||
// // then set that activity/task as "Start Task"
|
||||
// $this->wp->setStartTask($data["FLO_ELEMENT_DEST"]);
|
||||
// break;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
|
||||
if ($routes !== null) {
|
||||
foreach ($routes as $routeData) {
|
||||
$this->wp->addRoute($routeData["from"], $routeData["to"], $routeData["type"]);
|
||||
}
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// to add start event->activity as initial or end task
|
||||
switch ($data["FLO_ELEMENT_ORIGIN_TYPE"]) {
|
||||
case "bpmnEvent":
|
||||
switch ($data["FLO_ELEMENT_DEST_TYPE"]) {
|
||||
case "bpmnActivity":
|
||||
$event = \BpmnEventPeer::retrieveByPK($data["FLO_ELEMENT_ORIGIN"]);
|
||||
|
||||
switch ($event && $event->getEvnType()) {
|
||||
case "START":
|
||||
// then set that activity/task as "Start Task"
|
||||
$this->wp->setStartTask($data["FLO_ELEMENT_DEST"]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateFlow($floUid, $data)
|
||||
{
|
||||
if (! self::isModified("flow", $floUid, $data)) {
|
||||
self::log("Update Flow: $floUid (No Changes)");
|
||||
return false;
|
||||
}
|
||||
|
||||
parent::updateFlow($floUid, $data);
|
||||
}
|
||||
// public function updateFlow($floUid, $data, $flows)
|
||||
// {
|
||||
// parent::updateFlow($floUid, $data);
|
||||
// }
|
||||
|
||||
public function removeFlow($floUid)
|
||||
{
|
||||
@@ -224,7 +245,20 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$this->wp->setEndTask($activity->getActUid(), false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch ($flow->getFloElementOriginType()) {
|
||||
case "bpmnActivity":
|
||||
switch ($flow->getFloElementDestType()) {
|
||||
// activity->activity
|
||||
case "bpmnActivity":
|
||||
$this->wp->removeRouteFromTo($flow->getFloElementOrigin(), $flow->getFloElementDest());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Complete for other routes, activity->activity, activity->gateway and viceversa
|
||||
}
|
||||
|
||||
public function addEvent($data)
|
||||
@@ -236,35 +270,102 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
parent::addEvent($data);
|
||||
}
|
||||
|
||||
public function removeEvent($evnUid)
|
||||
public function mapBpmnFlowsToWorkflowRoutes()
|
||||
{
|
||||
// $event = \BpmnEventPeer::retrieveByPK($evnUid);
|
||||
//
|
||||
// switch ($event->getEvnType()) {
|
||||
// case "START":
|
||||
// $flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $event->getEvnUid());
|
||||
// if (! is_null($flow) && $flow->getFloElementDestType() == "bpmnActivity") {
|
||||
// $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementDest());
|
||||
// if (! is_null($activity)) {
|
||||
// $this->wp->setStartTask($activity->getActUid(), false);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case "END":
|
||||
// $flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $event->getEvnUid());
|
||||
// if (! is_null($flow) && $flow->getFloElementOriginType() == "bpmnActivity") {
|
||||
// $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin());
|
||||
// if (! is_null($activity)) {
|
||||
// $this->wp->setEndTask($activity->getActUid(), false);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
$activities = $this->getActivities();
|
||||
|
||||
parent::removeEvent($evnUid);
|
||||
foreach ($activities as $activity) {
|
||||
|
||||
$flows = \BpmnFlow::findAllBy(array(
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"],
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnActivity"
|
||||
));
|
||||
|
||||
//
|
||||
foreach ($flows as $flow) {
|
||||
switch ($flow->getFloElementDestType()) {
|
||||
case "bpmnActivity":
|
||||
// (activity -> activity)
|
||||
$this->wp->addRoute($activity["ACT_UID"], $flow->getFloElementDest(), "SEQUENTIAL");
|
||||
break;
|
||||
|
||||
case "bpmnGateway":
|
||||
// (activity -> gateway)
|
||||
// we must find the related flows: gateway -> <object>
|
||||
$gatUid = $flow->getFloElementDest();
|
||||
$gatewayFlows = \BpmnFlow::findAllBy(array(
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatUid,
|
||||
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnGateway"
|
||||
));
|
||||
|
||||
foreach ($gatewayFlows as $gatewayFlow) {
|
||||
$gatewayFlow = $gatewayFlow->toArray();
|
||||
|
||||
switch ($gatewayFlow['FLO_ELEMENT_DEST_TYPE']) {
|
||||
case 'bpmnActivity':
|
||||
// (gateway -> activity)
|
||||
$gateway = \BpmnGateway::findOneBy(\BpmnGatewayPeer::GAT_UID, $gatUid)->toArray();
|
||||
|
||||
switch ($gateway["GAT_TYPE"]) {
|
||||
//case 'SELECTION':
|
||||
case self::BPMN_GATEWAY_COMPLEX:
|
||||
$routeType = "SELECT";
|
||||
break;
|
||||
//case 'EVALUATION':
|
||||
case self::BPMN_GATEWAY_EXCLUSIVE:
|
||||
$routeType = "EVALUATE";
|
||||
break;
|
||||
//case 'PARALLEL':
|
||||
case self::BPMN_GATEWAY_PARALLEL:
|
||||
if ($gateway["GAT_DIRECTION"] == "DIVERGING") {
|
||||
$routeType = "PARALLEL";
|
||||
} elseif ($gateway["GAT_DIRECTION"] == "CONVERGING") {
|
||||
$routeType = "SEC-JOIN";
|
||||
} else {
|
||||
throw new \LogicException(sprintf(
|
||||
"Invalid Gateway direction, accepted values: [%s|%s], given: %s.",
|
||||
"DIVERGING", "CONVERGING", $gateway["GAT_DIRECTION"]
|
||||
));
|
||||
}
|
||||
break;
|
||||
//case 'PARALLEL_EVALUATION':
|
||||
case self::BPMN_GATEWAY_INCLUSIVE:
|
||||
if ($gateway["GAT_DIRECTION"] == "DIVERGING") {
|
||||
$routeType = "PARALLEL-BY-EVALUATION";
|
||||
} elseif ($gateway["GAT_DIRECTION"] == "CONVERGING") {
|
||||
$routeType = "SEC-JOIN";
|
||||
} else {
|
||||
throw new \LogicException(sprintf(
|
||||
"Invalid Gateway direction, accepted values: [%s|%s], given: %s.",
|
||||
"DIVERGING", "CONVERGING", $gateway["GAT_DIRECTION"]
|
||||
));
|
||||
}
|
||||
break;
|
||||
// case 'PARALLEL_JOIN':
|
||||
// $routeType = 'SEC-JOIN';
|
||||
// break;
|
||||
default:
|
||||
throw new \LogicException(sprintf("Unsupported Gateway type: %s", $gateway['GAT_TYPE']));
|
||||
}
|
||||
|
||||
$this->wp->addRoute($activity["ACT_UID"], $gatewayFlow['FLO_ELEMENT_DEST'], $routeType);
|
||||
break;
|
||||
default:
|
||||
// for processmaker is only allowed flows between "gateway -> activity"
|
||||
// any another flow is considered invalid
|
||||
throw new \LogicException(sprintf(
|
||||
"For ProcessMaker is only allowed flows between \"gateway -> activity\" " . PHP_EOL .
|
||||
"Given: bpmnGateway -> " . $gatewayFlow['FLO_ELEMENT_DEST_TYPE']
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function mapBpmnFlowsToWorkflowRoute($flow, $flows, $gateways, $events)
|
||||
public static function mapBpmnFlowsToWorkflowRoute2($flow, $flows, $gateways, $events)
|
||||
{
|
||||
$fromUid = $flow['FLO_ELEMENT_ORIGIN'];
|
||||
$result = array();
|
||||
@@ -387,11 +488,6 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
return $result;
|
||||
}
|
||||
|
||||
// public function getActivities()
|
||||
// {
|
||||
// return parent::getActivities();
|
||||
// }
|
||||
|
||||
public function remove()
|
||||
{
|
||||
parent::remove();
|
||||
|
||||
@@ -325,6 +325,7 @@ class Bpmn extends Handler
|
||||
|
||||
$activity = ActivityPeer::retrieveByPK($actUid);
|
||||
$activity->delete();
|
||||
//TODO if the activity was removed, the related flows to that activity must be removed
|
||||
|
||||
self::log("Remove Activity Success!");
|
||||
} catch (\Exception $e) {
|
||||
@@ -438,7 +439,6 @@ class Bpmn extends Handler
|
||||
$gateway->setPrjUid($this->getUid());
|
||||
$gateway->setProUid($this->getProcess("object")->getProUid());
|
||||
$gateway->save();
|
||||
|
||||
self::log("Add Gateway Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
@@ -500,6 +500,9 @@ class Bpmn extends Handler
|
||||
$gateway = GatewayPeer::retrieveByPK($gatUid);
|
||||
$gateway->delete();
|
||||
|
||||
// remove related object (flows)
|
||||
Flow::removeAllRelated($gatUid);
|
||||
|
||||
self::log("Remove Gateway Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
@@ -518,13 +521,48 @@ class Bpmn extends Handler
|
||||
}
|
||||
|
||||
try {
|
||||
switch ($data["FLO_ELEMENT_ORIGIN_TYPE"]) {
|
||||
case "bpmnActivity": $class = "BpmnActivity"; break;
|
||||
case "bpmnGateway": $class = "BpmnGateway"; break;
|
||||
case "bpmnEvent": $class = "BpmnEvent"; break;
|
||||
default:
|
||||
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s], given %s.",
|
||||
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", $data["FLO_ELEMENT_ORIGIN_TYPE"]
|
||||
));
|
||||
}
|
||||
|
||||
// Validate origin object exists
|
||||
if (! $class::exists($data["FLO_ELEMENT_ORIGIN"])) {
|
||||
throw new \RuntimeException(sprintf("Reference not found, the %s with UID: %s, does not exist!",
|
||||
ucfirst($data["FLO_ELEMENT_ORIGIN_TYPE"]), $data["FLO_ELEMENT_ORIGIN"]
|
||||
));
|
||||
}
|
||||
|
||||
switch ($data["FLO_ELEMENT_DEST_TYPE"]) {
|
||||
case "bpmnActivity": $class = "BpmnActivity"; break;
|
||||
case "bpmnGateway": $class = "BpmnGateway"; break;
|
||||
case "bpmnEvent": $class = "BpmnEvent"; break;
|
||||
default:
|
||||
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s], given %s.",
|
||||
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", $data["FLO_ELEMENT_DEST_TYPE"]
|
||||
));
|
||||
}
|
||||
|
||||
// Validate origin object exists
|
||||
if (! $class::exists($data["FLO_ELEMENT_DEST"])) {
|
||||
throw new \RuntimeException(sprintf("Reference not found, the %s with UID: %s, does not exist!",
|
||||
ucfirst($data["FLO_ELEMENT_DEST_TYPE"]), $data["FLO_ELEMENT_DEST"]
|
||||
));
|
||||
}
|
||||
|
||||
$flow = new Flow();
|
||||
$flow->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$flow->setPrjUid($this->getUid());
|
||||
$flow->setDiaUid($this->getDiagram("object")->getDiaUid());
|
||||
$flow->save();
|
||||
|
||||
self::log("Add Flow Success!");
|
||||
|
||||
return $flow->getFloUid();
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
|
||||
@@ -325,6 +325,24 @@ class Workflow extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function removeRouteFromTo($fromTasUid, $toTasUid)
|
||||
{
|
||||
try {
|
||||
self::log("Remove Route from $fromTasUid -> to $toTasUid");
|
||||
|
||||
$route = Route::findOneBy(array(
|
||||
RoutePeer::TAS_UID => $fromTasUid,
|
||||
RoutePeer::ROU_NEXT_TASK => $toTasUid
|
||||
));
|
||||
|
||||
$route->delete();
|
||||
self::log("Remove Route Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getRoute($rouUid)
|
||||
{
|
||||
$route = new Route();
|
||||
@@ -332,6 +350,11 @@ class Workflow extends Handler
|
||||
return $route->load($rouUid);
|
||||
}
|
||||
|
||||
public function getRoutes()
|
||||
{
|
||||
return Route::getAll($proUid = null, $start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************************
|
||||
* Migrated Methods from class.processMap.php class *
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ProcessMaker\Util;
|
||||
/**
|
||||
* Singleton Class Logger
|
||||
*
|
||||
* This Utility is usefull to log local messages
|
||||
* This Utility is useful to log local messages
|
||||
* @package ProcessMaker\Util
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ class Logger
|
||||
$this->setLog(date('Y-m-d H:i:s') . " ");
|
||||
|
||||
foreach ($args as $str) {
|
||||
$this->setLog((is_string($str) ? $str : print_r($str, true)) . PHP_EOL);
|
||||
$this->setLog((is_string($str) ? $str : var_export($str, true)) . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class Logger
|
||||
$this->setLog(date('Y-m-d H:i:s') . " ");
|
||||
|
||||
foreach ($args as $str) {
|
||||
$this->setLog((is_string($str) ? $str : print_r($str, true)) . " ");
|
||||
$this->setLog((is_string($str) ? $str : var_export($str, true)) . " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -249,9 +249,9 @@ class Project extends Api
|
||||
foreach ($diagram["flows"] as $flowData) {
|
||||
$flow = $bwp->getFlow($flowData["FLO_UID"]);
|
||||
if (is_null($flow)) {
|
||||
$bwp->addFlow($flowData, $diagram);
|
||||
$bwp->addFlow($flowData, $diagram["flows"]);
|
||||
} elseif (! $bwp->isEquals($flow, $flowData)) {
|
||||
$bwp->updateFlow($flowData["FLO_UID"], $flowData);
|
||||
$bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]);
|
||||
} else {
|
||||
Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required");
|
||||
}
|
||||
@@ -266,6 +266,8 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
$bwp->mapBpmnFlowsToWorkflowRoutes();
|
||||
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
|
||||
@@ -46,7 +46,6 @@ class FilesManager extends Api
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$request_data = (array)($request_data);
|
||||
|
||||
$filesManager = new \BusinessModel\FilesManager();
|
||||
$arrayData = $filesManager->addProcessFilesManager($prjUid, $userUid, $request_data);
|
||||
//Response
|
||||
@@ -60,15 +59,15 @@ class FilesManager extends Api
|
||||
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param array $request_data
|
||||
* @param string $prfUid {@min 32} {@max 32}
|
||||
*
|
||||
* @url POST /:prjUid/file-manager/upload
|
||||
* @url POST /:prjUid/file-manager/:prfUid/upload
|
||||
*/
|
||||
public function doPostProcessFilesManagerUpload($prjUid, $request_data)
|
||||
public function doPostProcessFilesManagerUpload($prjUid, $prfUid)
|
||||
{
|
||||
try {
|
||||
$filesManager = new \BusinessModel\FilesManager();
|
||||
$filesManager->uploadProcessFilesManager($prjUid, $request_data);
|
||||
$filesManager->uploadProcessFilesManager($prjUid, $prfUid);
|
||||
} catch (\Exception $e) {
|
||||
//response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
@@ -144,7 +143,7 @@ class ProcessFilesManagerStructure
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $prf_path;
|
||||
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user