diff --git a/features/backend/files_manager/basic_sequence_files_manager.feature b/features/backend/files_manager/basic_sequence_files_manager.feature index 68d5d7ffb..06088e786 100644 --- a/features/backend/files_manager/basic_sequence_files_manager.feature +++ b/features/backend/files_manager/basic_sequence_files_manager.feature @@ -86,7 +86,7 @@ Feature: Files Manager Resources #Para que funcione este test, debe existir el archivo que se quiere subir Scenario: Post files - Given POST I want to upload the file "/home/daniel/test.txt" to path "public". Url to create prf_uid "project/1265557095225ff5c688f46031700471/file-manager" and updload "project/1265557095225ff5c688f46031700471/file-manager/upload" + Given POST I want to upload the file "/home/daniel/test.txt" to path "public". Url to create prf_uid "project/1265557095225ff5c688f46031700471/file-manager" and updload "project/1265557095225ff5c688f46031700471/file-manager" Scenario: Delete file Given that I want to delete a "public/test.txt" diff --git a/features/backend/process_supervisor/main_tests_supervisor.feature b/features/backend/process_supervisor/main_tests_supervisor.feature index 1a1c5d767..ec7f35260 100644 --- a/features/backend/process_supervisor/main_tests_supervisor.feature +++ b/features/backend/process_supervisor/main_tests_supervisor.feature @@ -209,7 +209,7 @@ Requirements: Given POST this data: """ { - "dyn_uid": "<92562207752ceef36c7d874048012431>" + "dyn_uid": "92562207752ceef36c7d874048012431" } """ And I request "project/85794888452ceeef3675164057928956/process-supervisor/dynaform" diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index e6e26edca..5e577044d 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1329,18 +1329,22 @@ class RestContext extends BehatContext $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$postUrl); curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); - curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => "")); + curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => NULL)); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); curl_close($ch); - $aResult = explode(",",$postResult); - $aFileUid = explode(":",$aResult[0]); - $prfUid = trim(str_replace('"','',$aFileUid[1])); + $postResult = (array)json_decode($postResult); + if (sizeof($postResult) > 2) { + $prfUid = $postResult["prf_uid"]; + } else { + var_dump($postResult["error"]); + } + $url = $url.$prfUid."/upload"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); - curl_setopt($ch, CURLOPT_POSTFIELDS, array('my_file'=>'@'.$prfFile, 'prf_uid' => $prfUid)); + curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_file'=>'@'.$prfFile)); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); diff --git a/workflow/engine/classes/model/BpmnFlow.php b/workflow/engine/classes/model/BpmnFlow.php index 6d800f692..64ae9c04e 100644 --- a/workflow/engine/classes/model/BpmnFlow.php +++ b/workflow/engine/classes/model/BpmnFlow.php @@ -16,6 +16,24 @@ require_once 'classes/model/om/BaseBpmnFlow.php'; */ class BpmnFlow extends BaseBpmnFlow { + public static function removeAllRelated($elementUid) + { + $c = new Criteria('workflow'); + + $c1 = $c->getNewCriterion(BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $elementUid); + $c2 = $c->getNewCriterion(BpmnFlowPeer::FLO_ELEMENT_DEST, $elementUid); + + $c1->addOr($c2); + $c->add($c1); + + $flows = BpmnFlowPeer::doSelect($c); + + foreach ($flows as $flow) { + $flow->delete(); + } + } + + /** * @param $field string coming from \BpmnFlowPeer:: * @param $value string diff --git a/workflow/engine/src/BusinessModel/FilesManager.php b/workflow/engine/src/BusinessModel/FilesManager.php index f6fa3c22b..c9d4d9879 100644 --- a/workflow/engine/src/BusinessModel/FilesManager.php +++ b/workflow/engine/src/BusinessModel/FilesManager.php @@ -336,7 +336,8 @@ class FilesManager 'prf_type' => $oProcessFiles->getPrfType(), 'prf_editable' => $sEditable, 'prf_create_date' => $oProcessFiles->getPrfCreateDate(), - 'prf_update_date' => $oProcessFiles->getPrfUpdateDate()); + 'prf_update_date' => $oProcessFiles->getPrfUpdateDate(), + 'prf_content' => $content); return $oProcessFile; } catch (Exception $e) { throw $e; diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index 7ec39c752..1470fc8e4 100644 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -3,7 +3,6 @@ namespace ProcessMaker\Project\Adapter; use ProcessMaker\Project; use ProcessMaker\Util\Hash; -use Symfony\Component\DependencyInjection\Exception\LogicException; /** * Class BpmnWorkflow @@ -149,6 +148,32 @@ class BpmnWorkflow extends Project\Bpmn $this->wp->removeTask($actUid); } + public function removeGateway($gatUid) + { + $gatewayData = $this->getGateway($gatUid); + $flowsDest = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid); + + foreach ($flowsDest as $flowDest) { + switch ($flowDest->getFloElementOriginType()) { + case "bpmnActivity": + $actUid = $flowDest->getFloElementOrigin(); + $flowsOrigin = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid); + + foreach ($flowsOrigin as $flowOrigin) { + switch ($flowOrigin->getFloElementDestType()) { + case "bpmnActivity": + $toActUid = $flowOrigin->getFloElementDest(); + $this->wp->removeRouteFromTo($actUid, $toActUid); + break; + } + } + break; + } + } + + parent::removeGateway($gatUid); + } + // public function addFlow($data) // { // parent::addFlow($data); diff --git a/workflow/engine/src/ProcessMaker/Project/Bpmn.php b/workflow/engine/src/ProcessMaker/Project/Bpmn.php index a19110254..44e5b3541 100644 --- a/workflow/engine/src/ProcessMaker/Project/Bpmn.php +++ b/workflow/engine/src/ProcessMaker/Project/Bpmn.php @@ -500,6 +500,9 @@ class Bpmn extends Handler $gateway = GatewayPeer::retrieveByPK($gatUid); $gateway->delete(); + // remove related object (flows) + Flow::removeAllRelated($gatUid); + self::log("Remove Gateway Success!"); } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php index ce9e674ea..7feb40af8 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php @@ -143,7 +143,10 @@ class ProcessFilesManagerStructure * @var string {@from body} */ public $prf_path; - + + /** + * @var string {@from body} + */ public $prf_content; } diff --git a/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php b/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php index 5dd78bdee..78fce2c48 100644 --- a/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php +++ b/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php @@ -21,7 +21,7 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase public static function tearDownAfterClass() { - return false; + //return false; //cleaning DB foreach (self::$uids as $prjUid) { $bwap = Project\Adapter\BpmnWorkflow::load($prjUid); @@ -328,10 +328,10 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase // cleaning $bwap->removeActivity($actUid1); $bwap->removeActivity($actUid2); - $bwap->removeFlow($flowUid1); - $bwap->removeFlow($flowUid2); + $bwap->removeGateway($gatUid); $this->assertCount(0, $bwap->getActivities()); + $this->assertCount(0, $bwap->getGateways()); $this->assertCount(0, $bwap->getFlows()); $wp = Project\Workflow::load($bwap->getUid());