HOR-3207
Removed the deletion of WebEntry record when it is disabled. This attribute has no effect. Fixed importation of processes with WebEntry task information.
This commit is contained in:
@@ -44,13 +44,13 @@ class WorkflowTestCase extends TestCase
|
||||
* @param type $filename ProcessMaker file to be imported
|
||||
* @return string PRO_UID
|
||||
*/
|
||||
protected function import($filename)
|
||||
protected function import($filename, $regenerateUids=false)
|
||||
{
|
||||
$importer = new XmlImporter();
|
||||
$importer->setSourceFile($filename);
|
||||
return $importer->import(
|
||||
XmlImporter::IMPORT_OPTION_CREATE_NEW,
|
||||
XmlImporter::GROUP_IMPORT_OPTION_CREATE_NEW, true
|
||||
$regenerateUids ? XmlImporter::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW : XmlImporter::IMPORT_OPTION_CREATE_NEW,
|
||||
XmlImporter::GROUP_IMPORT_OPTION_CREATE_NEW, $regenerateUids
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use ProcessMaker\Importer\XmlImporter;
|
||||
|
||||
/**
|
||||
* WebEntryEventTest test
|
||||
*/
|
||||
@@ -165,6 +167,7 @@ class WebEntryEventTest extends \WorkflowTestCase
|
||||
'WE_LINK_SKIN' => SYS_SKIN,
|
||||
'WE_LINK_LANGUAGE' => SYS_LANG,
|
||||
'WE_LINK_DOMAIN' => $this->domain,
|
||||
'WEE_STATUS' => 'DISABLED',
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -484,6 +487,98 @@ class WebEntryEventTest extends \WorkflowTestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests importing a BPMN with WE2 information.
|
||||
* The import maintain the UIDs.
|
||||
*
|
||||
* @cover ProcessMaker\BusinessModel\WebEntryEvent
|
||||
*/
|
||||
public function testImportProcessWithWE2()
|
||||
{
|
||||
$proUid = $this->import(__DIR__.'/WebEntry2-multi-login.pmx');
|
||||
$this->assertNotEmpty($proUid);
|
||||
$taskCriteria = new \Criteria;
|
||||
$taskCriteria->add(\TaskPeer::PRO_UID, $proUid);
|
||||
$taskCriteria->add(\TaskPeer::TAS_UID, "wee-%", \Criteria::LIKE);
|
||||
$task = \TaskPeer::doSelectOne($taskCriteria);
|
||||
//Check steps
|
||||
$criteria = new \Criteria;
|
||||
$criteria->add(\StepPeer::TAS_UID, $task->getTasUid());
|
||||
$criteria->addAscendingOrderByColumn(\StepPeer::STEP_POSITION);
|
||||
$steps = [];
|
||||
$stepWithTrigger = 1;
|
||||
$uidStepWithTrigger = null;
|
||||
foreach (\StepPeer::doSelect($criteria) as $index => $step) {
|
||||
$steps[]=$step->getStepTypeObj();
|
||||
if ($index == $stepWithTrigger) {
|
||||
$uidStepWithTrigger = $step->getStepUid();
|
||||
}
|
||||
}
|
||||
$this->assertEquals(
|
||||
["DYNAFORM", "DYNAFORM", "INPUT_DOCUMENT", "OUTPUT_DOCUMENT"],
|
||||
$steps
|
||||
);
|
||||
//Check triggers
|
||||
$criteriaTri = new \Criteria;
|
||||
$criteriaTri->add(\StepTriggerPeer::TAS_UID, $task->getTasUid());
|
||||
$criteriaTri->add(\StepTriggerPeer::STEP_UID, $uidStepWithTrigger);
|
||||
$criteriaTri->addAscendingOrderByColumn(\StepTriggerPeer::ST_POSITION);
|
||||
$triggers = [];
|
||||
foreach (\StepTriggerPeer::doSelect($criteriaTri) as $stepTri) {
|
||||
$triggers[]=[$stepTri->getStepUid(), $stepTri->getStType()];
|
||||
}
|
||||
$this->assertEquals(
|
||||
[[$uidStepWithTrigger, "BEFORE"]],
|
||||
$triggers
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests importing a BPMN with WE2 information.
|
||||
* The import regenerates the UIDs.
|
||||
*
|
||||
* @cover ProcessMaker\BusinessModel\WebEntryEvent
|
||||
*/
|
||||
public function testImportProcessWithWE2WithRegenUid()
|
||||
{
|
||||
$proUid = $this->import(__DIR__.'/WebEntry2-multi-login.pmx', true);
|
||||
$this->assertNotEmpty($proUid);
|
||||
$taskCriteria = new \Criteria;
|
||||
$taskCriteria->add(\TaskPeer::PRO_UID, $proUid);
|
||||
$taskCriteria->add(\TaskPeer::TAS_UID, "wee-%", \Criteria::LIKE);
|
||||
$task = \TaskPeer::doSelectOne($taskCriteria);
|
||||
//Check steps
|
||||
$criteria = new \Criteria;
|
||||
$criteria->add(\StepPeer::TAS_UID, $task->getTasUid());
|
||||
$criteria->addAscendingOrderByColumn(\StepPeer::STEP_POSITION);
|
||||
$steps = [];
|
||||
$stepWithTrigger = 1;
|
||||
$uidStepWithTrigger = null;
|
||||
foreach (\StepPeer::doSelect($criteria) as $index => $step) {
|
||||
$steps[]=$step->getStepTypeObj();
|
||||
if ($index == $stepWithTrigger) {
|
||||
$uidStepWithTrigger = $step->getStepUid();
|
||||
}
|
||||
}
|
||||
$this->assertEquals(
|
||||
["DYNAFORM", "DYNAFORM", "INPUT_DOCUMENT", "OUTPUT_DOCUMENT"],
|
||||
$steps
|
||||
);
|
||||
//Check triggers
|
||||
$criteriaTri = new \Criteria;
|
||||
$criteriaTri->add(\StepTriggerPeer::TAS_UID, $task->getTasUid());
|
||||
$criteriaTri->add(\StepTriggerPeer::STEP_UID, $uidStepWithTrigger);
|
||||
$criteriaTri->addAscendingOrderByColumn(\StepTriggerPeer::ST_POSITION);
|
||||
$triggers = [];
|
||||
foreach (\StepTriggerPeer::doSelect($criteriaTri) as $stepTri) {
|
||||
$triggers[]=[$stepTri->getStepUid(), $stepTri->getStType()];
|
||||
}
|
||||
$this->assertEquals(
|
||||
[[$uidStepWithTrigger, "BEFORE"]],
|
||||
$triggers
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a dynaform
|
||||
* @return type
|
||||
|
||||
@@ -883,6 +883,29 @@ class Processes
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* change and Renew all Task GUID owned by WebEntries
|
||||
*
|
||||
* @param string $oData
|
||||
* @return boolean
|
||||
*/
|
||||
public function renewAllWebEntryEventGuid(&$oData)
|
||||
{
|
||||
$map = array();
|
||||
foreach ($oData->webEntryEvent as $key => $val) {
|
||||
if (isset($val["EVN_UID_OLD"])) {
|
||||
$uidNew = \ProcessMaker\BusinessModel\WebEntryEvent::getTaskUidFromEvnUid($val["EVN_UID"]);
|
||||
$uidOld = \ProcessMaker\BusinessModel\WebEntryEvent::getTaskUidFromEvnUid($val["EVN_UID_OLD"]);
|
||||
foreach($oData->tasks as $index => $task) {
|
||||
if ($task["TAS_UID"]===$uidOld) {
|
||||
$oData->tasks[$index]["TAS_UID"]=$uidNew;
|
||||
$oData->tasks[$index]["TAS_UID_OLD"]=$uidOld;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* change and Renew all Task GUID, because the process needs to have a new set of tasks
|
||||
*
|
||||
@@ -2617,6 +2640,7 @@ class Processes
|
||||
$oData->uid["PROCESS"] = array($oData->process["PRO_PARENT"] => $oData->process["PRO_UID"]);
|
||||
}
|
||||
|
||||
$this->renewAllWebEntryEventGuid($oData);
|
||||
$this->renewAllTaskGuid($oData);
|
||||
$this->renewAllDynaformGuid($oData);
|
||||
$this->renewAllInputGuid($oData);
|
||||
|
||||
@@ -269,13 +269,13 @@ class WebEntry
|
||||
$task->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["DYN_UID"])) {
|
||||
if (!empty($arrayData["DYN_UID"])) {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
|
||||
$dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
}
|
||||
|
||||
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
|
||||
if ($arrayDataMain["WE_METHOD"] == "WS" && !empty($arrayData["USR_UID"])) {
|
||||
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ class WebEntry
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayData["DYN_UID"])) {
|
||||
if (isset($arrayData["DYN_UID"]) && (!isset($arrayData["WE_TYPE"]) || $arrayData["WE_TYPE"]==='SINGLE')) {
|
||||
$dynaForm = new \Dynaform();
|
||||
|
||||
$arrayDynaFormData = $dynaForm->Load($arrayData["DYN_UID"]);
|
||||
@@ -313,7 +313,7 @@ class WebEntry
|
||||
}
|
||||
}
|
||||
|
||||
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
|
||||
if ($arrayDataMain["WE_METHOD"] == "WS" && !empty($arrayData["USR_UID"])) {
|
||||
$user = new \Users();
|
||||
|
||||
$arrayUserData = $user->load($arrayData["USR_UID"]);
|
||||
|
||||
@@ -317,13 +317,13 @@ class WebEntryEvent
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayData["DYN_UID"])) {
|
||||
if (!empty($arrayData["DYN_UID"])) {
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
|
||||
$dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $projectUid, $this->arrayFieldNameForException["dynaFormUid"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["USR_UID"])) {
|
||||
if (!empty($arrayData["USR_UID"])) {
|
||||
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -331,6 +331,18 @@ class WebEntryEvent
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an UID for the task related to the WebEntryEvent.
|
||||
* TAS_UID is based on the EVN_UID to maintain the steps assignation
|
||||
* during the import process
|
||||
*
|
||||
*/
|
||||
public static function getTaskUidFromEvnUid($eventUid)
|
||||
{
|
||||
$prefix = "wee-";
|
||||
return $prefix . substr($eventUid, (32 - strlen($prefix)) * -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create WebEntry
|
||||
*
|
||||
@@ -355,11 +367,14 @@ class WebEntryEvent
|
||||
//Task
|
||||
$task = new \Task();
|
||||
|
||||
$prefix = "wee-";
|
||||
$tasUid = static::getTaskUidFromEvnUid($eventUid);
|
||||
|
||||
if (\TaskPeer::retrieveByPK($tasUid)) {
|
||||
$this->webEntryEventWebEntryTaskUid = $tasUid;
|
||||
} else {
|
||||
$this->webEntryEventWebEntryTaskUid = $task->create(
|
||||
array(
|
||||
"TAS_UID" => $prefix . substr(\ProcessMaker\Util\Common::generateUID(), (32 - strlen($prefix)) * -1),
|
||||
"TAS_UID" => $tasUid,
|
||||
"PRO_UID" => $projectUid,
|
||||
"TAS_TYPE" => "WEBENTRYEVENT",
|
||||
"TAS_TITLE" => "WEBENTRYEVENT",
|
||||
@@ -370,6 +385,7 @@ class WebEntryEvent
|
||||
false
|
||||
);
|
||||
|
||||
if (!isset($arrayData['WE_TYPE']) || $arrayData['WE_TYPE']==='SINGLE') {
|
||||
//Task - Step
|
||||
$step = new \Step();
|
||||
|
||||
@@ -377,6 +393,7 @@ class WebEntryEvent
|
||||
if (!empty($dynaFormUid)) {
|
||||
$result = $step->update(array("STEP_UID" => $stepUid, "STEP_TYPE_OBJ" => "DYNAFORM", "STEP_UID_OBJ" => $dynaFormUid, "STEP_POSITION" => 1, "STEP_MODE" => "EDIT"));
|
||||
}
|
||||
}
|
||||
|
||||
//Task - User
|
||||
$task = new \Tasks();
|
||||
@@ -389,6 +406,7 @@ class WebEntryEvent
|
||||
|
||||
$result = $workflow->addRoute($this->webEntryEventWebEntryTaskUid, $activityUid, "SEQUENTIAL");
|
||||
|
||||
}
|
||||
//WebEntry
|
||||
if (isset($arrayData['WE_LINK_GENERATION']) && $arrayData['WE_LINK_GENERATION']==='ADVANCED') {
|
||||
$arrayData['WE_DATA'] = isset($arrayData['WEE_URL'])?$arrayData['WEE_URL']:null;
|
||||
@@ -522,7 +540,6 @@ class WebEntryEvent
|
||||
|
||||
try {
|
||||
//WebEntry
|
||||
if ($arrayData["WEE_STATUS"] == "ENABLED") {
|
||||
$this->createWebEntry(
|
||||
$projectUid,
|
||||
$arrayData["EVN_UID"],
|
||||
@@ -534,7 +551,6 @@ class WebEntryEvent
|
||||
$userUidCreator,
|
||||
$arrayData
|
||||
);
|
||||
}
|
||||
|
||||
//WebEntry-Event
|
||||
$webEntryEvent = new \WebEntryEvent();
|
||||
@@ -634,38 +650,6 @@ class WebEntryEvent
|
||||
|
||||
try {
|
||||
//WebEntry
|
||||
$option = "UPDATE";
|
||||
|
||||
if (isset($arrayData["WEE_STATUS"])) {
|
||||
if ($arrayData["WEE_STATUS"] == "ENABLED") {
|
||||
if ($arrayWebEntryEventData["WEE_STATUS"] == "DISABLED") {
|
||||
$option = "INSERT";
|
||||
}
|
||||
} else {
|
||||
if ($arrayWebEntryEventData["WEE_STATUS"] == "ENABLED") {
|
||||
$option = "DELETE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($option) {
|
||||
case "INSERT":
|
||||
$this->createWebEntry(
|
||||
$arrayFinalData["PRJ_UID"],
|
||||
$arrayFinalData["EVN_UID"],
|
||||
$arrayFinalData["ACT_UID"],
|
||||
$arrayFinalData["DYN_UID"],
|
||||
$arrayFinalData["USR_UID"],
|
||||
$arrayFinalData["WEE_TITLE"],
|
||||
$arrayFinalData["WEE_DESCRIPTION"],
|
||||
$userUidUpdater,
|
||||
$arrayFinalData
|
||||
);
|
||||
|
||||
$arrayData["WEE_WE_UID"] = $this->webEntryEventWebEntryUid;
|
||||
$arrayData["WEE_WE_TAS_UID"] = $this->webEntryEventWebEntryTaskUid;
|
||||
break;
|
||||
case "UPDATE":
|
||||
if ($arrayWebEntryEventData["WEE_WE_UID"] != "") {
|
||||
$task = new \Tasks();
|
||||
|
||||
@@ -760,14 +744,6 @@ class WebEntryEvent
|
||||
$arrayDataAux = $this->webEntry->update($arrayWebEntryEventData["WEE_WE_UID"], $userUidUpdater, $arrayDataAux);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "DELETE":
|
||||
$this->deleteWebEntry($arrayWebEntryEventData["WEE_WE_UID"], $arrayWebEntryEventData["WEE_WE_TAS_UID"]);
|
||||
|
||||
$arrayData["WEE_WE_UID"] = "";
|
||||
$arrayData["WEE_WE_TAS_UID"] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
//WebEntry-Event
|
||||
$webEntryEvent = \WebEntryEventPeer::retrieveByPK($webEntryEventUid);
|
||||
|
||||
Reference in New Issue
Block a user