Fixing conflict with PMC-852

This commit is contained in:
Julio Cesar Laura Avendaño
2019-07-22 12:05:21 -04:00
38 changed files with 3956 additions and 17 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use Maveriks\WebApplication;
trait AddParametersTrait
{
/**
* Create a new queue command.
*
* @return void
*/
public function __construct()
{
$this->signature .= '
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct();
}
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$workspace = $this->option('workspace');
if (!empty($workspace)) {
$webApplication = new WebApplication();
$webApplication->setRootDir($this->option('processmakerPath'));
$webApplication->loadEnvironment($workspace);
}
parent::handle();
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Queue\Console\FailedTableCommand as BaseFailedTableCommand;
use Illuminate\Support\Composer;
class FailedTableCommand extends BaseFailedTableCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:failed-table';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
/**
* Create a new queue failed-table command.
*
* @return void
*/
public function __construct(Filesystem $files, Composer $composer)
{
$this->signature .= '
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($files, $composer);
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\FlushFailedCommand as BaseFlushFailedCommand;
class FlushFailedCommand extends BaseFlushFailedCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:flush';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\ForgetFailedCommand as BaseForgetFailedCommand;
class ForgetFailedCommand extends BaseForgetFailedCommand
{
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\ListFailedCommand as BaseListFailedCommand;
class ListFailedCommand extends BaseListFailedCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:failed';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\RestartCommand as BaseRestartCommand;
class RestartCommand extends BaseRestartCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:restart';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\RetryCommand as BaseRetryCommand;
class RetryCommand extends BaseRetryCommand
{
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Queue\Console\TableCommand as BaseTableCommand;
use Illuminate\Support\Composer;
class TableCommand extends BaseTableCommand
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'queue:table';
/**
* This contains the necessary code to add parameters.
*/
use AddParametersTrait;
/**
* Create a new queue table command.
*
* @return void
*/
public function __construct(Filesystem $files, Composer $composer)
{
$this->signature .= '
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($files, $composer);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Console\Commands;
use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand;
use Illuminate\Queue\Worker;
class WorkCommand extends BaseWorkCommand
{
use AddParametersTrait;
/**
* Create a new queue work command.
*
* @param \Illuminate\Queue\Worker $worker
*
* @return void
*/
public function __construct(Worker $worker)
{
$this->signature .= '
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($worker);
}
}

8
app/Jobs/Email.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
namespace App\Jobs;
class Email extends QueuedClosure
{
}

8
app/Jobs/EmailEvent.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
namespace App\Jobs;
class EmailEvent extends QueuedClosure
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Jobs;
use Closure;
use Illuminate\Queue\CallQueuedClosure;
use Illuminate\Queue\SerializableClosure;
abstract class QueuedClosure extends CallQueuedClosure
{
/**
* Create a new job instance.
*
* @param \Illuminate\Queue\SerializableClosure $closure
*/
public function __construct(Closure $closure)
{
parent::__construct(new SerializableClosure($closure));
}
}

8
app/Jobs/ScriptTask.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
namespace App\Jobs;
class ScriptTask extends QueuedClosure
{
}

8
app/Jobs/ServiceTask.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
namespace App\Jobs;
class ServiceTask extends QueuedClosure
{
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use App\Console\Commands\WorkCommand;
use Illuminate\Queue\QueueServiceProvider;
class WorkCommandServiceProvider extends QueueServiceProvider
{
/**
* Overrides "register" method from Queue provider.
* @return void
*/
public function register()
{
parent::register();
//Extend command "queue:work".
$this->app->extend('command.queue.work', function ($command, $app) {
return new WorkCommand($app['queue.worker']);
});
}
}

View File

@@ -51,7 +51,6 @@
"php-imap/php-imap": "^3.0",
"nikic/php-parser": "3.1.5",
"laravel/tinker": "^1.0"
},
"require-dev": {
"fzaninotto/faker": "^1.7",
@@ -68,7 +67,7 @@
"ProcessMaker\\": "workflow/engine/src"
},
"psr-4": {
"App\\": "app/",
"App\\": "app/",
"Maveriks\\": "framework/src/Maveriks/",
"Tests\\": "tests/"
},

View File

@@ -24,6 +24,7 @@ return [
Illuminate\Encryption\EncryptionServiceProvider::class,
Laravel\Tinker\TinkerServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
],
'aliases' => [

87
config/queue.php Normal file
View File

@@ -0,0 +1,87 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'JOBS_PENDING',
'queue' => 'default',
'retry_after' => 90,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'database' => env('DB_CONNECTION', 'workflow'),
'table' => 'JOBS_FAILED',
],
];

View File

@@ -9,6 +9,7 @@ use Illuminate\Foundation\Http\Kernel;
use Luracast\Restler\Format\UploadFormat;
use Luracast\Restler\RestException;
use Maveriks\Util;
use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Services;
@@ -612,6 +613,11 @@ class WebApplication
\Propel::init(PATH_CONFIG . "databases.php");
/**
* JobsManager
*/
JobsManager::getSingleton()->init();
$oPluginRegistry = PluginRegistry::loadSingleton();
$attributes = $oPluginRegistry->getAttributes();
Bootstrap::LoadTranslationPlugins(defined('SYS_LANG') ? SYS_LANG : "en", $attributes);

View File

@@ -20,6 +20,7 @@ require_once __DIR__ . '/../../../gulliver/system/class.g.php';
require_once __DIR__ . '/../../../bootstrap/autoload.php';
require_once __DIR__ . '/../../../bootstrap/app.php';
use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
@@ -254,6 +255,11 @@ try {
//Processing
eprintln('Processing workspace: ' . $workspace, 'green');
/**
* JobsManager
*/
JobsManager::getSingleton()->init();
// We load plugins' pmFunctions
$oPluginRegistry = PluginRegistry::loadSingleton();

View File

@@ -1,5 +1,6 @@
<?php
use ProcessMaker\Core\JobsManager;
use ProcessMaker\Model\Process;
use ProcessMaker\Validation\MySQL57;
@@ -370,6 +371,21 @@ CLI::taskArg("workspace-name", true, true);
CLI::taskRun("run_check_queries_incompatibilities");
/*********************************************************************/
/**
* This command executes "artisan" loading the workspace connection parameters
*/
CLI::taskName('artisan');
CLI::taskDescription(<<<EOT
This command executes "artisan" loading the workspace parameters.
Example:
./processmaker artisan queue:work --workspace=workflow
To see other command options please refer to the artisan help.
php artisan --help
EOT
);
CLI::taskRun("run_artisan");
/**
* Function run_info
*
@@ -1378,3 +1394,32 @@ function check_queries_incompatibilities($wsName)
echo ">> No MySQL 5.7 incompatibilities in variables found for this workspace." . PHP_EOL;
}
}
/**
* This function obtains the connection parameters and passes them to the artisan.
* All artisan options can be applied. For more information on artisan options use
* php artisan --help
* @param array $args
*/
function run_artisan($args)
{
$jobsManager = JobsManager::getSingleton()->init();
$workspace = $jobsManager->getOptionValueFromArguments($args, "--workspace");
if ($workspace !== false) {
config(['system.workspace' => $workspace]);
$sw = in_array($args[0], ['queue:work', 'queue:listen']);
$tries = $jobsManager->getOptionValueFromArguments($args, "--tries");
if ($sw === true && $tries === false) {
$tries = $jobsManager->getTries();
array_push($args, "--tries={$tries}");
}
array_push($args, "--processmakerPath=" . PROCESSMAKER_PATH);
$command = "artisan " . implode(" ", $args);
CLI::logging("> {$command}\n");
passthru(PHP_BINARY . " {$command}");
} else {
CLI::logging("> The --workspace option is undefined.\n");
}
}

View File

@@ -4,6 +4,7 @@ use ProcessMaker\BusinessModel\EmailServer;
/*----------------------------------********---------------------------------*/
use ProcessMaker\ChangeLog\ChangeLog;
/*----------------------------------********---------------------------------*/
use ProcessMaker\Core\JobsManager;
use ProcessMaker\Core\System;
use ProcessMaker\Util\WsMessageResponse;
@@ -957,9 +958,6 @@ class WsBase
$msgError = "The default configuration wasn't defined";
}
$spool = new SpoolRun();
$spool->setConfig($setup);
$case = new Cases();
$oldFields = $case->loadCase($appUid, $delIndex);
if ($gmail == 1) {
@@ -1004,20 +1002,33 @@ class WsBase
isset($fieldsCase['PRO_ID']) ? $fieldsCase['PRO_ID'] : 0,
$this->getTaskId() ?$this->getTaskId():(isset($oldFields['TAS_ID'])? $oldFields['TAS_ID'] : 0)
);
$spool->create($messageArray);
$result = "";
if ($gmail != 1) {
$spool->sendMail();
if ($spool->status == 'sent') {
$result = new WsMessageResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to);
$result->setAppMessUid($spool->getSpoolId());
} else {
$result = new WsResponse(29, $spool->status . ' ' . $spool->error . print_r($setup, 1));
$closure = function() use ($setup, $messageArray, $gmail, $to) {
$spool = new SpoolRun();
$spool->setConfig($setup);
$spool->create($messageArray);
$spool->sendMail();
return $spool;
};
$result = new WsMessageResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to);
switch ($appMsgType) {
case WsBase::MESSAGE_TYPE_EMAIL_EVENT:
case WsBase::MESSAGE_TYPE_PM_FUNCTION:
JobsManager::getSingleton()->dispatch('EmailEvent', $closure);
break;
default :
$spool = $closure();
if ($spool->status == 'sent') {
$result = new WsMessageResponse(0, G::loadTranslation('ID_MESSAGE_SENT') . ": " . $to);
$result->setAppMessUid($spool->getSpoolId());
} else {
$result = new WsResponse(29, $spool->status . ' ' . $spool->error . PHP_EOL . print_r($setup, 1));
}
break;
}
}
return $result;
} catch (Exception $e) {
return new WsResponse(100, $e->getMessage());

View File

@@ -0,0 +1,19 @@
<?php
require_once 'classes/model/om/BaseJobsFailed.php';
/**
* Skeleton subclass for representing a row from the 'JOBS_FAILED' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class JobsFailed extends BaseJobsFailed {
} // JobsFailed

View File

@@ -0,0 +1,23 @@
<?php
// include base peer class
require_once 'classes/model/om/BaseJobsFailedPeer.php';
// include object class
include_once 'classes/model/JobsFailed.php';
/**
* Skeleton subclass for performing query and update operations on the 'JOBS_FAILED' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class JobsFailedPeer extends BaseJobsFailedPeer {
} // JobsFailedPeer

View File

@@ -0,0 +1,19 @@
<?php
require_once 'classes/model/om/BaseJobsPending.php';
/**
* Skeleton subclass for representing a row from the 'JOBS_PENDING' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class JobsPending extends BaseJobsPending {
} // JobsPending

View File

@@ -0,0 +1,23 @@
<?php
// include base peer class
require_once 'classes/model/om/BaseJobsPendingPeer.php';
// include object class
include_once 'classes/model/JobsPending.php';
/**
* Skeleton subclass for performing query and update operations on the 'JOBS_PENDING' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package classes.model
*/
class JobsPendingPeer extends BaseJobsPendingPeer {
} // JobsPendingPeer

View File

@@ -0,0 +1,82 @@
<?php
require_once 'propel/map/MapBuilder.php';
include_once 'creole/CreoleTypes.php';
/**
* This class adds structure of 'JOBS_FAILED' table to 'workflow' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package workflow.classes.model.map
*/
class JobsFailedMapBuilder
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'classes.model.map.JobsFailedMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('workflow');
$tMap = $this->dbMap->addTable('JOBS_FAILED');
$tMap->setPhpName('JobsFailed');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'string', CreoleTypes::BIGINT, true, 20);
$tMap->addColumn('CONNECTION', 'Connection', 'string', CreoleTypes::LONGVARCHAR, true, null);
$tMap->addColumn('QUEUE', 'Queue', 'string', CreoleTypes::LONGVARCHAR, true, null);
$tMap->addColumn('PAYLOAD', 'Payload', 'string', CreoleTypes::LONGVARCHAR, true, null);
$tMap->addColumn('EXCEPTION', 'Exception', 'string', CreoleTypes::LONGVARCHAR, true, null);
$tMap->addColumn('FAILED_AT', 'FailedAt', 'int', CreoleTypes::TIMESTAMP, true, null);
} // doBuild()
} // JobsFailedMapBuilder

View File

@@ -0,0 +1,84 @@
<?php
require_once 'propel/map/MapBuilder.php';
include_once 'creole/CreoleTypes.php';
/**
* This class adds structure of 'JOBS_PENDING' table to 'workflow' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package workflow.classes.model.map
*/
class JobsPendingMapBuilder
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'classes.model.map.JobsPendingMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('workflow');
$tMap = $this->dbMap->addTable('JOBS_PENDING');
$tMap->setPhpName('JobsPending');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'string', CreoleTypes::BIGINT, true, 20);
$tMap->addColumn('QUEUE', 'Queue', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addColumn('PAYLOAD', 'Payload', 'string', CreoleTypes::LONGVARCHAR, true, null);
$tMap->addColumn('ATTEMPTS', 'Attempts', 'int', CreoleTypes::TINYINT, true, 3);
$tMap->addColumn('RESERVED_AT', 'ReservedAt', 'int', CreoleTypes::TINYINT, false, 10);
$tMap->addColumn('AVAILABLE_AT', 'AvailableAt', 'int', CreoleTypes::TINYINT, true, 10);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TINYINT, true, 10);
} // doBuild()
} // JobsPendingMapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More