Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Omar
2014-03-27 17:17:09 -04:00
45 changed files with 2677 additions and 859 deletions

View File

@@ -527,7 +527,7 @@ class Applications
// replacing the status data with their respective translation
if (isset( $aRow['APP_STATUS'] )) {
$aRow['APP_STATUS'] = G::LoadTranslation( "ID_{$aRow['APP_STATUS']}" );
$aRow['APP_STATUS_LABEL'] = G::LoadTranslation( "ID_{$aRow['APP_STATUS']}" );
}
// replacing the priority data with their respective translation

View File

@@ -667,7 +667,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "USR_UID");
$caseReaderFields[] = array("name" => "PREVIOUS_USR_UID");
$caseReaderFields[] = array("name" => "APP_NUMBER");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "DEL_INDEX");
$caseReaderFields[] = array("name" => "APP_TITLE");
$caseReaderFields[] = array("name" => "APP_PRO_TITLE");
@@ -677,7 +677,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE");
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "DEL_PRIORITY");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "APP_FINISH_DATE");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
$caseReaderFields[] = array("name" => "CASE_NOTES_COUNT");
@@ -702,7 +702,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "PREVIOUS_USR_LASTNAME");
$caseReaderFields[] = array("name" => "PREVIOUS_USR_USERNAME");
$caseReaderFields[] = array("name" => "APP_NUMBER");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "DEL_INDEX");
$caseReaderFields[] = array("name" => "APP_TITLE");
$caseReaderFields[] = array("name" => "APP_PRO_TITLE");
@@ -712,7 +712,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE");
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "DEL_PRIORITY");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "APP_FINISH_DATE");
$caseReaderFields[] = array("name" => "APP_THREAD_INDEX");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
@@ -739,7 +739,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "PREVIOUS_USR_LASTNAME");
$caseReaderFields[] = array("name" => "PREVIOUS_USR_USERNAME");
$caseReaderFields[] = array("name" => "APP_NUMBER");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "DEL_INDEX");
$caseReaderFields[] = array("name" => "APP_TITLE");
$caseReaderFields[] = array("name" => "APP_PRO_TITLE");
@@ -749,7 +749,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE");
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "DEL_PRIORITY");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "APP_FINISH_DATE");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
$caseReaderFields[] = array("name" => "CASE_NOTES_COUNT");
@@ -766,7 +766,7 @@ class Configurations // extends Configuration
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_TASK") : "**ID_TASK**", "dataIndex" => "APP_TAS_TITLE", "width" => 120);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_CURRENT_USER") : "**ID_CURRENT_USER**", "dataIndex" => "APP_CURRENT_USER", "width" => 120, "sortable" => true);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 80);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50);
$caseReaderFields[] = array("name" => "APP_UID");
$caseReaderFields[] = array("name" => "USR_UID");
@@ -775,7 +775,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "PREVIOUS_USR_LASTNAME");
$caseReaderFields[] = array("name" => "PREVIOUS_USR_USERNAME");
$caseReaderFields[] = array("name" => "APP_NUMBER");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "DEL_INDEX");
$caseReaderFields[] = array("name" => "APP_TITLE");
$caseReaderFields[] = array("name" => "APP_PRO_TITLE");
@@ -785,7 +785,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE");
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "DEL_PRIORITY");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "APP_FINISH_DATE");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
$caseReaderFields[] = array("name" => "CASE_NOTES_COUNT");
@@ -805,13 +805,13 @@ class Configurations // extends Configuration
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 80);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_DELEGATION_DATE") : "**ID_DELEGATION_DATE**", "dataIndex" => "DEL_DELEGATE_DATE", "width" => 80);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_DUE_DATE") : "**ID_DUE_DATE**", "dataIndex" => "DEL_TASK_DUE_DATE", "width" => 80);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50);
$caseReaderFields[] = array("name" => "APP_UID");
$caseReaderFields[] = array("name" => "USR_UID");
$caseReaderFields[] = array("name" => "PREVIOUS_USR_UID");
$caseReaderFields[] = array("name" => "APP_NUMBER");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "DEL_INDEX");
$caseReaderFields[] = array("name" => "APP_TITLE");
$caseReaderFields[] = array("name" => "APP_PRO_TITLE");
@@ -822,7 +822,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "DEL_DELEGATE_DATE");
$caseReaderFields[] = array("name" => "DEL_PRIORITY");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "APP_FINISH_DATE");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
$caseReaderFields[] = array("name" => "CASE_NOTES_COUNT");
@@ -841,7 +841,7 @@ class Configurations // extends Configuration
//$caseColumns[] = array("header" => "Sent By", "dataIndex" => "APP_DEL_PREVIOUS_USER", "width" => 90);
//$caseColumns[] = array("header" => ($translation == 1)? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 110);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_PRIORITY") : "**ID_PRIORITY**", "dataIndex" => "DEL_PRIORITY", "width" => 50);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50);
$caseReaderFields[] = array("name" => "APP_UID");
$caseReaderFields[] = array("name" => "USR_UID");
@@ -859,7 +859,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "DEL_TASK_DUE_DATE");
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "DEL_PRIORITY");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "APP_FINISH_DATE");
$caseReaderFields[] = array("name" => "APP_DEL_PREVIOUS_USER");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
@@ -877,7 +877,7 @@ class Configurations // extends Configuration
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_CURRENT_USER") : "**ID_CURRENT_USER**", "dataIndex" => "APP_CURRENT_USER", "width" => 90, "sortable" => true);
//$caseColumns[] = array("header" => ($translation == 1)? G::LoadTranslation("ID_SENT_BY") : "**ID_SENT_BY**", "dataIndex" => "APP_DEL_PREVIOUS_USER", "width" => 90);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 110);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50);
$caseReaderFields[] = array("name" => "TAS_UID");
$caseReaderFields[] = array("name" => "DEL_INDEX");
@@ -891,7 +891,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "APP_CURRENT_USER");
//$caseReaderFields[] = array("name" => "APP_DEL_PREVIOUS_USER");
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
$caseReaderFields[] = array("name" => "CASE_NOTES_COUNT");
break;
@@ -907,7 +907,7 @@ class Configurations // extends Configuration
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_CURRENT_USER") : "**ID_CURRENT_USER**", "dataIndex" => "APP_CURRENT_USER", "width" => 90, "sortable" => false);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_SENT_BY") : "**ID_SENT_BY**", "dataIndex" => "APP_DEL_PREVIOUS_USER", "width" => 90);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_LAST_MODIFY") : "**ID_LAST_MODIFY**", "dataIndex" => "APP_UPDATE_DATE", "width" => 110);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS", "width" => 50);
$caseColumns[] = array("header" => ($translation == 1) ? G::LoadTranslation("ID_STATUS") : "**ID_STATUS**", "dataIndex" => "APP_STATUS_LABEL", "width" => 50);
$caseReaderFields[] = array("name" => "APP_UID");
$caseReaderFields[] = array("name" => "USR_UID");
@@ -919,7 +919,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "APP_CURRENT_USER");
$caseReaderFields[] = array("name" => "APP_DEL_PREVIOUS_USER");
$caseReaderFields[] = array("name" => "APP_UPDATE_DATE");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
$caseReaderFields[] = array("name" => "CASE_NOTES_COUNT");
break;
@@ -955,7 +955,7 @@ class Configurations // extends Configuration
$caseReaderFields[] = array("name" => "DEL_PRIORITY");
$caseReaderFields[] = array("name" => "APP_FINISH_DATE");
$caseReaderFields[] = array("name" => "APP_CURRENT_USER");
$caseReaderFields[] = array("name" => "APP_STATUS");
$caseReaderFields[] = array("name" => "APP_STATUS_LABEL");
$caseReaderFields[] = array("name" => "CASE_SUMMARY");
$caseReaderFields[] = array("name" => "CASE_NOTES_COUNT");
break;

View File

@@ -4555,6 +4555,7 @@ class processMap
{
try {
$oTask = new Task();
$oNewTask = new StdClass();
$oNewTask->label = G::LoadTranslation('ID_SUBPROCESS');
$oNewTask->uid = $oTask->create(array('PRO_UID' => $sProcessUID, 'TAS_TITLE' => $oNewTask->label, 'TAS_POSX' => $iX, 'TAS_POSY' => $iY, 'TAS_TYPE' => 'SUBPROCESS' ));
//$oJSON = new Services_JSON();

View File

@@ -522,5 +522,18 @@ class AppDelegation extends BaseAppDelegation
$data = $oRuleSet->getRow();
return (int)$data['DEL_INDEX'];
}
public function getCurrentTask ($appUid)
{
$oCriteria = new Criteria();
$oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID );
$oCriteria->add( AppDelegationPeer::APP_UID, $appUid );
$oCriteria->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX );
$oRuleSet = AppDelegationPeer::doSelectRS( $oCriteria );
$oRuleSet->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oRuleSet->next();
$data = $oRuleSet->getRow();
return $data['TAS_UID'];
}
}

View File

@@ -112,7 +112,7 @@ class BpmnActivity extends BaseBpmnActivity
$this->setBoundDefaults();
if ($this->bound->getBouUid() == "") {
$this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID());
$this->bound->setBouUid(\ProcessMaker\Util\Common::generateUID());
}
$this->bound->save($con);
@@ -142,7 +142,7 @@ class BpmnActivity extends BaseBpmnActivity
$this->bound = $bound;
} else {
$this->bound = new BpmnBound();
$this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID());
$this->bound->setBouUid(ProcessMaker\Util\Common::generateUID());
}
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);

View File

@@ -112,7 +112,7 @@ class BpmnEvent extends BaseBpmnEvent
$this->setBoundDefaults();
if ($this->bound->getBouUid() == "") {
$this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID());
$this->bound->setBouUid(\ProcessMaker\Util\Common::generateUID());
}
$this->bound->save($con);
@@ -142,7 +142,7 @@ class BpmnEvent extends BaseBpmnEvent
$this->bound = $bound;
} else {
$this->bound = new BpmnBound();
$this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID());
$this->bound->setBouUid(ProcessMaker\Util\Common::generateUID());
}
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);

View File

@@ -117,7 +117,7 @@ class BpmnGateway extends BaseBpmnGateway
$this->setBoundDefaults();
if ($this->bound->getBouUid() == "") {
$this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID());
$this->bound->setBouUid(\ProcessMaker\Util\Common::generateUID());
}
$this->bound->save($con);
@@ -147,7 +147,7 @@ class BpmnGateway extends BaseBpmnGateway
$this->bound = $bound;
} else {
$this->bound = new BpmnBound();
$this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID());
$this->bound->setBouUid(ProcessMaker\Util\Common::generateUID());
}
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);

View File

@@ -149,7 +149,7 @@ class Process extends BaseProcess
* $aData['PRO_UID'] the process id
* $aData['USR_UID'] the userid
* $aData['PRO_CATEGORY'] the id category
* @return void
* @return string
*/
public function create ($aData, $generateUid = true)

View File

@@ -148,5 +148,14 @@ class SubProcess extends BaseSubProcess
throw ($oError);
}
}
public static function findByParents($proParent, $tasParent)
{
$criteria = new Criteria('workflow');
$criteria->add(SubProcessPeer::PRO_PARENT, $proParent);
$criteria->add(SubProcessPeer::TAS_PARENT, $tasParent);
return SubProcessPeer::doSelectOne($criteria);
}
}

View File

