From d50cd2a2e1ae9e27b3d823b974ebd104cfae92de Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Tue, 25 Feb 2014 09:17:11 -0400 Subject: [PATCH 01/14] Se mejora BEHAT FILESMANAGER. --- .../basic_sequence_files_manager.feature | 2 +- features/bootstrap/RestContext.php | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) 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/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); From 8b91cb3ccf4c0259c77144ac9a0398cbe8268316 Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Tue, 25 Feb 2014 09:29:08 -0400 Subject: [PATCH 02/14] Se mejora BEHAT PROCESSSUPERVISOR. --- .../backend/process_supervisor/main_tests_supervisor.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 0a5f7e23827ddde96e946dff542c00e3c64c97c2 Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Tue, 25 Feb 2014 09:50:33 -0400 Subject: [PATCH 03/14] Se mejora PROCESSSUPERVISOR. --- workflow/engine/src/BusinessModel/FilesManager.php | 3 ++- .../src/Services/Api/ProcessMaker/Project/FilesManager.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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/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; } From d5f9c09f925c59abdfcb5bf2af8813128ac89ad5 Mon Sep 17 00:00:00 2001 From: Wendy Nestor Date: Tue, 25 Feb 2014 11:15:21 -0400 Subject: [PATCH 04/14] Culminacion del feature pm user y creacion de nuevos archivos --- .../main_test_files_manager.feature | 96 +++++++++++++++++++ .../negative_tests_files_manager.feature | 0 .../pm_user/main_tests_pm_user.feature | 23 ++++- features/bootstrap/RestContext.php | 33 ++++++- 4 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 features/backend/files_manager/main_test_files_manager.feature create mode 100644 features/backend/files_manager/negative_tests_files_manager.feature diff --git a/features/backend/files_manager/main_test_files_manager.feature b/features/backend/files_manager/main_test_files_manager.feature new file mode 100644 index 000000000..d457b9e44 --- /dev/null +++ b/features/backend/files_manager/main_test_files_manager.feature @@ -0,0 +1,96 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Files Manager Resources + + Background: + Given that I have a valid access_token + + Scenario: Get a list of main process files manager + Given I request "project/1265557095225ff5c688f46031700471/file-manager" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario: Get a list public folder of process files manager + Given I request "project/1265557095225ff5c688f46031700471/file-manager?path=public" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario: Get a list templates folder of process files manager + Given I request "project/1265557095225ff5c688f46031700471/file-manager?path=templates" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario Outline: Post files + Given POST this data: + """ + { + "prf_filename": "", + "prf_path": "", + "prf_content": "" + } + """ + And I request "project/1265557095225ff5c688f46031700471/file-manager" + Then the response status code should be + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "" + And store "prf_uid" in session array as variable "prf_uid" + + Examples: + | test_description | file_name | path | content | http_code | type | + | into public folder | testbehat.txt | public/ | test | 200 | object | + | into maintemplates folder | testbehat.txt | templates/ | test | 200 | object | + | into public subfolder | testbehat.txt | public/test_folder | test | 200 | object | + | into public subfolder | testbehat.txt | templates/test_folder | test | 200 | object | + + Scenario Outline: Post files + Given PUT this data: + """ + { + "prf_filename": "", + "prf_content": "" + } + """ + And I request "project/1265557095225ff5c688f46031700471/file-manager?path=" + Then the response status code should be + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "" + + Examples: + | test_description | file_name | path | content | http_code | type | + | put into public folder | testbehat.txt | public/ | put test | 200 | object | + | put into maintemplates folder | testbehat.txt | templates/ | put test | 200 | object | + | put into public subfolder | testbehat.txt | public/test_folder | put test | 200 | object | + | put into public subfolder | testbehat.txt | templates/test_folder | put test | 200 | object | + + + Scenario Outline: Delete file + Given that I want to delete a "" + And I request "project/1265557095225ff5c688f46031700471/file-manager?path=" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" + + Examples: + | test_description | path | + | delete public folder | public/testbehat.txt | + | delete maintemplates folder | templates/testbehat.txt | + | delete public subfolder | public/test_folder/testbehat.txt | + | delete public subfolder | templates/test_folder/testbehat.txt | + + #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" + + Scenario: Delete file + Given that I want to delete a "public/test.txt" + And I request "project/1265557095225ff5c688f46031700471/file-manager?path=public/test.txt" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" \ No newline at end of file diff --git a/features/backend/files_manager/negative_tests_files_manager.feature b/features/backend/files_manager/negative_tests_files_manager.feature new file mode 100644 index 000000000..e69de29bb diff --git a/features/backend/pm_user/main_tests_pm_user.feature b/features/backend/pm_user/main_tests_pm_user.feature index 97790df53..440eadbc3 100644 --- a/features/backend/pm_user/main_tests_pm_user.feature +++ b/features/backend/pm_user/main_tests_pm_user.feature @@ -94,7 +94,28 @@ Feature: User Main Tests | Create user Inactive | 4 | daniela | perez | daniela | daniela@gmail.com | grenn #544 | 555-6565 | US | FL | MIA | 555-6655-555 | Gerencia | | 2016-02-15 | | INACTIVE | PROCESSMAKER_OPERATOR | sample | sample | | Create user Vacation | 5 | micaela | sanchez | micaela | micaela@gmail.com | sancjh #544 | 555-6652 | US | FL | MIA | 555-6655-555 | Gerencia | | 2016-02-15 | | VACATION | PROCESSMAKER_OPERATOR | sample | sample | - + + #Para que funcione este test, debe existir el archivo que se quiere subir + #GET /api/1.0/{workspace}/user/{usr_uid} + # Upload a image + Scenario: Upload a image + Given POST I want to upload the image "/home/daniel/pic3.jpg" to user "00000000000000000000000000000001". Url "user/" + + + # Upload a image + Scenario Outline: Upload a image + Given POST I want to upload the image "" to user with the key "usr_uid" stored in session array as variable "usr_uid_". Url "user/" + + Examples: + + | Test_description | usr_number | usr_photo | + | Create without replaced by, calendar | 1 | /home/wendy/photo/pic1.jpg | + | Create without calendar | 2 | /home/wendy/photo/pic2.jpg | + | Create with all fields | 3 | /home/wendy/photo/pic3.jpg | + | Create user Inactive | 4 | ~/userPhoto/abcd.jpg | + | Create user Vacation | 5 | ~/userPhoto/abcd.jpg | + + Scenario: Get the users List when there are exactly 63 users And I request "users" And the content type is "application/json" diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index e6e26edca..557b26d2c 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1355,6 +1355,7 @@ class RestContext extends BehatContext { $baseUrl = $this->getParameter('base_url'); $url = $baseUrl.$url.$usrUid."/image-upload"; + $accesstoken = $this->getParameter('access_token'); $headr = array(); $headr[] = 'Authorization: Bearer '.$accesstoken; @@ -1365,8 +1366,36 @@ class RestContext extends BehatContext 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); + + if( $postResult === false) + { + //trigger_error(curl_error($ch)); + throw new Exception("Image upload failed ($imageFile):\n\n" + . curl_error($ch)); + } curl_close($ch); - echo $postResult; + echo $postResult; } -} + /** + * @Given /^POST I want to upload the image "([^"]*)" to user with the key "([^"]*)" stored in session array as variable "([^"]*)"\. Url "([^"]*)"$/ + */ + public function postIWantToUploadTheImageToUserWithTheKeyStoredInSessionArrayAsVariableUsrUidUrl($imageFile, $varName, $sessionVarName, $url) + { + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = array(); + } + if (!isset($sessionData->$sessionVarName) ) { + $varValue = ''; + } else { + $varValue = $sessionData->$sessionVarName; + } + + $usrUid = $varValue; + + $this->postIWantToUploadTheImageToUser($imageFile, $usrUid, $url); + } + +} \ No newline at end of file From 6ceb1098f3a8e3ec278f95065ebccd9ba5c24c92 Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Tue, 25 Feb 2014 12:43:18 -0400 Subject: [PATCH 05/14] Se cambia url para download y se mejor BEHAT en FILESMANAGER. --- features/bootstrap/RestContext.php | 2 +- .../engine/src/BusinessModel/FilesManager.php | 57 +++++++++---------- .../Api/ProcessMaker/Project/FilesManager.php | 8 +-- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 5e577044d..64ab457ed 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1329,7 +1329,7 @@ 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" => NULL)); + 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); diff --git a/workflow/engine/src/BusinessModel/FilesManager.php b/workflow/engine/src/BusinessModel/FilesManager.php index c9d4d9879..1aeabf40a 100644 --- a/workflow/engine/src/BusinessModel/FilesManager.php +++ b/workflow/engine/src/BusinessModel/FilesManager.php @@ -92,7 +92,8 @@ class FilesManager } else { $editable = 'false'; } - $aTheFiles[] = array( 'prf_filename' => $aFile['FILE'], + $aTheFiles[] = array( 'prf_uid' => $oProcessFiles->getPrfUid(), + 'prf_filename' => $aFile['FILE'], 'usr_uid' => $oProcessFiles->getUsrUid(), 'prf_update_usr_uid' => $oProcessFiles->getPrfUpdateUsrUid(), 'prf_path' => $sMainDirectory. PATH_SEP .$sSubDirectory, @@ -103,7 +104,8 @@ class FilesManager 'prf_content' => $fcontent); } else { - $aTheFiles[] = array('prf_filename' => $aFile['FILE'], + $aTheFiles[] = array('prf_uid' => $oProcessFiles->getPrfUid(), + 'prf_filename' => $aFile['FILE'], 'usr_uid' => '', 'prf_update_usr_uid' => '', 'prf_path' => $sMainDirectory. PATH_SEP .$sSubDirectory, @@ -403,44 +405,41 @@ class FilesManager /** * * @param string $sProcessUID {@min 32} {@max 32} - * @param string $path + * @param string $prfUid {@min 32} {@max 32} * * * @access public */ - public function downloadProcessFilesManager($sProcessUID, $path) + public function downloadProcessFilesManager($sProcessUID, $prfUid) { try { - $sMainDirectory = current(explode("/", $path)); - if ($sMainDirectory != 'public' && $sMainDirectory != 'templates') { - throw (new \Exception( 'invalid value specified for `prf_path`. Expecting `templates/` or `public/`')); + $path = ''; + $criteria = new \Criteria("workflow"); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH); + $criteria->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL); + $rsCriteria = \ProcessFilesPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $rsCriteria->next(); + while ($aRow = $rsCriteria->getRow()) { + $path = $aRow['PRF_PATH']; + $rsCriteria->next(); } - if ($sMainDirectory == 'templates') { - $sMainDirectory = 'mailTemplates'; + if ($path == ''){ + throw new \Exception('invalid value specified for `prf_uid`.')); } - $sfile = end(explode("/",$path)); - $sSubDirectorytemp = substr($path, strpos($path, "/")+1); - if (strstr($sSubDirectorytemp,'/')) { - $sSubDirectory = str_replace('/'.$sfile,"",$sSubDirectorytemp); - $sSubDirectoryCheck = str_replace($sfile,"",$sSubDirectorytemp); + $sFile = end(explode("/",$path)); + $sPath = str_replace($sFile,'',$path); + $sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID))))); + $sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath); + if ($sMainDirectory == PATH_DATA_MAILTEMPLATES){ + $sMainDirectory = 'mainTemplates'; } else { - $sSubDirectory = ''; - $sSubDirectoryCheck = ''; + $sMainDirectory = 'public'; } - switch ($sMainDirectory) { - case 'mailTemplates': - $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectoryCheck . $sfile; - break; - case 'public': - $sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectoryCheck . $sfile; - break; - default: - $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sfile; - break; - } - if (file_exists(PATH_SEP.$sDirectory)) { + if (file_exists($path)) { $oProcessMap = new \processMap(new \DBConnection()); - $oProcessMap->downloadFile($sProcessUID,$sMainDirectory,$sSubDirectory,$sfile); + $oProcessMap->downloadFile($sProcessUID,$sMainDirectory,$sSubDirectory,$sFile); + die(); } else { throw (new \Exception( 'invalid value specified for `path`.')); } diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php index 7feb40af8..3eb5b4ac0 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php @@ -116,15 +116,15 @@ class FilesManager extends Api /** * @param string $prjUid {@min 32} {@max 32} - * @param string $path + * @param string $prfUid {@min 32} {@max 32} * - * @url GET /:prjUid/file-manager/download + * @url GET /:prjUid/file-manager/:prfUid/download */ - public function doGetProcessFilesManagerDownload($prjUid, $path) + public function doGetProcessFilesManagerDownload($prjUid, $prfUid) { try { $filesManager = new \BusinessModel\FilesManager(); - $filesManager->downloadProcessFilesManager($prjUid, $path); + $filesManager->downloadProcessFilesManager($prjUid, $prfUid); } catch (\Exception $e) { //response throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); From d9fb6db233e681af42ee7d9946dc90695bd5609f Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Tue, 25 Feb 2014 12:46:29 -0400 Subject: [PATCH 06/14] Se cambia url para download y se mejor BEHAT en FILESMANAGER. --- workflow/engine/src/BusinessModel/FilesManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/src/BusinessModel/FilesManager.php b/workflow/engine/src/BusinessModel/FilesManager.php index 1aeabf40a..f3777bae3 100644 --- a/workflow/engine/src/BusinessModel/FilesManager.php +++ b/workflow/engine/src/BusinessModel/FilesManager.php @@ -425,7 +425,7 @@ class FilesManager $rsCriteria->next(); } if ($path == ''){ - throw new \Exception('invalid value specified for `prf_uid`.')); + throw new \Exception('invalid value specified for `prf_uid`.'); } $sFile = end(explode("/",$path)); $sPath = str_replace($sFile,'',$path); From 28da2096944190ae1331cefb287dd030eb0a6575 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 25 Feb 2014 11:54:56 -0500 Subject: [PATCH 07/14] working in the build-vendor --- build-vendor.php | 40 ++++++++++++++----- workflow/engine/templates/designer/index.html | 6 ++- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/build-vendor.php b/build-vendor.php index 2337ca922..5c6d2ee16 100644 --- a/build-vendor.php +++ b/build-vendor.php @@ -32,7 +32,6 @@ if (in_array('--no-ansi', $argv)) { $vendorDir = dirname(__FILE__) . DS . 'vendor'; - if (! is_dir($vendorDir )) { echo "Vendor directory is missing!" . PHP_EOL; exit(); @@ -43,16 +42,38 @@ $projects = array( 'colosa/pmUI' ); +out("build-vendor.php", 'purple'); + +out("generating files for ", 'purple', false); +out( $debug ? 'debug' : 'production', 'success', false); +out(" mode", 'purple'); + foreach ($projects as $project) { echo PHP_EOL; out("=> Building project: ", 'info', false); echo $project.' '.PHP_EOL; chdir($vendorDir.DS.$project); - if ($debug) - echo `rake pmBuildDebug`; - else - echo `rake pmBuild`; - out("Completed!", 'success'); + if ($debug) { + exec ('rake pmBuildDebug', $output, $exitCode ); + } else { + exec ('rake pmBuild', $output, $exitCode ); + } + + if ($exitCode) { + out("$project executed with errors!", 'error'); + foreach ($output as $line) { + print "$line\n"; + } + echo PHP_EOL; + die; + } else { + foreach ($output as $line) { + print "$line\n"; + } + out("$project completed", 'success'); + echo PHP_EOL; + } + } echo PHP_EOL; @@ -70,8 +91,9 @@ function out($text, $color = null, $newLine = true) { $styles = array( 'success' => "\033[0;35;32m%s\033[0m", - 'error' => "\033[0;35;31m%s\033[0m", - 'info' => "\033[1;33;34m%s\033[0m" + 'error' => "\033[0;35;31m%s\033[0m", + 'purple' => "\033[0;35;35m%s\033[0m", + 'info' => "\033[1;33;34m%s\033[0m" ); $format = '%s'; @@ -85,4 +107,4 @@ function out($text, $color = null, $newLine = true) } printf($format, $text); -} \ No newline at end of file +} diff --git a/workflow/engine/templates/designer/index.html b/workflow/engine/templates/designer/index.html index f015a67eb..e97d84e43 100644 --- a/workflow/engine/templates/designer/index.html +++ b/workflow/engine/templates/designer/index.html @@ -69,12 +69,14 @@ - + + + From b11d8afbe39d33bcd9f2cf241b00ad053c48e50e Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Tue, 25 Feb 2014 13:04:36 -0400 Subject: [PATCH 08/14] Fix incorrect object declaration, PHP 5.4.x compatibility --- workflow/engine/methods/dynaforms/fields_Ajax.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/engine/methods/dynaforms/fields_Ajax.php b/workflow/engine/methods/dynaforms/fields_Ajax.php index 3f268f8d1..10ea47d8c 100755 --- a/workflow/engine/methods/dynaforms/fields_Ajax.php +++ b/workflow/engine/methods/dynaforms/fields_Ajax.php @@ -88,7 +88,7 @@ $r = 0; foreach ($dependentFields as $d) { $sendContent[$r] = new stdclass(); $sendContent[$r]->name = $d; - $sendContent[$r]->content = null; + $sendContent[$r]->content = new stdclass(); foreach ($G_FORM->fields[$d] as $attribute => $value) { switch ($attribute) { case 'type': @@ -108,7 +108,7 @@ function toJSArray ($array) { $result = array (); foreach ($array as $k => $v) { - $o = null; + $o = new stdclass(); $o->key = $k; $o->value = $v; $result[] = $o; From 887fa6b46ae3d40931d1c23e1681eacdc6116632 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Tue, 25 Feb 2014 13:47:59 -0400 Subject: [PATCH 09/14] Adding Unit Tests to BpmnWorkflow Adapter - Adding Activity->Gateway Flow handler - Adding Activity->Gateway ==> Route Listener to Adapter Now gateways with DIVERGING and CONVERGING directions are interpreted as its respective workflow route types. --- .../Project/Adapter/BpmnWorkflow.php | 42 +++--- .../src/ProcessMaker/Project/Workflow.php | 22 ++- .../Project/Adapter/BpmnWorkflowTest.php | 142 ++++++++++++++++-- 3 files changed, 163 insertions(+), 43 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index 1470fc8e4..8a48fba3c 100644 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -150,26 +150,26 @@ class BpmnWorkflow extends Project\Bpmn public function removeGateway($gatUid) { - $gatewayData = $this->getGateway($gatUid); - $flowsDest = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $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; - } - } +// 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); } @@ -298,6 +298,10 @@ class BpmnWorkflow extends Project\Bpmn \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnGateway" )); + if ($gatewayFlows > 0) { + $this->wp->resetTaskRoutes($activity["ACT_UID"]); + } + foreach ($gatewayFlows as $gatewayFlow) { $gatewayFlow = $gatewayFlow->toArray(); diff --git a/workflow/engine/src/ProcessMaker/Project/Workflow.php b/workflow/engine/src/ProcessMaker/Project/Workflow.php index 148b9cc56..c98ca1134 100644 --- a/workflow/engine/src/ProcessMaker/Project/Workflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Workflow.php @@ -195,8 +195,8 @@ class Workflow extends Handler { try { self::log("Remove Task: $tasUid"); - $task = new Task(); - $task->remove($tasUid); + $task = new Tasks(); + $task->deleteTask($tasUid); self::log("Remove Task Success!"); } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); @@ -275,18 +275,18 @@ class Workflow extends Handler } if ($type != 'SEQUENTIAL' && $type != 'SEC-JOIN' && $type != 'DISCRIMINATOR') { - if ($this->getNumberOfRoutes($this->proUid, $fromTasUid, $toTasUid, $type) > 0) { - throw new \LogicException("Unexpected behaviour"); - } + //if ($this->getNumberOfRoutes($this->proUid, $fromTasUid, $toTasUid, $type) > 0) { + //throw new \LogicException("Unexpected behaviour"); + //} } //if ($delete || $type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') { - $oTasks = new Tasks(); - $oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid); + //$oTasks = new Tasks(); + //$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid); //} $result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $delete); - self::log("Add Route Success! -> ", $result); + self::log("Add Route Success! - ROU_UID: ", $result); return $result; } catch (\Exception $e) { @@ -295,6 +295,12 @@ class Workflow extends Handler } } + public function resetTaskRoutes($actUid) + { + $oTasks = new Tasks(); + $oTasks->deleteAllRoutesOfTask($this->proUid, $actUid); + } + public function updateRoute($rouUid, $routeData) { $routeData['ROU_UID'] = $rouUid; diff --git a/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php b/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php index 78fce2c48..2a7cf0922 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); @@ -346,37 +346,46 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase */ function testActivityToInclusiveGatewayToActivityFlowsMultiple($bwap) { - /*$actUid1 = $bwap->addActivity(array( + $actUid1 = $bwap->addActivity(array( "ACT_NAME" => "Activity #1", - "BOU_X" => 198, - "BOU_Y" => 56 + "BOU_X" => 311, + "BOU_Y" => 26 )); $actUid2 = $bwap->addActivity(array( "ACT_NAME" => "Activity #2", - "BOU_X" => 198, - "BOU_Y" => 250 + "BOU_X" => 99, + "BOU_Y" => 200 + )); + $actUid3 = $bwap->addActivity(array( + "ACT_NAME" => "Activity #3", + "BOU_X" => 310, + "BOU_Y" => 200 + )); + $actUid4 = $bwap->addActivity(array( + "ACT_NAME" => "Activity #4", + "BOU_X" => 542, + "BOU_Y" => 200 )); $gatUid = $bwap->addGateway(array( "GAT_NAME" => "Gateway #1", "GAT_TYPE" => "INCLUSIVE", "GAT_DIRECTION" => "DIVERGING", - "BOU_X" => 256, - "BOU_Y" => 163 + "BOU_X" => 369, + "BOU_Y" => 123 )); - $flowUid1 = $bwap->addFlow(array( + $bwap->addFlow(array( 'FLO_TYPE' => 'SEQUENCE', 'FLO_ELEMENT_ORIGIN' => $actUid1, 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity', 'FLO_ELEMENT_DEST' => $gatUid, 'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway', - 'FLO_X1' => 273, - 'FLO_Y1' => 273, - 'FLO_X2' => 163, - 'FLO_Y2' => 163, + 'FLO_X1' => 386, + 'FLO_Y1' => 174, + 'FLO_X2' => 206, + 'FLO_Y2' => 206, )); - - $flowUid1 = $bwap->addFlow(array( + $bwap->addFlow(array( 'FLO_TYPE' => 'SEQUENCE', 'FLO_ELEMENT_ORIGIN' => $gatUid, 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway', @@ -387,8 +396,109 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase 'FLO_X2' => 249, 'FLO_Y2' => 249, )); + $bwap->addFlow(array( + 'FLO_TYPE' => 'SEQUENCE', + 'FLO_ELEMENT_ORIGIN' => $gatUid, + 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway', + 'FLO_ELEMENT_DEST' => $actUid3, + 'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity', + 'FLO_X1' => 386, + 'FLO_Y1' => 174, + 'FLO_X2' => 206, + 'FLO_Y2' => 206, + )); + $bwap->addFlow(array( + 'FLO_TYPE' => 'SEQUENCE', + 'FLO_ELEMENT_ORIGIN' => $gatUid, + 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway', + 'FLO_ELEMENT_DEST' => $actUid4, + 'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity', + 'FLO_X1' => 386, + 'FLO_Y1' => 617, + 'FLO_X2' => 207, + 'FLO_Y2' => 207, + )); - $bwap->mapBpmnFlowsToWorkflowRoutes();*/ + $bwap->mapBpmnFlowsToWorkflowRoutes(); + + $this->assertCount(4, $bwap->getActivities()); + $this->assertCount(1, $bwap->getGateways()); + $this->assertCount(4, $bwap->getFlows()); + + $wp = Project\Workflow::load($bwap->getUid()); + + $this->assertCount(3, $wp->getRoutes()); + + return array($actUid2, $actUid3, $actUid4); + } + + /** + * @depends testNew + * @depends testActivityToInclusiveGatewayToActivityFlowsMultiple + * @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap + * @param array $activitiesUid + */ + function testActivityToInclusiveGatewayToActivityFlowsMultipleJoin($bwap, $activitiesUid) + { + $gatUid = $bwap->addGateway(array( + "GAT_NAME" => "Gateway #2", + "GAT_TYPE" => "INCLUSIVE", + "GAT_DIRECTION" => "CONVERGING", + "BOU_X" => 369, + "BOU_Y" => 338 + )); + $actUid5 = $bwap->addActivity(array( + "ACT_NAME" => "Activity #5", + "BOU_X" => 312, + "BOU_Y" => 464 + )); + $bwap->addFlow(array( + 'FLO_TYPE' => 'SEQUENCE', + 'FLO_ELEMENT_ORIGIN' => $activitiesUid[0], + 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity', + 'FLO_ELEMENT_DEST' => $gatUid, + 'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway', + 'FLO_X1' => 174, + 'FLO_Y1' => 365, + 'FLO_X2' => 355, + 'FLO_Y2' => 355, + )); + $bwap->addFlow(array( + 'FLO_TYPE' => 'SEQUENCE', + 'FLO_ELEMENT_ORIGIN' => $activitiesUid[1], + 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity', + 'FLO_ELEMENT_DEST' => $gatUid, + 'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway', + 'FLO_X1' => 385, + 'FLO_Y1' => 382, + 'FLO_X2' => 338, + 'FLO_Y2' => 338, + )); + $bwap->addFlow(array( + 'FLO_TYPE' => 'SEQUENCE', + 'FLO_ELEMENT_ORIGIN' => $activitiesUid[2], + 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity', + 'FLO_ELEMENT_DEST' => $gatUid, + 'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway', + 'FLO_X1' => 617, + 'FLO_Y1' => 398, + 'FLO_X2' => 355, + 'FLO_Y2' => 355, + )); + + $bwap->addFlow(array( + 'FLO_TYPE' => 'SEQUENCE', + 'FLO_ELEMENT_ORIGIN' => $gatUid, + 'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway', + 'FLO_ELEMENT_DEST' => $actUid5, + 'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity', + 'FLO_X1' => 382, + 'FLO_Y1' => 387, + 'FLO_X2' => 463, + 'FLO_Y2' => 463, + )); + + $bwap->mapBpmnFlowsToWorkflowRoutes(); } } From 1dbc02926c63ac5051818a91cf472b71b8db434e Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Tue, 25 Feb 2014 14:23:04 -0400 Subject: [PATCH 10/14] Completing Unit Tests to BpmnWorkflow Adapter - Adding Activity->Gateway Flow handler - Adding Activity->Gateway ==> Route Listener to Adapter Now gateways with DIVERGING and CONVERGING directions are interpreted as its respective workflow route types. --- .../Project/Adapter/BpmnWorkflowTest.php | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php b/workflow/engine/src/Tests/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php index 2a7cf0922..769f50910 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); @@ -424,10 +424,17 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase $this->assertCount(4, $bwap->getActivities()); $this->assertCount(1, $bwap->getGateways()); $this->assertCount(4, $bwap->getFlows()); + $this->assertCount(1, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid)); + $this->assertCount(3, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid)); $wp = Project\Workflow::load($bwap->getUid()); + $this->assertCount(4, $wp->getTasks()); $this->assertCount(3, $wp->getRoutes()); + $this->assertCount(3, \Route::findAllBy(\RoutePeer::TAS_UID, $actUid1)); + $this->assertCount(1, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid2)); + $this->assertCount(1, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid3)); + $this->assertCount(1, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid4)); return array($actUid2, $actUid3, $actUid4); } @@ -499,6 +506,23 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase )); $bwap->mapBpmnFlowsToWorkflowRoutes(); + + $this->assertCount(8, $bwap->getFlows()); + $this->assertCount(5, $bwap->getActivities()); + $this->assertCount(2, $bwap->getGateways()); + $this->assertCount(3, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid)); + $this->assertCount(1, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid)); + + $wp = Project\Workflow::load($bwap->getUid()); + + $this->assertCount(5, $wp->getTasks()); + $this->assertCount(6, $wp->getRoutes()); + + $this->assertCount(1, \Route::findAllBy(\RoutePeer::TAS_UID, $activitiesUid[0])); + $this->assertCount(1, \Route::findAllBy(\RoutePeer::TAS_UID, $activitiesUid[1])); + $this->assertCount(1, \Route::findAllBy(\RoutePeer::TAS_UID, $activitiesUid[2])); + $this->assertCount(3, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid5)); + } } From ce2c490b55ca8bd0f61e8db11cd897e8c3565b03 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Tue, 25 Feb 2014 16:53:25 -0400 Subject: [PATCH 11/14] Removing deprecated function on BpmnWorkflow adapter --- .../ProcessMaker/Project/Adapter/BpmnWorkflow.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index 8a48fba3c..8ddc8f3bf 100644 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -479,19 +479,6 @@ class BpmnWorkflow extends Project\Bpmn return empty($result) ? null : $result; } - protected static function findInArray($value, $key, $list) - { - $result = array(); - - foreach ($list as $item) { - if (array_key_exists($key, $item) && $item[$key] == $value) { - $result[] = $item; - } - } - - return $result; - } - public function remove() { parent::remove(); From 2351c0417c0b08a496100c1d4d3118eba8c3445c Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Tue, 25 Feb 2014 20:38:51 -0500 Subject: [PATCH 12/14] designer uses the minified version of css --- workflow/engine/templates/designer/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/workflow/engine/templates/designer/index.html b/workflow/engine/templates/designer/index.html index e97d84e43..d9a9b83a3 100644 --- a/workflow/engine/templates/designer/index.html +++ b/workflow/engine/templates/designer/index.html @@ -40,10 +40,12 @@ {/foreach} {else} - - + + + {/foreach} + + + + + + + + + + + + + + + + {else} + + @@ -52,33 +69,34 @@ var prj_uid = "{$prj_uid}"; var credentials = "{$credentials}"; + + -{/if} - - + - - - - + + + + + + + + + + - - - - - - - + +{/if} + + From 5e294cb92bc82a9df6920e08d69b8672a66be0f1 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Wed, 26 Feb 2014 07:51:37 -0500 Subject: [PATCH 14/14] adding the update script, use it only in Dev stage --- build-vendor.php | 1 - update | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 update diff --git a/build-vendor.php b/build-vendor.php index 4d5b81abb..8ce968286 100644 --- a/build-vendor.php +++ b/build-vendor.php @@ -97,7 +97,6 @@ $jsFiles = array ( "workflow/public_html/lib/pmUI/pmui.min.js", "workflow/public_html/lib/mafe/mafe.min.js", "workflow/public_html/lib/mafe/designer.min.js", - "workflow/public_html/lib/js/tiny_mce.min.js", "gulliver/js/tinymce/jscripts/tiny_mce/tiny_mce.js", "gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmGrids/editor_plugin.js", diff --git a/update b/update new file mode 100755 index 000000000..62821f1a9 --- /dev/null +++ b/update @@ -0,0 +1,26 @@ + +echo "

Michelangelo Update

Changelog Processmaker

" > temp.txt + +git pull +git log -n 20 --relative-date --graph --format=short >> temp.txt + + + +cd vendor/colosa/pmUI +echo "

Changelog pmUI


" >> ../../../temp.txt +git pull +git log -n 20 --relative-date --graph --format=short >> ../../../temp.txt + +cd ../MichelangeloFE +echo "

Changelog MichelangeloFE


" >> ../../../temp.txt +git pull +git log -n 20 --relative-date --graph --format=short >> ../../../temp.txt + + +cd ../../../ +echo "

build-vendor.php


" >> temp.txt +php build-vendor.php >> temp.txt + +sed ':a;N;$!ba;s/\n/
/g' temp.txt > workflow/public_html/build-log.html + +echo "update executed succesfully, check the log in http:///build-log.html "