Refactoring Bpmn/Workflow handling layer (2nd commit)
This commit is contained in:
@@ -392,6 +392,8 @@ class Bootstrap
|
||||
self::registerClass("UsersPeer", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "UsersPeer.php");
|
||||
|
||||
self::registerClass("Xml_Node", PATH_GULLIVER . "class.xmlDocument.php");
|
||||
|
||||
self::registerClass("Tasks", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.tasks.php");
|
||||
}
|
||||
|
||||
//below this line, still not approved methods
|
||||
|
||||
@@ -87,16 +87,13 @@ class Tasks
|
||||
{
|
||||
try {
|
||||
$aTasks = array();
|
||||
$sDelimiter = DBAdapter::getStringDelimiter();
|
||||
$sDelimiter = @DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(TaskPeer::PRO_UID, $sProUid);
|
||||
$aConditions = array();
|
||||
$aConditions[] = array(TaskPeer::TAS_UID, ContentPeer::CON_ID
|
||||
);
|
||||
$aConditions[] = array(ContentPeer::CON_CATEGORY, $sDelimiter . 'TAS_TITLE' . $sDelimiter
|
||||
);
|
||||
$aConditions[] = array(ContentPeer::CON_LANG, $sDelimiter . SYS_LANG . $sDelimiter
|
||||
);
|
||||
$aConditions[] = array(TaskPeer::TAS_UID, ContentPeer::CON_ID);
|
||||
$aConditions[] = array(ContentPeer::CON_CATEGORY, $sDelimiter . 'TAS_TITLE' . $sDelimiter);
|
||||
$aConditions[] = array(ContentPeer::CON_LANG, $sDelimiter . SYS_LANG . $sDelimiter);
|
||||
$oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
|
||||
$oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
|
||||
$oDataset = TaskPeer::doSelectRS($oCriteria);
|
||||
|
||||
@@ -51,7 +51,7 @@ class Content extends BaseContent
|
||||
* @param string $sUID
|
||||
* @return variant
|
||||
*/
|
||||
public function load ($ConCategory, $ConParent, $ConId, $ConLang)
|
||||
public static function load ($ConCategory, $ConParent, $ConId, $ConLang)
|
||||
{
|
||||
$content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang );
|
||||
if (is_null( $content )) {
|
||||
@@ -76,7 +76,7 @@ class Content extends BaseContent
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang)
|
||||
public static function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang)
|
||||
{
|
||||
$Criteria = new Criteria( 'workflow' );
|
||||
$Criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
@@ -113,7 +113,7 @@ class Content extends BaseContent
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function updateEqualValue ($ConCategory, $ConParent, $ConId, $ConValue)
|
||||
public static function updateEqualValue ($ConCategory, $ConParent, $ConId, $ConValue)
|
||||
{
|
||||
$con = Propel::getConnection('workflow');
|
||||
$c1 = new Criteria('workflow');
|
||||
@@ -136,7 +136,7 @@ class Content extends BaseContent
|
||||
* @return string
|
||||
* if the row doesn't exist, it will be created automatically, even the default 'en' language
|
||||
*/
|
||||
public function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang)
|
||||
public static function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang)
|
||||
{
|
||||
//search in 'en' language, the default language
|
||||
$content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, 'en' );
|
||||
@@ -262,7 +262,7 @@ class Content extends BaseContent
|
||||
* @param string $ConValue
|
||||
* @return variant
|
||||
*/
|
||||
public function removeContent ($ConCategory, $ConParent, $ConId)
|
||||
public static function removeContent ($ConCategory, $ConParent, $ConId)
|
||||
{
|
||||
try {
|
||||
$c = new Criteria();
|
||||
|
||||
@@ -406,7 +406,7 @@ class Task extends BaseTask
|
||||
|
||||
if ($this->validate()) {
|
||||
$this->setTasTitle((isset($aData['TAS_TITLE']) ? $aData['TAS_TITLE']: ''));
|
||||
$this->setTasDescription("");
|
||||
$this->setTasDescription((isset($aData['TAS_DESCRIPTION']) ? $aData['TAS_DESCRIPTION']: ''));
|
||||
$this->setTasDefTitle("");
|
||||
$this->setTasDefDescription("");
|
||||
$this->setTasDefProcCode("");
|
||||
|
||||
@@ -47,7 +47,7 @@ try {
|
||||
|
||||
foreach ($UIDS as $UID) {
|
||||
$oProcessMap->deleteProcess($UID);
|
||||
ProcessMaker\Adapter\Bpmn\Model::deleteProject($UID);
|
||||
//ProcessMaker\Adapter\Bpmn\Model::deleteProject($UID);
|
||||
}
|
||||
$resp->status = 0;
|
||||
$resp->msg = 'All process was deleted successfully';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,12 +3,11 @@ namespace ProcessMaker\Project;
|
||||
|
||||
use ProcessMaker\Util\Logger;
|
||||
|
||||
abstract class ProjectHandler implements ProjectHandlerInterface
|
||||
abstract class ProjectHandler //implements ProjectHandlerInterface
|
||||
{
|
||||
public abstract function create($data);
|
||||
public abstract function update($prjUid, $data);
|
||||
public abstract function delete($prjUid);
|
||||
public abstract function load($prjUid);
|
||||
public abstract function save();
|
||||
public abstract function update();
|
||||
public abstract function delete();
|
||||
|
||||
/**
|
||||
* Log in ProcessMaker Standard Output if debug mode is enabled.
|
||||
|
||||
@@ -3,8 +3,8 @@ namespace ProcessMaker\Project;
|
||||
|
||||
interface ProjectHandlerInterface
|
||||
{
|
||||
public function create($data);
|
||||
public function update($prjUid, $data);
|
||||
public function delete($prjUid);
|
||||
public function load($prjUid);
|
||||
public function save();
|
||||
public function update();
|
||||
public function delete();
|
||||
public static function load();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (! class_exists("Propel")) {
|
||||
include_once "../../bootstrap.php";
|
||||
include_once __DIR__ . "/../../bootstrap.php";
|
||||
}
|
||||
|
||||
use \ProcessMaker\Project\Adapter\WorkflowProject;
|
||||
@@ -18,26 +19,239 @@ class WorkflowProjectTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
$data = array(
|
||||
"PRO_UID" => "b72405854591363786050152eabf59dc",
|
||||
"PRO_TITLE" => "Test Project #1",
|
||||
"PRO_DESCRIPTION" => "Description for - Test Project #1",
|
||||
"PRO_CATEGORY" => "",
|
||||
"USR_UID" => "00000000000000000000000000000001",
|
||||
"TASKS" => array(
|
||||
array(
|
||||
"TAS_UID" => "85459136378bf56050152ea9dcb72405",
|
||||
"TAS_TITLE" => "task_1",
|
||||
"TAS_POSX" => "50",
|
||||
"TAS_POSY" => "50",
|
||||
"TAS_WIDTH" => "100",
|
||||
"TAS_HEIGHT" => "25"
|
||||
)
|
||||
),
|
||||
"ROUTES" => array()
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
);
|
||||
|
||||
$result = $this->workflowProject->create($data);
|
||||
$wp = new WorkflowProject($data);
|
||||
|
||||
var_dump($result);
|
||||
$processData = $wp->getProperties();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($data[$key], $processData[$key]);
|
||||
}
|
||||
|
||||
return $wp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testAddTask($wp)
|
||||
{
|
||||
$data = array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_DESCRIPTION" => "Description for task #1",
|
||||
"TAS_POSX" => "50",
|
||||
"TAS_POSY" => "50",
|
||||
"TAS_WIDTH" => "100",
|
||||
"TAS_HEIGHT" => "25"
|
||||
);
|
||||
|
||||
$tasUid = $wp->addTask($data);
|
||||
|
||||
$taskData = $wp->getTask($tasUid);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($data[$key], $taskData[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testUpdateTask($wp)
|
||||
{
|
||||
$data = array(
|
||||
"TAS_TITLE" => "task #1 (updated)",
|
||||
"TAS_POSX" => "150",
|
||||
"TAS_POSY" => "250"
|
||||
);
|
||||
|
||||
// at this time, there is only one task
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
|
||||
$wp->updateTask($tasks[0]['TAS_UID'], $data);
|
||||
$taskData = $wp->getTask($tasks[0]['TAS_UID']);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($data[$key], $taskData[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testRemoveTask($wp)
|
||||
{
|
||||
$tasUid = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "150",
|
||||
"TAS_POSY" => "250"
|
||||
));
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(2, $tasks);
|
||||
|
||||
$wp->removeTask($tasUid);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testGetTasks($wp)
|
||||
{
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "250",
|
||||
"TAS_POSY" => "250"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #3",
|
||||
"TAS_POSX" => "350",
|
||||
"TAS_POSY" => "350"
|
||||
));
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(3, $tasks);
|
||||
|
||||
$wp->removeTask($tasUid1);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(2, $tasks);
|
||||
|
||||
$wp->removeTask($tasUid2);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
|
||||
$wp->removeTask($tasks[0]['TAS_UID']);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(0, $tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testAddRoute()
|
||||
{
|
||||
$wp = new WorkflowProject(array(
|
||||
"PRO_TITLE" => "Test Project #2 (Sequential)",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
));
|
||||
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_POSX" => "410",
|
||||
"TAS_POSY" => "61"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "159",
|
||||
"TAS_POSY" => "370"
|
||||
));
|
||||
|
||||
$rouUid = $wp->addRoute($tasUid1, $tasUid2, "SEQUENTIAL");
|
||||
|
||||
$routeSaved = $wp->getRoute($rouUid);
|
||||
|
||||
$this->assertEquals($tasUid1, $routeSaved['TAS_UID']);
|
||||
$this->assertEquals($tasUid2, $routeSaved['ROU_NEXT_TASK']);
|
||||
$this->assertEquals("SEQUENTIAL", $routeSaved['ROU_TYPE']);
|
||||
}
|
||||
|
||||
public function testAddSelectRoute()
|
||||
{
|
||||
$wp = new WorkflowProject(array(
|
||||
"PRO_TITLE" => "Test Project #3 (Select)",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
));
|
||||
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_POSX" => "410",
|
||||
"TAS_POSY" => "61"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "159",
|
||||
"TAS_POSY" => "370"
|
||||
));
|
||||
$tasUid3 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #3",
|
||||
"TAS_POSX" => "670",
|
||||
"TAS_POSY" => "372"
|
||||
));
|
||||
|
||||
$wp->addSelectRoute($tasUid1, array($tasUid2, $tasUid3));
|
||||
}
|
||||
|
||||
public function testCompleteWorkflowProject()
|
||||
{
|
||||
$wp = new WorkflowProject(array(
|
||||
"PRO_TITLE" => "Test Complete Project #4",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
));
|
||||
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_POSX" => "406",
|
||||
"TAS_POSY" => "71"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "188",
|
||||
"TAS_POSY" => "240"
|
||||
));
|
||||
$tasUid3 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #3",
|
||||
"TAS_POSX" => "406",
|
||||
"TAS_POSY" => "239"
|
||||
));
|
||||
$tasUid4 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #4",
|
||||
"TAS_POSX" => "294",
|
||||
"TAS_POSY" => "366"
|
||||
));
|
||||
$tasUid5 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #5",
|
||||
"TAS_POSX" => "640",
|
||||
"TAS_POSY" => "240"
|
||||
));
|
||||
$tasUid6 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #6",
|
||||
"TAS_POSX" => "640",
|
||||
"TAS_POSY" => "359"
|
||||
));
|
||||
|
||||
|
||||
$wp->addRoute($tasUid1, $tasUid2, "PARALLEL");
|
||||
$wp->addRoute($tasUid1, $tasUid3, "PARALLEL");
|
||||
$wp->addRoute($tasUid1, $tasUid5, "PARALLEL");
|
||||
|
||||
$wp->addRoute($tasUid2, $tasUid4, "SEC-JOIN");
|
||||
$wp->addRoute($tasUid3, $tasUid4, "SEC-JOIN");
|
||||
|
||||
$wp->addRoute($tasUid5, $tasUid6, "EVALUATE");
|
||||
$wp->addRoute($tasUid5, "-1", "EVALUATE");
|
||||
|
||||
$wp->setStartTask($tasUid1);
|
||||
|
||||
$wp->setEndTask($tasUid4);
|
||||
$wp->setEndTask($tasUid6);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
// pm-bootstrap.php
|
||||
//
|
||||
|
||||
$config = parse_ini_file("config.ini");
|
||||
$config = parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . "config.ini");
|
||||
|
||||
$workspace = $config['workspace'];
|
||||
$lang = $config['lang'];
|
||||
$processMakerHome = $config['pm_home_dir'];
|
||||
@@ -132,7 +133,7 @@ if (is_file(PATH_DATA_SITE.PATH_SEP . '.server_info')) {
|
||||
|
||||
// create memcached singleton
|
||||
Bootstrap::LoadClass( 'memcached' );
|
||||
$memcache = PMmemcached::getSingleton( SYS_SYS );
|
||||
//$memcache = PMmemcached::getSingleton( SYS_SYS );
|
||||
|
||||
Propel::init(PATH_CONFIG . "databases.php");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user