@@ -354,7 +354,7 @@ class Task extends BaseTask
* create a new Task
*
* @param array $aData with new values
* @return void
* @return string
*/
public function create($aData, $generateUid = true)
{

View File

@@ -29,6 +29,9 @@ $first = isset( $_POST["first"] ) ? true :false;
if ($sort == 'CASE_SUMMARY' || $sort == 'CASE_NOTES_COUNT') {
$sort = 'APP_NUMBER';//DEFAULT VALUE
}
if ($sort == 'APP_STATUS_LABEL') {
$sort = 'APP_STATUS';
}
try {
$userUid = (isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "")? $_SESSION["USER_LOGGED"] : null;

View File

@@ -23,6 +23,27 @@
*/
ini_set( 'max_execution_time', '0' );
$ext = pathinfo($_FILES["PROCESS_FILENAME"]["name"], PATHINFO_EXTENSION);
if ($ext == "pmx") {
$importer = new \ProcessMaker\Importer\XmlImporter();
$importer->setSourceFromGlobals("PROCESS_FILENAME");
$data = array("usr_uid" => $_SESSION['USER_LOGGED']);
$res = $importer->import($data);
$result = array(
"success" => true,
"catchMessage" => "",
"ExistProcessInDatabase" => 0,
"ExistGroupsInDatabase" => 0,
"sNewProUid" => $res[0]["new_uid"],
"project_type" => "bpmn"
);
echo json_encode($result);
exit(0);
}
function reservedWordsSqlValidate ($data)
{
$arrayAux = array ();

View File

@@ -91,7 +91,7 @@ class Cases
Validator::catUid($category, '$cat_uid');
}
$status = G::toUpper($status);
$listStatus = array('TODO', 'DRAFT', 'COMPLETED', 'CANCEL', 'OPEN', 'CLOSE');
$listStatus = array('TO_DO', 'DRAFT', 'COMPLETED', 'CANCEL', 'OPEN', 'CLOSE');
if (!(in_array($status, $listStatus))) {
$status = '';
}
@@ -136,7 +136,6 @@ class Cases
}
}
if ($solrEnabled) {
$result = $ApplicationSolrIndex->getAppGridData(
$userUid,
@@ -184,25 +183,25 @@ class Cases
}
}
if ($paged == false) {
$result = $result['data'];
$response = $result['data'];
} else {
$result['total'] = $result['totalCount'];
unset($result['totalCount']);
$result['start'] = $start+1;
$result['limit'] = $limit;
$result['sort'] = G::toLower($sort);
$result['dir'] = G::toLower($dir);
$result['cat_uid'] = $category;
$result['pro_uid'] = $process;
$result['search'] = $search;
$response['total'] = $result['totalCount'];
$response['start'] = $start+1;
$response['limit'] = $limit;
$response['sort'] = G::toLower($sort);
$response['dir'] = G::toLower($dir);
$response['cat_uid'] = $category;
$response['pro_uid'] = $process;
$response['search'] = $search;
if ($action == 'search') {
$result['app_status'] = G::toLower($status);
$result['usr_uid'] = $user;
$result['date_from'] = $dateFrom;
$result['date_to'] = $dateTo;
$response['app_status'] = G::toLower($status);
$response['usr_uid'] = $user;
$response['date_from'] = $dateFrom;
$response['date_to'] = $dateTo;
}
$response['data'] = $result['data'];
}
return $result;
return $response;
}
/**
@@ -636,14 +635,22 @@ class Cases
* @copyright Colosa - Bolivia
*/
public function putCancelCase($app_uid, $usr_uid, $del_index = false) {
Validator::appUid($app_uid, '$cas_uid');
Validator::isString($app_uid, '$app_uid');
Validator::isString($usr_uid, '$usr_uid');
Validator::appUid($app_uid, '$app_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
Validator::isInteger($del_index, '$del_index');
$case = new \Cases();
$fields = $case->loadCase($app_uid);
if ($fields['APP_STATUS'] == 'CANCELLED') {
throw (new \Exception("The case '$app_uid' is canceled"));
}
$case->cancelCase( $app_uid, $del_index, $usr_uid );
}
@@ -661,15 +668,20 @@ class Cases
* @copyright Colosa - Bolivia
*/
public function putPauseCase($app_uid, $usr_uid, $del_index = false, $unpaused_date = null) {
Validator::appUid($app_uid, '$cas_uid');
Validator::isString($app_uid, '$app_uid');
Validator::isString($usr_uid, '$usr_uid');
Validator::appUid($app_uid, '$app_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($unpaused_date != null) {
Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date');
}
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
Validator::isInteger($del_index, '$del_index');
if ($unpaused_date != null) {
Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date');
}
$case = new \Cases();
$case->pauseCase( $app_uid, $del_index, $usr_uid, $unpaused_date );
@@ -687,12 +699,16 @@ class Cases
* @copyright Colosa - Bolivia
*/
public function putUnpauseCase($app_uid, $usr_uid, $del_index = false) {
Validator::appUid($app_uid, '$cas_uid');
Validator::isString($app_uid, '$app_uid');
Validator::isString($usr_uid, '$usr_uid');
Validator::appUid($app_uid, '$app_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
Validator::isInteger($del_index, '$del_index');
$case = new \Cases();
$case->unpauseCase( $app_uid, $del_index, $usr_uid );
@@ -710,13 +726,18 @@ class Cases
* @copyright Colosa - Bolivia
*/
public function putExecuteTriggerCase($app_uid, $tri_uid, $usr_uid, $del_index = false) {
Validator::appUid($app_uid, '$cas_uid');
Validator::isString($app_uid, '$app_uid');
Validator::isString($tri_uid, '$tri_uid');
Validator::isString($usr_uid, '$usr_uid');
Validator::appUid($app_uid, '$app_uid');
Validator::triUid($tri_uid, '$tri_uid');
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
}
Validator::isInteger($del_index, '$del_index');
$case = new \wsBase();
$case->executeTrigger( $usr_uid, $app_uid, $tri_uid, $del_index );
@@ -733,7 +754,8 @@ class Cases
* @copyright Colosa - Bolivia
*/
public function deleteCase($app_uid) {
Validator::appUid($app_uid, '$cas_uid');
Validator::isString($app_uid, '$app_uid');
Validator::appUid($app_uid, '$app_uid');
$case = new \Cases();
$case->removeCase( $app_uid );
}
@@ -1289,4 +1311,123 @@ class Cases
$oCriteria->addDescendingOrderByColumn('CREATE_DATE');
return $oCriteria;
}
/**
* Get Case Variables
*
* @access public
* @param string $app_uid, Uid for case
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function getCaseVariables($app_uid) {
Validator::isString($app_uid, '$app_uid');
Validator::appUid($app_uid, '$app_uid');
$case = new \Cases();
$fields = $case->loadCase($app_uid);
return $fields['APP_DATA'];
}
/**
* Put Set Case Variables
*
* @access public
* @param string $app_uid, Uid for case
* @param array $app_data, Data for case variables
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function setCaseVariables($app_uid, $app_data) {
Validator::isString($app_uid, '$app_uid');
Validator::appUid($app_uid, '$app_uid');
Validator::isArray($app_data, '$app_data');
$case = new \Cases();
$fields = $case->loadCase($app_uid);
$data = array_merge($fields['APP_DATA'], array('APP_DATA' => $app_data));
$case->updateCase($app_uid, $data);
}
/**
* Get Case Notes
*
* @access public
* @param string $app_uid, Uid for case
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function getCaseNotes($app_uid, $usr_uid) {
Validator::isString($app_uid, '$app_uid');
Validator::appUid($app_uid, '$app_uid');
$case = new \Cases();
$caseLoad = $case->loadCase($app_uid);
$pro_uid = $caseLoad['PRO_UID'];
$tas_uid = \AppDelegation::getCurrentTask($app_uid);
$respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' );
$respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' );
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
throw (new \Exception("You do not have permission to cases notes."));
}
$appNote = new \AppNotes();
$note_data = $appNote->getNotesList($app_uid);
$response = array();
$response['total'] = $note_data['array']['totalCount'];
$response['notes'] = array();
$con = 0;
foreach ($note_data['array']['notes'] as $value) {
$response['notes'][$con]['app_uid'] = $value['APP_UID'];
$response['notes'][$con]['usr_uid'] = $value['USR_UID'];
$response['notes'][$con]['note_date'] = $value['NOTE_DATE'];
$response['notes'][$con]['note_content'] = $value['NOTE_CONTENT'];
$con++;
}
return $response;
}
/**
* Save new case note
*
* @access public
* @param string $app_uid, Uid for case
* @param array $app_data, Data for case variables
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail = false) {
Validator::isString($app_uid, '$app_uid');
Validator::appUid($app_uid, '$app_uid');
Validator::isString($usr_uid, '$usr_uid');
Validator::usrUid($usr_uid, '$usr_uid');
Validator::isString($note_content, '$note_content');
if (strlen($note_content) > 500) {
throw (new \Exception("Invalid value for '$note_content', the permitted maximum length of 500 characters."));
}
Validator::isBoolean($send_mail, '$send_mail');
$case = new \Cases();
$caseLoad = $case->loadCase($app_uid);
$pro_uid = $caseLoad['PRO_UID'];
$tas_uid = \AppDelegation::getCurrentTask($app_uid);
$respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' );
$respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' );
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
throw (new \Exception("You do not have permission to cases notes."));
}
$note_content = addslashes($note_content);
$appNote = new \AppNotes();
$appNote->addCaseNote($app_uid, $usr_uid, $note_content, intval($send_mail));
}
}

View File

@@ -6,15 +6,15 @@ class InputDocument
/**
* Get data of Cases InputDocument
*
* @param string $caseUid
* @param string $applicationUid
* @param string $userUid
*
* return array Return an array with data of an InputDocument
*/
public function getCasesInputDocuments($caseUid, $userUid)
public function getCasesInputDocuments($applicationUid, $userUid)
{
try {
$sApplicationUID = $caseUid;
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');
$oCase = new \Cases();
@@ -49,16 +49,16 @@ class InputDocument
/**
* Get data of Cases InputDocument
*
* @param string $caseUid
* @param string $applicationUid
* @param string $userUid
* @param string $inputDocumentUid
*
* return array Return an array with data of an InputDocument
*/
public function getCasesInputDocument($caseUid, $userUid, $inputDocumentUid)
public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid)
{
try {
$sApplicationUID = $caseUid;
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');
$oCase = new \Cases();
@@ -104,7 +104,7 @@ class InputDocument
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This row doesn\'t exist!'));
throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!'));
}
\G::LoadClass('wsBase');
$ws = new \wsBase();
@@ -117,17 +117,19 @@ class InputDocument
/**
* Get data of Cases InputDocument
*
* @param string $caseUid
* @param string $applicationUid
* @param string $taskUid
* @param string $appDocComment
* @param string $inputDocumentUid
* @param string $userUid
*
* return array Return an array with data of an InputDocument
*/
public function addCasesInputDocument($caseUid, $inputDocumentUid, $userUid)
public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid)
{
try {
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) {
$code = $_FILES['form']['error']['APP_DOC_FILENAME'];
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) {
$code = $_FILES['form']['error'];
switch ($code) {
case UPLOAD_ERR_INI_SIZE:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_INI_SIZE' );
@@ -159,31 +161,22 @@ class InputDocument
\G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
die();
}
\G::LoadClass("case");
//$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"]
$appDocUid = '';
//$appDocUid = $_POST["form"]["APP_DOC_UID"];
$appDocUid = \G::generateUniqueID();
$docVersion = '';
//$docVersion = intval($_POST["form"]["docVersion"]);
$appDocType = 'INPUT';
//$appDocType = $_POST["form"]["APP_DOC_TYPE"];
$appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : "";
$actionType = $_POST["form"]["actionType"];
$case = new \Cases();
$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs");
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
$case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, "REDIRECT", "casesListExtJs");
//Load the fields
$arrayField = $case->loadCase($_SESSION["APPLICATION"]);
$arrayField = $case->loadCase($applicationUid);
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants());
//Triggers
$arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $inputDocumentUid, "AFTER");
$arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER");
//Add Input Document
if (!$_FILES["form"]["error"]) {
$_FILES["form"]["error"] = 0;
}
if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) {
$appDocUid = $case->addInputDocument(
$inputDocumentUid,
@@ -191,44 +184,39 @@ class InputDocument
$docVersion,
$appDocType,
$appDocComment,
$actionType,
$_SESSION["APPLICATION"],
$_SESSION["INDEX"],
$_SESSION["TASK"],
$_SESSION["USER_LOGGED"],
'',
$applicationUid,
$delIndex,
$taskUid,
$userUid,
"xmlform",
$_FILES["form"]["name"]["APP_DOC_FILENAME"],
$_FILES["form"]["error"]["APP_DOC_FILENAME"],
$_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"]
$_FILES["form"]["name"],
$_FILES["form"]["error"],
$_FILES["form"]["tmp_name"]
);
}
if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) {
}
if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) {
//Trigger - Execute after - Start
$arrayField["APP_DATA"] = $case->executeTriggers(
$_SESSION["TASK"],
$taskUid,
"INPUT_DOCUMENT",
$inputDocumentUid,
"AFTER",
$arrayField["APP_DATA"]
);
//Trigger - Execute after - End
}
}
//Save data
$arrayData = array();
$arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"];
//$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"];
$arrayData["APP_DATA"] = $arrayField["APP_DATA"];
$arrayData["DEL_INDEX"] = $_SESSION["INDEX"];
$arrayData["TAS_UID"] = $_SESSION["TASK"];
$case->updateCase($_SESSION["APPLICATION"], $arrayData);
$arrayData["DEL_INDEX"] = $delIndex;
$arrayData["TAS_UID"] = $taskUid;
$case->updateCase($applicationUid, $arrayData);
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -6,21 +6,21 @@ class OutputDocument
/**
* Get data of Cases OutputDocument
*
* @param string $caseUid
* @param string $applicationUid
* @param string $userUid
*
* return array Return an array with data of an OutputDocument
*/
public function getCasesOutputDocuments($caseUid, $userUid)
public function getCasesOutputDocuments($applicationUid, $userUid)
{
try {
\G::LoadClass('case');
$oCase = new \Cases();
$fields = $oCase->loadCase( $caseUid );
$fields = $oCase->loadCase( $applicationUid );
$sProcessUID = $fields['PRO_UID'];
$sTaskUID = '';
$oCriteria = new \BusinessModel\Cases();
$oCriteria->getAllGeneratedDocumentsCriteria( $sProcessUID, $caseUid, $sTaskUID, $userUid);
$oCriteria->getAllGeneratedDocumentsCriteria( $sProcessUID, $applicationUid, $sTaskUID, $userUid);
$result = array ();
global $_DBArray;
foreach ($_DBArray['outputDocuments'] as $key => $row) {
@@ -47,16 +47,16 @@ class OutputDocument
/**
* Get data of Cases OutputDocument
*
* @param string $caseUid
* @param string $applicationUid
* @param string $userUid
* @param string $outputDocumentUid
* @param string $applicationDocumentUid
*
* return array Return an array with data of an OutputDocument
* return object Return an object with data of an OutputDocument
*/
public function getCasesOutputDocument($caseUid, $userUid, $outputDocumentUid)
public function getCasesOutputDocument($applicationUid, $userUid, $applicationDocumentUid)
{
try {
$sApplicationUID = $caseUid;
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');
$oCase = new \Cases();
@@ -79,12 +79,13 @@ class OutputDocument
$docrow['app_doc_type'] = $row['TYPE'];
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
if ($docrow['app_doc_uid'] == $outputDocumentUid) {
if ($docrow['app_doc_uid'] == $applicationDocumentUid) {
$result = $docrow;
}
}
}
return $result;
$oResponse = json_decode(json_encode($result), false);
return $oResponse;
} catch (\Exception $e) {
throw $e;
}
@@ -93,20 +94,19 @@ class OutputDocument
/**
* Delete OutputDocument
*
* @param string $outputDocumentUid
* @param string $applicationDocumentUid
*
* return array Return an array with data of an OutputDocument
*/
public function removeOutputDocument($outputDocumentUid)
public function removeOutputDocument($applicationDocumentUid)
{
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $outputDocumentUid, 1 );
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This row doesn\'t exist!'));
throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!'));
}
\G::LoadClass('wsBase');
$ws = new \wsBase();
$ws->removeDocument($outputDocumentUid);
$ws->removeDocument($applicationDocumentUid);
} catch (\Exception $e) {
throw $e;
}
@@ -115,116 +115,505 @@ class OutputDocument
/**
* Get data of Cases OutputDocument
*
* @param string $caseUid
* @param string $applicationUid
* @param string $outputDocumentUid
* @param string $userUid
*
* return array Return an array with data of an OutputDocument
* return object Return an object with data of an OutputDocument
*/
public function addCasesOutputDocument($caseUid, $outputDocumentUid, $userUid)
public function addCasesOutputDocument($applicationUid, $outputDocumentUid, $userUid)
{
try {
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) {
$code = $_FILES['form']['error']['APP_DOC_FILENAME'];
switch ($code) {
case UPLOAD_ERR_INI_SIZE:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_INI_SIZE' );
$sApplication = $applicationUid;
$index = \AppDelegation::getCurrentIndex($applicationUid);
$sUserLogged = $userUid;
$outputID = $outputDocumentUid;
$g = new \G();
$g->sessionVarSave();
\G::LoadClass( 'case' );
$oCase = new \Cases();
$oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' );
//require_once 'classes/model/OutputDocument.php';
$oOutputDocument = new \OutputDocument();
$aOD = $oOutputDocument->load( $outputID );
$Fields = $oCase->loadCase( $sApplication );
$sFilename = preg_replace( '[^A-Za-z0-9_]', '_', \G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) );
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php");
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php");
//Get the Custom Folder ID (create if necessary)
$oFolder = new \AppFolder();
$folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication );
//Tags
$fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication );
//Get last Document Version and apply versioning if is enabled
$oAppDocument = new \AppDocument();
$lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication );
$oCriteria = new \Criteria( 'workflow' );
$oCriteria->add( \AppDocumentPeer::APP_UID, $sApplication );
$oCriteria->add( \AppDocumentPeer::DOC_UID, $outputID );
$oCriteria->add( \AppDocumentPeer::DOC_VERSION, $lastDocVersion );
$oCriteria->add( \AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' );
$oDataset = \AppDocumentPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) {
//Create new Version of current output
$lastDocVersion ++;
if ($aRow = $oDataset->getRow()) {
$aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags);
$oAppDocument = new \AppDocument();
$oAppDocument->create( $aFields );
$sDocUID = $aRow['APP_DOC_UID'];
}
} else {
////No versioning so Update a current Output or Create new if no exist
if ($aRow = $oDataset->getRow()) {
//Update
$aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
);
$oAppDocument = new \AppDocument();
$oAppDocument->update( $aFields );
$sDocUID = $aRow['APP_DOC_UID'];
} else {
//we are creating the appdocument row
//create
if ($lastDocVersion == 0) {
$lastDocVersion ++;
}
$aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags
);
$oAppDocument = new \AppDocument();
$aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields );
}
}
$sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion;
$pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die;
\G::mk_dir( $pathOutput );
$aProperties = array ();
if (! isset( $aOD['OUT_DOC_MEDIA'] )) {
$aOD['OUT_DOC_MEDIA'] = 'Letter';
}
if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) {
$aOD['OUT_DOC_LEFT_MARGIN'] = '15';
}
if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) {
$aOD['OUT_DOC_RIGHT_MARGIN'] = '15';
}
if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) {
$aOD['OUT_DOC_TOP_MARGIN'] = '15';
}
if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) {
$aOD['OUT_DOC_BOTTOM_MARGIN'] = '15';
}
$aProperties['media'] = $aOD['OUT_DOC_MEDIA'];
$aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']
);
if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) {
$aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR'];
}
$this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid);
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
//G::LoadClass('plugin');
$oPluginRegistry = & \PMPluginRegistry::getSingleton();
if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) {
$triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
$aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace;
$oAppDocument1 = new \AppDocument();
$oAppDocument1->update( $aFields );
$sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP;
$oData['APP_UID'] = $sApplication;
$oData['ATTACHMENT_FOLDER'] = true;
switch ($aOD['OUT_DOC_GENERATE']) {
case "BOTH":
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
$documentData->sFileType = "PDF";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.pdf' );
}
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
$documentData->sFileType = "DOC";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.doc' );
}
break;
case UPLOAD_ERR_FORM_SIZE:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_FORM_SIZE' );
case "PDF":
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() );
$documentData->sFileType = "PDF";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.pdf' );
}
break;
case UPLOAD_ERR_PARTIAL:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_PARTIAL' );
break;
case UPLOAD_ERR_NO_FILE:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_FILE' );
break;
case UPLOAD_ERR_NO_TMP_DIR:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_TMP_DIR' );
break;
case UPLOAD_ERR_CANT_WRITE:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_CANT_WRITE' );
break;
case UPLOAD_ERR_EXTENSION:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_EXTENSION' );
break;
default:
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_UNKNOWN' );
case "DOC":
$documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() );
$documentData->sFileType = "DOC";
$documentData->bUseOutputFolder = true;
$uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
if ($uploadReturn) {
//Only delete if the file was saved correctly
unlink( $pathOutput . $sFilename . '.doc' );
}
break;
}
\G::SendMessageText( $message, "ERROR" );
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
\G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
die();
}
\G::LoadClass("case");
//$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"]
$appDocUid = '';
//$appDocUid = $_POST["form"]["APP_DOC_UID"];
$docVersion = '';
//$docVersion = intval($_POST["form"]["docVersion"]);
$appDocType = 'INPUT';
//$appDocType = $_POST["form"]["APP_DOC_TYPE"];
$appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : "";
$actionType = $_POST["form"]["actionType"];
$case = new \Cases();
$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs");
//Load the fields
$arrayField = $case->loadCase($_SESSION["APPLICATION"]);
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants());
//Triggers
$arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $outputDocumentUid, "AFTER");
//Add Input Document
if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) {
$appDocUid = $case->addInputDocument(
$outputDocumentUid,
$appDocUid,
$docVersion,
$appDocType,
$appDocComment,
$actionType,
$_SESSION["APPLICATION"],
$_SESSION["INDEX"],
$_SESSION["TASK"],
$_SESSION["USER_LOGGED"],
"xmlform",
$_FILES["form"]["name"]["APP_DOC_FILENAME"],
$_FILES["form"]["error"]["APP_DOC_FILENAME"],
$_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"]
);
}
if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) {
//Trigger - Execute after - Start
$arrayField["APP_DATA"] = $case->executeTriggers(
$_SESSION["TASK"],
"INPUT_DOCUMENT",
$outputDocumentUid,
"AFTER",
$arrayField["APP_DATA"]
);
//Trigger - Execute after - End
}
//Save data
$arrayData = array();
$arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"];
//$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"];
$arrayData["APP_DATA"] = $arrayField["APP_DATA"];
$arrayData["DEL_INDEX"] = $_SESSION["INDEX"];
$arrayData["TAS_UID"] = $_SESSION["TASK"];
$case->updateCase($_SESSION["APPLICATION"], $arrayData);
$g->sessionVarRestore();
return $this->getCasesOutputDocument($applicationUid, $userUid, $sDocUID);
} catch (\Exception $e) {
throw $e;
}
}
/*
* Generate the output document
* @param string $sUID
* @param array $aFields
* @param string $sPath
* @return variant
*/
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array(), $sApplication)
{
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
$sContent = \G::replaceDataGridField($sContent, $aFields);
\G::verifyPath($sPath, true);
//Start - Create .doc
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
$size = array();
$size["Letter"] = "216mm 279mm";
$size["Legal"] = "216mm 357mm";
$size["Executive"] = "184mm 267mm";
$size["B5"] = "182mm 257mm";
$size["Folio"] = "216mm 330mm";
$size["A0Oversize"] = "882mm 1247mm";
$size["A0"] = "841mm 1189mm";
$size["A1"] = "594mm 841mm";
$size["A2"] = "420mm 594mm";
$size["A3"] = "297mm 420mm";
$size["A4"] = "210mm 297mm";
$size["A5"] = "148mm 210mm";
$size["A6"] = "105mm 148mm";
$size["A7"] = "74mm 105mm";
$size["A8"] = "52mm 74mm";
$size["A9"] = "37mm 52mm";
$size["A10"] = "26mm 37mm";
$size["Screenshot640"] = "640mm 480mm";
$size["Screenshot800"] = "800mm 600mm";
$size["Screenshot1024"] = "1024mm 768mm";
$sizeLandscape["Letter"] = "279mm 216mm";
$sizeLandscape["Legal"] = "357mm 216mm";
$sizeLandscape["Executive"] = "267mm 184mm";
$sizeLandscape["B5"] = "257mm 182mm";
$sizeLandscape["Folio"] = "330mm 216mm";
$sizeLandscape["A0Oversize"] = "1247mm 882mm";
$sizeLandscape["A0"] = "1189mm 841mm";
$sizeLandscape["A1"] = "841mm 594mm";
$sizeLandscape["A2"] = "594mm 420mm";
$sizeLandscape["A3"] = "420mm 297mm";
$sizeLandscape["A4"] = "297mm 210mm";
$sizeLandscape["A5"] = "210mm 148mm";
$sizeLandscape["A6"] = "148mm 105mm";
$sizeLandscape["A7"] = "105mm 74mm";
$sizeLandscape["A8"] = "74mm 52mm";
$sizeLandscape["A9"] = "52mm 37mm";
$sizeLandscape["A10"] = "37mm 26mm";
$sizeLandscape["Screenshot640"] = "480mm 640mm";
$sizeLandscape["Screenshot800"] = "600mm 800mm";
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
if (!isset($aProperties['media'])) {
$aProperties['media'] = 'Letter';
}
if ($sLandscape) {
$media = $sizeLandscape[$aProperties['media']];
} else {
$media = $size[$aProperties['media']];
}
$marginLeft = '15';
if (isset($aProperties['margins']['left'])) {
$marginLeft = $aProperties['margins']['left'];
}
$marginRight = '15';
if (isset($aProperties['margins']['right'])) {
$marginRight = $aProperties['margins']['right'];
}
$marginTop = '15';
if (isset($aProperties['margins']['top'])) {
$marginTop = $aProperties['margins']['top'];
}
$marginBottom = '15';
if (isset($aProperties['margins']['bottom'])) {
$marginBottom = $aProperties['margins']['bottom'];
}
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:DoNotHyphenateCaps/>
<w:PunctuationKerning/>
<w:DrawingGridHorizontalSpacing>9.35 pt</w:DrawingGridHorizontalSpacing>
<w:DrawingGridVerticalSpacing>9.35 pt</w:DrawingGridVerticalSpacing>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
@page WordSection1
{size:' . $media . ';
margin-left:' . $marginLeft . 'mm;
margin-right:' . $marginRight . 'mm;
margin-bottom:' . $marginBottom . 'mm;
margin-top:' . $marginTop . 'mm;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.WordSection1
{page:WordSection1;}
-->
</style>
</head>
<body>
<div class=WordSection1>');
fwrite($oFile, $sContent);
fwrite($oFile, "\n</div></body></html>\n\n");
fclose($oFile);
/* End - Create .doc */
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
fwrite($oFile, $sContent);
fclose($oFile);
/* Start - Create .pdf */
if (isset($aProperties['report_generator'])) {
switch ($aProperties['report_generator']) {
case 'TCPDF':
$o = new \OutputDocument();
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
break;
case 'HTML2PDF':
default:
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties, $sApplication);
break;
}
} else {
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
}
}
//end if $sTypeDocToGener
/* End - Create .pdf */
} else {
return \PEAR::raiseError(
null, G_ERROR_USER_UID, null, null, 'You tried to call to a generate method without send the Output Document UID, fields to use and the file path!', 'G_Error', true
);
}
}
/*
* Generate Html2ps_pdf
* @param string $sUID
* @param array $aFields
* @param string $sPath
* @param string $sApplication
* @return variant
*/
public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array(), $sApplication)
{
define("MAX_FREE_FRACTION", 1);
define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $sApplication . '/outdocs/');
\G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
require_once (PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php');
require_once (PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php');
parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
$GLOBALS['g_config'] = array(
'cssmedia' => 'screen',
'media' => 'Letter',
'scalepoints' => false,
'renderimages' => true,
'renderfields' => true,
'renderforms' => false,
'pslevel' => 3,
'renderlinks' => true,
'pagewidth' => 800,
'landscape' => $sLandscape,
'method' => 'fpdf',
'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15,),
'encoding' => '',
'ps2pdf' => false,
'compress' => true,
'output' => 2,
'pdfversion' => '1.3',
'transparency_workaround' => false,
'imagequality_workaround' => false,
'draw_page_border' => isset($_REQUEST['pageborder']),
'debugbox' => false,
'html2xhtml' => true,
'mode' => 'html',
'smartpagebreak' => true
);
$GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties);
$g_media = \Media::predefined($GLOBALS['g_config']['media']);
$g_media->set_landscape($GLOBALS['g_config']['landscape']);
$g_media->set_margins($GLOBALS['g_config']['margins']);
$g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
if (isset($GLOBALS['g_config']['pdfSecurity'])) {
if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) &&
$GLOBALS['g_config']['pdfSecurity']['openPassword'] != ""
) {
$GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt(
$GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID
);
}
if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) &&
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != ""
) {
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt(
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID
);
}
$g_media->set_security($GLOBALS['g_config']['pdfSecurity']);
require_once (HTML2PS_DIR . 'pdf.fpdf.encryption.php');
}
$pipeline = new \Pipeline();
if (extension_loaded('curl')) {
require_once (HTML2PS_DIR . 'fetcher.url.curl.class.php');
$pipeline->fetchers = array(new \FetcherURLCurl());
if (isset($proxy)) {
if ($proxy != '') {
$pipeline->fetchers[0]->set_proxy($proxy);
}
}
} else {
require_once (HTML2PS_DIR . 'fetcher.url.class.php');
$pipeline->fetchers[] = new \FetcherURL();
}
$pipeline->data_filters[] = new \DataFilterDoctype();
$pipeline->data_filters[] = new \DataFilterUTF8($GLOBALS['g_config']['encoding']);
if ($GLOBALS['g_config']['html2xhtml']) {
$pipeline->data_filters[] = new \DataFilterHTML2XHTML();
} else {
$pipeline->data_filters[] = new \DataFilterXHTML2XHTML();
}
$pipeline->parser = new \ParserXHTML();
$pipeline->pre_tree_filters = array();
$header_html = '';
$footer_html = '';
$filter = new \PreTreeFilterHeaderFooter($header_html, $footer_html);
$pipeline->pre_tree_filters[] = $filter;
if ($GLOBALS['g_config']['renderfields']) {
$pipeline->pre_tree_filters[] = new \PreTreeFilterHTML2PSFields();
}
if ($GLOBALS['g_config']['method'] === 'ps') {
$pipeline->layout_engine = new \LayoutEnginePS();
} else {
$pipeline->layout_engine = new \LayoutEngineDefault();
}
$pipeline->post_tree_filters = array();
if ($GLOBALS['g_config']['pslevel'] == 3) {
$image_encoder = new \PSL3ImageEncoderStream();
} else {
$image_encoder = new \PSL2ImageEncoderStream();
}
switch ($GLOBALS['g_config']['method']) {
case 'fastps':
if ($GLOBALS['g_config']['pslevel'] == 3) {
$pipeline->output_driver = new \OutputDriverFastPS($image_encoder);
} else {
$pipeline->output_driver = new \OutputDriverFastPSLevel2($image_encoder);
}
break;
case 'pdflib':
$pipeline->output_driver = new \OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']);
break;
case 'fpdf':
$pipeline->output_driver = new \OutputDriverFPDF();
break;
case 'png':
$pipeline->output_driver = new \OutputDriverPNG();
break;
case 'pcl':
$pipeline->output_driver = new \OutputDriverPCL();
break;
default:
die('Unknown output method');
}
if (isset($GLOBALS['g_config']['watermarkhtml'])) {
$watermark_text = $GLOBALS['g_config']['watermarkhtml'];
} else {
$watermark_text = '';
}
$pipeline->output_driver->set_watermark($watermark_text);
if ($watermark_text != '') {
$dispatcher = & $pipeline->getDispatcher();
}
if ($GLOBALS['g_config']['debugbox']) {
$pipeline->output_driver->set_debug_boxes(true);
}
if ($GLOBALS['g_config']['draw_page_border']) {
$pipeline->output_driver->set_show_page_border(true);
}
if ($GLOBALS['g_config']['ps2pdf']) {
$pipeline->output_filters[] = new \OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']);
}
if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps') {
$pipeline->output_filters[] = new \OutputFilterGZip();
}
if (!isset($GLOBALS['g_config']['process_mode'])) {
$GLOBALS['g_config']['process_mode'] = '';
}
if ($GLOBALS['g_config']['process_mode'] == 'batch') {
$filename = 'batch';
} else {
$filename = $sFilename;
}
switch ($GLOBALS['g_config']['output']) {
case 0:
$pipeline->destination = new \DestinationBrowser($filename);
break;
case 1:
$pipeline->destination = new \DestinationDownload($filename);
break;
case 2:
$pipeline->destination = new \DestinationFile($filename);
break;
}
copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
try {
$status = $pipeline->process(((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $sApplication . '/outdocs/' . $sFilename . '.html', $g_media);
copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf');
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf');
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
} catch (\Exception $e) {
if ($e->getMessage() == 'ID_OUTPUT_NOT_GENERATE') {
include_once 'classes/model/AppDocument.php';
$dataDocument = explode('_', $sFilename);
if (!isset($dataDocument[1])) {
$dataDocument[1] = 1;
}
$oAppDocument = new \AppDocument();
$oAppDocument->remove($dataDocument[0], $dataDocument[1]);
\G::SendTemporalMessage(\G::LoadTranslation('ID_OUTPUT_NOT_GENERATE'), 'Error');
}
}
}
}

