Merged in feature/PMC-1241 (pull request #7171)
PMC-1241 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
28
database/factories/AdditionalTablesFactory.php
Normal file
28
database/factories/AdditionalTablesFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\AdditionalTables::class, function(Faker $faker) {
|
||||
return [
|
||||
'ADD_TAB_UID' => G::generateUniqueID(),
|
||||
'ADD_TAB_NAME' => $faker->name,
|
||||
'ADD_TAB_CLASS_NAME' => $faker->name,
|
||||
'ADD_TAB_DESCRIPTION' => $faker->text,
|
||||
'ADD_TAB_SDW_LOG_INSERT' => 0,
|
||||
'ADD_TAB_SDW_LOG_UPDATE' => 0,
|
||||
'ADD_TAB_SDW_LOG_DELETE' => 0,
|
||||
'ADD_TAB_SDW_LOG_SELECT' => 0,
|
||||
'ADD_TAB_SDW_MAX_LENGTH' => 0,
|
||||
'ADD_TAB_SDW_AUTO_DELETE' => 0,
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => 'workflow',
|
||||
'PRO_UID' => function() {
|
||||
return factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID;
|
||||
},
|
||||
'ADD_TAB_TYPE' => '',
|
||||
'ADD_TAB_GRID' => '',
|
||||
'ADD_TAB_TAG' => '',
|
||||
'ADD_TAB_OFFLINE' => 0,
|
||||
'ADD_TAB_UPDATE_DATE' => $faker->dateTime()
|
||||
];
|
||||
});
|
||||
50
database/factories/FieldsFactory.php
Normal file
50
database/factories/FieldsFactory.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\Fields::class, function (Faker $faker) {
|
||||
return [
|
||||
'FLD_UID' => G::generateUniqueID(),
|
||||
'ADD_TAB_UID' => G::generateUniqueID(),
|
||||
'FLD_INDEX' => 0,
|
||||
'FLD_NAME' => 'VAR_' . $faker->sentence(1),
|
||||
'FLD_DESCRIPTION' => $faker->sentence(2),
|
||||
'FLD_TYPE' => 'VARCHAR',
|
||||
'FLD_SIZE' => 255,
|
||||
'FLD_NULL' => 1,
|
||||
'FLD_AUTO_INCREMENT' => 0,
|
||||
'FLD_KEY' => 1,
|
||||
'FLD_TABLE_INDEX' => 0,
|
||||
'FLD_FOREIGN_KEY' => 0,
|
||||
'FLD_FOREIGN_KEY_TABLE' => '',
|
||||
'FLD_DYN_NAME' => '',
|
||||
'FLD_DYN_UID' => '',
|
||||
'FLD_FILTER' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
// Create columns from a table with the foreign keys
|
||||
$factory->state(\ProcessMaker\Model\Fields::class, 'foreign_keys', function (Faker $faker) {
|
||||
return [
|
||||
'FLD_UID' => G::generateUniqueID(),
|
||||
'ADD_TAB_UID' => function() {
|
||||
$table = factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 1]);
|
||||
return $table->ADD_TAB_UID;
|
||||
},
|
||||
'FLD_INDEX' => 0,
|
||||
'FLD_NAME' => 'VAR_' . $faker->sentence(1),
|
||||
'FLD_DESCRIPTION' => $faker->sentence(2),
|
||||
'FLD_TYPE' => 'VARCHAR',
|
||||
'FLD_SIZE' => 255,
|
||||
'FLD_NULL' => 1,
|
||||
'FLD_AUTO_INCREMENT' => 0,
|
||||
'FLD_KEY' => 1,
|
||||
'FLD_TABLE_INDEX' => 0,
|
||||
'FLD_FOREIGN_KEY' => 0,
|
||||
'FLD_FOREIGN_KEY_TABLE' => '',
|
||||
'FLD_DYN_NAME' => '',
|
||||
'FLD_DYN_UID' => '',
|
||||
'FLD_FILTER' => 0,
|
||||
];
|
||||
});
|
||||
@@ -32,6 +32,7 @@ define('PMTABLE_KEY', 'pmtable');
|
||||
define('DB_ADAPTER', 'mysql');
|
||||
// Path related some specific directories
|
||||
define('PATH_SEP', '/');
|
||||
define("PATH_PLUGINS", PATH_CORE . "plugins" . PATH_SEP);
|
||||
define('PATH_WORKSPACE', PATH_TRUNK . '/shared/sites/' . SYS_SYS . '/');
|
||||
define('PATH_METHODS', dirname(__DIR__) . '/workflow/engine/methods/');
|
||||
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use AdditionalTables;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\Model\AdditionalTables as AdditionalTablesModel;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdditionalTablesTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* This tests the creation of a PMTable.
|
||||
* @test
|
||||
* @covers \AdditionalTables::create()
|
||||
*/
|
||||
public function it_should_create()
|
||||
{
|
||||
$data = [
|
||||
"ADD_TAB_UID" => "",
|
||||
"ADD_TAB_NAME" => "PMT_TEST11",
|
||||
"ADD_TAB_CLASS_NAME" => "PmtTest11",
|
||||
"ADD_TAB_DESCRIPTION" => "",
|
||||
"ADD_TAB_PLG_UID" => "",
|
||||
"DBS_UID" => "workflow",
|
||||
"PRO_UID" => "",
|
||||
"ADD_TAB_TYPE" => "",
|
||||
"ADD_TAB_GRID" => "",
|
||||
"ADD_TAB_OFFLINE" => false,
|
||||
"ADD_TAB_UPDATE_DATE" => "2019-10-22 19:52:52"
|
||||
];
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$result = $additionalTables->create($data);
|
||||
|
||||
$additionalTablesModel = AdditionalTablesModel::where('ADD_TAB_UID', '=', $result)
|
||||
->get()
|
||||
->first();
|
||||
$actual = $additionalTablesModel->toArray();
|
||||
unset($data["ADD_TAB_UID"]);
|
||||
|
||||
$this->assertArraySubset($data, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This attempts to create a PMTable without correct data to cause an exception.
|
||||
* @test
|
||||
* @covers \AdditionalTables::create()
|
||||
*/
|
||||
public function it_should_create_without_data()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
$additionalTables = new AdditionalTables();
|
||||
$this->expectException(Exception::class);
|
||||
$additionalTables->create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* This updates the data of a PMTable.
|
||||
* @test
|
||||
* @covers \AdditionalTables::update()
|
||||
*/
|
||||
public function it_should_update()
|
||||
{
|
||||
$additionalTables = factory(AdditionalTablesModel::class)->create();
|
||||
|
||||
$expected = [
|
||||
"ADD_TAB_UID" => $additionalTables->ADD_TAB_UID,
|
||||
"ADD_TAB_NAME" => "PMT_TEST11",
|
||||
"ADD_TAB_CLASS_NAME" => "PmtTest11",
|
||||
"DBS_UID" => "workflow",
|
||||
"ADD_TAB_OFFLINE" => false,
|
||||
"ADD_TAB_UPDATE_DATE" => "2019-10-22 19:53:11"
|
||||
];
|
||||
$additionalTables = new AdditionalTables();
|
||||
$additionalTables->update($expected);
|
||||
|
||||
$additionalTables = AdditionalTablesModel::where('ADD_TAB_UID', '=', $expected['ADD_TAB_UID'])
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$this->assertEquals($expected["ADD_TAB_NAME"], $additionalTables->ADD_TAB_NAME);
|
||||
$this->assertEquals($expected["ADD_TAB_CLASS_NAME"], $additionalTables->ADD_TAB_CLASS_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tries to update the data of a non-existent "PMTable".
|
||||
* @test
|
||||
* @covers \AdditionalTables::update()
|
||||
*/
|
||||
public function it_should_update_if_registry_not_exist()
|
||||
{
|
||||
$expected = [
|
||||
"ADD_TAB_UID" => G::generateUniqueID(),
|
||||
"ADD_TAB_NAME" => "PMT_TEST11",
|
||||
"ADD_TAB_CLASS_NAME" => "PmtTest11",
|
||||
"DBS_UID" => "workflow",
|
||||
"ADD_TAB_OFFLINE" => false,
|
||||
"ADD_TAB_UPDATE_DATE" => "2019-10-22 19:53:11"
|
||||
];
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$additionalTables = new AdditionalTables();
|
||||
$additionalTables->update($expected);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
||||
|
||||
use Faker\Factory;
|
||||
use ProcessMaker\BusinessModel\Light;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LightTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* This verifies that the mobile_offline_tables_download_interval parameter
|
||||
* is defined in the result returned by the getConfiguration() method.
|
||||
*
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function it_should_return_mobile_offline_tables_download_interval_from_get_configuration_method()
|
||||
{
|
||||
$param = [
|
||||
'fileLimit' => true,
|
||||
'tz' => true,
|
||||
];
|
||||
$light = new Light();
|
||||
|
||||
/**
|
||||
* In the getConfiguration() method, the next section:
|
||||
*
|
||||
* $postMaxSize = $this->return_bytes(ini_get('post_max_size'));
|
||||
* $uploadMaxFileSize = $this->return_bytes(ini_get('upload_max_filesize'));
|
||||
* if ($postMaxSize < $uploadMaxFileSize) {
|
||||
* $uploadMaxFileSize = $postMaxSize;
|
||||
* }
|
||||
*
|
||||
* It can only be tested if you change the values of "post_max_size" and "upload_max_filesize"
|
||||
* in php.ini, you can't use the ini_set() function.
|
||||
* The mode change of these directives is "PHP_INI_PERDIR", where is entry can be
|
||||
* set in php.ini, .htaccess, httpd.conf or .user.ini, see here:
|
||||
* https://www.php.net/manual/es/ini.list.php
|
||||
* https://www.php.net/manual/en/configuration.changes.modes.php
|
||||
*/
|
||||
$result = $light->getConfiguration($param);
|
||||
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the value of mobile_offline_tables_download_interval
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function this_should_return_mobile_offline_tables_download_interval_inside_env()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$expected = 30;
|
||||
|
||||
$content = "mobile_offline_tables_download_interval = {$expected};";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$light = new Light();
|
||||
$result = $light->getConfiguration([]);
|
||||
$actual = $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the default value of mobile_offline_tables_download_interval.
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function this_should_return_default_value_if_mobile_offline_tables_download_interval_inside_env_is_not_an_integer()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$faker = $faker = Factory::create();
|
||||
$alphanumeric = $faker->regexify('[A-Za-z0-9]{20}');
|
||||
$content = "mobile_offline_tables_download_interval = '{$alphanumeric}';";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$light = new Light();
|
||||
$result = $light->getConfiguration([]);
|
||||
$expected = (string) $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertTrue(ctype_digit($expected));
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,20 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Core;
|
||||
|
||||
use G;
|
||||
use Faker\Factory;
|
||||
use ProcessMaker\Core\System;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SystemTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Define the required variables
|
||||
*/
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
$config = config('database.connections.testexternal');
|
||||
define('DB_HOST', $config['host']);
|
||||
define('DB_NAME', $config['database']);
|
||||
define('DB_USER', $config['username']);
|
||||
define('DB_PASS', $config['password']);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,6 +25,8 @@ class SystemTest extends TestCase
|
||||
*/
|
||||
public function it_should_init_laravel_configurations()
|
||||
{
|
||||
$this->markTestIncomplete("@todo: Please correct this unit test");
|
||||
|
||||
$object = new System();
|
||||
$object->initLaravel();
|
||||
|
||||
@@ -36,4 +36,112 @@ class SystemTest extends TestCase
|
||||
$this->assertEquals(DB_USER, config('database.connections.workflow.username'));
|
||||
$this->assertEquals(DB_PASS, config('database.connections.workflow.password'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return default system configuration parameters.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_default_system_configuration_parameters()
|
||||
{
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
$this->assertArrayHasKey('server_hostname_requests_frontend', $result);
|
||||
$this->assertArrayHasKey('disable_php_upload_execution', $result);
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return default system configuration parameters without workspace.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_default_system_configuration_parameters_without_workspace()
|
||||
{
|
||||
config(["system.workspace" => '']);
|
||||
putenv("REQUEST_URI=/sysworkflow");
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
$this->assertArrayHasKey('server_hostname_requests_frontend', $result);
|
||||
$this->assertArrayHasKey('disable_php_upload_execution', $result);
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return system configuration parameters defined inside env file.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_system_configuration_parameters_defined_inside_env_file()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$expected = 30;
|
||||
|
||||
$content = "mobile_offline_tables_download_interval = {$expected};";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
$actual = $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return default system configuration parameters defined inside env file when is not integer.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_default_system_configuration_parameters_defined_inside_env_file_when_is_not_an_integer()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$faker = $faker = Factory::create();
|
||||
$alphanumeric = $faker->regexify('[A-Za-z0-9]{20}');
|
||||
$content = "mobile_offline_tables_download_interval = '{$alphanumeric}';";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
$expected = (string) $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertTrue(is_numeric($expected));
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return proxy_pass defined inside env file.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_proxy_pass_defined_inside_env_file()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$faker = $faker = Factory::create();
|
||||
$content = "proxy_pass = '{$faker->password}';";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertArrayHasKey("proxy_pass", $result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Fields;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdditionalTablesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test belongs to ADD_TAB_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::columns()
|
||||
* @test
|
||||
*/
|
||||
public function it_has_a_columns_defined()
|
||||
{
|
||||
$table = factory(AdditionalTables::class)->create([
|
||||
'ADD_TAB_UID' => function () {
|
||||
return factory(Fields::class)->create()->ADD_TAB_UID;
|
||||
}
|
||||
]);
|
||||
$this->assertInstanceOf(Fields::class, $table->columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope query to get the offline tables
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::scopeOffline()
|
||||
* @test
|
||||
*/
|
||||
public function it_filter_offline_table()
|
||||
{
|
||||
factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 0]);
|
||||
$table = factory(AdditionalTables::class)->create([
|
||||
'ADD_TAB_OFFLINE' => 1
|
||||
]);
|
||||
$this->assertCount(1, $table->offline([$table->ADD_TAB_OFFLINE])->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get the structure of offline tables
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::getTablesOfflineStructure()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_structure_from_offline_tables()
|
||||
{
|
||||
factory(Fields::class)->states('foreign_keys')->create();
|
||||
$results = AdditionalTables::getTablesOfflineStructure();
|
||||
$this->assertNotEmpty($results);
|
||||
foreach ($results as $row) {
|
||||
$this->assertArrayHasKey('add_tab_uid', $row);
|
||||
$this->assertArrayHasKey('add_tab_name', $row);
|
||||
$this->assertArrayHasKey('add_tab_description', $row);
|
||||
$this->assertArrayHasKey('add_tab_class_name', $row);
|
||||
$this->assertArrayHasKey('fields', $row);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get the data of offline tables
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::getTablesOfflineData()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_data_from_offline_tables()
|
||||
{
|
||||
factory(Fields::class)->states('foreign_keys')->create();
|
||||
$results = AdditionalTables::getTablesOfflineData();
|
||||
$this->assertNotEmpty($results);
|
||||
foreach ($results as $row) {
|
||||
$this->assertArrayHasKey('add_tab_uid', $row);
|
||||
$this->assertArrayHasKey('add_tab_name', $row);
|
||||
$this->assertArrayHasKey('add_tab_description', $row);
|
||||
$this->assertArrayHasKey('add_tab_class_name', $row);
|
||||
$this->assertArrayHasKey('rows', $row);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Fields;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FieldsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test belongs to ADD_TAB_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Fields::table()
|
||||
* @test
|
||||
*/
|
||||
public function it_has_a_columns_defined()
|
||||
{
|
||||
$tableColumns = factory(Fields::class)->create([
|
||||
'ADD_TAB_UID' => function () {
|
||||
return factory(AdditionalTables::class)->create()->ADD_TAB_UID;
|
||||
}
|
||||
]);
|
||||
$this->assertInstanceOf(AdditionalTables::class, $tableColumns->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope and the query with a specific ADD_TAB_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Fields::scopeTable()
|
||||
* @covers \ProcessMaker\Model\Fields::getFields()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_fields_from_specific_table()
|
||||
{
|
||||
$fields = factory(Fields::class)->create();
|
||||
$result = Fields::getFields($fields->ADD_TAB_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
}
|
||||
@@ -1086,6 +1086,7 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_DESCRIPTION);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TYPE);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TAG);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_OFFLINE);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::PRO_UID);
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::DBS_UID);
|
||||
|
||||
|
||||
@@ -97,6 +97,10 @@ class AdditionalTablesMapBuilder
|
||||
|
||||
$tMap->addColumn('ADD_TAB_TAG', 'AddTabTag', 'string', CreoleTypes::VARCHAR, false, 256);
|
||||
|
||||
$tMap->addColumn('ADD_TAB_OFFLINE', 'AddTabOffline', 'int', CreoleTypes::TINYINT, true, null);
|
||||
|
||||
$tMap->addColumn('ADD_TAB_UPDATE_DATE', 'AddTabUpdateDate', 'int', CreoleTypes::TIMESTAMP, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // AdditionalTablesMapBuilder
|
||||
|
||||
@@ -123,6 +123,18 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
*/
|
||||
protected $add_tab_tag = '';
|
||||
|
||||
/**
|
||||
* The value for the add_tab_offline field.
|
||||
* @var int
|
||||
*/
|
||||
protected $add_tab_offline = 0;
|
||||
|
||||
/**
|
||||
* The value for the add_tab_update_date field.
|
||||
* @var int
|
||||
*/
|
||||
protected $add_tab_update_date;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -313,6 +325,49 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
return $this->add_tab_tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [add_tab_offline] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAddTabOffline()
|
||||
{
|
||||
|
||||
return $this->add_tab_offline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] [add_tab_update_date] column value.
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the integer unix timestamp will be returned.
|
||||
* @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
|
||||
* @throws PropelException - if unable to convert the date/time to timestamp.
|
||||
*/
|
||||
public function getAddTabUpdateDate($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
|
||||
if ($this->add_tab_update_date === null || $this->add_tab_update_date === '') {
|
||||
return null;
|
||||
} elseif (!is_int($this->add_tab_update_date)) {
|
||||
// a non-timestamp value was set externally, so we convert it
|
||||
$ts = strtotime($this->add_tab_update_date);
|
||||
if ($ts === -1 || $ts === false) {
|
||||
throw new PropelException("Unable to parse value of [add_tab_update_date] as date/time value: " .
|
||||
var_export($this->add_tab_update_date, true));
|
||||
}
|
||||
} else {
|
||||
$ts = $this->add_tab_update_date;
|
||||
}
|
||||
if ($format === null) {
|
||||
return $ts;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $ts);
|
||||
} else {
|
||||
return date($format, $ts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [add_tab_uid] column.
|
||||
*
|
||||
@@ -665,6 +720,57 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
|
||||
} // setAddTabTag()
|
||||
|
||||
/**
|
||||
* Set the value of [add_tab_offline] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAddTabOffline($v)
|
||||
{
|
||||
|
||||
// Since the native PHP type for this column is integer,
|
||||
// we will cast the input value to an int (if it is not).
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->add_tab_offline !== $v || $v === 0) {
|
||||
$this->add_tab_offline = $v;
|
||||
$this->modifiedColumns[] = AdditionalTablesPeer::ADD_TAB_OFFLINE;
|
||||
}
|
||||
|
||||
} // setAddTabOffline()
|
||||
|
||||
/**
|
||||
* Set the value of [add_tab_update_date] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAddTabUpdateDate($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v)) {
|
||||
$ts = strtotime($v);
|
||||
//Date/time accepts null values
|
||||
if ($v == '') {
|
||||
$ts = null;
|
||||
}
|
||||
if ($ts === -1 || $ts === false) {
|
||||
throw new PropelException("Unable to parse date/time value for [add_tab_update_date] from input: " .
|
||||
var_export($v, true));
|
||||
}
|
||||
} else {
|
||||
$ts = $v;
|
||||
}
|
||||
if ($this->add_tab_update_date !== $ts) {
|
||||
$this->add_tab_update_date = $ts;
|
||||
$this->modifiedColumns[] = AdditionalTablesPeer::ADD_TAB_UPDATE_DATE;
|
||||
}
|
||||
|
||||
} // setAddTabUpdateDate()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
@@ -714,12 +820,16 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
|
||||
$this->add_tab_tag = $rs->getString($startcol + 15);
|
||||
|
||||
$this->add_tab_offline = $rs->getInt($startcol + 16);
|
||||
|
||||
$this->add_tab_update_date = $rs->getTimestamp($startcol + 17, null);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 16; // 16 = AdditionalTablesPeer::NUM_COLUMNS - AdditionalTablesPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 18; // 18 = AdditionalTablesPeer::NUM_COLUMNS - AdditionalTablesPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating AdditionalTables object", $e);
|
||||
@@ -971,6 +1081,12 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
case 15:
|
||||
return $this->getAddTabTag();
|
||||
break;
|
||||
case 16:
|
||||
return $this->getAddTabOffline();
|
||||
break;
|
||||
case 17:
|
||||
return $this->getAddTabUpdateDate();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
@@ -1007,6 +1123,8 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
$keys[13] => $this->getAddTabType(),
|
||||
$keys[14] => $this->getAddTabGrid(),
|
||||
$keys[15] => $this->getAddTabTag(),
|
||||
$keys[16] => $this->getAddTabOffline(),
|
||||
$keys[17] => $this->getAddTabUpdateDate(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
@@ -1086,6 +1204,12 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
case 15:
|
||||
$this->setAddTabTag($value);
|
||||
break;
|
||||
case 16:
|
||||
$this->setAddTabOffline($value);
|
||||
break;
|
||||
case 17:
|
||||
$this->setAddTabUpdateDate($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
@@ -1173,6 +1297,14 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
$this->setAddTabTag($arr[$keys[15]]);
|
||||
}
|
||||
|
||||
if (array_key_exists($keys[16], $arr)) {
|
||||
$this->setAddTabOffline($arr[$keys[16]]);
|
||||
}
|
||||
|
||||
if (array_key_exists($keys[17], $arr)) {
|
||||
$this->setAddTabUpdateDate($arr[$keys[17]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1248,6 +1380,14 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
$criteria->add(AdditionalTablesPeer::ADD_TAB_TAG, $this->add_tab_tag);
|
||||
}
|
||||
|
||||
if ($this->isColumnModified(AdditionalTablesPeer::ADD_TAB_OFFLINE)) {
|
||||
$criteria->add(AdditionalTablesPeer::ADD_TAB_OFFLINE, $this->add_tab_offline);
|
||||
}
|
||||
|
||||
if ($this->isColumnModified(AdditionalTablesPeer::ADD_TAB_UPDATE_DATE)) {
|
||||
$criteria->add(AdditionalTablesPeer::ADD_TAB_UPDATE_DATE, $this->add_tab_update_date);
|
||||
}
|
||||
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
@@ -1332,6 +1472,10 @@ abstract class BaseAdditionalTables extends BaseObject implements Persistent
|
||||
|
||||
$copyObj->setAddTabTag($this->add_tab_tag);
|
||||
|
||||
$copyObj->setAddTabOffline($this->add_tab_offline);
|
||||
|
||||
$copyObj->setAddTabUpdateDate($this->add_tab_update_date);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class BaseAdditionalTablesPeer
|
||||
const CLASS_DEFAULT = 'classes.model.AdditionalTables';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 16;
|
||||
const NUM_COLUMNS = 18;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
@@ -79,6 +79,12 @@ abstract class BaseAdditionalTablesPeer
|
||||
/** the column name for the ADD_TAB_TAG field */
|
||||
const ADD_TAB_TAG = 'ADDITIONAL_TABLES.ADD_TAB_TAG';
|
||||
|
||||
/** the column name for the ADD_TAB_OFFLINE field */
|
||||
const ADD_TAB_OFFLINE = 'ADDITIONAL_TABLES.ADD_TAB_OFFLINE';
|
||||
|
||||
/** the column name for the ADD_TAB_UPDATE_DATE field */
|
||||
const ADD_TAB_UPDATE_DATE = 'ADDITIONAL_TABLES.ADD_TAB_UPDATE_DATE';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
@@ -90,10 +96,10 @@ abstract class BaseAdditionalTablesPeer
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('AddTabUid', 'AddTabName', 'AddTabClassName', 'AddTabDescription', 'AddTabSdwLogInsert', 'AddTabSdwLogUpdate', 'AddTabSdwLogDelete', 'AddTabSdwLogSelect', 'AddTabSdwMaxLength', 'AddTabSdwAutoDelete', 'AddTabPlgUid', 'DbsUid', 'ProUid', 'AddTabType', 'AddTabGrid', 'AddTabTag', ),
|
||||
BasePeer::TYPE_COLNAME => array (AdditionalTablesPeer::ADD_TAB_UID, AdditionalTablesPeer::ADD_TAB_NAME, AdditionalTablesPeer::ADD_TAB_CLASS_NAME, AdditionalTablesPeer::ADD_TAB_DESCRIPTION, AdditionalTablesPeer::ADD_TAB_SDW_LOG_INSERT, AdditionalTablesPeer::ADD_TAB_SDW_LOG_UPDATE, AdditionalTablesPeer::ADD_TAB_SDW_LOG_DELETE, AdditionalTablesPeer::ADD_TAB_SDW_LOG_SELECT, AdditionalTablesPeer::ADD_TAB_SDW_MAX_LENGTH, AdditionalTablesPeer::ADD_TAB_SDW_AUTO_DELETE, AdditionalTablesPeer::ADD_TAB_PLG_UID, AdditionalTablesPeer::DBS_UID, AdditionalTablesPeer::PRO_UID, AdditionalTablesPeer::ADD_TAB_TYPE, AdditionalTablesPeer::ADD_TAB_GRID, AdditionalTablesPeer::ADD_TAB_TAG, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('ADD_TAB_UID', 'ADD_TAB_NAME', 'ADD_TAB_CLASS_NAME', 'ADD_TAB_DESCRIPTION', 'ADD_TAB_SDW_LOG_INSERT', 'ADD_TAB_SDW_LOG_UPDATE', 'ADD_TAB_SDW_LOG_DELETE', 'ADD_TAB_SDW_LOG_SELECT', 'ADD_TAB_SDW_MAX_LENGTH', 'ADD_TAB_SDW_AUTO_DELETE', 'ADD_TAB_PLG_UID', 'DBS_UID', 'PRO_UID', 'ADD_TAB_TYPE', 'ADD_TAB_GRID', 'ADD_TAB_TAG', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
|
||||
BasePeer::TYPE_PHPNAME => array ('AddTabUid', 'AddTabName', 'AddTabClassName', 'AddTabDescription', 'AddTabSdwLogInsert', 'AddTabSdwLogUpdate', 'AddTabSdwLogDelete', 'AddTabSdwLogSelect', 'AddTabSdwMaxLength', 'AddTabSdwAutoDelete', 'AddTabPlgUid', 'DbsUid', 'ProUid', 'AddTabType', 'AddTabGrid', 'AddTabTag', 'AddTabOffline', 'AddTabUpdateDate', ),
|
||||
BasePeer::TYPE_COLNAME => array (AdditionalTablesPeer::ADD_TAB_UID, AdditionalTablesPeer::ADD_TAB_NAME, AdditionalTablesPeer::ADD_TAB_CLASS_NAME, AdditionalTablesPeer::ADD_TAB_DESCRIPTION, AdditionalTablesPeer::ADD_TAB_SDW_LOG_INSERT, AdditionalTablesPeer::ADD_TAB_SDW_LOG_UPDATE, AdditionalTablesPeer::ADD_TAB_SDW_LOG_DELETE, AdditionalTablesPeer::ADD_TAB_SDW_LOG_SELECT, AdditionalTablesPeer::ADD_TAB_SDW_MAX_LENGTH, AdditionalTablesPeer::ADD_TAB_SDW_AUTO_DELETE, AdditionalTablesPeer::ADD_TAB_PLG_UID, AdditionalTablesPeer::DBS_UID, AdditionalTablesPeer::PRO_UID, AdditionalTablesPeer::ADD_TAB_TYPE, AdditionalTablesPeer::ADD_TAB_GRID, AdditionalTablesPeer::ADD_TAB_TAG, AdditionalTablesPeer::ADD_TAB_OFFLINE, AdditionalTablesPeer::ADD_TAB_UPDATE_DATE, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('ADD_TAB_UID', 'ADD_TAB_NAME', 'ADD_TAB_CLASS_NAME', 'ADD_TAB_DESCRIPTION', 'ADD_TAB_SDW_LOG_INSERT', 'ADD_TAB_SDW_LOG_UPDATE', 'ADD_TAB_SDW_LOG_DELETE', 'ADD_TAB_SDW_LOG_SELECT', 'ADD_TAB_SDW_MAX_LENGTH', 'ADD_TAB_SDW_AUTO_DELETE', 'ADD_TAB_PLG_UID', 'DBS_UID', 'PRO_UID', 'ADD_TAB_TYPE', 'ADD_TAB_GRID', 'ADD_TAB_TAG', 'ADD_TAB_OFFLINE', 'ADD_TAB_UPDATE_DATE', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -103,10 +109,10 @@ abstract class BaseAdditionalTablesPeer
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('AddTabUid' => 0, 'AddTabName' => 1, 'AddTabClassName' => 2, 'AddTabDescription' => 3, 'AddTabSdwLogInsert' => 4, 'AddTabSdwLogUpdate' => 5, 'AddTabSdwLogDelete' => 6, 'AddTabSdwLogSelect' => 7, 'AddTabSdwMaxLength' => 8, 'AddTabSdwAutoDelete' => 9, 'AddTabPlgUid' => 10, 'DbsUid' => 11, 'ProUid' => 12, 'AddTabType' => 13, 'AddTabGrid' => 14, 'AddTabTag' => 15, ),
|
||||
BasePeer::TYPE_COLNAME => array (AdditionalTablesPeer::ADD_TAB_UID => 0, AdditionalTablesPeer::ADD_TAB_NAME => 1, AdditionalTablesPeer::ADD_TAB_CLASS_NAME => 2, AdditionalTablesPeer::ADD_TAB_DESCRIPTION => 3, AdditionalTablesPeer::ADD_TAB_SDW_LOG_INSERT => 4, AdditionalTablesPeer::ADD_TAB_SDW_LOG_UPDATE => 5, AdditionalTablesPeer::ADD_TAB_SDW_LOG_DELETE => 6, AdditionalTablesPeer::ADD_TAB_SDW_LOG_SELECT => 7, AdditionalTablesPeer::ADD_TAB_SDW_MAX_LENGTH => 8, AdditionalTablesPeer::ADD_TAB_SDW_AUTO_DELETE => 9, AdditionalTablesPeer::ADD_TAB_PLG_UID => 10, AdditionalTablesPeer::DBS_UID => 11, AdditionalTablesPeer::PRO_UID => 12, AdditionalTablesPeer::ADD_TAB_TYPE => 13, AdditionalTablesPeer::ADD_TAB_GRID => 14, AdditionalTablesPeer::ADD_TAB_TAG => 15, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('ADD_TAB_UID' => 0, 'ADD_TAB_NAME' => 1, 'ADD_TAB_CLASS_NAME' => 2, 'ADD_TAB_DESCRIPTION' => 3, 'ADD_TAB_SDW_LOG_INSERT' => 4, 'ADD_TAB_SDW_LOG_UPDATE' => 5, 'ADD_TAB_SDW_LOG_DELETE' => 6, 'ADD_TAB_SDW_LOG_SELECT' => 7, 'ADD_TAB_SDW_MAX_LENGTH' => 8, 'ADD_TAB_SDW_AUTO_DELETE' => 9, 'ADD_TAB_PLG_UID' => 10, 'DBS_UID' => 11, 'PRO_UID' => 12, 'ADD_TAB_TYPE' => 13, 'ADD_TAB_GRID' => 14, 'ADD_TAB_TAG' => 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 ('AddTabUid' => 0, 'AddTabName' => 1, 'AddTabClassName' => 2, 'AddTabDescription' => 3, 'AddTabSdwLogInsert' => 4, 'AddTabSdwLogUpdate' => 5, 'AddTabSdwLogDelete' => 6, 'AddTabSdwLogSelect' => 7, 'AddTabSdwMaxLength' => 8, 'AddTabSdwAutoDelete' => 9, 'AddTabPlgUid' => 10, 'DbsUid' => 11, 'ProUid' => 12, 'AddTabType' => 13, 'AddTabGrid' => 14, 'AddTabTag' => 15, 'AddTabOffline' => 16, 'AddTabUpdateDate' => 17, ),
|
||||
BasePeer::TYPE_COLNAME => array (AdditionalTablesPeer::ADD_TAB_UID => 0, AdditionalTablesPeer::ADD_TAB_NAME => 1, AdditionalTablesPeer::ADD_TAB_CLASS_NAME => 2, AdditionalTablesPeer::ADD_TAB_DESCRIPTION => 3, AdditionalTablesPeer::ADD_TAB_SDW_LOG_INSERT => 4, AdditionalTablesPeer::ADD_TAB_SDW_LOG_UPDATE => 5, AdditionalTablesPeer::ADD_TAB_SDW_LOG_DELETE => 6, AdditionalTablesPeer::ADD_TAB_SDW_LOG_SELECT => 7, AdditionalTablesPeer::ADD_TAB_SDW_MAX_LENGTH => 8, AdditionalTablesPeer::ADD_TAB_SDW_AUTO_DELETE => 9, AdditionalTablesPeer::ADD_TAB_PLG_UID => 10, AdditionalTablesPeer::DBS_UID => 11, AdditionalTablesPeer::PRO_UID => 12, AdditionalTablesPeer::ADD_TAB_TYPE => 13, AdditionalTablesPeer::ADD_TAB_GRID => 14, AdditionalTablesPeer::ADD_TAB_TAG => 15, AdditionalTablesPeer::ADD_TAB_OFFLINE => 16, AdditionalTablesPeer::ADD_TAB_UPDATE_DATE => 17, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('ADD_TAB_UID' => 0, 'ADD_TAB_NAME' => 1, 'ADD_TAB_CLASS_NAME' => 2, 'ADD_TAB_DESCRIPTION' => 3, 'ADD_TAB_SDW_LOG_INSERT' => 4, 'ADD_TAB_SDW_LOG_UPDATE' => 5, 'ADD_TAB_SDW_LOG_DELETE' => 6, 'ADD_TAB_SDW_LOG_SELECT' => 7, 'ADD_TAB_SDW_MAX_LENGTH' => 8, 'ADD_TAB_SDW_AUTO_DELETE' => 9, 'ADD_TAB_PLG_UID' => 10, 'DBS_UID' => 11, 'PRO_UID' => 12, 'ADD_TAB_TYPE' => 13, 'ADD_TAB_GRID' => 14, 'ADD_TAB_TAG' => 15, 'ADD_TAB_OFFLINE' => 16, 'ADD_TAB_UPDATE_DATE' => 17, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -239,6 +245,10 @@ abstract class BaseAdditionalTablesPeer
|
||||
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_TAG);
|
||||
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_OFFLINE);
|
||||
|
||||
$criteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UPDATE_DATE);
|
||||
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(ADDITIONAL_TABLES.ADD_TAB_UID)';
|
||||
|
||||
@@ -2522,6 +2522,8 @@
|
||||
<column name="ADD_TAB_TYPE" type="VARCHAR" size="32" required="false" default=""/>
|
||||
<column name="ADD_TAB_GRID" type="VARCHAR" size="256" required="false" default=""/>
|
||||
<column name="ADD_TAB_TAG" type="VARCHAR" size="256" required="false" default=""/>
|
||||
<column name="ADD_TAB_OFFLINE" type="TINYINT" required="true" default="0"/>
|
||||
<column name="ADD_TAB_UPDATE_DATE" type="TIMESTAMP" required="true"/>
|
||||
<index name="indexAdditionalProcess">
|
||||
<index-column name="PRO_UID"/>
|
||||
</index>
|
||||
|
||||
@@ -2755,6 +2755,18 @@ msgstr "AVAILABLE GROUPS"
|
||||
msgid "AVAILABLE MEMBERS"
|
||||
msgstr "AVAILABLE MEMBERS"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_AVAILABLE_OFFLINE
|
||||
#: LABEL/ID_AVAILABLE_OFFLINE
|
||||
msgid "Available offline"
|
||||
msgstr "Available offline"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_AVAILABLE_OFFLINE_THE_MOBILE_APPLICATIONS
|
||||
#: LABEL/ID_AVAILABLE_OFFLINE_THE_MOBILE_APPLICATIONS
|
||||
msgid "Available offline, the mobile applications will download this table for offline use"
|
||||
msgstr "Available offline, the mobile applications will download this table for offline use"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_AVAILABLE_PERMISSIONS
|
||||
#: LABEL/ID_AVAILABLE_PERMISSIONS
|
||||
@@ -20075,6 +20087,24 @@ msgstr "User has been updated successfully"
|
||||
msgid "Off"
|
||||
msgstr "Off"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_OFFLINE_TABLES
|
||||
#: LABEL/ID_OFFLINE_TABLES
|
||||
msgid "Offline Tables"
|
||||
msgstr "Offline Tables"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_OFFLINE_TABLES_ENABLE
|
||||
#: LABEL/ID_OFFLINE_TABLES_ENABLE
|
||||
msgid "Set Offline"
|
||||
msgstr "Set Offline"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_OFFLINE_TABLES_DISABLE
|
||||
#: LABEL/ID_OFFLINE_TABLES_DISABLE
|
||||
msgid "Set Online"
|
||||
msgstr "Set Online"
|
||||
|
||||
# TRANSLATION
|
||||
# LABEL/ID_OF_THE_MONTH
|
||||
#: LABEL/ID_OF_THE_MONTH
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Model\AdditionalTables as AdditionalTablesModel;
|
||||
use ProcessMaker\Validation\ExceptionRestApi;
|
||||
use ProcessMaker\Validation\ValidationUploadedFiles;
|
||||
|
||||
@@ -218,6 +219,34 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the offline property.
|
||||
* @param stdClass $httpData
|
||||
* @return stdClass
|
||||
*/
|
||||
public function updateOffline(stdClass $httpData): stdClass
|
||||
{
|
||||
$result = new stdClass();
|
||||
try {
|
||||
$array = G::json_decode(stripslashes($httpData->rows));
|
||||
$data = [];
|
||||
$enable = false;
|
||||
foreach ($array as $value) {
|
||||
if ($value->type !== "NORMAL") {
|
||||
$data[] = $value->id;
|
||||
$enable = $value->offline ? 1 : 0;
|
||||
}
|
||||
}
|
||||
AdditionalTablesModel::updatePropertyOffline($data, $enable);
|
||||
$result->success = true;
|
||||
$result->message = $enable ? G::LoadTranslation("ID_ENABLE") : G::LoadTranslation("ID_DISABLE");
|
||||
} catch (Exception $e) {
|
||||
$result->success = false;
|
||||
$result->message = $e->getMessage();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete pm table
|
||||
*
|
||||
|
||||
@@ -57261,6 +57261,8 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_AVAILABLE_FIELDS','en','Available Fields','2014-01-15') ,
|
||||
( 'LABEL','ID_AVAILABLE_GROUPS','en','AVAILABLE GROUPS','2014-01-15') ,
|
||||
( 'LABEL','ID_AVAILABLE_MEMBERS','en','AVAILABLE MEMBERS','2014-01-15') ,
|
||||
( 'LABEL','ID_AVAILABLE_OFFLINE','en','Available offline','2019-10-15') ,
|
||||
( 'LABEL','ID_AVAILABLE_OFFLINE_THE_MOBILE_APPLICATIONS','en','Available offline, the mobile applications will download this table for offline use','2019-10-15') ,
|
||||
( 'LABEL','ID_AVAILABLE_PERMISSIONS','en','AVAILABLE PERMISSIONS','2014-01-15') ,
|
||||
( 'LABEL','ID_AVAILABLE_TRIGGERS','en','Available Triggers','2014-01-15') ,
|
||||
( 'LABEL','ID_AVAILABLE_USERS','en','AVAILABLE USERS','2014-01-15') ,
|
||||
@@ -60214,6 +60216,9 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
|
||||
( 'LABEL','ID_OBJECT_REMOVE','en','Object has been removed successfully','2014-01-15') ,
|
||||
( 'LABEL','ID_OBJECT_UPDATE','en','User has been updated successfully','2014-01-15') ,
|
||||
( 'LABEL','ID_OFF','en','Off','2014-01-15') ,
|
||||
( 'LABEL','ID_OFFLINE_TABLES','en','Offline Tables','2019-12-19') ,
|
||||
( 'LABEL','ID_OFFLINE_TABLES_ENABLE','en','Set Offline Tables','2019-12-19') ,
|
||||
( 'LABEL','ID_OFFLINE_TABLES_DISABLE','en','Set Online Tables','2019-12-19') ,
|
||||
( 'LABEL','ID_OF_THE_MONTH','en','of the month(s)','2014-01-15') ,
|
||||
( 'LABEL','ID_OK','en','Ok','2015-09-17') ,
|
||||
( 'LABEL','ID_OLD_VERSION','en','old version','2014-01-15') ,
|
||||
|
||||
@@ -1162,6 +1162,8 @@ CREATE TABLE `ADDITIONAL_TABLES`
|
||||
`ADD_TAB_TYPE` VARCHAR(32) default '',
|
||||
`ADD_TAB_GRID` VARCHAR(256) default '',
|
||||
`ADD_TAB_TAG` VARCHAR(256) default '',
|
||||
`ADD_TAB_OFFLINE` TINYINT default 0 NOT NULL,
|
||||
`ADD_TAB_UPDATE_DATE` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`ADD_TAB_UID`),
|
||||
KEY `indexAdditionalProcess`(`PRO_UID`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET='utf8';
|
||||
|
||||
@@ -696,9 +696,8 @@ class Light
|
||||
$sAppDocUid = $oAppDocument->getAppDocUid();
|
||||
$iDocVersion = $oAppDocument->getDocVersion();
|
||||
$info = pathinfo($oAppDocument->getAppDocFilename());
|
||||
$ext = (isset($info['extension']) ? $info['extension'] : '');//BUG fix: must handle files without any extension
|
||||
$ext = (isset($info['extension']) ? $info['extension'] : ''); //BUG fix: must handle files without any extension
|
||||
|
||||
//$app_uid = G::getPathFromUID($oAppDocument->Fields['APP_UID']);
|
||||
$file = G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
|
||||
|
||||
$realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
|
||||
@@ -1358,12 +1357,14 @@ class Light
|
||||
*/
|
||||
public function getConfiguration($params)
|
||||
{
|
||||
$response = [];
|
||||
|
||||
$sysConf = Bootstrap::getSystemConfiguration('', '', config("system.workspace"));
|
||||
$multiTimeZone = false;
|
||||
//Set Time Zone
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (\PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
||||
$multiTimeZone = (int)($sysConf['system_utc_time_zone']) == 1;
|
||||
$multiTimeZone = (int) ($sysConf['system_utc_time_zone']) == 1;
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$tz = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
|
||||
@@ -1423,6 +1424,8 @@ class Light
|
||||
$response['tz'] = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
|
||||
}
|
||||
|
||||
$response['mobile_offline_tables_download_interval'] = $sysConf['mobile_offline_tables_download_interval'];
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -1431,13 +1434,13 @@ class Light
|
||||
switch (substr($size_str, -1)) {
|
||||
case 'M':
|
||||
case 'm':
|
||||
return (int)$size_str * 1048576;
|
||||
return (int) $size_str * 1048576;
|
||||
case 'K':
|
||||
case 'k':
|
||||
return (int)$size_str * 1024;
|
||||
return (int) $size_str * 1024;
|
||||
case 'G':
|
||||
case 'g':
|
||||
return (int)$size_str * 1073741824;
|
||||
return (int) $size_str * 1073741824;
|
||||
default:
|
||||
return $size_str;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,9 @@ class ReportTable
|
||||
'DBS_UID' => ($arrayData['REP_TAB_CONNECTION']) ? $arrayData['REP_TAB_CONNECTION'] : 'workflow',
|
||||
'PRO_UID' => $arrayData['PRO_UID'],
|
||||
'ADD_TAB_TYPE' => $arrayData['REP_TAB_TYPE'],
|
||||
'ADD_TAB_GRID' => $arrayData['REP_TAB_GRID']
|
||||
'ADD_TAB_GRID' => $arrayData['REP_TAB_GRID'],
|
||||
'ADD_TAB_OFFLINE' => !empty($arrayData['REP_TAB_OFFLINE']) ?? 0,
|
||||
'ADD_TAB_UPDATE_DATE' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
if ($arrayData['REP_TAB_UID'] == '' || (isset($arrayData['forceUid']) && $arrayData['forceUid'])) {
|
||||
@@ -806,6 +808,8 @@ class ReportTable
|
||||
$tableData->REP_TAB_CONNECTION = $contentSchema['DBS_UID'];
|
||||
$tableData->REP_TAB_TYPE = (isset($contentSchema['ADD_TAB_TYPE'])) ? $contentSchema['ADD_TAB_TYPE'] : '';
|
||||
$tableData->REP_TAB_GRID = (isset($contentSchema['ADD_TAB_GRID'])) ? $contentSchema['ADD_TAB_GRID'] : '';
|
||||
$tableData->REP_TAB_OFFLINE = (isset($contentSchema['ADD_TAB_OFFLINE'])) ? $contentSchema['ADD_TAB_OFFLINE'] : '0';
|
||||
$tableData->REP_TAB_UPDATE_DATE = date('Y-m-d H:i:s');
|
||||
$tableData->columns = G::json_encode($columns);
|
||||
$tableData->forceUid = true;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class Table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTables($pro_uid = '', $reportFlag = false)
|
||||
public function getTables($pro_uid = '', $reportFlag = false, $offline = false)
|
||||
{
|
||||
//VALIDATION
|
||||
if ($reportFlag) {
|
||||
@@ -87,6 +87,7 @@ class Table
|
||||
$tabData['PMT_UID'] = $tab_uid;
|
||||
$tabData['PMT_TAB_NAME'] = $table['ADD_TAB_NAME'];
|
||||
$tabData['PMT_TAB_DESCRIPTION'] = $table['ADD_TAB_DESCRIPTION'];
|
||||
$tabData['PMT_TAB_OFFLINE'] = $table['ADD_TAB_OFFLINE'];
|
||||
$tabData['PMT_TAB_CLASS_NAME'] = $table['ADD_TAB_CLASS_NAME'];
|
||||
$tabData['PMT_NUM_ROWS'] = $tableData['count'];
|
||||
}
|
||||
@@ -384,6 +385,8 @@ class Table
|
||||
'ADD_TAB_NAME' => $dataValidate['REP_TAB_NAME'],
|
||||
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||||
'ADD_TAB_DESCRIPTION' => $dataValidate['REP_TAB_DSC'],
|
||||
'ADD_TAB_OFFLINE' => 0,
|
||||
'ADD_TAB_UPDATE_DATE' => date('Y-m-d H:i:s'),
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => ($dataValidate['REP_TAB_CONNECTION'] ? $dataValidate['REP_TAB_CONNECTION'] : 'workflow'),
|
||||
'PRO_UID' => $dataValidate['PRO_UID'],
|
||||
@@ -396,6 +399,8 @@ class Table
|
||||
'ADD_TAB_NAME' => $dataValidate['PMT_TAB_NAME'],
|
||||
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||||
'ADD_TAB_DESCRIPTION' => $dataValidate['PMT_TAB_DSC'],
|
||||
'ADD_TAB_OFFLINE' => !empty($dataValidate['PMT_TAB_OFFLINE']) ?? 0,
|
||||
'ADD_TAB_UPDATE_DATE' => date('Y-m-d H:i:s'),
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => ($dataValidate['PMT_TAB_CONNECTION'] ? $dataValidate['PMT_TAB_CONNECTION'] : 'workflow'),
|
||||
'PRO_UID' => '',
|
||||
@@ -549,6 +554,11 @@ class Table
|
||||
$dataValidate['rep_tab_dsc'] = $tableData['pmt_tab_dsc'];
|
||||
$tableDsc = true;
|
||||
}
|
||||
if (!empty($tableData['pmt_tab_offline'])) {
|
||||
$dataValidate['rep_tab_offline'] = $tableData['pmt_tab_offline'];
|
||||
$tableDsc = true;
|
||||
}
|
||||
$dataValidate['rep_tab_update_date'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
if (!empty($tableData['fields'])) {
|
||||
$dataValidate['fields'] = $tableData['fields'];
|
||||
|
||||
@@ -73,7 +73,8 @@ class System
|
||||
'files_white_list' => '',
|
||||
'delay' => '0',
|
||||
'tries' => '10',
|
||||
'retry_after' => '90'
|
||||
'retry_after' => '90',
|
||||
'mobile_offline_tables_download_interval' => 24
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -1203,6 +1204,15 @@ class System
|
||||
$config['proxy_pass'] = G::decrypt($config['proxy_pass'], 'proxy_pass');
|
||||
}
|
||||
|
||||
/**
|
||||
* Here if you validate if the type of data obtained from the configuration
|
||||
* files are valid, otherwise the default value is used.
|
||||
*/
|
||||
$value = (string) $config['mobile_offline_tables_download_interval'];
|
||||
if (!is_numeric($value)) {
|
||||
$config['mobile_offline_tables_download_interval'] = self::$defaultConfig['mobile_offline_tables_download_interval'];
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
105
workflow/engine/src/ProcessMaker/Model/AdditionalTables.php
Normal file
105
workflow/engine/src/ProcessMaker/Model/AdditionalTables.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use AdditionalTables as ModelAdditionalTables;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AdditionalTables extends Model
|
||||
{
|
||||
protected $table = 'ADDITIONAL_TABLES';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the fields related to the table belongs to
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return $this->belongsTo(Fields::class, 'ADD_TAB_UID', 'ADD_TAB_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the offline tables
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeOffline($query)
|
||||
{
|
||||
return $query->where('ADD_TAB_OFFLINE', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure of offline tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTablesOfflineStructure()
|
||||
{
|
||||
$query = AdditionalTables::query()->select([
|
||||
'ADD_TAB_UID',
|
||||
'ADD_TAB_NAME',
|
||||
'ADD_TAB_DESCRIPTION',
|
||||
'ADD_TAB_CLASS_NAME'
|
||||
]);
|
||||
$query->offline();
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
$data[$key]['fields'] = Fields::getFields($item->ADD_TAB_UID);
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of offline tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTablesOfflineData()
|
||||
{
|
||||
$query = AdditionalTables::query()->select([
|
||||
'ADD_TAB_UID',
|
||||
'ADD_TAB_NAME',
|
||||
'ADD_TAB_DESCRIPTION',
|
||||
'ADD_TAB_CLASS_NAME'
|
||||
]);
|
||||
$query->offline();
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
|
||||
$additionalTables = new ModelAdditionalTables();
|
||||
$result = $additionalTables->getAllData($item->ADD_TAB_UID);
|
||||
if (empty($result['rows'])) {
|
||||
$data[$key]['rows'] = [];
|
||||
} else {
|
||||
foreach ($result['rows'] as $i => $row) {
|
||||
$data[$key]['rows'][$i] = $row;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the offline property.
|
||||
* @param array $tablesUid
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public static function updatePropertyOffline(array $tablesUid, $value): void
|
||||
{
|
||||
$query = AdditionalTables::whereIn('ADD_TAB_UID', $tablesUid)
|
||||
->update(['ADD_TAB_OFFLINE' => $value]);
|
||||
}
|
||||
}
|
||||
55
workflow/engine/src/ProcessMaker/Model/Fields.php
Normal file
55
workflow/engine/src/ProcessMaker/Model/Fields.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fields extends Model
|
||||
{
|
||||
protected $table = 'FIELDS';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the fields related to the table belongs to
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
return $this->belongsTo(AdditionalTables::class, 'ADD_TAB_UID', 'ADD_TAB_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the offline tables
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $tabUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTable($query, $tabUid)
|
||||
{
|
||||
return $query->where('ADD_TAB_UID', '=', $tabUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offline tables
|
||||
*
|
||||
* @param string $tabUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFields($tabUid)
|
||||
{
|
||||
$query = Fields::query();
|
||||
$query->table($tabUid);
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\Table as BusinessModelTable;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
@@ -14,85 +16,137 @@ use ProcessMaker\Services\Api;
|
||||
class Pmtable extends Api
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* Get a list of the PM tables in the workspace. It does not include any Report Table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @url GET
|
||||
* @status 200
|
||||
*
|
||||
* @param boolean $offline {@from path}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url GET
|
||||
* @class AccessControl {@permission PM_LOGIN}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#PM_Tables_List:_GET_.2Fpmtable
|
||||
*/
|
||||
public function doGetPmTables()
|
||||
public function doGetPmTables($offline = false)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$response = $oPmTable->getTables();
|
||||
if ($offline) {
|
||||
$response = AdditionalTables::getTablesOfflineStructure();
|
||||
} else {
|
||||
$pmTable = new BusinessModelTable();
|
||||
$response = $pmTable->getTables();
|
||||
}
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* Get the data of the offline PM tables
|
||||
*
|
||||
* @url GET /offline/data
|
||||
* @status 200
|
||||
*
|
||||
* @param boolean $compress {@from path}
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @class AccessControl {@permission PM_LOGIN}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#PM_Tables_List:_GET_.2Fpmtable
|
||||
*/
|
||||
public function doGetPmTablesDataOffline($compress = true)
|
||||
{
|
||||
try {
|
||||
$data = AdditionalTables::getTablesOfflineData();
|
||||
if ($compress) {
|
||||
$json = json_encode($data);
|
||||
$compressed = gzcompress($json, 5);
|
||||
echo $compressed;
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure from a specific PM Table, including a list of its fields and their properties.
|
||||
*
|
||||
* @url GET /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#Get_PM_Table_Structure:_GET_.2Fpmtable.2F.7Bpmt_uid.7D
|
||||
*/
|
||||
public function doGetPmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oPmTable = new BusinessModelTable();
|
||||
$response = $oPmTable->getTable($pmt_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data from a PM table
|
||||
*
|
||||
* @url GET /:pmt_uid/data
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param string $filter
|
||||
* @param string $q
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url GET /:pmt_uid/data
|
||||
*
|
||||
*/
|
||||
public function doGetPmTableData($pmt_uid, $filter = null, $q = "")
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oPmTable = new BusinessModelTable();
|
||||
$response = $oPmTable->getTableData($pmt_uid, null, $filter, false, $q);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PM Table
|
||||
*
|
||||
* @url POST
|
||||
* @status 201
|
||||
*
|
||||
* @param array $request_data
|
||||
* @param string $pmt_tab_name {@from body}
|
||||
* @param string $pmt_tab_dsc {@from body}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url POST
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostPmTable(
|
||||
$request_data,
|
||||
@@ -100,58 +154,58 @@ class Pmtable extends Api
|
||||
$pmt_tab_dsc = ''
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->saveTable($request_data);
|
||||
if (isset($response['pro_uid'])) {
|
||||
unset($response['pro_uid']);
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* Add a new record to a PM Table
|
||||
*
|
||||
* @param array $request_data
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url POST /:pmt_uid/data
|
||||
* @status 201
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
*/
|
||||
public function doPostPmTableData(
|
||||
$pmt_uid,
|
||||
$request_data
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->saveTableData($pmt_uid, $request_data);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pm-table.
|
||||
* Update the structure of a PM table.
|
||||
*
|
||||
* @url PUT /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @return void
|
||||
* @throw RestException
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @throws RestException
|
||||
*/
|
||||
public function doPutPmTable(
|
||||
$pmt_uid,
|
||||
@@ -167,9 +221,10 @@ class Pmtable extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pm-table data.
|
||||
* Update the data of an existing record in a PM table.
|
||||
*
|
||||
* @url PUT /:pmt_uid/data
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
@@ -185,37 +240,47 @@ class Pmtable extends Api
|
||||
$request_data
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->updateTableData($pmt_uid, $request_data);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specified PM table and all its data.
|
||||
*
|
||||
* @url DELETE /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url DELETE /:pmt_uid
|
||||
*/
|
||||
public function doDeletePmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->deleteTable($pmt_uid);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a record from a PM table, by specifying its primary key(s). The PM Table can have up to 3 primary key
|
||||
* fields.
|
||||
*
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2/:key3/:value3
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param string $key1 {@min 1}
|
||||
* @param string $value1 {@min 1}
|
||||
@@ -225,15 +290,10 @@ class Pmtable extends Api
|
||||
* @param string $value3
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2/:key3/:value3
|
||||
*/
|
||||
public function doDeletePmTableData($pmt_uid, $key1, $value1, $key2 = '', $value2 = '', $key3 = '', $value3 = '')
|
||||
{
|
||||
@@ -245,10 +305,10 @@ class Pmtable extends Api
|
||||
if ($key3 != '') {
|
||||
$rows[$key3] = $value3;
|
||||
}
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->deleteTableData($pmt_uid, $rows);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
workflow/public_html/images/offline-pin.png
Normal file
BIN
workflow/public_html/images/offline-pin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 317 B |
Reference in New Issue
Block a user