2014-01-23 11:42:54 -04:00
|
|
|
<?php
|
2014-04-02 17:02:02 -04:00
|
|
|
namespace ProcessMaker\Services\Api\Project;
|
2014-01-23 11:42:54 -04:00
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Project\DataBaseConnection Api Controller
|
|
|
|
|
*
|
2014-01-25 06:10:24 -04:00
|
|
|
* @author Brayan Pereyra <brayan@colosa.com>
|
2014-01-23 11:42:54 -04:00
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class DataBaseConnection extends Api
|
|
|
|
|
{
|
|
|
|
|
/**
|
2014-02-06 12:36:46 -04:00
|
|
|
* @param string $prj_uid {@min 1} {@max 32}
|
2014-01-23 11:42:54 -04:00
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
2014-02-06 12:36:46 -04:00
|
|
|
* @url GET /:prj_uid/database-connections
|
2014-01-23 11:42:54 -04:00
|
|
|
*/
|
2014-02-06 12:36:46 -04:00
|
|
|
public function doGetDataBaseConnections($prj_uid)
|
2014-01-23 11:42:54 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oDBConnection = new \ProcessMaker\BusinessModel\DataBaseConnection();
|
2014-02-06 12:36:46 -04:00
|
|
|
$response = $oDBConnection->getDataBaseConnections($prj_uid);
|
2014-01-23 11:42:54 -04:00
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-06 12:36:46 -04:00
|
|
|
* @param string $prj_uid {@min 1} {@max 32}
|
|
|
|
|
* @param string $dbs_uid {@min 1} {@max 32}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @return array
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-02-06 12:36:46 -04:00
|
|
|
* @url GET /:prj_uid/database-connection/:dbs_uid
|
2014-01-23 11:42:54 -04:00
|
|
|
*/
|
2014-02-06 12:36:46 -04:00
|
|
|
public function doGetDataBaseConnection($prj_uid, $dbs_uid)
|
2014-01-23 11:42:54 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oDBConnection = new \ProcessMaker\BusinessModel\DataBaseConnection();
|
2014-02-06 12:36:46 -04:00
|
|
|
$response = $oDBConnection->getDataBaseConnection($prj_uid, $dbs_uid);
|
2014-01-23 11:42:54 -04:00
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-06 12:36:46 -04:00
|
|
|
* @param string $prj_uid {@min 1} {@max 32}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @param array $request_data
|
|
|
|
|
*
|
2014-02-17 15:46:43 -04:00
|
|
|
* @param string $dbs_type {@from body} {@required true}
|
2017-03-22 12:08:43 -04:00
|
|
|
* @param string $dbs_server {@from body} {@required false}
|
|
|
|
|
* @param string $dbs_database_name {@from body} {@required false}
|
2014-02-13 09:53:55 -04:00
|
|
|
* @param string $dbs_username {@from body}
|
2014-02-17 15:46:43 -04:00
|
|
|
* @param string $dbs_encode {@from body} {@required true}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @param string $dbs_password {@from body}
|
2014-02-06 10:42:04 -04:00
|
|
|
* @param string $dbs_description {@from body}
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-02-06 12:36:46 -04:00
|
|
|
* @url POST /:prj_uid/database-connection/test
|
2014-02-06 10:42:04 -04:00
|
|
|
*/
|
|
|
|
|
public function doPostTestDataBaseConnection(
|
2014-02-06 12:36:46 -04:00
|
|
|
$prj_uid,
|
2014-02-06 10:42:04 -04:00
|
|
|
$request_data,
|
|
|
|
|
$dbs_type,
|
|
|
|
|
$dbs_server,
|
|
|
|
|
$dbs_database_name,
|
|
|
|
|
$dbs_username,
|
|
|
|
|
$dbs_encode,
|
|
|
|
|
$dbs_password = '',
|
|
|
|
|
$dbs_description = ''
|
|
|
|
|
) {
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oDBConnection = new \ProcessMaker\BusinessModel\DataBaseConnection();
|
2014-02-06 12:36:46 -04:00
|
|
|
$request_data['pro_uid'] = $prj_uid;
|
2014-02-06 10:42:04 -04:00
|
|
|
$response = $oDBConnection->testConnection($request_data, true);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-06 12:36:46 -04:00
|
|
|
* @param string $prj_uid {@min 1} {@max 32}
|
2014-02-06 10:42:04 -04:00
|
|
|
* @param array $request_data
|
|
|
|
|
*
|
2014-02-17 15:46:43 -04:00
|
|
|
* @param string $dbs_type {@from body} {@required true}
|
2017-03-22 12:08:43 -04:00
|
|
|
* @param string $dbs_server {@from body} {@required false}
|
|
|
|
|
* @param string $dbs_database_name {@from body} {@required false}
|
2014-02-13 09:53:55 -04:00
|
|
|
* @param string $dbs_username {@from body}
|
2014-02-17 15:46:43 -04:00
|
|
|
* @param string $dbs_encode {@from body} {@required true}
|
2014-02-06 10:42:04 -04:00
|
|
|
* @param string $dbs_password {@from body}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @param string $dbs_description {@from body}
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-02-06 12:36:46 -04:00
|
|
|
* @url POST /:prj_uid/database-connection
|
2014-01-23 11:42:54 -04:00
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-01-25 06:10:24 -04:00
|
|
|
public function doPostDataBaseConnection(
|
2014-02-06 12:36:46 -04:00
|
|
|
$prj_uid,
|
2014-01-25 06:27:56 -04:00
|
|
|
$request_data,
|
|
|
|
|
$dbs_type,
|
2014-01-25 06:10:24 -04:00
|
|
|
$dbs_server,
|
2014-01-25 06:27:56 -04:00
|
|
|
$dbs_database_name,
|
|
|
|
|
$dbs_username,
|
|
|
|
|
$dbs_encode,
|
|
|
|
|
$dbs_password = '',
|
2014-01-25 06:10:24 -04:00
|
|
|
$dbs_description = ''
|
|
|
|
|
) {
|
2014-01-23 11:42:54 -04:00
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oDBConnection = new \ProcessMaker\BusinessModel\DataBaseConnection();
|
2014-02-06 12:36:46 -04:00
|
|
|
$response = $oDBConnection->saveDataBaseConnection($prj_uid, $request_data, true);
|
2014-01-23 11:42:54 -04:00
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-10-11 11:19:53 -04:00
|
|
|
* Update database connection.
|
|
|
|
|
*
|
2014-02-06 12:36:46 -04:00
|
|
|
* @param string $prj_uid {@min 1} {@max 32}
|
|
|
|
|
* @param string $dbs_uid {@min 1} {@max 32}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @param array $request_data
|
2014-02-17 15:46:43 -04:00
|
|
|
* @param string $dbs_type {@from body} {@required true}
|
|
|
|
|
* @param string $dbs_server {@from body} {@required true}
|
|
|
|
|
* @param string $dbs_database_name {@from body} {@required true}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @param string $dbs_username {@from body}
|
2014-02-17 15:46:43 -04:00
|
|
|
* @param string $dbs_encode {@from body} {@required true}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @param string $dbs_password {@from body}
|
|
|
|
|
* @param string $dbs_description {@from body}
|
|
|
|
|
* @return void
|
2014-02-06 12:36:46 -04:00
|
|
|
* @url PUT /:prj_uid/database-connection/:dbs_uid
|
2017-10-11 11:19:53 -04:00
|
|
|
* @class AccessControl {@permission PM_SETUP}
|
|
|
|
|
* @access protected
|
2014-01-23 11:42:54 -04:00
|
|
|
*/
|
2014-01-25 06:10:24 -04:00
|
|
|
public function doPutDataBaseConnection(
|
2014-02-06 12:36:46 -04:00
|
|
|
$prj_uid,
|
|
|
|
|
$dbs_uid,
|
2014-01-25 06:27:56 -04:00
|
|
|
$request_data,
|
|
|
|
|
$dbs_type,
|
2014-01-25 06:10:24 -04:00
|
|
|
$dbs_server,
|
2014-01-25 06:27:56 -04:00
|
|
|
$dbs_database_name,
|
|
|
|
|
$dbs_username,
|
|
|
|
|
$dbs_encode,
|
|
|
|
|
$dbs_password = '',
|
2014-01-25 06:10:24 -04:00
|
|
|
$dbs_description = ''
|
|
|
|
|
) {
|
2014-01-23 11:42:54 -04:00
|
|
|
try {
|
2014-02-06 12:36:46 -04:00
|
|
|
$request_data['dbs_uid'] = $dbs_uid;
|
2014-04-02 17:02:02 -04:00
|
|
|
$oDBConnection = new \ProcessMaker\BusinessModel\DataBaseConnection();
|
2014-02-06 12:36:46 -04:00
|
|
|
$response = $oDBConnection->saveDataBaseConnection($prj_uid, $request_data);
|
2014-01-23 11:42:54 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-06 12:36:46 -04:00
|
|
|
* @param string $prj_uid {@min 1} {@max 32}
|
|
|
|
|
* @param string $dbs_uid {@min 1} {@max 32}
|
2014-01-23 11:42:54 -04:00
|
|
|
* @return void
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2014-02-06 12:36:46 -04:00
|
|
|
* @url DELETE /:prj_uid/database-connection/:dbs_uid
|
2014-01-23 11:42:54 -04:00
|
|
|
*/
|
2014-02-06 12:36:46 -04:00
|
|
|
public function doDeleteDataBaseConnection($prj_uid, $dbs_uid)
|
2014-01-23 11:42:54 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oDBConnection = new \ProcessMaker\BusinessModel\DataBaseConnection();
|
2014-02-06 12:36:46 -04:00
|
|
|
$response = $oDBConnection->deleteDataBaseConnection($prj_uid, $dbs_uid);
|
2014-01-23 11:42:54 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-28 11:34:07 -04:00
|
|
|
|