From c8cf6fb4deded2de6ecc0bed03f5c4400b8806c4 Mon Sep 17 00:00:00 2001 From: Henry Jordan Date: Tue, 14 Jul 2020 20:20:31 +0000 Subject: [PATCH] PMCORE-1817 --- .../classes/model/map/SchedulerMapBuilder.php | 2 + .../engine/classes/model/om/BaseScheduler.php | 136 +++++++++++++----- .../classes/model/om/BaseSchedulerPeer.php | 23 +-- workflow/engine/config/schema.xml | 1 + workflow/engine/data/mysql/schema.sql | 1 + .../BusinessModel/TaskSchedulerBM.php | 24 +++- 6 files changed, 134 insertions(+), 53 deletions(-) diff --git a/workflow/engine/classes/model/map/SchedulerMapBuilder.php b/workflow/engine/classes/model/map/SchedulerMapBuilder.php index b7d26b434..76b29ce83 100755 --- a/workflow/engine/classes/model/map/SchedulerMapBuilder.php +++ b/workflow/engine/classes/model/map/SchedulerMapBuilder.php @@ -81,6 +81,8 @@ class SchedulerMapBuilder $tMap->addColumn('EXPRESSION', 'Expression', 'string', CreoleTypes::VARCHAR, false, 255); + $tMap->addColumn('DEFAULT_VALUE', 'DefaultValue', 'string', CreoleTypes::LONGVARCHAR, false, null); + $tMap->addColumn('BODY', 'Body', 'string', CreoleTypes::VARCHAR, false, 255); $tMap->addColumn('TYPE', 'Type', 'string', CreoleTypes::VARCHAR, false, 255); diff --git a/workflow/engine/classes/model/om/BaseScheduler.php b/workflow/engine/classes/model/om/BaseScheduler.php index 13e9b2dec..b97472273 100644 --- a/workflow/engine/classes/model/om/BaseScheduler.php +++ b/workflow/engine/classes/model/om/BaseScheduler.php @@ -75,6 +75,12 @@ abstract class BaseScheduler extends BaseObject implements Persistent */ protected $expression; + /** + * The value for the default_value field. + * @var string + */ + protected $default_value; + /** * The value for the body field. * @var string @@ -225,6 +231,17 @@ abstract class BaseScheduler extends BaseObject implements Persistent return $this->expression; } + /** + * Get the [default_value] column value. + * + * @return string + */ + public function getDefaultValue() + { + + return $this->default_value; + } + /** * Get the [body] column value. * @@ -531,6 +548,28 @@ abstract class BaseScheduler extends BaseObject implements Persistent } // setExpression() + /** + * Set the value of [default_value] column. + * + * @param string $v new value + * @return void + */ + public function setDefaultValue($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->default_value !== $v) { + $this->default_value = $v; + $this->modifiedColumns[] = SchedulerPeer::DEFAULT_VALUE; + } + + } // setDefaultValue() + /** * Set the value of [body] column. * @@ -754,28 +793,30 @@ abstract class BaseScheduler extends BaseObject implements Persistent $this->expression = $rs->getString($startcol + 7); - $this->body = $rs->getString($startcol + 8); + $this->default_value = $rs->getString($startcol + 8); - $this->type = $rs->getString($startcol + 9); + $this->body = $rs->getString($startcol + 9); - $this->category = $rs->getString($startcol + 10); + $this->type = $rs->getString($startcol + 10); - $this->system = $rs->getInt($startcol + 11); + $this->category = $rs->getString($startcol + 11); - $this->timezone = $rs->getString($startcol + 12); + $this->system = $rs->getInt($startcol + 12); - $this->enable = $rs->getInt($startcol + 13); + $this->timezone = $rs->getString($startcol + 13); - $this->creation_date = $rs->getTimestamp($startcol + 14, null); + $this->enable = $rs->getInt($startcol + 14); - $this->last_update = $rs->getTimestamp($startcol + 15, null); + $this->creation_date = $rs->getTimestamp($startcol + 15, null); + + $this->last_update = $rs->getTimestamp($startcol + 16, null); $this->resetModified(); $this->setNew(false); // FIXME - using NUM_COLUMNS may be clearer. - return $startcol + 16; // 16 = SchedulerPeer::NUM_COLUMNS - SchedulerPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 17; // 17 = SchedulerPeer::NUM_COLUMNS - SchedulerPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating Scheduler object", $e); @@ -1006,27 +1047,30 @@ abstract class BaseScheduler extends BaseObject implements Persistent return $this->getExpression(); break; case 8: - return $this->getBody(); + return $this->getDefaultValue(); break; case 9: - return $this->getType(); + return $this->getBody(); break; case 10: - return $this->getCategory(); + return $this->getType(); break; case 11: - return $this->getSystem(); + return $this->getCategory(); break; case 12: - return $this->getTimezone(); + return $this->getSystem(); break; case 13: - return $this->getEnable(); + return $this->getTimezone(); break; case 14: - return $this->getCreationDate(); + return $this->getEnable(); break; case 15: + return $this->getCreationDate(); + break; + case 16: return $this->getLastUpdate(); break; default: @@ -1057,14 +1101,15 @@ abstract class BaseScheduler extends BaseObject implements Persistent $keys[5] => $this->getInterval(), $keys[6] => $this->getDescription(), $keys[7] => $this->getExpression(), - $keys[8] => $this->getBody(), - $keys[9] => $this->getType(), - $keys[10] => $this->getCategory(), - $keys[11] => $this->getSystem(), - $keys[12] => $this->getTimezone(), - $keys[13] => $this->getEnable(), - $keys[14] => $this->getCreationDate(), - $keys[15] => $this->getLastUpdate(), + $keys[8] => $this->getDefaultValue(), + $keys[9] => $this->getBody(), + $keys[10] => $this->getType(), + $keys[11] => $this->getCategory(), + $keys[12] => $this->getSystem(), + $keys[13] => $this->getTimezone(), + $keys[14] => $this->getEnable(), + $keys[15] => $this->getCreationDate(), + $keys[16] => $this->getLastUpdate(), ); return $result; } @@ -1121,27 +1166,30 @@ abstract class BaseScheduler extends BaseObject implements Persistent $this->setExpression($value); break; case 8: - $this->setBody($value); + $this->setDefaultValue($value); break; case 9: - $this->setType($value); + $this->setBody($value); break; case 10: - $this->setCategory($value); + $this->setType($value); break; case 11: - $this->setSystem($value); + $this->setCategory($value); break; case 12: - $this->setTimezone($value); + $this->setSystem($value); break; case 13: - $this->setEnable($value); + $this->setTimezone($value); break; case 14: - $this->setCreationDate($value); + $this->setEnable($value); break; case 15: + $this->setCreationDate($value); + break; + case 16: $this->setLastUpdate($value); break; } // switch() @@ -1200,35 +1248,39 @@ abstract class BaseScheduler extends BaseObject implements Persistent } if (array_key_exists($keys[8], $arr)) { - $this->setBody($arr[$keys[8]]); + $this->setDefaultValue($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { - $this->setType($arr[$keys[9]]); + $this->setBody($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { - $this->setCategory($arr[$keys[10]]); + $this->setType($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { - $this->setSystem($arr[$keys[11]]); + $this->setCategory($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { - $this->setTimezone($arr[$keys[12]]); + $this->setSystem($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { - $this->setEnable($arr[$keys[13]]); + $this->setTimezone($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { - $this->setCreationDate($arr[$keys[14]]); + $this->setEnable($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { - $this->setLastUpdate($arr[$keys[15]]); + $this->setCreationDate($arr[$keys[15]]); + } + + if (array_key_exists($keys[16], $arr)) { + $this->setLastUpdate($arr[$keys[16]]); } } @@ -1274,6 +1326,10 @@ abstract class BaseScheduler extends BaseObject implements Persistent $criteria->add(SchedulerPeer::EXPRESSION, $this->expression); } + if ($this->isColumnModified(SchedulerPeer::DEFAULT_VALUE)) { + $criteria->add(SchedulerPeer::DEFAULT_VALUE, $this->default_value); + } + if ($this->isColumnModified(SchedulerPeer::BODY)) { $criteria->add(SchedulerPeer::BODY, $this->body); } @@ -1374,6 +1430,8 @@ abstract class BaseScheduler extends BaseObject implements Persistent $copyObj->setExpression($this->expression); + $copyObj->setDefaultValue($this->default_value); + $copyObj->setBody($this->body); $copyObj->setType($this->type); diff --git a/workflow/engine/classes/model/om/BaseSchedulerPeer.php b/workflow/engine/classes/model/om/BaseSchedulerPeer.php index e723f4ccc..3148c18e4 100644 --- a/workflow/engine/classes/model/om/BaseSchedulerPeer.php +++ b/workflow/engine/classes/model/om/BaseSchedulerPeer.php @@ -25,7 +25,7 @@ abstract class BaseSchedulerPeer const CLASS_DEFAULT = 'classes.model.Scheduler'; /** The total number of columns. */ - const NUM_COLUMNS = 16; + const NUM_COLUMNS = 17; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -55,6 +55,9 @@ abstract class BaseSchedulerPeer /** the column name for the EXPRESSION field */ const EXPRESSION = 'SCHEDULER.EXPRESSION'; + /** the column name for the DEFAULT_VALUE field */ + const DEFAULT_VALUE = 'SCHEDULER.DEFAULT_VALUE'; + /** the column name for the BODY field */ const BODY = 'SCHEDULER.BODY'; @@ -90,10 +93,10 @@ abstract class BaseSchedulerPeer * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Startingtime', 'Endingtime', 'Everyon', 'Interval', 'Description', 'Expression', 'Body', 'Type', 'Category', 'System', 'Timezone', 'Enable', 'CreationDate', 'LastUpdate', ), - BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID, SchedulerPeer::TITLE, SchedulerPeer::STARTINGTIME, SchedulerPeer::ENDINGTIME, SchedulerPeer::EVERYON, SchedulerPeer::INTERVAL, SchedulerPeer::DESCRIPTION, SchedulerPeer::EXPRESSION, SchedulerPeer::BODY, SchedulerPeer::TYPE, SchedulerPeer::CATEGORY, SchedulerPeer::SYSTEM, SchedulerPeer::TIMEZONE, SchedulerPeer::ENABLE, SchedulerPeer::CREATION_DATE, SchedulerPeer::LAST_UPDATE, ), - BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'startingTime', 'endingTime', 'everyOn', 'interval', 'description', 'expression', 'body', 'type', 'category', 'system', 'timezone', 'enable', 'creation_date', 'last_update', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) + BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Startingtime', 'Endingtime', 'Everyon', 'Interval', 'Description', 'Expression', 'DefaultValue', 'Body', 'Type', 'Category', 'System', 'Timezone', 'Enable', 'CreationDate', 'LastUpdate', ), + BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID, SchedulerPeer::TITLE, SchedulerPeer::STARTINGTIME, SchedulerPeer::ENDINGTIME, SchedulerPeer::EVERYON, SchedulerPeer::INTERVAL, SchedulerPeer::DESCRIPTION, SchedulerPeer::EXPRESSION, SchedulerPeer::DEFAULT_VALUE, SchedulerPeer::BODY, SchedulerPeer::TYPE, SchedulerPeer::CATEGORY, SchedulerPeer::SYSTEM, SchedulerPeer::TIMEZONE, SchedulerPeer::ENABLE, SchedulerPeer::CREATION_DATE, SchedulerPeer::LAST_UPDATE, ), + BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'startingTime', 'endingTime', 'everyOn', 'interval', 'description', 'expression', 'default_value', 'body', 'type', 'category', 'system', 'timezone', 'enable', 'creation_date', 'last_update', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) ); /** @@ -103,10 +106,10 @@ abstract class BaseSchedulerPeer * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Startingtime' => 2, 'Endingtime' => 3, 'Everyon' => 4, 'Interval' => 5, 'Description' => 6, 'Expression' => 7, 'Body' => 8, 'Type' => 9, 'Category' => 10, 'System' => 11, 'Timezone' => 12, 'Enable' => 13, 'CreationDate' => 14, 'LastUpdate' => 15, ), - BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID => 0, SchedulerPeer::TITLE => 1, SchedulerPeer::STARTINGTIME => 2, SchedulerPeer::ENDINGTIME => 3, SchedulerPeer::EVERYON => 4, SchedulerPeer::INTERVAL => 5, SchedulerPeer::DESCRIPTION => 6, SchedulerPeer::EXPRESSION => 7, SchedulerPeer::BODY => 8, SchedulerPeer::TYPE => 9, SchedulerPeer::CATEGORY => 10, SchedulerPeer::SYSTEM => 11, SchedulerPeer::TIMEZONE => 12, SchedulerPeer::ENABLE => 13, SchedulerPeer::CREATION_DATE => 14, SchedulerPeer::LAST_UPDATE => 15, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'startingTime' => 2, 'endingTime' => 3, 'everyOn' => 4, 'interval' => 5, 'description' => 6, 'expression' => 7, 'body' => 8, 'type' => 9, 'category' => 10, 'system' => 11, 'timezone' => 12, 'enable' => 13, 'creation_date' => 14, 'last_update' => 15, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Startingtime' => 2, 'Endingtime' => 3, 'Everyon' => 4, 'Interval' => 5, 'Description' => 6, 'Expression' => 7, 'DefaultValue' => 8, 'Body' => 9, 'Type' => 10, 'Category' => 11, 'System' => 12, 'Timezone' => 13, 'Enable' => 14, 'CreationDate' => 15, 'LastUpdate' => 16, ), + BasePeer::TYPE_COLNAME => array (SchedulerPeer::ID => 0, SchedulerPeer::TITLE => 1, SchedulerPeer::STARTINGTIME => 2, SchedulerPeer::ENDINGTIME => 3, SchedulerPeer::EVERYON => 4, SchedulerPeer::INTERVAL => 5, SchedulerPeer::DESCRIPTION => 6, SchedulerPeer::EXPRESSION => 7, SchedulerPeer::DEFAULT_VALUE => 8, SchedulerPeer::BODY => 9, SchedulerPeer::TYPE => 10, SchedulerPeer::CATEGORY => 11, SchedulerPeer::SYSTEM => 12, SchedulerPeer::TIMEZONE => 13, SchedulerPeer::ENABLE => 14, SchedulerPeer::CREATION_DATE => 15, SchedulerPeer::LAST_UPDATE => 16, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'startingTime' => 2, 'endingTime' => 3, 'everyOn' => 4, 'interval' => 5, 'description' => 6, 'expression' => 7, 'default_value' => 8, 'body' => 9, 'type' => 10, 'category' => 11, 'system' => 12, 'timezone' => 13, 'enable' => 14, 'creation_date' => 15, 'last_update' => 16, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) ); /** @@ -223,6 +226,8 @@ abstract class BaseSchedulerPeer $criteria->addSelectColumn(SchedulerPeer::EXPRESSION); + $criteria->addSelectColumn(SchedulerPeer::DEFAULT_VALUE); + $criteria->addSelectColumn(SchedulerPeer::BODY); $criteria->addSelectColumn(SchedulerPeer::TYPE); diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 149a1b037..3886c2e9e 100755 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -6043,6 +6043,7 @@ + diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 44ce1b63a..12c8d82c6 100644 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -3345,6 +3345,7 @@ CREATE TABLE `SCHEDULER` `interval` VARCHAR(10), `description` VARCHAR(255), `expression` VARCHAR(255), + `default_value` MEDIUMTEXT, `body` VARCHAR(255), `type` VARCHAR(255), `category` VARCHAR(255), diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBM.php b/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBM.php index 08f1a7201..fa6829ad5 100755 --- a/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBM.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBM.php @@ -1,7 +1,10 @@ "*/5 * * * 0,1,2,3,4,5,6", "description" => "ID_TASK_SCHEDULER_MESSAGE_EVENTS_DESC" ] - /*----------------------------------********---------------------------------*/ - ,[ + /*----------------------------------********---------------------------------*/, [ "title" => "ID_TASK_SCHEDULER_ACTION_EMAIL", "enable" => "1", "service" => "", @@ -190,7 +192,7 @@ class TaskSchedulerBM "expression" => "0 */1 * * 0,1,2,3,4,5,6", "description" => "ID_TASK_SCHEDULER_PM_PLUGINS_DESC" ] - /*----------------------------------********---------------------------------*/ + /*----------------------------------********---------------------------------*/ ]; /** * Return the records in Schedule Table by category @@ -206,7 +208,11 @@ class TaskSchedulerBM if (is_null($category)) { return $tasks; } else { - return TaskScheduler::where('category', $category)->get(); + $tasks = TaskScheduler::where('category', $category)->get(); + foreach ($tasks as $task) { + $task->default_value = json_decode($task->default_value); + } + return $tasks; } } /** @@ -255,7 +261,15 @@ class TaskSchedulerBM $task->enable = $service["enable"]; $task->everyOn = $service["everyOn"]; $task->interval = $service["interval"]; + $task->default_value = json_encode([ + "startingTime" => $service["startingTime"], + "endingTime" => $service["endingTime"], + "everyOn" => $service["everyOn"], + "interval" => $service["interval"], + "expression" => $service["expression"], + "timezone" => null + ]); $task->save(); } } -} \ No newline at end of file +}