Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -48,7 +48,6 @@
|
||||
},
|
||||
"require-dev":{
|
||||
"guzzle/guzzle":"~3.1.1",
|
||||
"behat/behat":"2.4.*@stable",
|
||||
"lisachenko/go-aop-php": "*"
|
||||
"behat/behat":"2.4.*@stable"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ Feature: Output Documents Negative Tests
|
||||
Examples:
|
||||
|
||||
| test_description | project | inp_doc_title | inp_doc_description | inp_doc_form_needed | inp_doc_original | inp_doc_published | inp_doc_versioning | inp_doc_destination_path | inp_doc_tags | error_code | error_message |
|
||||
| Create with project invalid | 14414793652a5d718b65590036 | My InputDocument1 | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | project |
|
||||
| Create with project invalid | 14414793652a5d718b65590036 | My InputDocument1 | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | prj_uid |
|
||||
| Invalid inp doc from needed | 14414793652a5d718b65590036026581 | My InputDocument4 | My InputDocument4 DESCRIPTION | VRESAMPLE12334$%#@ | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_form_needed |
|
||||
| Invalid inp doc original | 14414793652a5d718b65590036026581 | My InputDocument5 | My InputDocument5 DESCRIPTION | VIRTUAL | COORIGI 123@#$%$% | PRIVATE | 1 | | INPUT | 400 | inp_doc_original |
|
||||
| Invalid inp doc published | 14414793652a5d718b65590036026581 | My InputDocument6 | My InputDocument6 DESCRIPTION | VIRTUAL | ORIGINAL | PRIV123234@##$$%% | 0 | | INPUT | 400 | inp_doc_published |
|
||||
| Invalid inp doc versioning | 14414793652a5d718b65590036026581 | My InputDocument7 | My InputDocument7 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 87 | | INPUT | 400 | inp_doc_versioning |
|
||||
| Create without id of project | | My InputDocument10 | My InputDocument10 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | project |
|
||||
| Create without id of project | | My InputDocument10 | My InputDocument10 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | prj_uid |
|
||||
| Create without inp doc form needed | 14414793652a5d718b65590036026581 | My InputDocument11 | My InputDocument11 DESCRIPTION | | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_form_needed |
|
||||
| Create without inp doc original | 14414793652a5d718b65590036026581 | My InputDocument12 | My InputDocument12 DESCRIPTION | REAL | | PRIVATE | 1 | | INPUT | 400 | inp_doc_original |
|
||||
| Create without inp doc published | 14414793652a5d718b65590036026581 | My InputDocument13 | My InputDocument13 DESCRIPTION | VREAL | ORIGINAL | | 1 | | INPUT | 400 | inp_doc_published |
|
||||
| Create without inp doc title | 14414793652a5d718b65590036026581 | | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_title |
|
||||
| Create without inp doc title | 14414793652a5d718b65590036026581 | | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_title |
|
||||
|
||||
@@ -3095,7 +3095,10 @@ class Bootstrap
|
||||
);
|
||||
}
|
||||
|
||||
require_once PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php";
|
||||
//require_once PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php";
|
||||
|
||||
$loader = require PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php";
|
||||
$loader->add('', PATH_HOME . 'engine/src/');
|
||||
}
|
||||
|
||||
public static function parseIniFile($filename)
|
||||
|
||||
@@ -3294,7 +3294,7 @@ class G
|
||||
*
|
||||
* @author Erik A.O. <erik@colosa.com>
|
||||
*/
|
||||
public function json_encode($Json)
|
||||
public static function json_encode($Json)
|
||||
{
|
||||
if ( function_exists('json_encode') ) {
|
||||
return json_encode($Json);
|
||||
|
||||
@@ -16,6 +16,11 @@ require_once 'classes/model/om/BaseBpmnFlow.php';
|
||||
*/
|
||||
class BpmnFlow extends BaseBpmnFlow
|
||||
{
|
||||
/**
|
||||
* @param $field string coming from \BpmnFlowPeer::<FIELD_NAME>
|
||||
* @param $value string
|
||||
* @return \BpmnFlow|null
|
||||
*/
|
||||
public static function findOneBy($field, $value)
|
||||
{
|
||||
$rows = self::findAllBy($field, $value);
|
||||
|
||||
@@ -213,5 +213,30 @@ class Route extends BaseRoute
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $field
|
||||
* @param null $value
|
||||
* @return \Route|null
|
||||
*/
|
||||
public static function findOneBy($field, $value = null)
|
||||
{
|
||||
$rows = self::findAllBy($field, $value);
|
||||
|
||||
return empty($rows) ? null : $rows[0];
|
||||
}
|
||||
|
||||
public static function findAllBy($field, $value = null)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field => $value);
|
||||
|
||||
$c = new Criteria('workflow');
|
||||
|
||||
foreach ($field as $key => $value) {
|
||||
$c->add($key, $value, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
return RoutePeer::doSelect($c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,24 +38,28 @@ if ($access != 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
G::LoadClass( 'processMap' );
|
||||
$oProcessMap = new ProcessMap();
|
||||
//G::LoadClass( 'processMap' );
|
||||
//$oProcessMap = new ProcessMap();
|
||||
|
||||
$UIDS = explode( ',', $_POST['PRO_UIDS'] );
|
||||
$uids = explode(',', $_POST['PRO_UIDS']);
|
||||
|
||||
try {
|
||||
|
||||
foreach ($UIDS as $UID) {
|
||||
$oProcessMap->deleteProcess($UID);
|
||||
//ProcessMaker\Adapter\Bpmn\Model::deleteProject($UID);
|
||||
foreach ($uids as $uid) {
|
||||
//$oProcessMap->deleteProcess($uid);
|
||||
ProcessMaker\Project\Workflow::removeIfExists($uid);
|
||||
ProcessMaker\Project\Bpmn::removeIfExists($uid);
|
||||
}
|
||||
|
||||
$resp = new StdClass();
|
||||
$resp->status = 0;
|
||||
$resp->msg = 'All process was deleted successfully';
|
||||
echo G::json_encode( $resp );
|
||||
|
||||
echo G::json_encode($resp);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$resp->status = 1;
|
||||
$resp->msg = $e->getMessage();
|
||||
echo G::json_encode( $resp );
|
||||
echo G::json_encode($resp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -180,6 +180,40 @@ class DynaForm
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the DynaForm in table DYNAFORM
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the DynaForm in table DYNAFORM
|
||||
*/
|
||||
public function throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
|
||||
|
||||
if ($processUid != "") {
|
||||
$criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
|
||||
|
||||
if (!$rsCriteria->next()) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if exists the title of a DynaForm
|
||||
*
|
||||
@@ -265,9 +299,7 @@ class DynaForm
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
//Verify data
|
||||
$process = new \BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
$this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
|
||||
//Load DynaForm
|
||||
$dynaForm = new \Dynaform();
|
||||
@@ -277,6 +309,8 @@ class DynaForm
|
||||
$processUid = $arrayDynaFormData["PRO_UID"];
|
||||
|
||||
//Verify data
|
||||
$process = new \BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
|
||||
|
||||
if (isset($arrayData["DYN_TITLE"])) {
|
||||
@@ -312,9 +346,7 @@ class DynaForm
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
$this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
|
||||
//Load DynaForm
|
||||
$dynaForm = new \Dynaform();
|
||||
@@ -408,7 +440,7 @@ class DynaForm
|
||||
//Verify data
|
||||
$process->throwExceptionIfNoExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID"));
|
||||
|
||||
$process->throwExceptionIfNotExistsDynaForm($processUidCopyImport, $dynaFormUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
|
||||
$this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
|
||||
|
||||
//Copy/Import
|
||||
//Create
|
||||
@@ -840,9 +872,7 @@ class DynaForm
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
$this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
|
||||
//Get data
|
||||
$criteria = $this->getDynaFormCriteria();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -420,40 +420,6 @@ class Process
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the DynaForm in table DYNAFORM
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the DynaForm in table DYNAFORM
|
||||
*/
|
||||
public function throwExceptionIfNotExistsDynaForm($processUid, $dynaFormUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\DynaformPeer::DYN_UID);
|
||||
|
||||
if ($processUid != "") {
|
||||
$criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
|
||||
|
||||
if (!$rsCriteria->next()) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Template in Routing Screen Template
|
||||
*
|
||||
@@ -553,7 +519,9 @@ class Process
|
||||
}
|
||||
|
||||
if (isset($arrayData["PRO_SUMMARY_DYNAFORM"]) && $arrayData["PRO_SUMMARY_DYNAFORM"] . "" != "") {
|
||||
$this->throwExceptionIfNotExistsDynaForm($processUid, $arrayData["PRO_SUMMARY_DYNAFORM"], $this->arrayFieldNameForException["processSummaryDynaform"]);
|
||||
$dynaForm = new \BusinessModel\DynaForm();
|
||||
|
||||
$dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["PRO_SUMMARY_DYNAFORM"], $processUid, $this->arrayFieldNameForException["processSummaryDynaform"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["PRO_DERIVATION_SCREEN_TPL"]) && $arrayData["PRO_DERIVATION_SCREEN_TPL"] . "" != "") {
|
||||
@@ -1444,19 +1412,17 @@ class Process
|
||||
public function getInputDocuments($processUid)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \Process();
|
||||
|
||||
if (!$process->exists($processUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($processUid, "PROCESS"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
//Get data
|
||||
$arrayInputDocument = array();
|
||||
|
||||
$inputdoc = new \BusinessModel\InputDocument();
|
||||
//Verify data
|
||||
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
|
||||
$criteria = $inputdoc->getInputDocumentCriteria();
|
||||
//Get data
|
||||
$inputDocument = new \BusinessModel\InputDocument();
|
||||
$inputDocument->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
|
||||
$inputDocument->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
|
||||
$criteria = $inputDocument->getInputDocumentCriteria();
|
||||
|
||||
$criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
$criteria->addAscendingOrderByColumn("INP_DOC_TITLE");
|
||||
@@ -1467,9 +1433,10 @@ class Process
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayInputDocument[] = $inputdoc->getInputDocumentDataFromRecord($row);
|
||||
$arrayInputDocument[] = $inputDocument->getInputDocumentDataFromRecord($row);
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayInputDocument;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
|
||||
@@ -151,7 +151,9 @@ class WebEntry
|
||||
}
|
||||
|
||||
if ($dynaFormUid != "") {
|
||||
$process->throwExceptionIfNotExistsDynaForm($processUid, $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
$dynaForm = new \BusinessModel\DynaForm();
|
||||
|
||||
$dynaForm->throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
}
|
||||
|
||||
//Get data
|
||||
@@ -293,7 +295,10 @@ class WebEntry
|
||||
}
|
||||
|
||||
$process->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]);
|
||||
$process->throwExceptionIfNotExistsDynaForm($processUid, $arrayData["DYN_UID"], $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
|
||||
$dynaForm = new \BusinessModel\DynaForm();
|
||||
|
||||
$dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
|
||||
$task = new \Task();
|
||||
|
||||
|
||||
@@ -163,12 +163,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
switch ($event && $event->getEvnType()) {
|
||||
case "START":
|
||||
self::log("Setting Task:" . $data["FLO_ELEMENT_DEST"] . " as STARTING TASK");
|
||||
|
||||
// then set that activity/task as "Start Task"
|
||||
$this->wp->updateTask($data["FLO_ELEMENT_DEST"], array("TAS_START" => "TRUE"));
|
||||
|
||||
self::log("Setting as \"Stating Task\" Success!");
|
||||
$this->wp->setStartTask($data["FLO_ELEMENT_DEST"]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -177,6 +173,10 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
}
|
||||
|
||||
public function removeFlow($floUid)
|
||||
{
|
||||
parent::removeFlow($floUid);
|
||||
}
|
||||
|
||||
public function addEvent($data)
|
||||
{
|
||||
@@ -189,32 +189,27 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
public function removeEvent($evnUid)
|
||||
{
|
||||
$flow = \BpmnFlowPeer::retrieveByPK($evnUid);
|
||||
$event = \BpmnEventPeer::retrieveByPK($evnUid);
|
||||
|
||||
if (! is_null($flow)) {
|
||||
$data = $flow->toArray();
|
||||
|
||||
// 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":
|
||||
self::log("Unset Task:" . $data["FLO_ELEMENT_DEST"] . " as NOT STARTING TASK");
|
||||
|
||||
// then set that activity/task as "Start Task"
|
||||
$this->wp->updateTask($data["FLO_ELEMENT_DEST"], array("TAS_START" => "FALSE"));
|
||||
|
||||
self::log("Unset as \"Stating Task\" Success!");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
parent::removeEvent($evnUid);
|
||||
|
||||
@@ -86,12 +86,14 @@ class Bpmn extends Handler
|
||||
// setting defaults
|
||||
$data['PRJ_UID'] = array_key_exists('PRJ_UID', $data) ? $data['PRJ_UID'] : Hash::generateUID();
|
||||
|
||||
self::log("Create Project with data: ", $data);
|
||||
$this->project = new Project();
|
||||
$this->project->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$this->project->setPrjCreateDate(date("Y-m-d H:i:s"));
|
||||
$this->project->save();
|
||||
|
||||
$this->prjUid = $this->project->getPrjUid();
|
||||
self::log("Create Project Success!");
|
||||
}
|
||||
|
||||
public function update()
|
||||
@@ -106,11 +108,20 @@ class Bpmn extends Handler
|
||||
* 2. Remove Project related objects
|
||||
*/
|
||||
|
||||
$activities = $this->getActivities();
|
||||
|
||||
foreach ($activities as $activity) {
|
||||
self::log("Remove Project With Uid: {$this->prjUid}");
|
||||
foreach ($this->getActivities() as $activity) {
|
||||
$this->removeActivity($activity["ACT_UID"]);
|
||||
}
|
||||
foreach ($this->getGateways() as $gateway) {
|
||||
$this->removeGateway($gateway["GAT_UID"]);
|
||||
}
|
||||
foreach ($this->getEvents() as $event) {
|
||||
$this->removeEvent($event["EVN_UID"]);
|
||||
}
|
||||
foreach ($this->getFlows() as $flow) {
|
||||
$this->removeFlow($flow["FLO_UID"]);
|
||||
}
|
||||
|
||||
if ($process = $this->getProcess("object")) {
|
||||
$process->delete();
|
||||
}
|
||||
@@ -120,6 +131,19 @@ class Bpmn extends Handler
|
||||
if ($project = $this->getProject("object")) {
|
||||
$project->delete();
|
||||
}
|
||||
self::log("Remove Project Success!");
|
||||
}
|
||||
|
||||
public static function removeIfExists($prjUid)
|
||||
{
|
||||
$project = ProjectPeer::retrieveByPK($prjUid);
|
||||
|
||||
if ($project) {
|
||||
$me = new self();
|
||||
$me->prjUid = $project->getPrjUid();
|
||||
$me->project = $project;
|
||||
$me->remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER)
|
||||
|
||||
@@ -54,15 +54,15 @@ class Workflow extends Handler
|
||||
|
||||
public function create($data)
|
||||
{
|
||||
// setting defaults
|
||||
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID();
|
||||
$data['USR_UID'] = array_key_exists('PRO_CREATE_USER', $data) ? $data['PRO_CREATE_USER'] : null;
|
||||
$data['PRO_TITLE'] = array_key_exists('PRO_TITLE', $data) ? trim($data['PRO_TITLE']) : "";
|
||||
$data['PRO_CATEGORY'] = array_key_exists('PRO_CATEGORY', $data) ? $data['PRO_CATEGORY'] : "";
|
||||
|
||||
try {
|
||||
self::log("===> Executing -> ".__METHOD__, "Create Process with data:", $data);
|
||||
|
||||
// setting defaults
|
||||
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID();
|
||||
$data['USR_UID'] = array_key_exists('PRO_CREATE_USER', $data) ? $data['PRO_CREATE_USER'] : null;
|
||||
$data['PRO_TITLE'] = array_key_exists('PRO_TITLE', $data) ? trim($data['PRO_TITLE']) : "";
|
||||
$data['PRO_CATEGORY'] = array_key_exists('PRO_CATEGORY', $data) ? $data['PRO_CATEGORY'] : "";
|
||||
|
||||
//validate if process with specified name already exists
|
||||
if (Process::existsByProTitle($data["PRO_TITLE"])) {
|
||||
throw new Exception\ProjectAlreadyExists($this, $data["PRO_TITLE"]);
|
||||
@@ -111,6 +111,17 @@ class Workflow extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeIfExists($proUid)
|
||||
{
|
||||
$process = \ProcessPeer::retrieveByPK($proUid);
|
||||
|
||||
if ($process) {
|
||||
$me = new self();
|
||||
$me->proUid = $process->getProUid();
|
||||
$me->remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
//return Project::getAll($start, $limit, $filter, $changeCaseTo);
|
||||
@@ -211,16 +222,33 @@ class Workflow extends Handler
|
||||
return $tasks->getAllTasks($this->proUid);
|
||||
}
|
||||
|
||||
public function setStartTask($tasUid)
|
||||
public function setStartTask($tasUid, $value = true)
|
||||
{
|
||||
$value = $value ? "TRUE" : "FALSE";
|
||||
|
||||
self::log("Setting Start Task with Uid: $tasUid: $value");
|
||||
$task = \TaskPeer::retrieveByPK($tasUid);
|
||||
$task->setTasStart("TRUE");
|
||||
$task->setTasStart($value);
|
||||
$task->save();
|
||||
self::log("Setting Start Task -> $value, Success!");
|
||||
}
|
||||
|
||||
public function setEndTask($tasUid)
|
||||
public function setEndTask($tasUid, $value = true)
|
||||
{
|
||||
$this->addSequentialRoute($tasUid, "-1", "SEQUENTIAL", true);
|
||||
self::log("Setting End Task with Uid: $tasUid: " . ($value ? "TRUE" : "FALSE"));
|
||||
if ($value) {
|
||||
$this->addSequentialRoute($tasUid, "-1");
|
||||
} else {
|
||||
$route = \Route::findOneBy(array(
|
||||
\RoutePeer::TAS_UID => $tasUid,
|
||||
\RoutePeer::ROU_NEXT_TASK => "-1"
|
||||
));
|
||||
|
||||
if (! is_null($route)) {
|
||||
$this->removeRoute($route->getRouUid());
|
||||
}
|
||||
}
|
||||
self::log("Setting End Task -> ".($value ? "TRUE" : "FALSE").", Success!");
|
||||
}
|
||||
|
||||
public function addSequentialRoute($fromTasUid, $toTasUid, $delete = null)
|
||||
@@ -239,32 +267,6 @@ class Workflow extends Handler
|
||||
{
|
||||
try {
|
||||
self::log("Add Route from task: $fromTasUid -> to task: $toTasUid ($type)");
|
||||
/*switch ($type) {
|
||||
case 0:
|
||||
$sType = 'SEQUENTIAL';
|
||||
break;
|
||||
case 1:
|
||||
$sType = 'SELECT';
|
||||
break;
|
||||
case 2:
|
||||
$sType = 'EVALUATE';
|
||||
break;
|
||||
case 3:
|
||||
$sType = 'PARALLEL';
|
||||
break;
|
||||
case 4:
|
||||
$sType = 'PARALLEL-BY-EVALUATION';
|
||||
break;
|
||||
case 5:
|
||||
$sType = 'SEC-JOIN';
|
||||
break;
|
||||
case 8:
|
||||
$sType = 'DISCRIMINATOR';
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("Invalid type code, given: $type, expected: integer [1...8]");
|
||||
}
|
||||
}*/
|
||||
|
||||
$validTypes = array("SEQUENTIAL", "SELECT", "EVALUATE", "PARALLEL", "PARALLEL-BY-EVALUATION", "SEC-JOIN", "DISCRIMINATOR");
|
||||
|
||||
@@ -272,21 +274,16 @@ class Workflow extends Handler
|
||||
throw new \Exception("Invalid Route type, given: $type, expected: [".implode(",", $validTypes)."]");
|
||||
}
|
||||
|
||||
//if ($type != 0 && $type != 5 && $type != 8) {
|
||||
if ($type != 'SEQUENTIAL' && $type != 'SEC-JOIN' && $type != 'DISCRIMINATOR') {
|
||||
if ($this->getNumberOfRoutes($this->proUid, $fromTasUid, $toTasUid, $type) > 0) {
|
||||
// die(); ????
|
||||
throw new \RuntimeException("Unexpected behaviour");
|
||||
throw new \LogicException("Unexpected behaviour");
|
||||
}
|
||||
//unset($aRow);
|
||||
}
|
||||
//if ($delete || $type == 0 || $type == 5 || $type == 8) {
|
||||
if ($delete || $type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') {
|
||||
//$oTasks = new Tasks();
|
||||
|
||||
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
|
||||
//$oTasks->deleteAllGatewayOfTask($this->proUid, $fromTasUid);
|
||||
}
|
||||
//if ($delete || $type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') {
|
||||
$oTasks = new Tasks();
|
||||
$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
|
||||
//}
|
||||
|
||||
$result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $delete);
|
||||
self::log("Add Route Success! -> ", $result);
|
||||
|
||||
@@ -237,7 +237,7 @@ class Project extends Api
|
||||
if ($mappedUid !== false) {
|
||||
$flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid;
|
||||
}
|
||||
|
||||
|
||||
$mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result);
|
||||
if ($mappedUid !== false) {
|
||||
$flowData["FLO_ELEMENT_DEST"] = $mappedUid;
|
||||
@@ -358,6 +358,8 @@ class Project extends Api
|
||||
{
|
||||
try {
|
||||
$process = new \BusinessModel\Process();
|
||||
$process->setFormatFieldNameInUppercase(false);
|
||||
$process->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
||||
|
||||
$response = $process->getInputDocuments($prj_uid);
|
||||
|
||||
|
||||
@@ -12,17 +12,19 @@ use \Luracast\Restler\RestException;
|
||||
class InputDocument extends Api
|
||||
{
|
||||
/**
|
||||
* @url GET /:projectUid/input-document/:inputDocumentUid
|
||||
* @url GET /:prj_uid/input-document/:inp_doc_uid
|
||||
*
|
||||
* @param string $inputDocumentUid {@min 32}{@max 32}
|
||||
* @param string $projectUid {@min 32}{@max 32}
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetInputDocument($inputDocumentUid, $projectUid)
|
||||
public function doGetInputDocument($inp_doc_uid, $prj_uid)
|
||||
{
|
||||
try {
|
||||
$inputdoc = new \BusinessModel\InputDocument();
|
||||
$inputDocument = new \BusinessModel\InputDocument();
|
||||
$inputDocument->setFormatFieldNameInUppercase(false);
|
||||
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
||||
|
||||
$response = $inputdoc->getInputDocument($inputDocumentUid);
|
||||
$response = $inputDocument->getInputDocument($inp_doc_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
@@ -31,37 +33,21 @@ class InputDocument extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /:projectUid/input-document
|
||||
* @url POST /:prj_uid/input-document
|
||||
*
|
||||
* @param string $projectUid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
* @param string $inp_doc_title {@from body}{@required true}
|
||||
* @param string $inp_doc_description {@from body}
|
||||
* @param string $inp_doc_form_needed {@from body}{@choice VIRTUAL,REAL,VREAL}
|
||||
* @param string $inp_doc_original {@from body}{@choice ORIGINAL,COPY,COPYLEGAL}
|
||||
* @param string $inp_doc_published {@from body}{@choice PRIVATE}
|
||||
* @param int $inp_doc_versioning {@from body}{@choice 0,1}
|
||||
* @param string $inp_doc_destination_path {@from body}
|
||||
* @param string $inp_doc_tags {@from body}
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostInputDocument(
|
||||
$projectUid,
|
||||
$request_data,
|
||||
$inp_doc_title = "",
|
||||
$inp_doc_description = "",
|
||||
$inp_doc_form_needed = "VIRTUAL",
|
||||
$inp_doc_original = "ORIGINAL",
|
||||
$inp_doc_published = "PRIVATE",
|
||||
$inp_doc_versioning = 0,
|
||||
$inp_doc_destination_path = "",
|
||||
$inp_doc_tags = ""
|
||||
) {
|
||||
public function doPostInputDocument($prj_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$inputdoc = new \BusinessModel\InputDocument();
|
||||
$inputDocument = new \BusinessModel\InputDocument();
|
||||
$inputDocument->setFormatFieldNameInUppercase(false);
|
||||
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
||||
|
||||
$arrayData = $inputdoc->create($projectUid, $request_data);
|
||||
$arrayData = $inputDocument->create($prj_uid, $request_data);
|
||||
|
||||
$response = $arrayData;
|
||||
|
||||
@@ -72,54 +58,39 @@ class InputDocument extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* @url PUT /:projectUid/input-document/:inputDocumentUid
|
||||
* @url PUT /:prj_uid/input-document/:inp_doc_uid
|
||||
*
|
||||
* @param string $inputDocumentUid {@min 32}{@max 32}
|
||||
* @param string $projectUid {@min 32}{@max 32}
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
* @param string $inp_doc_title {@from body}
|
||||
* @param string $inp_doc_description {@from body}
|
||||
* @param string $inp_doc_form_needed {@from body}{@choice VIRTUAL,REAL,VREAL}
|
||||
* @param string $inp_doc_original {@from body}{@choice ORIGINAL,COPY,COPYLEGAL}
|
||||
* @param string $inp_doc_published {@from body}{@choice PRIVATE}
|
||||
* @param int $inp_doc_versioning {@from body}{@choice 0,1}
|
||||
* @param string $inp_doc_destination_path {@from body}
|
||||
* @param string $inp_doc_tags {@from body}
|
||||
*/
|
||||
public function doPutInputDocument(
|
||||
$inputDocumentUid,
|
||||
$projectUid,
|
||||
$request_data,
|
||||
$inp_doc_title = "",
|
||||
$inp_doc_description = "",
|
||||
$inp_doc_form_needed = "VIRTUAL",
|
||||
$inp_doc_original = "ORIGINAL",
|
||||
$inp_doc_published = "PRIVATE",
|
||||
$inp_doc_versioning = 0,
|
||||
$inp_doc_destination_path = "",
|
||||
$inp_doc_tags = ""
|
||||
) {
|
||||
public function doPutInputDocument($inp_doc_uid, $prj_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$inputdoc = new \BusinessModel\InputDocument();
|
||||
$inputDocument = new \BusinessModel\InputDocument();
|
||||
$inputDocument->setFormatFieldNameInUppercase(false);
|
||||
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
||||
|
||||
$arrayData = $inputdoc->update($inputDocumentUid, $request_data);
|
||||
$arrayData = $inputDocument->update($inp_doc_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:projectUid/input-document/:inputDocumentUid
|
||||
* @url DELETE /:prj_uid/input-document/:inp_doc_uid
|
||||
*
|
||||
* @param string $inputDocumentUid {@min 32}{@max 32}
|
||||
* @param string $projectUid {@min 32}{@max 32}
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDeleteInputDocument($inputDocumentUid, $projectUid)
|
||||
public function doDeleteInputDocument($inp_doc_uid, $prj_uid)
|
||||
{
|
||||
try {
|
||||
$inputdoc = new \BusinessModel\InputDocument();
|
||||
$inputDocument = new \BusinessModel\InputDocument();
|
||||
$inputDocument->setFormatFieldNameInUppercase(false);
|
||||
$inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid"));
|
||||
|
||||
$inputdoc->delete($inputDocumentUid);
|
||||
$inputDocument->delete($inp_doc_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user