View File

@@ -44,7 +44,7 @@ class Subprocess
$response['spr_name'] = $aRow['con_value'];
$response['spr_synchronous'] = $aRow['sp_synchronous'];
$response['spr_variables_out'] = unserialize($aRow['sp_variables_out']);
if ($response['spr_synchronous'] === 1) {
if ((int)$response['spr_synchronous'] === 1) {
$response['spr_variables_in'] = unserialize($aRow['sp_variables_in']);
}
return $response;
@@ -91,7 +91,7 @@ class Subprocess
'PRO_PARENT' => $pro_uid,
'TAS_PARENT' => $tas_uid,
'SP_TYPE' => 'SIMPLE',
'SP_SYNCHRONOUS' => $spr_data['spr_synchronous'],
'SP_SYNCHRONOUS' => (int)$spr_data['spr_synchronous'],
'SP_SYNCHRONOUS_TYPE' => 'ALL',
'SP_SYNCHRONOUS_WAIT' => 0,
'SP_VARIABLES_OUT' => serialize( $spr_data['spr_variables_out'] ),

View File

@@ -237,11 +237,11 @@ class Validator{
{
$date = trim($date);
if ($date == '') {
throw (new \Exception("The value '' is not valid fot the format '$format'."));
throw (new \Exception("The value '' is not a valid date for the format '$format'."));
}
$d = \DateTime::createFromFormat($format, $date);
if (!($d && $d->format($format) == $date)) {
throw (new \Exception("The value '$date' is not valid fot the format '$format'."));
throw (new \Exception("The value '$date' is not a valid date for the format '$format'."));
}
return $date;
}
@@ -263,6 +263,40 @@ class Validator{
}
}
/**
* Validate is string
* @var array $field. Field type string
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*/
static public function isString($field, $nameField)
{
if (!is_string($field)) {
throw (new \Exception("Invalid value for '$nameField' it must be a string."));
}
}
/**
* Validate is integer
* @var array $field. Field type integer
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*/
static public function isInteger($field, $nameField)
{
if (!is_integer($field)) {
throw (new \Exception("Invalid value for '$nameField' it must be a integer."));
}
}
/**
* Validate is boolean
* @var boolean $field. Field type boolean

View File

@@ -14,7 +14,7 @@ abstract class Exporter
/**
* Exporter version
*/
const VERSION = "2.0";
const VERSION = "3.0";
/**
* @var \ProcessMaker\Project\Adapter\BpmnWorkflow
@@ -67,18 +67,18 @@ abstract class Exporter
{
$data = array();
$data["Metadata"] = $this->getMetadata();
$data["Metadata"]["project_name"] = $this->getProjectName();
$data["metadata"] = $this->getMetadata();
$data["metadata"]["project_name"] = $this->getProjectName();
$bpmnStruct["ACTIVITY"] = \BpmnActivity::getAll($this->prjUid);
$bpmnStruct["BOUND"] = \BpmnBound::getAll($this->prjUid);
$bpmnStruct["DATA"] = array();
$bpmnStruct["DIAGRAM"] = \BpmnDiagram::getAll($this->prjUid);
$bpmnStruct["DOCUMENTATION"] = array();
$bpmnStruct["BPMN_EVENT"] = \BpmnEvent::getAll($this->prjUid);
$bpmnStruct["EVENT"] = \BpmnEvent::getAll($this->prjUid);
$bpmnStruct["EXTENSION"] = array();
$bpmnStruct["FLOW"] = \BpmnFlow::getAll($this->prjUid, null, null, "", CASE_UPPER, false);
$bpmnStruct["BPMN_GATEWAY"] = \BpmnGateway::getAll($this->prjUid);
$bpmnStruct["GATEWAY"] = \BpmnGateway::getAll($this->prjUid);
$bpmnStruct["LANE"] = array();
$bpmnStruct["LANESET"] = array();
$bpmnStruct["PARTICIPANT"] = array();
@@ -95,9 +95,9 @@ abstract class Exporter
$workflowData["processCategory"] = empty($workflowData["processCategory"]) ? array() : $workflowData["processCategory"];
$data["BPMN-Definition"] = $bpmnStruct;
$data["Workflow-Definition"] = $workflowData;
$data["Workflow-Files"] = array();
$data["bpmn-definition"] = $bpmnStruct;
$data["workflow-definition"] = $workflowData;
$data["workflow-files"] = array();
// getting dynaforms
$dynaforms = array();
@@ -113,7 +113,7 @@ abstract class Exporter
$htmlFile = PATH_DYNAFORM . $dynaform['DYN_FILENAME'] . '.html';
if (file_exists($htmlFile)) {
$data["Workflow-Files"]["DYNAFORMS"][] = array(
$data["workflow-files"]["DYNAFORMS"][] = array(
"filename" => $dynaform['DYN_FILENAME'] . '.html',
"filepath" => $dynaform['DYN_FILENAME'] . '.html',
"file_content" => file_get_contents($htmlFile)
@@ -132,7 +132,7 @@ abstract class Exporter
foreach ($templatesFiles as $templatesFile) {
if (is_dir($templatesFile)) continue;
$data["Workflow-Files"][$target][] = array(
$data["workflow-files"][$target][] = array(
"filename" => basename($templatesFile),
"filepath" => str_replace($templatesDir, "", $templatesFile),
"file_content" => file_get_contents($templatesFile)
@@ -148,7 +148,7 @@ abstract class Exporter
*
* @return string
*/
public function getContainerName()
public static function getContainerName()
{
return "ProcessMaker-Project";
}

View File

@@ -38,21 +38,20 @@ class XmlExporter extends Exporter
*/
public function build()
{
$this->rootNode = $this->dom->createElement($this->getContainerName());
$this->rootNode = $this->dom->createElement(self::getContainerName());
$this->rootNode->setAttribute("version", self::getVersion());
$this->dom->appendChild($this->rootNode);
$data = $this->buildData();
// metadata set up
$metadata = $data["Metadata"];
$metadataNode = $this->dom->createElement("Metadata");
$metadata = $data["metadata"];
$metadataNode = $this->dom->createElement("metadata");
foreach ($metadata as $key => $value) {
$metaNode = $this->dom->createElement("meta:$key");
//$metaNode->setAttribute("key", $key);
//$metaNode->setAttribute("value", $value);
$metaNode->appendChild($this->dom->createTextNode($value));
$metaNode = $this->dom->createElement("meta");
$metaNode->setAttribute("key", $key);
$metaNode->appendChild($this->getTextNode($value));
$metadataNode->appendChild($metaNode);
}
@@ -60,10 +59,10 @@ class XmlExporter extends Exporter
// end setting metadata
// bpmn struct data set up
$dbData = array("BPMN" => $data["BPMN-Definition"], "Workflow" => $data["Workflow-Definition"]);
//file_put_contents("/home/erik/out.log", print_r($dbData, true)); die;
$dbData = array("BPMN" => $data["bpmn-definition"], "workflow" => $data["workflow-definition"]);
foreach ($dbData as $sectionName => $sectionData) {
$dataNode = $this->dom->createElement("Definition");
$dataNode = $this->dom->createElement("definition");
$dataNode->setAttribute("class", $sectionName);
foreach ($sectionData as $elementName => $elementData) {
@@ -73,19 +72,10 @@ class XmlExporter extends Exporter
foreach ($elementData as $recordData) {
$recordNode = $this->dom->createElement("record");
$recordData = array_change_key_case($recordData, CASE_LOWER);
//var_dump($recordData); die;
foreach ($recordData as $key => $value) {
$columnNode = $this->dom->createElement($key);
if (preg_match('/^[\w\s\.]+$/', $value, $match) || empty($value)) {
$textNode = $this->dom->createTextNode($value);
} else {
$textNode = $this->dom->createCDATASection($value);
}
$columnNode->appendChild($textNode);
$columnNode->appendChild($this->getTextNode($value));
$recordNode->appendChild($columnNode);
}
@@ -98,20 +88,16 @@ class XmlExporter extends Exporter
$this->rootNode->appendChild($dataNode);
}
$workflowFilesNode = $this->dom->createElement("Workflow-Files");
$workflowFilesNode = $this->dom->createElement("workflow-files");
// workflow dynaforms files
foreach ($data["Workflow-Files"] as $elementName => $elementData) {
foreach ($data["workflow-files"] as $elementName => $elementData) {
foreach ($elementData as $fileData) {
$fileNode = $this->dom->createElement("file");
$fileNode->setAttribute("target", strtolower($elementName));
$filenameNode = $this->dom->createElement("file_name");
if (preg_match('/^[\w\s\.\-]+$/', $fileData["filename"], $match)) {
$filenameNode->appendChild($this->dom->createTextNode($fileData["filename"]));
} else {
$filenameNode->appendChild($this->dom->createCDATASection($fileData["filename"]));
}
$filenameNode->appendChild($this->getTextNode($fileData["filename"]));
$fileNode->appendChild($filenameNode);
$filepathNode = $this->dom->createElement("file_path");
@@ -146,4 +132,13 @@ class XmlExporter extends Exporter
$this->build();
return $this->dom->saveXml();
}
private function getTextNode($value)
{
if (preg_match('/^[\w\s\.\-]+$/', $value, $match)) {
return $this->dom->createTextNode($value);
} else {
return $this->dom->createCDATASection($value);
}
}
}

View File

@@ -24,16 +24,66 @@ abstract class Importer
const IMPORT_STAT_INVALID_SOURCE_FILE = 102;
public abstract function import();
public abstract function validateSource();
public abstract function targetExists();
public function import($option = self::IMPORT_OPTION_CREATE_NEW)
{
switch ($option) {
case self::IMPORT_OPTION_CREATE_NEW:
$this->prepare();
$this->createNewProject();
break;
case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW:
break;
case self::IMPORT_OPTION_OVERWRITE:
break;
}
}
/**
* Validates the source file
* @return mixed
*/
public function validateSource()
{
return true;
}
/**
* Verify if the project already exists
* @return mixed
*/
public function targetExists()
{
return false;
}
public function createNewProject()
{
}
public function updateProject()
{
}
public function disableCurrentProject()
{
}
/**
* Sets the temporal file save directory
* @param $dirName
*/
public function setSaveDir($dirName)
{
$this->saveDir = rtrim($dirName, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
/**
* Gets the temporal file save directory
* @return string
*/
public function getSaveDir()
{
if (empty($this->saveDir)) {
@@ -43,11 +93,20 @@ abstract class Importer
return $this->saveDir;
}
/**
* Sets the temporal source file
* @param $filename
*/
public function setSourceFile($filename)
{
$this->filename = $filename;
}
/**
* Set source from Global Http Request resource
* @param $varName
* @throws \Exception
*/
public function setSourceFromGlobals($varName)
{
/*[PROCESS_FILENAME] => Array
@@ -77,6 +136,11 @@ abstract class Importer
umask($oldUmask);
}
/**
* Prepare for import, it makes all validations needed
* @return int
* @throws \Exception
*/
public function prepare()
{
if ($this->validateSource() === false) {

View File

@@ -1,17 +1,150 @@
<?php
namespace ProcessMaker\Importer;
class XmlImporter
use ProcessMaker\Project\Adapter;
class XmlImporter extends Importer
{
public $filename = "";
/**
* @var \DOMDocument
*/
protected $dom;
protected $root;
protected $version = "";
public function __construct()
{
$this->dom = new \DOMDocument();
}
public function setSourceFile($filename)
{
$this->filename = $filename;
}
public function import()
public function load()
{
$this->dom->load($this->filename);
$this->root = $this->dom->documentElement;
// validate version
$this->version = $this->root->getAttribute("version");
if (empty($this->version)) {
throw new \Exception("ProcessMaker Project version is missing on file source.");
}
// read metadata section
$metadata = $this->root->getElementsByTagName("metadata");
if ($metadata->length != 1) {
throw new \Exception("Invalid Document format, metadata section is missing or has multiple definition.");
}
$metadata = $metadata->item(0);
// load project definition
/** @var \DOMElement[]|\DomNodeList $definitions */
$definitions = $this->root->getElementsByTagName("definition");
if ($definitions->length == 0) {
throw new \Exception("Definition section is missing.");
} elseif ($definitions->length < 2) {
throw new \Exception("Definition section is incomplete.");
}
$tables = array();
foreach ($definitions as $definition) {
$defClass = strtoupper($definition->getAttribute("class"));
$tables[$defClass] = array();
// getting tables def
// first we need to know if the project already exists
/** @var \DOMElement[] $tablesNodeList */
$tablesNodeList = $definition->getElementsByTagName("table");
foreach ($tablesNodeList as $tableNode) {
$tableName = $tableNode->getAttribute("name"); //strtoupper($tableNode->getAttribute("name"));
$tables[$defClass][$tableName] = array();
/** @var \DOMElement[] $recordsNodeList */
$recordsNodeList = $tableNode->getElementsByTagName("record");
foreach ($recordsNodeList as $recordsNode) {
if (! $recordsNode->hasChildNodes()) {
continue;
}
$columns = array();
foreach ($recordsNode->childNodes as $columnNode) {
if ($columnNode->nodeName == "#text") continue;
//$columns[strtoupper($columnNode->nodeName)] = self::getNodeText($columnNode);;
$columns[$columnNode->nodeName] = self::getNodeText($columnNode);;
}
$tables[$defClass][$tableName][] = $columns;
}
}
}
$wfFilesNodeList = $this->root->getElementsByTagName("workflow-files");
$wfFiles = array();
if ($wfFilesNodeList->length > 0) {
$filesNodeList = $wfFilesNodeList->item(0)->getElementsByTagName("file");
foreach ($filesNodeList as $fileNode) {
$target = $fileNode->getAttribute("target");
if (! isset($wfFiles[$target])) {
$wfFiles[$target] = array();
}
$fileContent = self::getNodeText($fileNode->getElementsByTagName("file_content")->item(0));
$fileContent = base64_decode($fileContent);
$wfFiles[$target][] = array(
"file_name" => self::getNodeText($fileNode->getElementsByTagName("file_name")->item(0)),
"file_path" => self::getNodeText($fileNode->getElementsByTagName("file_path")->item(0)),
"file_content" => $fileContent
);
}
}
//print_r($tables);
//print_r($wfFiles);
return $tables;
}
public function import($data = array())
{
$tables = $this->load();
// Build BPMN project struct
$project = $tables["BPMN"]["PROJECT"][0];
$diagram = $tables["BPMN"]["DIAGRAM"][0];
$diagram["activities"] = $tables["BPMN"]["ACTIVITY"];
$diagram["artifacts"] = array();
$diagram["events"] = $tables["BPMN"]["EVENT"];
$diagram["flows"] = $tables["BPMN"]["FLOW"];
$diagram["gateways"] = $tables["BPMN"]["GATEWAY"];
$diagram["lanes"] = array();
$diagram["laneset"] = array();
$project["diagrams"] = array($diagram);
$project["prj_author"] = isset($data["usr_uid"])? $data["usr_uid"]: "00000000000000000000000000000001";
$project["process"] = $tables["BPMN"]["PROCESS"][0];
$result = Adapter\BpmnWorkflow::createFromStruct($project);
return $result;
}
private static function getNodeText($node)
{
if ($node->nodeType == XML_ELEMENT_NODE) {
return $node->textContent;
} else if ($node->nodeType == XML_TEXT_NODE || $node->nodeType == XML_CDATA_SECTION_NODE) {
return (string) simplexml_import_dom($node->parentNode);
}
}
}

View File

@@ -2,7 +2,7 @@
namespace ProcessMaker\Project\Adapter;
use ProcessMaker\Project;
use ProcessMaker\Util\Hash;
use ProcessMaker\Util;
/**
* Class BpmnWorkflow
@@ -69,7 +69,9 @@ class BpmnWorkflow extends Project\Bpmn
} catch (\Exception $e) {
$prjUid = $this->getUid();
$this->remove();
//$this->remove();
$bpmnProject = Project\Bpmn::load($prjUid);
$bpmnProject->remove();
throw new \RuntimeException(sprintf(
"Can't create Bpmn Project with prj_uid: %s, workflow creation fails." . PHP_EOL . $e->getMessage()
@@ -134,6 +136,13 @@ class BpmnWorkflow extends Project\Bpmn
if (array_key_exists("ACT_NAME", $data)) {
$taskData["TAS_POSY"] = $data["BOU_Y"];
}
if (array_key_exists("ACT_TYPE", $data)) {
if ($data["ACT_TYPE"] == "SUB_PROCESS") {
$taskData["TAS_TYPE"] = "SUBPROCESS";
} else {
$taskData["TAS_TYPE"] = "NORMAL";
}
}
$this->wp->addTask($taskData);
@@ -163,6 +172,7 @@ class BpmnWorkflow extends Project\Bpmn
{
parent::removeActivity($actUid);
$this->wp->removeTask($actUid);
}
public function removeGateway($gatUid)
@@ -393,4 +403,308 @@ class BpmnWorkflow extends Project\Bpmn
$this->wp->remove();
}
}
public static function createFromStruct($projectData)
{
$bwp = new self;
$result = array();
// if (array_key_exists("prj_uid", $projectData)) {
// $result[0]["old_uid"] = $projectData["prj_uid"];
// } else {
// $result[0]["old_uid"] = "";
// }
//$projectData["prj_uid"] = Util\Common::generateUID();
$result[0]["new_uid"] = $projectData["prj_uid"];
$result[0]["old_uid"] = "";
$result[0]["object"] = "project";
$bwp->create(array(
"PRJ_UID" => $projectData["prj_uid"],
"PRJ_AUTHOR" => $projectData["prj_author"]
));
$bwp->addDiagram(array_change_key_case($projectData["diagrams"][0], CASE_UPPER));
$bwp->addProcess(array_change_key_case($projectData["process"], CASE_UPPER));
$result = array_merge($result, self::updateFromStruct($bwp->prjUid, $projectData));
return $result;
}
/**
* Compose and return a Project struct
*
* Example struct return:
* array(
* "prj_uid" => "25111170353317e324d6e23073851309",
* "prj_name" => "example project",
* "prj_description" => "project desc.",
* ...
* "diagrams" => array(
* array(
* "dia_uid" => "94208559153317e325f1c24068030751",
* "dia_name" => "Example Diagram",
* ...
* "activities" => array(...),
* "events" => array(...),
* "gateways" => array(...),
* "flows" => array(...),
* "artifacts" => array(...),
* "laneset" => array(...),
* "lanes" => array(...)
* )
* )
* )
*
* @param $prjUid
* @return array
*/
public static function getStruct($prjUid)
{
$bwp = BpmnWorkflow::load($prjUid);
$project = array_change_key_case($bwp->getProject(), CASE_LOWER);
$diagram = $bwp->getDiagram();
$process = $bwp->getProcess();
$diagram["pro_uid"] = $process["PRO_UID"];
$configList = array("changeCaseTo" => CASE_LOWER);
if (! is_null($diagram)) {
$diagram = array_change_key_case($diagram, CASE_LOWER);
$diagram["activities"] = $bwp->getActivities($configList);
$diagram["events"] = $bwp->getEvents($configList);
$diagram["gateways"] = $bwp->getGateways($configList);
$diagram["flows"] = $bwp->getFlows($configList);
$diagram["artifacts"] = $bwp->getArtifacts($configList);
$diagram["laneset"] = $bwp->getLanesets($configList);
$diagram["lanes"] = $bwp->getLanes($configList);
$project["diagrams"][] = $diagram;
}
return $project;
}
/**
* Update project from a struct defined.
*
* This function make add, update or delete of elements of a project
* Actions is based on a diff from project save in Db and the given structure as param, by the following criteria.
*
* 1. Elements that are on the struct, but they are not in the Db will be created on Db
* 2. Elements that are on the struct and they are found in db, will be compared, if they have been modified then will be updated on Db
* 3. Elements found in Db but they are not present on the struct will be considered deleted, so they will be deleted from Db.
*
* Example Struct:
* array(
* "prj_uid" => "25111170353317e324d6e23073851309",
* "prj_name" => "example project",
* "prj_description" => "project desc.",
* ...
* "diagrams" => array(
* array(
* "dia_uid" => "94208559153317e325f1c24068030751",
* "dia_name" => "Example Diagram",
* ...
* "activities" => array(...),
* "events" => array(...),
* "gateways" => array(...),
* "flows" => array(...),
* "artifacts" => array(...),
* "laneset" => array(...),
* "lanes" => array(...)
* )
* )
* )
*
* Notes:
* 1. All elements keys are in lowercase
* 2. the "diagrams" element is an array of arrays
*
* @param $prjUid
* @param $projectData
* @return array
*/
public static function updateFromStruct($prjUid, $projectData)
{
$diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array();
$result = array();
$bwp = BpmnWorkflow::load($prjUid);
//var_dump($bwp->getUid()); die;
/*
* Diagram's Activities Handling
*/
$whiteList = array();
foreach ($diagram["activities"] as $i => $activityData) {
$activityData = array_change_key_case($activityData, CASE_UPPER);
unset($activityData["_EXTENDED"], $activityData["BOU_ELEMENT_ID"]);
$activityData = Util\ArrayUtil::boolToIntValues($activityData);
$activity = $bwp->getActivity($activityData["ACT_UID"]);
if (is_null($activity)) {
$oldActUid = $activityData["ACT_UID"];
$activityData["ACT_UID"] = Util\Common::generateUID();
$bwp->addActivity($activityData);
$result[] = array("object" => "activity", "new_uid" => $activityData["ACT_UID"], "old_uid" => $oldActUid);
} elseif (! $bwp->isEquals($activity, $activityData)) {
$bwp->updateActivity($activityData["ACT_UID"], $activityData);
} else {
Util\Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required");
}
$diagram["activities"][$i] = $activityData;
$whiteList[] = $activityData["ACT_UID"];
}
$activities = $bwp->getActivities();
// looking for removed elements
foreach ($activities as $activityData) {
if (! in_array($activityData["ACT_UID"], $whiteList)) {
$bwp->removeActivity($activityData["ACT_UID"]);
}
}
/*
* Diagram's Gateways Handling
*/
$whiteList = array();
//print_r($diagram);
foreach ($diagram["gateways"] as $i => $gatewayData) {
$gatewayData = array_change_key_case($gatewayData, CASE_UPPER);
unset($gatewayData["_EXTENDED"]);
$gateway = $bwp->getGateway($gatewayData["GAT_UID"]);
if (is_null($gateway)) {
$oldActUid = $gatewayData["GAT_UID"];
$gatewayData["GAT_UID"] = Util\Common::generateUID();
$bwp->addGateway($gatewayData);
$result[] = array("object" => "gateway", "new_uid" => $gatewayData["GAT_UID"], "old_uid" => $oldActUid);
} elseif (! $bwp->isEquals($gateway, $gatewayData)) {
$bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData);
} else {
Util\Logger::log("Update Gateway ({$gatewayData["GAT_UID"]}) Skipped - No changes required");
}
$diagram["gateways"][$i] = $gatewayData;
$whiteList[] = $gatewayData["GAT_UID"];
}
$gateways = $bwp->getGateways();
// looking for removed elements
foreach ($gateways as $gatewayData) {
if (! in_array($gatewayData["GAT_UID"], $whiteList)) {
$bwp->removeGateway($gatewayData["GAT_UID"]);
}
}
/*
* Diagram's Events Handling
*/
$whiteList = array();
foreach ($diagram["events"] as $i => $eventData) {
$eventData = array_change_key_case($eventData, CASE_UPPER);
unset($eventData["_EXTENDED"]);
if (array_key_exists("EVN_CANCEL_ACTIVITY", $eventData)) {
$eventData["EVN_CANCEL_ACTIVITY"] = $eventData["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
}
if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $eventData)) {
$eventData["EVN_WAIT_FOR_COMPLETION"] = $eventData["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
}
$event = $bwp->getEvent($eventData["EVN_UID"]);
if (is_null($event)) {
$oldActUid = $eventData["EVN_UID"];
$eventData["EVN_UID"] = Util\Common::generateUID();
$bwp->addEvent($eventData);
$result[] = array("object" => "event", "new_uid" => $eventData["EVN_UID"], "old_uid" => $oldActUid);
} elseif (! $bwp->isEquals($event, $eventData)) {
$bwp->updateEvent($eventData["EVN_UID"], $eventData);
} else {
Util\Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required");
}
$diagram["events"][$i] = $eventData;
$whiteList[] = $eventData["EVN_UID"];
}
$events = $bwp->getEvents();
// looking for removed elements
foreach ($events as $eventData) {
if (! in_array($eventData["EVN_UID"], $whiteList)) {
// If it is not in the white list so, then remove them
$bwp->removeEvent($eventData["EVN_UID"]);
}
}
/*
* Diagram's Flows Handling
*/
$whiteList = array();
foreach ($diagram["flows"] as $i => $flowData) {
$flowData = array_change_key_case($flowData, CASE_UPPER);
// if it is a new flow record
if (! \BpmnFlow::exists($flowData["FLO_UID"])) {
$oldFloUid = $flowData["FLO_UID"];
$flowData["FLO_UID"] = Util\Common::generateUID();
$mappedUid = self::mapUid($flowData["FLO_ELEMENT_ORIGIN"], $result);
if ($mappedUid !== false) {
$flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid;
}
$mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result);
if ($mappedUid !== false) {
$flowData["FLO_ELEMENT_DEST"] = $mappedUid;
}
$result[] = array("object" => "flow", "new_uid" => $flowData["FLO_UID"], "old_uid" => $oldFloUid);
}
$diagram["flows"][$i] = $flowData;
$whiteList[] = $flowData["FLO_UID"];
}
foreach ($diagram["flows"] as $flowData) {
$flow = $bwp->getFlow($flowData["FLO_UID"]);
if (is_null($flow)) {
$bwp->addFlow($flowData, $diagram["flows"]);
} elseif (! $bwp->isEquals($flow, $flowData)) {
$bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]);
} else {
Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required");
}
}
$flows = $bwp->getFlows();
// looking for removed elements
foreach ($flows as $flowData) {
if (! in_array($flowData["FLO_UID"], $whiteList)) {
$bwp->removeFlow($flowData["FLO_UID"]);
}
}
$bwp->mapBpmnFlowsToWorkflowRoutes();
return $result;
}
protected static function mapUid($oldUid, $list)
{
foreach ($list as $item) {
if ($item["old_uid"] == $oldUid) {
return $item["new_uid"];
}
}
return false;
}
}

View File

@@ -2,7 +2,7 @@
namespace ProcessMaker\Project\Adapter;
use ProcessMaker\Project;
use ProcessMaker\Util\Hash;
use ProcessMaker\Util\Common;
/**
* Class WorkflowBpmn

View File

@@ -27,7 +27,7 @@ use \BpmnArtifactPeer as ArtifactPeer;
use \BasePeer;
use ProcessMaker\Util\Hash;
use ProcessMaker\Util\Common;
use ProcessMaker\Exception;
/**
@@ -99,7 +99,7 @@ class Bpmn extends Handler
public function create($data)
{
// setting defaults
$data['PRJ_UID'] = array_key_exists('PRJ_UID', $data) ? $data['PRJ_UID'] : Hash::generateUID();
$data['PRJ_UID'] = array_key_exists('PRJ_UID', $data) ? $data['PRJ_UID'] : Common::generateUID();
self::log("Create Project with data: ", $data);
$this->project = new Project();
@@ -175,6 +175,11 @@ class Bpmn extends Handler
return $this->prjUid;
}
/**
* @param string $retType
* @return array|Project
* @throws \RuntimeException
*/
public function getProject($retType = "array")
{
if (empty($this->project)) {
@@ -195,7 +200,7 @@ class Bpmn extends Handler
}
// setting defaults
$data['DIA_UID'] = array_key_exists('DIA_UID', $data) ? $data['DIA_UID'] : Hash::generateUID();
$data['DIA_UID'] = array_key_exists('DIA_UID', $data) ? $data['DIA_UID'] : Common::generateUID();
$data['DIA_NAME'] = array_key_exists('DIA_NAME', $data) ? $data['DIA_NAME'] : $this->project->getPrjName();
$this->diagram = new Diagram();
@@ -225,7 +230,7 @@ class Bpmn extends Handler
}
// setting defaults
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID();;
$data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::generateUID();;
$data['PRO_NAME'] = array_key_exists('PRO_NAME', $data) ? $data['PRO_NAME'] : $this->diagram->getDiaName();
$this->process = new Process();
@@ -256,7 +261,7 @@ class Bpmn extends Handler
}
// setting defaults
$data['ACT_UID'] = array_key_exists('ACT_UID', $data) ? $data['ACT_UID'] : Hash::generateUID();;
$data['ACT_UID'] = array_key_exists('ACT_UID', $data) ? $data['ACT_UID'] : Common::generateUID();;
try {
self::log("Add Activity with data: ", $data);
@@ -342,7 +347,7 @@ class Bpmn extends Handler
public function addEvent($data)
{
// setting defaults
$data['EVN_UID'] = array_key_exists('EVN_UID', $data) ? $data['EVN_UID'] : Hash::generateUID();
$data['EVN_UID'] = array_key_exists('EVN_UID', $data) ? $data['EVN_UID'] : Common::generateUID();
try {
self::log("Add Event with data: ", $data);
@@ -432,7 +437,7 @@ class Bpmn extends Handler
public function addGateway($data)
{
// setting defaults
$data['GAT_UID'] = array_key_exists('GAT_UID', $data) ? $data['GAT_UID'] : Hash::generateUID();
$data['GAT_UID'] = array_key_exists('GAT_UID', $data) ? $data['GAT_UID'] : Common::generateUID();
try {
self::log("Add Gateway with data: ", $data);
@@ -517,7 +522,7 @@ class Bpmn extends Handler
self::log("Add Flow with data: ", $data);
// setting defaults
$data['FLO_UID'] = array_key_exists('FLO_UID', $data) ? $data['FLO_UID'] : Hash::generateUID();
$data['FLO_UID'] = array_key_exists('FLO_UID', $data) ? $data['FLO_UID'] : Common::generateUID();
if (array_key_exists('FLO_STATE', $data)) {
$data['FLO_STATE'] = is_array($data['FLO_STATE']) ? json_encode($data['FLO_STATE']) : $data['FLO_STATE'];
}

View File

@@ -10,8 +10,9 @@ use \Task;
use \Route;
use \RoutePeer;
use ProcessMaker\Util\Hash;
use ProcessMaker\Util\Common;
use ProcessMaker\Exception;
use ProcessMaker\Util;
/**
* Class Workflow
@@ -55,7 +56,7 @@ 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['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Common::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'] : "";
@@ -165,7 +166,7 @@ class Workflow extends Handler
public function addTask($taskData)
{
// Setting defaults
$taskData['TAS_UID'] = array_key_exists('TAS_UID', $taskData) ? $taskData['TAS_UID'] : Hash::generateUID();
$taskData['TAS_UID'] = array_key_exists('TAS_UID', $taskData) ? $taskData['TAS_UID'] : Common::generateUID();
$taskData['PRO_UID'] = $this->proUid;
try {
@@ -173,6 +174,12 @@ class Workflow extends Handler
$task = new Task();
$tasUid = $task->create($taskData, false);
self::log("Add Task Success!");
// SubProcess Handling
if ($task->getTasType() == "SUBPROCESS") {
$this->addSubProcess($this->proUid, $tasUid);
}
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
throw $e;
@@ -201,9 +208,17 @@ class Workflow extends Handler
{
try {
self::log("Remove Task: $tasUid");
$task = \TaskPeer::retrieveByPK($tasUid);
$tasType = $task->getTasType();
$task = new Tasks();
$task->deleteTask($tasUid);
self::log("Remove Task Success!");
if ($tasType == "SUBPROCESS") {
$this->removeSupProcess($this->proUid, $tasUid);
}
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
throw $e;
@@ -237,6 +252,53 @@ class Workflow extends Handler
return $tasks->getAllTasks($this->proUid);
}
public function addSubProcess($proUid = '', $tasUid)//$iX = 0, $iY = 0)
{
try {
$subProcess = new \SubProcess();
$data = array(
'SP_UID' => Util\Common::generateUID(),
'PRO_UID' => 0,
'TAS_UID' => 0,
'PRO_PARENT' => $proUid,
'TAS_PARENT' => $tasUid,
'SP_TYPE' => 'SIMPLE',
'SP_SYNCHRONOUS' => 0,
'SP_SYNCHRONOUS_TYPE' => 'ALL',
'SP_SYNCHRONOUS_WAIT' => 0,
'SP_VARIABLES_OUT' => '',
'SP_VARIABLES_IN' => '',
'SP_GRID_IN' => ''
);
self::log("Adding SubProcess with data: ", $data);
$spUid = $subProcess->create($data);
self::log("Adding SubProcess success!, created sp_uid: ", $spUid);
return $spUid;
} catch (\Exception $oError) {
throw ($oError);
}
}
public function removeSupProcess($proUid, $tasUid)
{
try {
$subProcess = \SubProcess::findByParents($proUid, $tasUid);
self::log("Remove SupProcess: ".$subProcess->getSpUid());
$subProcess->delete();
self::log("Remove SupProcess Success!");
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
throw $e;
}
}
public function updateSubProcess()
{
}
/**
* @param string $tasUid
* @param bool $value

View File

@@ -3,4 +3,65 @@ namespace ProcessMaker\Util;
class Common extends \Maveriks\Util\Common
{
/**
* Generate random number
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
* @access public
* @return string
*/
public static function generateUID()
{
do {
$sUID = str_replace('.', '0', uniqid(rand(0, 999999999), true));
} while (strlen( $sUID ) != 32);
return $sUID;
}
/**
* Generate a numeric or alphanumeric code
*
* @author Julio Cesar Laura Avendaño <juliocesar@colosa.com>
* @access public
* @param int $iDigits
* @param string $sType
* @return string
*/
public function generateCode($iDigits = 4, $sType = 'NUMERIC')
{
if (($iDigits < 4) || ($iDigits > 50)) {
$iDigits = 4;
}
if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) {
$sType = 'NUMERIC';
}
$aValidCharacters = array(
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
);
switch ($sType) {
case 'NUMERIC':
$iMin = 0;
$iMax = 9;
break;
case 'ALPHA':
$iMin = 10;
$iMax = 35;
break;
case 'ALPHANUMERIC':
$iMin = 0;
$iMax = 35;
break;
}
$sCode = '';
for ($i = 0; $i < $iDigits; $i ++) {
$sCode .= $aValidCharacters[rand($iMin, $iMax)];
}
return $sCode;
}
}

View File

@@ -1,68 +0,0 @@
<?php
namespace ProcessMaker\Util;
class Hash
{
/**
* Generate random number
*
* @author Fernando Ontiveros Lira <fernando@colosa.com>
* @access public
* @return string
*/
public static function generateUID()
{
do {
$sUID = str_replace('.', '0', uniqid(rand(0, 999999999), true));
} while (strlen( $sUID ) != 32);
return $sUID;
}
/**
* Generate a numeric or alphanumeric code
*
* @author Julio Cesar Laura Avendaño <juliocesar@colosa.com>
* @access public
* @param int $iDigits
* @param string $sType
* @return string
*/
public function generateCode($iDigits = 4, $sType = 'NUMERIC')
{
if (($iDigits < 4) || ($iDigits > 50)) {
$iDigits = 4;
}
if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) {
$sType = 'NUMERIC';
}
$aValidCharacters = array(
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
);
switch ($sType) {
case 'NUMERIC':
$iMin = 0;
$iMax = 9;
break;
case 'ALPHA':
$iMin = 10;
$iMax = 35;
break;
case 'ALPHANUMERIC':
$iMin = 0;
$iMax = 35;
break;
}
$sCode = '';
for ($i = 0; $i < $iDigits; $i ++) {
$sCode .= $aValidCharacters[rand($iMin, $iMax)];
}
return $sCode;
}
}

View File

@@ -721,7 +721,7 @@ class Cases extends Api
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url PUT /:cas_uid/cancel-case
* @url PUT /:cas_uid/cancel
*/
public function doPutCancelCase($cas_uid)
{
@@ -743,7 +743,7 @@ class Cases extends Api
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url PUT /:cas_uid/pause-case
* @url PUT /:cas_uid/pause
*/
public function doPutPauseCase($cas_uid, $unpaused_date = null)
{
@@ -768,7 +768,7 @@ class Cases extends Api
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url PUT /:cas_uid/unpause-case
* @url PUT /:cas_uid/unpause
*/
public function doPutUnpauseCase($cas_uid)
{
@@ -822,5 +822,93 @@ class Cases extends Api
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get Case Variables
*
* @param string $app_uid {@min 1}{@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url GET /:app_uid/variables
*/
public function doGetCaseVariables($app_uid)
{
try {
$cases = new \BusinessModel\Cases();
$response = $cases->getCaseVariables($app_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Put Case Variables
*
* @param string $app_uid {@min 1}{@max 32}
* @param array $request_data
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url PUT /:app_uid/variable
*/
public function doPutCaseVariables($app_uid, $request_data)
{
try {
$cases = new \BusinessModel\Cases();
$cases->setCaseVariables($app_uid, $request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get Case Notes
*
* @param string $app_uid {@min 1}{@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url GET /:app_uid/notes
*/
public function doGetCaseNotes($app_uid)
{
try {
$usr_uid = $this->getUserId();
$cases = new \BusinessModel\Cases();
$response = $cases->getCaseNotes($app_uid, $usr_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Put Case Variables
*
* @param string $app_uid {@min 1}{@max 32}
* @param string $note_content {@min 1}{@max 500}
* @param int $send_mail {@choice 1,0}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @url POST /:app_uid/note
*/
public function doPostCaseNote($app_uid, $note_content, $send_mail = 0)
{
try {
$usr_uid = $this->getUserId();
$cases = new \BusinessModel\Cases();
$send_mail = ($send_mail == 0) ? false : true;
$cases->saveCaseNote($app_uid, $usr_uid, $note_content, $send_mail);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}

View File

@@ -12,16 +12,16 @@ use \Luracast\Restler\RestException;
class InputDocument extends Api
{
/**
* @url GET /:cas_uid/input-documents
* @url GET /:app_uid/input-documents
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
*/
public function doGetInputDocuments($cas_uid)
public function doGetInputDocuments($app_uid)
{
try {
$userUid = $this->getUserId();
$inputDocument = new \BusinessModel\Cases\InputDocument();
$response = $inputDocument->getCasesInputDocuments($cas_uid, $userUid);
$response = $inputDocument->getCasesInputDocuments($app_uid, $userUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -29,17 +29,17 @@ class InputDocument extends Api
}
/**
* @url GET /:cas_uid/input-document/:inp_doc_uid
* @url GET /:app_uid/input-document/:inp_doc_uid
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
* @param string $inp_doc_uid {@min 32}{@max 32}
*/
public function doGetInputDocument($cas_uid, $inp_doc_uid)
public function doGetInputDocument($app_uid, $inp_doc_uid)
{
try {
$userUid = $this->getUserId();
$inputDocument = new \BusinessModel\Cases\InputDocument();
$response = $inputDocument->getCasesInputDocument($cas_uid, $userUid, $inp_doc_uid);
$response = $inputDocument->getCasesInputDocument($app_uid, $userUid, $inp_doc_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -47,12 +47,12 @@ class InputDocument extends Api
}
/**
* @url DELETE /:cas_uid/input-document/:inp_doc_uid
* @url DELETE /:app_uid/input-document/:inp_doc_uid
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
* @param string $inp_doc_uid {@min 32}{@max 32}
*/
public function doDeleteInputDocument($cas_uid, $inp_doc_uid)
public function doDeleteInputDocument($app_uid, $inp_doc_uid)
{
try {
$inputDocument = new \BusinessModel\Cases\InputDocument();
@@ -62,22 +62,22 @@ class InputDocument extends Api
}
}
/**
* @url POST /:cas_uid/input-document
* @url POST /:app_uid/input-document
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $app_uid { @min 32}{@max 32}
* @param string $tas_uid {@min 32}{@max 32}
* @param string $app_doc_comment
* @param string $inp_doc_uid {@min 32}{@max 32}
*/
public function doPostInputDocument($cas_uid, $inp_doc_uid)
public function doPostInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid)
{
try {
$userUid = $this->getUserId();
$inputDocument = new \BusinessModel\Cases\InputDocument();
$response = $inputDocument->addCasesInputDocument($cas_uid, $inp_doc_uid, $userUid);
$response = $inputDocument->addCasesInputDocument($app_uid, $tas_uid, $app_doc_comment, $inp_doc_uid, $userUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}

View File

@@ -12,16 +12,16 @@ use \Luracast\Restler\RestException;
class OutputDocument extends Api
{
/**
* @url GET /:cas_uid/output-documents
* @url GET /:app_uid/output-documents
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
*/
public function doGetOutputDocuments($cas_uid)
public function doGetOutputDocuments($app_uid)
{
try {
$userUid = $this->getUserId();
$outputDocument = new \BusinessModel\Cases\OutputDocument();
$response = $outputDocument->getCasesOutputDocuments($cas_uid, $userUid);
$response = $outputDocument->getCasesOutputDocuments($app_uid, $userUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -29,17 +29,17 @@ class OutputDocument extends Api
}
/**
* @url GET /:cas_uid/output-document/:out_doc_uid
* @url GET /:app_uid/output-document/:app_doc_uid
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $out_doc_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
* @param string $app_doc_uid {@min 32}{@max 32}
*/
public function doGetOutputDocument($cas_uid, $out_doc_uid)
public function doGetOutputDocument($app_uid, $app_doc_uid)
{
try {
$userUid = $this->getUserId();
$outputDocument = new \BusinessModel\Cases\OutputDocument();
$response = $outputDocument->getCasesOutputDocument($cas_uid, $userUid, $out_doc_uid);
$response = $outputDocument->getCasesOutputDocument($app_uid, $userUid, $app_doc_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -47,32 +47,32 @@ class OutputDocument extends Api
}
/**
* @url DELETE /:cas_uid/output-document/:out_doc_uid
* @url DELETE /:app_uid/output-document/:app_doc_uid
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $out_doc_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
* @param string $app_doc_uid {@min 32}{@max 32}
*/
public function doDeleteOutputDocument($cas_uid, $out_doc_uid)
public function doDeleteOutputDocument($app_uid, $app_doc_uid)
{
try {
$outputDocument = new \BusinessModel\Cases\OutputDocument();
$outputDocument->removeOutputDocument($out_doc_uid);
$outputDocument->removeOutputDocument($app_doc_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url POST /:cas_uid/output-document
* @url POST /:app_uid/output-document
*
* @param string $cas_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
* @param string $out_doc_uid {@min 32}{@max 32}
*/
public function doPostOutputDocument($cas_uid, $out_doc_uid)
public function doPostOutputDocument($app_uid, $out_doc_uid)
{
try {
$userUid = $this->getUserId();
$outputDocument = new \BusinessModel\Cases\OutputDocument();
$response = $outputDocument->addCasesOutputDocument($cas_uid, $out_doc_uid, $userUid);
$response = $outputDocument->addCasesOutputDocument($app_uid, $out_doc_uid, $userUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));

View File

@@ -3,7 +3,6 @@ namespace Services\Api\ProcessMaker;
use Luracast\Restler\RestException;
use ProcessMaker\Services\Api;
use ProcessMaker\Adapter\Bpmn\Model as BpmnModel;
use \ProcessMaker\Project\Adapter;
use \ProcessMaker\Util;
@@ -35,29 +34,7 @@ class Project extends Api
public function get($prjUid)
{
try {
$bwp = Adapter\BpmnWorkflow::load($prjUid);
$project = array_change_key_case($bwp->getProject(), CASE_LOWER);
$diagram = $bwp->getDiagram();
$process = $bwp->getProcess();
$diagram["pro_uid"] = $process["PRO_UID"];
$configList = array("changeCaseTo" => CASE_LOWER);
if (! is_null($diagram)) {
$diagram = array_change_key_case($diagram, CASE_LOWER);
$diagram["activities"] = $bwp->getActivities($configList);
$diagram["events"] = $bwp->getEvents($configList);
$diagram["gateways"] = $bwp->getGateways($configList);
$diagram["flows"] = $bwp->getFlows($configList);
$diagram["artifacts"] = $bwp->getArtifacts($configList);
$diagram["laneset"] = $bwp->getLanesets($configList);
$diagram["lanes"] = $bwp->getLanes($configList);
$project["diagrams"][] = $diagram;
}
return $project;
return Adapter\BpmnWorkflow::getStruct($prjUid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
@@ -69,28 +46,7 @@ class Project extends Api
public function post($request_data)
{
try {
// NEED REFACTOR
// $config = array();
// $config['project'] = array('replace_uids' => true);
//
// $bpmnModel = new BpmnModel();
// $result = $bpmnModel->createProject($request_data, $config['project']['replace_uids']);
//
// if (array_key_exists('prj_uid', $result)) {
// $prjUid = $result['prj_uid'];
// } else {
// $prjUid = $result[0]['new_uid'];
// }
//
// $wfProcess = Workflow::loadFromBpmnProject($prjUid);
//
// $process = new \BusinessModel\Process();
// $userUid = $this->getUserId();
// $data = array('process' => $wfProcess);
//
// $process->createProcess($userUid, $data);
// return $result;
//TODO
} catch (\Exception $e) {
// TODO in case that $process->createProcess($userUid, $data); fails maybe the BPMN project was created successfully
// so, we need remove it or change the creation order.
@@ -102,173 +58,7 @@ class Project extends Api
public function put($prjUid, $request_data)
{
try {
$projectData = $request_data;
$diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array();
$result = array();
$bwp = Adapter\BpmnWorkflow::load($prjUid);
/*
* Diagram's Activities Handling
*/
$whiteList = array();
foreach ($diagram["activities"] as $i => $activityData) {
$activityData = array_change_key_case($activityData, CASE_UPPER);
unset($activityData["_EXTENDED"], $activityData["BOU_ELEMENT_ID"]);
$activityData = Util\ArrayUtil::boolToIntValues($activityData);
$activity = $bwp->getActivity($activityData["ACT_UID"]);
if (is_null($activity)) {
$oldActUid = $activityData["ACT_UID"];
$activityData["ACT_UID"] = Util\Hash::generateUID();
$bwp->addActivity($activityData);
$result[] = array("object" => "activity", "new_uid" => $activityData["ACT_UID"], "old_uid" => $oldActUid);
} elseif (! $bwp->isEquals($activity, $activityData)) {
$bwp->updateActivity($activityData["ACT_UID"], $activityData);
} else {
Util\Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required");
}
$diagram["activities"][$i] = $activityData;
$whiteList[] = $activityData["ACT_UID"];
}
$activities = $bwp->getActivities();
// looking for removed elements
foreach ($activities as $activityData) {
if (! in_array($activityData["ACT_UID"], $whiteList)) {
$bwp->removeActivity($activityData["ACT_UID"]);
}
}
/*
* Diagram's Gateways Handling
*/
$whiteList = array();
foreach ($diagram["gateways"] as $i => $gatewayData) {
$gatewayData = array_change_key_case($gatewayData, CASE_UPPER);
unset($gatewayData["_EXTENDED"]);
$gateway = $bwp->getGateway($gatewayData["GAT_UID"]);
if (is_null($gateway)) {
$oldActUid = $gatewayData["GAT_UID"];
$gatewayData["GAT_UID"] = Util\Hash::generateUID();
$bwp->addGateway($gatewayData);
$result[] = array("object" => "gateway", "new_uid" => $gatewayData["GAT_UID"], "old_uid" => $oldActUid);
} elseif (! $bwp->isEquals($gateway, $gatewayData)) {
$bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData);
} else {
Util\Logger::log("Update Gateway ({$gatewayData["GAT_UID"]}) Skipped - No changes required");
}
$diagram["gateways"][$i] = $gatewayData;
$whiteList[] = $gatewayData["GAT_UID"];
}
$gateways = $bwp->getGateways();
// looking for removed elements
foreach ($gateways as $gatewayData) {
if (! in_array($gatewayData["GAT_UID"], $whiteList)) {
$bwp->removeGateway($gatewayData["GAT_UID"]);
}
}
/*
* Diagram's Events Handling
*/
$whiteList = array();
foreach ($diagram["events"] as $i => $eventData) {
$eventData = array_change_key_case($eventData, CASE_UPPER);
unset($eventData["_EXTENDED"]);
if (array_key_exists("EVN_CANCEL_ACTIVITY", $eventData)) {
$eventData["EVN_CANCEL_ACTIVITY"] = $eventData["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
}
if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $eventData)) {
$eventData["EVN_WAIT_FOR_COMPLETION"] = $eventData["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
}
$event = $bwp->getEvent($eventData["EVN_UID"]);
if (is_null($event)) {
$oldActUid = $eventData["EVN_UID"];
$eventData["EVN_UID"] = Util\Hash::generateUID();
$bwp->addEvent($eventData);
$result[] = array("object" => "event", "new_uid" => $eventData["EVN_UID"], "old_uid" => $oldActUid);
} elseif (! $bwp->isEquals($event, $eventData)) {
$bwp->updateEvent($eventData["EVN_UID"], $eventData);
} else {
Util\Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required");
}
$diagram["events"][$i] = $eventData;
$whiteList[] = $eventData["EVN_UID"];
}
$events = $bwp->getEvents();
// looking for removed elements
foreach ($events as $eventData) {
if (! in_array($eventData["EVN_UID"], $whiteList)) {
// If it is not in the white list so, then remove them
$bwp->removeEvent($eventData["EVN_UID"]);
}
}
/*
* Diagram's Flows Handling
*/
$whiteList = array();
foreach ($diagram["flows"] as $i => $flowData) {
$flowData = array_change_key_case($flowData, CASE_UPPER);
// if it is a new flow record
if (! \BpmnFlow::exists($flowData["FLO_UID"])) {
$oldFloUid = $flowData["FLO_UID"];
$flowData["FLO_UID"] = Util\Hash::generateUID();
$mappedUid = self::mapUid($flowData["FLO_ELEMENT_ORIGIN"], $result);
if ($mappedUid !== false) {
$flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid;
}
$mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result);
if ($mappedUid !== false) {
$flowData["FLO_ELEMENT_DEST"] = $mappedUid;
}
$result[] = array("object" => "flow", "new_uid" => $flowData["FLO_UID"], "old_uid" => $oldFloUid);
}
$diagram["flows"][$i] = $flowData;
$whiteList[] = $flowData["FLO_UID"];
}
foreach ($diagram["flows"] as $flowData) {
$flow = $bwp->getFlow($flowData["FLO_UID"]);
if (is_null($flow)) {
$bwp->addFlow($flowData, $diagram["flows"]);
} elseif (! $bwp->isEquals($flow, $flowData)) {
$bwp->updateFlow($flowData["FLO_UID"], $flowData, $diagram["flows"]);
} else {
Util\Logger::log("Update Flow ({$flowData["FLO_UID"]}) Skipped - No changes required");
}
}
$flows = $bwp->getFlows();
// looking for removed elements
foreach ($flows as $flowData) {
if (! in_array($flowData["FLO_UID"], $whiteList)) {
$bwp->removeFlow($flowData["FLO_UID"]);
}
}
$bwp->mapBpmnFlowsToWorkflowRoutes();
return $result;
return Adapter\BpmnWorkflow::updateFromStruct($prjUid, $request_data);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
@@ -277,10 +67,7 @@ class Project extends Api
public function delete($prjUid)
{
try {
$process = new \BusinessModel\Process();
$process->deleteProcess($prjUid);
BpmnModel::deleteProject($prjUid);
// TODO
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
@@ -385,17 +172,6 @@ class Project extends Api
}
}
protected static function mapUid($oldUid, $list)
{
foreach ($list as $item) {
if ($item["old_uid"] == $oldUid) {
return $item["new_uid"];
}
}
return false;
}
/**
* @url GET /:prj_uid/variables
*

View File

@@ -0,0 +1,392 @@
<?php
namespace Tests\BusinessModel;
if (!class_exists("Propel")) {
include_once (__DIR__ . "/../bootstrap.php");
}
/**
* Class Cases Test
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @protected
* @package Tests\BusinessModel
*/
class CasesAction13_17Test extends \PHPUnit_Framework_TestCase
{
protected $oCases;
protected $nowCountTodo = 0;
protected $nowCountDraft = 0;
protected $nowCountPaused = 0;
protected $idCaseToDo = '';
protected $idCaseDraft = '';
/**
* Set class for test
*
* @coversNothing
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function setUp()
{
\G::loadClass('pmFunctions');
$usrUid = '00000000000000000000000000000001';
$proUid = '2317283235320c1a36972b2028131767';
$tasUid = '7983935495320c1a75e1df6068322280';
$idCaseToDo = PMFNewCase($proUid, $usrUid, $tasUid, array());
PMFDerivateCase($idCaseToDo, 1);
$this->idCaseToDo = $idCaseToDo;
$idCaseDraft = PMFNewCase($proUid, $usrUid, $tasUid, array());
$this->idCaseDraft = $idCaseDraft;
$this->oCases = new \BusinessModel\Cases();
$listToDo = $this->oCases->getList(array('userId' => '00000000000000000000000000000001'));
$this->nowCountTodo = $listToDo['total'];
$listDraft = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft'));
$this->nowCountDraft = $listDraft['total'];
$listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused'));
$this->nowCountPaused = $listPaused['total'];
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::putCancelCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutCancelCaseErrorAppUidArray()
{
$this->oCases->putCancelCase(array(), '00000000000000000000000000000001');
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::putCancelCase
* @expectedException Exception
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutCancelCaseErrorAppUidIncorrect()
{
$this->oCases->putCancelCase('IdDoesNotExists', '00000000000000000000000000000001');
}
/**
* Test error for type in second field the function
*
* @covers \BusinessModel\Cases::putCancelCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutCancelCaseErrorUsrUidArray()
{
$this->oCases->putCancelCase($this->idCaseDraft, array());
}
/**
* Test error for type in second field the function
*
* @covers \BusinessModel\Cases::putCancelCase
* @expectedException Exception
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutCancelCaseErrorUsrUidIncorrect()
{
$this->oCases->putCancelCase($this->idCaseDraft, 'IdDoesNotExists');
}
/**
* Test error for type in third field the function
*
* @covers \BusinessModel\Cases::putCancelCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$del_index' it must be a integer.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutCancelCaseErrorDelIndexIncorrect()
{
$this->oCases->putCancelCase($this->idCaseDraft, '00000000000000000000000000000001', 'string');
}
/**
* Test for cancel case
*
* @covers \BusinessModel\Cases::putCancelCase
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutCancelCase()
{
$this->oCases->putCancelCase($this->idCaseDraft, '00000000000000000000000000000001');
$this->oCases = new \BusinessModel\Cases();
$listDraft = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft'));
$this->assertNotEquals($this->nowCountDraft, $listDraft['total']);
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::putPauseCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutPauseCaseErrorAppUidArray()
{
$this->oCases->putPauseCase(array(), '00000000000000000000000000000001');
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::putPauseCase
* @expectedException Exception
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutPauseCaseErrorAppUidIncorrect()
{
$this->oCases->putPauseCase('IdDoesNotExists', '00000000000000000000000000000001');
}
/**
* Test error for type in second field the function
*
* @covers \BusinessModel\Cases::putPauseCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutPauseCaseErrorUsrUidArray()
{
$this->oCases->putPauseCase($this->idCaseDraft, array());
}
/**
* Test error for type in second field the function
*
* @covers \BusinessModel\Cases::putPauseCase
* @expectedException Exception
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutPauseCaseErrorUsrUidIncorrect()
{
$this->oCases->putPauseCase($this->idCaseDraft, 'IdDoesNotExists');
}
/**
* Test error for type in third field the function
*
* @covers \BusinessModel\Cases::putPauseCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$del_index' it must be a integer.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutPauseCaseErrorDelIndexIncorrect()
{
$this->oCases->putPauseCase($this->idCaseDraft, '00000000000000000000000000000001', 'string');
}
/**
* Test error for type in fourth field the function
*
* @covers \BusinessModel\Cases::putPauseCase
* @expectedException Exception
* @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutPauseCaseErrorDateIncorrect()
{
$this->oCases->putPauseCase($this->idCaseDraft, '00000000000000000000000000000001', false, '2014-44-44');
}
/**
* Test for cancel case
*
* @covers \BusinessModel\Cases::putPauseCase
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutPauseCase()
{
$this->oCases->putPauseCase($this->idCaseToDo, '00000000000000000000000000000001');
$this->oCases = new \BusinessModel\Cases();
$listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused'));
$this->assertNotEquals($this->nowCountPaused, $listPaused['total']);
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::putUnpauseCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutUnpauseCaseErrorAppUidArray()
{
$this->oCases->putUnpauseCase(array(), '00000000000000000000000000000001');
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::putUnpauseCase
* @expectedException Exception
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutUnpauseCaseErrorAppUidIncorrect()
{
$this->oCases->putUnpauseCase('IdDoesNotExists', '00000000000000000000000000000001');
}
/**
* Test error for type in second field the function
*
* @covers \BusinessModel\Cases::putUnpauseCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutUnpauseCaseErrorUsrUidArray()
{
$this->oCases->putUnpauseCase($this->idCaseDraft, array());
}
/**
* Test error for type in second field the function
*
* @covers \BusinessModel\Cases::putUnpauseCase
* @expectedException Exception
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutUnpauseCaseErrorUsrUidIncorrect()
{
$this->oCases->putUnpauseCase($this->idCaseDraft, 'IdDoesNotExists');
}
/**
* Test error for type in third field the function
*
* @covers \BusinessModel\Cases::putUnpauseCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$del_index' it must be a integer.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutUnpauseCaseErrorDelIndexIncorrect()
{
$this->oCases->putUnpauseCase($this->idCaseDraft, '00000000000000000000000000000001', 'string');
}
/**
* Test for cancel case
*
* @covers \BusinessModel\Cases::putUnpauseCase
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testPutUnpauseCase()
{
$this->oCases->putUnpauseCase($this->idCaseToDo, '00000000000000000000000000000001');
$this->oCases = new \BusinessModel\Cases();
$listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused'));
$this->assertEquals($this->nowCountPaused, $listPaused['total']);
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::deleteCase
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testDeleteCaseErrorAppUidArray()
{
$this->oCases->deleteCase(array());
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::deleteCase
* @expectedException Exception
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testDeleteCaseErrorAppUidIncorrect()
{
$this->oCases->deleteCase('IdDoesNotExists');
}
/**
* Test for cancel case
*
* @covers \BusinessModel\Cases::deleteCase
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testDeleteCase()
{
$this->oCases->deleteCase($this->idCaseToDo);
$this->oCases = new \BusinessModel\Cases();
$listToDo = $this->oCases->getList(array('userId' => '00000000000000000000000000000001'));
$this->assertNotEquals($this->nowCountTodo, $listToDo['total']);
}
}

View File

@@ -67,14 +67,14 @@ class CasesTest extends \PHPUnit_Framework_TestCase
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The user with userId: 'UidInexistente' does not exist.
* @expectedExceptionMessage The user with userId: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesErrorNotExistsUserIdArray()
{
$this->oCases->getList(array('userId' => 'UidInexistente'));
$this->oCases->getList(array('userId' => 'IdDoesNotExists'));
}
/**
@@ -97,7 +97,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The process with $pro_uid: 'UidInexistente' does not exist.
* @expectedExceptionMessage The process with $pro_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
@@ -106,7 +106,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
{
$this->oCases->getList(array(
'userId' => '00000000000000000000000000000001',
'process' => 'UidInexistente'
'process' => 'IdDoesNotExists'
));
}
@@ -115,7 +115,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The category with $cat_uid: 'UidInexistente' does not exist.
* @expectedExceptionMessage The category with $cat_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
@@ -124,7 +124,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
{
$this->oCases->getList(array(
'userId' => '00000000000000000000000000000001',
'category' => 'UidInexistente'
'category' => 'IdDoesNotExists'
));
}
@@ -133,7 +133,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The user with $usr_uid: 'UidInexistente' does not exist.
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
@@ -142,7 +142,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
{
$this->oCases->getList(array(
'userId' => '00000000000000000000000000000001',
'user' => 'UidInexistente'
'user' => 'IdDoesNotExists'
));
}
@@ -151,7 +151,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The value '2014-44-44' is not valid fot the format 'Y-m-d'.
* @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
@@ -169,7 +169,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The value '2014-44-44' is not valid fot the format 'Y-m-d'.
* @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
@@ -440,7 +440,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
*
* @covers \BusinessModel\Cases::getTaskCase
* @depends testAddCase
* @param array $aResponse, Data for parent department
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/

View File

@@ -0,0 +1,100 @@
<?php
namespace Tests\BusinessModel;
if (!class_exists("Propel")) {
include_once (__DIR__ . "/../bootstrap.php");
}
/**
* Class Documents Cases Test
*
* @copyright Colosa - Bolivia
*
* @protected
* @package Tests\BusinessModel
*/
class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
{
protected $oOutputDocument;
protected $idCase = '';
/**
* Set class for test
*
* @coversNothing
*
* @copyright Colosa - Bolivia
*/
public function setUp()
{
$this->oOutputDocument = new \BusinessModel\Cases\OutputDocument();
}
/**
* Test add OutputDocument
*
* @covers \BusinessModel\Cases\OutputDocument::addCasesOutputDocument
*
* @copyright Colosa - Bolivia
*/
public function testAddCasesOutputDocument()
{
\G::loadClass('pmFunctions');
$usrUid = '00000000000000000000000000000001';
$proUid = '1265557095225ff5c688f46031700471';
$tasUid = '1352844695225ff5fe54de2005407079';
$idCase = PMFNewCase($proUid, $usrUid, $tasUid, array());
$response = $this->oOutputDocument->addCasesOutputDocument($idCase, '10401087752fa8bc6f0cab6048419434', '00000000000000000000000000000001');
$this->assertTrue(is_object($response));
$aResponse = json_decode(json_encode($response), true);
$aResponse = array_merge(array("idCase" => $idCase), $aResponse);
return $aResponse;
}
/**
* Test get OutputDocuments
*
* @covers \BusinessModel\Cases\OutputDocument::getCasesOutputDocuments
* @depends testAddCasesOutputDocument
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocuments(array $aResponse)
{
$response = $this->oOutputDocument->getCasesOutputDocuments($aResponse["idCase"], '00000000000000000000000000000001');
$this->assertTrue(is_array($response));
}
/**
* Test get OutputDocument
*
* @covers \BusinessModel\Cases\OutputDocument::getCasesOutputDocument
* @depends testAddCasesOutputDocument
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocument(array $aResponse)
{
$response = $this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], '00000000000000000000000000000001', $aResponse["app_doc_uid"]);
$this->assertTrue(is_object($response));
}
/**
* Test remove OutputDocument
*
* @covers \BusinessModel\Cases\OutputDocument::removeOutputDocument
* @depends testAddCasesOutputDocument
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testRemoveOutputDocument(array $aResponse)
{
echo $aResponse["app_doc_uid"];
$response = $this->oOutputDocument->removeOutputDocument($aResponse["app_doc_uid"]);
$this->assertTrue(empty($response));
}
}

View File

@@ -559,6 +559,7 @@ ImportPMTableCSV = function(){
[',', 'Comma (,)']]
});
var w = new Ext.Window({
id: 'windowImportUploader',
title : '',
width : 440,
height : 180,
@@ -672,6 +673,7 @@ ExportPMTableCSV = function(){
[',', 'Comma (,)']]
});
var w = new Ext.Window({
id: 'windowExportUploader',
title : '',
width : 320,
height : 140,

View File

@@ -511,6 +511,7 @@ DeletePMTable = function() {
ImportPMTable = function(){
var w = new Ext.Window({
id: 'windowPmTableUploaderImport',
title: '',
width: 420,
height: 160,
@@ -570,6 +571,7 @@ ImportPMTable = function(){
}
else {
win = new Ext.Window({
id: 'windowImportingError',
applyTo:'hello-win',
layout:'fit',
width:500,
@@ -659,6 +661,7 @@ PMTableData = function()
}
win = new Ext.Window({
id: 'windowPmtablesReportTable',
layout: 'fit',
width: 700,
height: 400,

View File

@@ -1086,7 +1086,11 @@ importProcess = function()
if (resp_.ExistProcessInDatabase == "0") {
if (resp_.ExistGroupsInDatabase == "0") {
var sNewProUid = resp_.sNewProUid;
window.location.href = "processes_Map?PRO_UID=" + sNewProUid;
if (resp_.project_type && resp_.project_type == "bpmn") {
window.location.href = "../designer?prj_uid=" + sNewProUid;
} else {
window.location.href = "processes_Map?PRO_UID=" + sNewProUid;
}
}
else {
importProcessGlobal.sNewProUid = resp_.sNewProUid;