Files
luos/workflow/engine/src/ProcessMaker/Services/Api/Pmtable.php

254 lines
7.2 KiB
PHP
Raw Normal View History

<?php
namespace ProcessMaker\Services\Api;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Pmtable Api Controller
*
* @protected
*/
class Pmtable extends Api
{
/**
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
* @url GET
*/
public function doGetPmTables()
{
try {
$oPmTable = new \ProcessMaker\BusinessModel\Table();
$response = $oPmTable->getTables();
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $pmt_uid {@min 1} {@max 32}
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
* @url GET /:pmt_uid
*/
public function doGetPmTable($pmt_uid)
{
try {
$oPmTable = new \ProcessMaker\BusinessModel\Table();
$response = $oPmTable->getTable($pmt_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $pmt_uid {@min 1} {@max 32}
2016-07-20 11:59:03 -04:00
* @param string $filter
* @param string $q
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
* @url GET /:pmt_uid/data
*/
2016-07-20 11:59:03 -04:00
public function doGetPmTableData($pmt_uid, $filter = null, $q = "")
{
try {
$oPmTable = new \ProcessMaker\BusinessModel\Table();
2016-07-20 11:59:03 -04:00
$response = $oPmTable->getTableData($pmt_uid, null, $filter, false, $q);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @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
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
* @url POST
* @status 201
*/
public function doPostPmTable(
$request_data,
$pmt_tab_name,
$pmt_tab_dsc = ''
) {
try {
$oReportTable = new \ProcessMaker\BusinessModel\Table();
$response = $oReportTable->saveTable($request_data);
if (isset($response['pro_uid'])) {
unset($response['pro_uid']);
}
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
2014-02-13 16:28:38 -04:00
/**
* @param string $pmt_uid {@min 1} {@max 32}
*
* @param array $request_data
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
2014-02-13 16:28:38 -04:00
* @url POST /:pmt_uid/data
* @status 201
*/
public function doPostPmTableData(
$pmt_uid,
2014-04-28 12:15:48 -04:00
$request_data
2014-02-13 16:28:38 -04:00
) {
try {
$oReportTable = new \ProcessMaker\BusinessModel\Table();
2014-02-13 16:28:38 -04:00
$response = $oReportTable->saveTableData($pmt_uid, $request_data);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
2017-10-13 10:59:18 -04:00
* Update pm-table.
*
* @url PUT /:pmt_uid
*
2017-10-13 10:59:18 -04:00
* @param string $pmt_uid {@min 1} {@max 32}
* @param array $request_data
*
2017-10-13 10:59:18 -04:00
* @return void
* @throw RestException
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
*/
public function doPutPmTable(
$pmt_uid,
2014-04-28 12:15:48 -04:00
$request_data
) {
try {
$request_data['pmt_uid'] = $pmt_uid;
$oReportTable = new \ProcessMaker\BusinessModel\Table();
$response = $oReportTable->updateTable($request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
2014-02-13 16:28:38 -04:00
/**
2017-10-13 10:59:18 -04:00
* Update pm-table data.
*
* @url PUT /:pmt_uid/data
*
2014-02-13 16:28:38 -04:00
* @param string $pmt_uid {@min 1} {@max 32}
* @param array $request_data
2017-10-13 10:59:18 -04:00
*
2014-02-13 16:28:38 -04:00
* @return array
2017-10-13 10:59:18 -04:00
* @throws RestException
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
2014-02-13 16:28:38 -04:00
*/
public function doPutPmTableData(
$pmt_uid,
2014-04-28 12:15:48 -04:00
$request_data
2014-02-13 16:28:38 -04:00
) {
try {
$oReportTable = new \ProcessMaker\BusinessModel\Table();
2014-02-13 16:28:38 -04:00
$response = $oReportTable->updateTableData($pmt_uid, $request_data);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $pmt_uid {@min 1} {@max 32}
*
* @return void
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
* @url DELETE /:pmt_uid
*/
public function doDeletePmTable($pmt_uid)
{
try {
$oReportTable = new \ProcessMaker\BusinessModel\Table();
$response = $oReportTable->deleteTable($pmt_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
2014-02-13 16:28:38 -04:00
/**
* @param string $pmt_uid {@min 1} {@max 32}
* @param string $key1 {@min 1}
* @param string $value1 {@min 1}
* @param string $key2
* @param string $value2
* @param string $key3
* @param string $value3
*
* @return array
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
2016-07-21 09:52:33 -04:00
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
2014-02-13 16:28:38 -04:00
* @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 = '')
{
try {
$rows = array($key1 => $value1);
if ($key2 != '') {
$rows[$key2] = $value2;
}
if ($key3 != '') {
$rows[$key3] = $value3;
}
$oReportTable = new \ProcessMaker\BusinessModel\Table();
2014-02-13 16:28:38 -04:00
$response = $oReportTable->deleteTableData($pmt_uid, $rows);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}