MT-61: Fix removeProject method
This commit is contained in:
@@ -177,7 +177,8 @@ abstract class Importer
|
||||
$objectList = $granularObj->loadObjectsListSelected($this->importData, $objectsToImport);
|
||||
foreach($objectList as $rowObject) {
|
||||
if($rowObject['name'] === 'PROCESSDEFINITION') {
|
||||
$this->removeProject();
|
||||
$onlyDiagram = true;
|
||||
$this->removeProject($onlyDiagram);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,14 +326,14 @@ abstract class Importer
|
||||
$project->setDisabled();
|
||||
}
|
||||
|
||||
public function removeProject()
|
||||
public function removeProject($onlyDiagram = false)
|
||||
{
|
||||
/* @var $process \Process */
|
||||
$process = new \Process();
|
||||
$process->load($this->metadata["uid"]);
|
||||
$this->currentProcessTitle = $process->getProTitle();
|
||||
$project = \ProcessMaker\Project\Adapter\BpmnWorkflow::load($this->metadata["uid"]);
|
||||
$project->remove(true, false);
|
||||
$project->remove(true, false, $onlyDiagram);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1217,10 +1217,10 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($flagForceRemoveProject = false, $flagRemoveCases = true)
|
||||
public function remove($flagForceRemoveProject = false, $flagRemoveCases = true, $onlyDiagram = false)
|
||||
{
|
||||
parent::remove($flagForceRemoveProject);
|
||||
$this->wp->remove($flagRemoveCases);
|
||||
$this->wp->remove($flagRemoveCases, $onlyDiagram);
|
||||
}
|
||||
|
||||
public static function createFromStruct(array $projectData, $generateUid = true)
|
||||
|
||||
@@ -115,11 +115,11 @@ class Workflow extends Handler
|
||||
$process->update($data);
|
||||
}
|
||||
|
||||
public function remove($flagRemoveCases = true)
|
||||
public function remove($flagRemoveCases = true, $onlyDiagram = false)
|
||||
{
|
||||
try {
|
||||
self::log("Remove Process with uid: {$this->proUid}");
|
||||
$this->deleteProcess($this->proUid, $flagRemoveCases);
|
||||
$this->deleteProcess($this->proUid, $flagRemoveCases, $onlyDiagram);
|
||||
self::log("Remove Process Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
@@ -577,7 +577,7 @@ class Workflow extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProcess($sProcessUID, $flagRemoveCases = true)
|
||||
public function deleteProcess($sProcessUID, $flagRemoveCases = true, $onlyDiagram = false)
|
||||
{
|
||||
try {
|
||||
//G::LoadClass('case');
|
||||
@@ -651,46 +651,49 @@ class Workflow extends Handler
|
||||
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the dynaforms of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\DynaformPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oDynaform->remove($aRow['DYN_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the input documents of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\InputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \InputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oInputDocument->remove($aRow['INP_DOC_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the output documents of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oOutputDocument->remove($aRow['OUT_DOC_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
//Delete the triggers of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\TriggersPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \TriggersPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oTrigger->remove($aRow['TRI_UID']);
|
||||
//Delete the dynaforms of process
|
||||
if (!$onlyDiagram) {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\DynaformPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oDynaform->remove($aRow['DYN_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the input documents of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\InputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \InputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oInputDocument->remove($aRow['INP_DOC_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the output documents of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oOutputDocument->remove($aRow['OUT_DOC_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
//Delete the triggers of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\TriggersPeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \TriggersPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oTrigger->remove($aRow['TRI_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
}
|
||||
|
||||
//Delete the routes of process
|
||||
@@ -746,39 +749,17 @@ class Workflow extends Handler
|
||||
$oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
//Delete the DB sources of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\DbSourcePeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \DbSourcePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
|
||||
/**
|
||||
* note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
|
||||
* in order to solve the bug 0004389, we use the validation function Exists
|
||||
* inside the remove function in order to verify if the DbSource record
|
||||
* exists in the Database, however there is a strange behavior within the
|
||||
* propel engine, when the first record is erased somehow the "_deleted"
|
||||
* attribute of the next row is set to true, so when propel tries to erase
|
||||
* it, obviously it can't and trows an error. With the "Exist" function
|
||||
* we ensure that if there is the record in the database, the _delete attribute must be false.
|
||||
*
|
||||
* note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
|
||||
* I have just identified the source of the issue, when is created a $oDbSource DbSource object
|
||||
* it's used whenever a record is erased or removed in the db, however the problem
|
||||
* it's that the same object is used every time, and the delete method invoked
|
||||
* sets the _deleted attribute to true when its called, of course as we use
|
||||
* the same object, the first time works fine but trowns an error with the
|
||||
* next record, cos it's the same object and the delete method checks if the _deleted
|
||||
* attribute it's true or false, the attrib _deleted is setted to true the
|
||||
* first time and later is never changed, the issue seems to be part of
|
||||
* every remove function in the model classes, not only DbSource
|
||||
* i recommend that a more general solution must be achieved to resolve
|
||||
* this issue in every model class, to prevent future problems.
|
||||
*/
|
||||
$oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
|
||||
if (!$onlyDiagram) {
|
||||
//Delete the DB sources of process
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(\DbSourcePeer::PRO_UID, $sProcessUID);
|
||||
$oDataset = \DbSourcePeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
|
||||
$oDataset->next();
|
||||
}
|
||||
}
|
||||
//Delete the supervisors
|
||||
$oCriteria = new Criteria('workflow');
|
||||
|
||||
Reference in New Issue
Block a user