update rakefile

Update rakefile to translations

update Rakefile for translations

update intervals in Task Schedule

update insert.sql error in instalation

add Translations in index.php task scheduler

fix timezone in execution on task scheduler

fix timezone

add translation to TASKSCHEDULER

control for intervals in task scheduler is last_update property

PMCORE-1549

PMCORE-1542

Revert "PMCORE-1542 (pull request #7355)"

This reverts pull request #7355.

> PMCORE-1542

fix schedule Run command
This commit is contained in:
Henry Jordan
2020-06-02 19:04:44 +00:00
parent f1b62b24e2
commit 848ff9a887
15 changed files with 2231 additions and 20 deletions

View File

@@ -1,5 +1,17 @@
require 'rubygems'
require 'json'
require "po_to_json"
class PoToJson
def _generate_for_json(language, overwrite = {})
@options = parse_options(overwrite.merge(language: language))
#parse_document
#@parsed ||= inject_meta(parse_document)
generated = build_json_for(parse_document)
end
end
desc "Default Task - Build Library"
task :default => [:required] do
Rake::Task['build'].execute
@@ -67,9 +79,20 @@ task :build => [:required] do
mafeHash = getHash(Dir.pwd + "/vendor/colosa/MichelangeloFE")
pmdynaformHash = getHash(Dir.pwd + "/vendor/colosa/pmDynaform")
puts "Building PO to JSON".cyan
Dir["#{Dir.pwd}/workflow/engine/content/translations/*.po"].each do |file|
lang = file.split('.')
json_string = PoToJson.new(file)._generate_for_json(lang[1], :pretty => true)
File.open("#{Dir.pwd}/workflow/public_html/translations/#{lang[1]}.json",'w').write(json_string)
puts file
end
puts "Building file: Task Scheduler".cyan
system "npm run build --prefix #{Dir.pwd}/vendor/colosa/taskscheduler"
system "cp -Rf #{Dir.pwd}/vendor/colosa/taskscheduler/taskscheduler #{targetDir}/taskscheduler"
system "cp #{Dir.pwd}/vendor/colosa/taskscheduler/taskscheduler/index.html #{targetDir}/taskscheduler"
system "cp #{Dir.pwd}/vendor/colosa/taskscheduler/public/index.html #{targetDir}/taskscheduler"
hashVendors = pmuiHash+"-"+mafeHash
## Building minified JS Files
@@ -469,3 +492,10 @@ def getLog
return output
end
def generate_for_json()
@overwrite = {pretty: false}
@options = parse_options(overwrite.merge(language: 'en'))
@parsed ||= inject_meta(parse_document)
generated = build_json_for(build_json_for(@parsed))
end

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Console\Commands;
use Maveriks\WebApplication;
@@ -6,14 +7,16 @@ use \Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Model\TaskScheduler;
class ScheduleRunCommand extends BaseCommand
{
use AddParametersTrait;
/**
/**
* Create a new command instance.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function __construct(\Illuminate\Console\Scheduling\Schedule $schedule)
@@ -24,11 +27,10 @@ class ScheduleRunCommand extends BaseCommand
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
{--processmakerPath=./ : ProcessMaker path.}
';
$this->description .= ' (ProcessMaker has extended this command)';
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($schedule);
}
/**
* Execute the console command.
*
@@ -43,13 +45,37 @@ class ScheduleRunCommand extends BaseCommand
$webApplication->setRootDir($this->option('processmakerPath'));
$webApplication->loadEnvironment($workspace, false);
}
TaskScheduler::all()->each(function($p) use ($that){
if($p->isDue()){
Log::info("Si se ejecuta" . $p->expression);
}
if($p->enable == '1'){
$that->schedule->exec($p->body)->cron($p->expression)->between($p->startingTime, $p->endingTime);
}
TaskScheduler::all()->each(function ($p) use ($that) {
$starting = isset($p->startingTime) ? $p->startingTime : "0:00";
$ending = isset($p->startingTime) ? $p->endingTime : "23:59";
$timezone = isset($p->timezone) && $p->timezone != ""? $p->timezone: date_default_timezone_get();
$that->schedule->exec($p->body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) {
$now = Carbon::now();
$result = false;
$datework = Carbon::createFromFormat('Y-m-d H:i:s', $p->last_update);
if (isset($p->everyOn)) {
switch ($p->interval) {
case "day":
$interval = $now->diffInDays($datework);
$result = ($interval !== 0 && ($interval % intval($p->everyOn)) == 0);
break;
case "week":
$interval = $now->diffInDays($datework);
$result = ($interval !== 0 && $interval % (intval($p->everyOn) * 7) == 0);
break;
case "month":
$interval = $now->diffInMonths($datework);
$result = ($interval !== 0 && $interval % intval($p->everyOn) == 0);
break;
case "year":
$interval = $now->diffInYears($datework);
$result = ($interval !== 0 && $interval % intval($p->everyOn) == 0);
break;
}
return $result;
}
return true;
});
});
parent::handle();
}

View File

@@ -22,6 +22,10 @@
{
"type": "git",
"url": "git@bitbucket.org:colosa/pmui.git"
},
{
"type": "git",
"url": "git@bitbucket.org:colosa/taskscheduler.git"
}
],
"minimum-stability": "dev",
@@ -34,6 +38,7 @@
"colosa/pmui": "release/3.4.8-dev",
"colosa/michelangelofe": "release/3.4.8-dev",
"colosa/pmdynaform": "release/3.4.8-dev",
"colosa/taskscheduler": "0.1.0",
"google/apiclient": "1.1.6",
"dapphp/securimage": "^3.6",
"psr/log": "1.0.0",

15
composer.lock generated
View File

@@ -146,6 +146,21 @@
],
"time": "2020-03-10T12:38:14+00:00"
},
{
"name": "colosa/taskscheduler",
"version": "0.1.0",
"source": {
"type": "git",
"url": "git@bitbucket.org:colosa/taskscheduler.git",
"reference": "master"
},
"type": "library",
"description": "JS Library to render ProcessMaker Task Scheduler",
"homepage": "http://processmaker.com",
"keywords": [
"Vue js lib ProcessMaker Task Scheduler"
]
},
{
"name": "colosa/pmUI",
"version": "dev-release/3.4.8",

View File

@@ -615,6 +615,11 @@ class RBAC
'PER_UID' => '00000000000000000000000000000068',
'PER_CODE' => 'PM_FOLDERS_OWNER',
'PER_NAME' => 'View Your Folders'
],
[
'PER_UID' => '00000000000000000000000000000069',
'PER_CODE' => 'PM_TASK_SCHEDULER_ADMIN',
'PER_NAME' => 'View Task Scheduler'
]
];

4
rbac/engine/data/mysql/insert.sql Normal file → Executable file
View File

@@ -68,6 +68,9 @@ INSERT INTO `RBAC_PERMISSIONS` VALUES
('00000000000000000000000000000067','PM_SETUP_LOG_FILES','2018-02-06 00:00:00','2018-02-06 00:00:00',1,'00000000000000000000000000000002'),
('00000000000000000000000000000068','PM_FOLDERS_OWNER','2020-01-29 00:00:00','2020-01-29 00:00:00',1,'00000000000000000000000000000002');
INSERT INTO `RBAC_PERMISSIONS` VALUES
('00000000000000000000000000000069','PM_TASK_SCHEDULER_ADMIN','2020-01-29 00:00:00','2020-01-29 00:00:00',1,'00000000000000000000000000000002');
INSERT INTO `RBAC_ROLES` VALUES
('00000000000000000000000000000001','','00000000000000000000000000000001','RBAC_ADMIN','2007-07-31 19:10:22','2007-08-03 12:24:36',1),
('00000000000000000000000000000002','','00000000000000000000000000000002','PROCESSMAKER_ADMIN','2007-07-31 19:10:22','2007-08-03 12:24:36',1),
@@ -144,6 +147,7 @@ INSERT INTO `RBAC_ROLES_PERMISSIONS` VALUES
('00000000000000000000000000000002','00000000000000000000000000000065'),
('00000000000000000000000000000002','00000000000000000000000000000067'),
('00000000000000000000000000000002','00000000000000000000000000000068'),
('00000000000000000000000000000002','00000000000000000000000000000069'),
('00000000000000000000000000000003','00000000000000000000000000000001'),
('00000000000000000000000000000003','00000000000000000000000000000005'),
('00000000000000000000000000000003','00000000000000000000000000000040'),

View File

@@ -15,7 +15,7 @@ class VariableTest extends TestCase
/**
* Test it create variables related to the process
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_create_variable_by_process()
@@ -62,7 +62,7 @@ class VariableTest extends TestCase
/**
* Tests the exception
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_return_an_exception_when_var_name_is_empty()
@@ -94,7 +94,7 @@ class VariableTest extends TestCase
/**
* Tests the exception
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_return_an_exception_when_var_field_type_is_empty()
@@ -126,7 +126,7 @@ class VariableTest extends TestCase
/**
* Tests the exception
*
* @covers \ProcessMaker\BusinessModel\Variables::create()
* @covers \ProcessMaker\BusinessModel\Variable::create()
* @test
*/
public function it_return_an_exception_when_var_label_is_empty()
@@ -158,7 +158,7 @@ class VariableTest extends TestCase
/**
* Test it return the variables related to the PRO_UID
*
* @covers \ProcessMaker\BusinessModel\Variables::getVariables()
* @covers \ProcessMaker\BusinessModel\Variable::getVariables()
* @test
*/
public function it_list_variables_by_process()

View File

@@ -233,7 +233,7 @@ class XmlImporterTest extends TestCase
* Test the import new option and the import new group option with repeated title.
* @test
* @covers \ProcessMaker\Importer\XmlImporter::import()
* @covers \ProcessMaker\Importer\XmlImporter::updateTheProcessOwner()
* @covers \ProcessMaker\Importer\XmlImporter::updateProcessInformation()
*/
public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_try_rename_title()
{

View File

@@ -73,6 +73,10 @@ class SchedulerMapBuilder
$tMap->addColumn('ENDINGTIME', 'Endingtime', 'string', CreoleTypes::VARCHAR, false, 100);
$tMap->addColumn('EVERYON', 'Everyon', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('INTERVAL', 'Interval', 'string', CreoleTypes::VARCHAR, false, 10);
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('EXPRESSION', 'Expression', 'string', CreoleTypes::VARCHAR, false, 255);
@@ -89,6 +93,10 @@ class SchedulerMapBuilder
$tMap->addColumn('ENABLE', 'Enable', 'int', CreoleTypes::TINYINT, false, 3);
$tMap->addColumn('CREATION_DATE', 'CreationDate', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('LAST_UPDATE', 'LastUpdate', 'int', CreoleTypes::TIMESTAMP, false, null);
} // doBuild()
} // SchedulerMapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -6033,7 +6033,9 @@
<column name="id" type="BIGINT" size="20" required="true" autoIncrement="true" primaryKey="true"/>
<column name="title" type="VARCHAR" size="255" required="false"/>
<column name="startingTime" type="VARCHAR" size="100" required="false"/>
<column name="endingTime" type="VARCHAR" size="100" required="false"/>}
<column name="endingTime" type="VARCHAR" size="100" required="false"/>
<column name="everyOn" type="VARCHAR" size="255" required="false"/>
<column name="interval" type="VARCHAR" size="10" required="false"/>
<column name="description" type="VARCHAR" size="255" required="false"/>
<column name="expression" type="VARCHAR" size="255" required="false"/>
<column name="body" type="VARCHAR" size="255" required="false"/>
@@ -6042,5 +6044,7 @@
<column name="system" type="TINYINT" size="3" required="false"/>
<column name="timezone" type="VARCHAR" size="255" required="false"/>
<column name="enable" type="TINYINT" size="3" required="false"/>
<column name="creation_date" type="TIMESTAMP" required="false"/>
<column name="last_update" type="TIMESTAMP" required="false"/>
</table>
</database>

View File

@@ -3325,5 +3325,32 @@ CREATE TABLE `JOBS_FAILED`
`failed_at` DATETIME NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';
#-----------------------------------------------------------------------------
#-- SCHEDULER
#-----------------------------------------------------------------------------
DROP TABLE IF EXISTS `SCHEDULER`;
CREATE TABLE `SCHEDULER`
(
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255),
`startingTime` VARCHAR(100),
`endingTime` VARCHAR(100),
`everyOn` VARCHAR(255),
`interval` VARCHAR(10),
`description` VARCHAR(255),
`expression` VARCHAR(255),
`body` VARCHAR(255),
`type` VARCHAR(255),
`category` VARCHAR(255),
`system` TINYINT(3),
`timezone` VARCHAR(255),
`enable` TINYINT(3),
`creation_date` DATETIME,
`last_update` DATETIME,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -14,12 +14,15 @@ try {
"var timezoneArray = " . G::json_encode($arrayTimeZoneId) . ";\n" .
"</script>\n";
echo($js);
}
$js = "" .
"<script type=\"text/javascript\" src=/js/ext/translation.".SYS_LANG.".".G::browserCacheFilesGetUid() ."js></script>\n".
"<script type='text/javascript'>\n" .
"var server = '" . System::getHttpServerHostnameRequestsFrontEnd() . "';\n" .
"var credentials = " . G::json_encode($pmDynaform->getCredentials()) . ";\n" .
"var category = '" . $category . "';\n" .
"var lang = '" . SYS_LANG . "';\n" .
"</script>\n";
echo($js);

View File

@@ -17,7 +17,9 @@ use Illuminate\Console\Scheduling\Schedule;
class TaskScheduler extends Model
{
protected $table = 'SCHEDULER';
public $timestamps = false;
public $timestamps = true;
const CREATED_AT = 'creation_date';
const UPDATED_AT = 'last_update';
public function isDue(){
$date = Carbon::now();