I add new UnitTest for REST classes

This commit is contained in:
jennylee
2012-10-05 17:27:46 -04:00
parent 5ac4358d80
commit 3e135b4ac3
9 changed files with 871 additions and 4 deletions

View File

@@ -0,0 +1,171 @@
<?php
if (!defined('PATH_SEP')) {
define('PATH_SEP', '/');
}
require_once PATH_HOME . 'engine/services/rest/crud/AppOwner.php';
require_once("Rest/JsonMessage.php");
require_once("Rest/XmlMessage.php");
require_once("Rest/RestMessage.php");
class AppOwnerTest extends PHPUnit_Extensions_Database_TestCase
{
public function setup()
{
}
protected function getTearDownOperation()
{
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
}
/**
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
*/
// only instantiate pdo once for test clean-up/fixture load
static private $pdo = null;
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
private $conn = null;
public function getConnection()
{
if ($this->conn === null) {
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
if (self::$pdo == null) {
self::$pdo = new PDO(
$dsn,
$_SERVER['PM_UNIT_DB_USER'],
$_SERVER['PM_UNIT_DB_PASS'] );
}
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
}
return $this->conn;
}
/**
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
public function getDataSet()
{
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
}
public function testGet()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("741388075505cd6bba2e993094312973", "000000000000000000000000000002", "00000000000000000000000000000001");
$table = "APP_OWNER";
$rest = new RestMessage();
$resp = $rest->sendGET($table,$key);
//$rest->displayResponse();
$queryTable = $this->getConnection()->createQueryTable(
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312973"'
);
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
}
public function testPost()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("741388075505cd6bba2e993094312900", "000000000000000000000000000003", "00000000000000000000000000000001");
$table = "APP_OWNER";
$rest = new RestMessage();
$rest->sendPOST($table,$key);
//$rest->displayResponse();
$key1 = array("741388075505cd6bba2e993094312900", "000000000000000000000000000003", "00000000000000000000000000000001");
$resp = $rest->sendGET($table,$key1);
$queryTable = $this->getConnection()->createQueryTable(
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312900"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
public function testPut()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("741388075505cd6bba2e993094312900", "000000000000000000000000000004", "00000000000000000000000000000001");
$table = "APP_OWNER";
$rest = new RestMessage();
$rest->sendPUT($table,$key);
//$rest->displayResponse();
$key1 = array("741388075505cd6bba2e993094312900", "000000000000000000000000000004", "00000000000000000000000000000001");
$resp = $rest->sendGET($table,$key1);
$queryTable = $this->getConnection()->createQueryTable(
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312900"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
public function testDelete()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("741388075505cd6bba2e993094312900", "000000000000000000000000000004", "00000000000000000000000000000001");
$table = "APP_OWNER";
$rest = new RestMessage();
$rest->sendDELETE($table,$key);
//$rest->displayResponse();
$queryTable = $this->getConnection()->createQueryTable(
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312900"'
);
$resp = array();
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
}

View File

@@ -50,7 +50,7 @@ class ApplicationTest extends PHPUnit_Extensions_Database_TestCase
public function getDataSet()
{
//return $this->createXMLDataSet('pmSLA/tests/db.xml');
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
}
public function testGet()
@@ -73,10 +73,87 @@ class ApplicationTest extends PHPUnit_Extensions_Database_TestCase
$resp = $rest->sendGET($table,$APP_UID);
//$rest->displayResponse();
//Obtengo solo el campo q necesito del array
//$ultimo = end( $resp );
//$solo = object mysql_fetch_field ( resource $resp ['data'] );
$queryTable = $this->getConnection()->createQueryTable(
'APPLICATION', 'SELECT * FROM APPLICATION WHERE APP_UID = "741388075505cd6bba2e993094312973"'
);
$this->assertEquals($resp, $queryTable, "ERROR");
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
public function testPost()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$APP_UID = array("4670755835065b7eb6a4187052654566", "2008", "", "DRAFT", "6548800755065a63d67f727063273525", "", "", "N", "00000000000000000000000000000001", "00000000000000000000000000000001", "2012-09-28 10:44:59", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "", "00a9357205f5ea2d9325e166092b0e3f");
$table = "APPLICATION";
$rest = new RestMessage();
$rest->sendPOST($table,$APP_UID);
$rest->displayResponse();
$ID = array("4670755835065b7eb6a4187052654566");
$resp = $rest->sendGET($table,$ID);
$queryTable = $this->getConnection()->createQueryTable(
'APPLICATION', 'SELECT * FROM APPLICATION WHERE APP_UID = "4670755835065b7eb6a4187052654566"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
public function testPut()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$APP_UID = array("4670755835065b7eb6a4187052654566", "2008", "", "DRAFT", "6548800755065a63d67f727063273525", "", "", "N", "00000000000000000000000000000001", "00000000000000000000000000000001", "2012-09-28 10:44:59", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "", "00a9357205f5ea2d9325e166092b0e3f");
$table = "APPLICATION";
$rest = new RestMessage();
$rest->sendPUT($table,$APP_UID);
//$rest->displayResponse();
}
public function testDelete()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$APP_UID = array("4670755835065b7eb6a4187052654566");
$table = "APPLICATION";
$rest = new RestMessage();
$rest->sendDELETE($table,$APP_UID);
//$rest->displayResponse();
}
}

View File

@@ -35,12 +35,12 @@ abstract class CURLMessage
*/
function __construct()
{
$serverDNS = explode(DOT,$_SERVER['SERVER_NAME']);
$serverDNS = explode(DOT,"jennylee.pmos.colosa.net");//$_SERVER['SERVER_NAME']);
$serverDNS = array_reverse($serverDNS);
$workspace = array_pop($serverDNS); //***aware this must contains the workspace name***
$this->restServer = PROTOCOL_HTTP . COLON.PATH_SEP . PATH_SEP;
$this->restServer .= $_SERVER['SERVER_NAME'] . PATH_SEP;
$this->restServer .= "jennylee.pmos.colosa.net"/*$_SERVER['SERVER_NAME'] */. PATH_SEP;
$this->restServer .= $this->serviceTechnic . PATH_SEP . $workspace . PATH_SEP;
$this->ch = curl_init();

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" ?>
<dataset>
<table name="SLA">
<column>SLA_UID</column>
<column>PRO_UID</column>
<column>SLA_NAME</column>
<column>SLA_DESCRIPTION</column>
<column>SLA_TYPE</column>
<column>SLA_TAS_START</column>
<column>SLA_TAS_END</column>
<column>SLA_TIME_DURATION</column>
<column>SLA_TIME_DURATION_MODE</column>
<column>SLA_CONDITIONS</column>
<column>SLA_PEN_ENABLED</column>
<column>SLA_PEN_TIME</column>
<column>SLA_PEN_TIME_MODE</column>
<column>SLA_PEN_VALUE</column>
<column>SLA_PEN_VALUE_UNIT</column>
<column>SLA_STATUS</column>
</table>
<table name="APP_SLA">
<column>APP_UID</column>
<column>SLA_UID</column>
<column>APP_SLA_INIT_DATE</column>
<column>APP_SLA_DUE_DATE</column>
<column>APP_SLA_FINISH_DATE</column>
<column>APP_SLA_DURATION</column>
<column>APP_SLA_REMAINING</column>
<column>APP_SLA_EXCEEDED</column>
<column>APP_SLA_PEN_VALUE</column>
<column>APP_SLA_STATUS</column>
</table>
</dataset>

View File

@@ -0,0 +1,169 @@
<?php
if (!defined('PATH_SEP')) {
define('PATH_SEP', '/');
}
require_once PATH_HOME . 'engine/services/rest/crud/Translation.php';
require_once("Rest/JsonMessage.php");
require_once("Rest/XmlMessage.php");
require_once("Rest/RestMessage.php");
class TraslationTest extends PHPUnit_Extensions_Database_TestCase
{
public function setup()
{
}
protected function getTearDownOperation()
{
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
}
/**
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
*/
// only instantiate pdo once for test clean-up/fixture load
static private $pdo = null;
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
private $conn = null;
public function getConnection()
{
if ($this->conn === null) {
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
if (self::$pdo == null) {
self::$pdo = new PDO(
$dsn,
$_SERVER['PM_UNIT_DB_USER'],
$_SERVER['PM_UNIT_DB_PASS'] );
}
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
}
return $this->conn;
}
/**
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
public function getDataSet()
{
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
}
public function testGet()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array( "LABEL", "LOGIN", "en");
$table = "TRANSLATION";
$rest = new RestMessage();
$resp = $rest->sendGET($table,$key);
//$rest->displayResponse();
$queryTable = $this->getConnection()->createQueryTable(
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "LABEL" AND TRN_ID = "LOGIN"'
);
//$this->assertEquals($resp, $key, "ERROR getting data");
}
public function testPost()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array( "HOUSE", "PUSHIN", "en", "sample", "2012-06-06" );
$table = "TRANSLATION";
$rest = new RestMessage();
$rest->sendPOST($table,$key);
//$rest->displayResponse();
$key1 = array("HOUSE", "PUSHIN", "en");
$resp = $rest->sendGET($table,$key1);
$queryTable = $this->getConnection()->createQueryTable(
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
public function testPut()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("HOUSE", "PUSHIN", "en", "samplemod", "2012-07-06");
$table = "TRANSLATION";
$rest = new RestMessage();
$rest->sendPUT($table,$key);
//$rest->displayResponse();
$key1 = array("HOUSE", "PUSHIN", "en");
$resp = $rest->sendGET($table,$key1);
$queryTable = $this->getConnection()->createQueryTable(
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
public function testDelete()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("HOUSE", "PUSHIN", "en");
$table = "TRANSLATION";
$rest = new RestMessage();
$rest->sendDELETE($table,$key);
//$rest->displayResponse();
$queryTable = $this->getConnection()->createQueryTable(
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
}

View File

@@ -0,0 +1,169 @@
<?php
if (!defined('PATH_SEP')) {
define('PATH_SEP', '/');
}
require_once PATH_HOME . 'engine/services/rest/crud/UsersProperties.php';
require_once("Rest/JsonMessage.php");
require_once("Rest/XmlMessage.php");
require_once("Rest/RestMessage.php");
class UsersPropertiesTest extends PHPUnit_Extensions_Database_TestCase
{
public function setup()
{
}
protected function getTearDownOperation()
{
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
}
/**
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
*/
// only instantiate pdo once for test clean-up/fixture load
static private $pdo = null;
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
private $conn = null;
public function getConnection()
{
if ($this->conn === null) {
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
if (self::$pdo == null) {
self::$pdo = new PDO(
$dsn,
$_SERVER['PM_UNIT_DB_USER'],
$_SERVER['PM_UNIT_DB_PASS'] );
}
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
}
return $this->conn;
}
/**
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
public function getDataSet()
{
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
}
public function testGet()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array( "00000000000000000000000000000001");
$table = "USERS_PROPERTIES";
$rest = new RestMessage();
$resp = $rest->sendGET($table,$key);
//$rest->displayResponse();
$queryTable = $this->getConnection()->createQueryTable(
'USERS_PROPERTIES', 'SELECT * FROM USERS_PROPERTIES WHERE USR_UID = "00000000000000000000000000000001"'
);
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
}
public function testPost()
{
$msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array( "00000000000000000000000000000002", "2012-09-04 09:48:57", "0", 'a:1:{i:0;s:32:"21232f297a57a5a743894a0e4a801fc3";}');
$table = "USERS_PROPERTIES";
$rest = new RestMessage();
$rest->sendPOST($table,$key);
//$rest->displayResponse();
$key1 = array("00000000000000000000000000000002");
$resp = $rest->sendGET($table,$key1);
$queryTable = $this->getConnection()->createQueryTable(
'USERS_PROPERTIES', 'SELECT * FROM USERS_PROPERTIES WHERE USR_UID = "00000000000000000000000000000002"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
}
public function testPut()
{
/* $msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("HOUSE", "PUSHIN", "en", "samplemod", "2012-07-06");
$table = "TRANSLATION";
$rest = new RestMessage();
$rest->sendPUT($table,$key);
//$rest->displayResponse();
$key1 = array("HOUSE", "PUSHIN", "en");
$resp = $rest->sendGET($table,$key1);
$queryTable = $this->getConnection()->createQueryTable(
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");*/
}
public function testDelete()
{
/* $msg = array( 'user'=>'admin' , 'password'=>'admin');
$method = "login";
$jsonm = new JsonMessage();
$jsonm->send($method,$msg);
//$jsonm->displayResponse();
$xmlm = new XmlMessage();
$xmlm->send($method, $msg);
//$xmlm->displayResponse();
$key = array("HOUSE", "PUSHIN", "en");
$table = "TRANSLATION";
$rest = new RestMessage();
$rest->sendDELETE($table,$key);
//$rest->displayResponse();
$queryTable = $this->getConnection()->createQueryTable(
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
);
//$this->assertEquals($queryTable, $resp, "ERROR getting data");*/
}
}

View File

@@ -61,5 +61,77 @@ class Services_Rest_AppOwner
return $result;
}
/**
* Implementation for 'POST' method for Rest API
*
* @param mixed $appUid, $ownUid, $usrUid Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function post($appUid, $ownUid, $usrUid)
{
try {
$result = array();
$obj = new AppOwner();
$obj->setAppUid($appUid);
$obj->setOwnUid($ownUid);
$obj->setUsrUid($usrUid);
$obj->save();
} catch (Exception $e) {
throw new RestException(412, $e->getMessage());
}
}
/**
* Implementation for 'PUT' method for Rest API
*
* @param mixed $appUid, $ownUid, $usrUid Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function put($appUid, $ownUid, $usrUid)
{
try {
$obj = AppOwnerPeer::retrieveByPK($appUid, $ownUid, $usrUid);
$obj->save();
} catch (Exception $e) {
throw new RestException(412, $e->getMessage());
}
}
/**
* Implementation for 'DELETE' method for Rest API
*
* @param mixed $appUid, $ownUid, $usrUid Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function delete($appUid, $ownUid, $usrUid)
{
$conn = Propel::getConnection(AppOwnerPeer::DATABASE_NAME);
try {
$conn->begin();
$obj = AppOwnerPeer::retrieveByPK($appUid, $ownUid, $usrUid);
if (! is_object($obj)) {
throw new RestException(412, 'Record does not exist.');
}
$obj->delete();
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
throw new RestException(412, $e->getMessage());
}
}
}

View File

@@ -74,5 +74,105 @@ class Services_Rest_Application
return $result;
}
/**
* Implementation for 'POST' method for Rest API
*
* @param mixed $appUid Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function post($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
{
try {
$result = array();
$obj = new Application();
$obj->setAppUid($appUid);
$obj->setAppNumber($appNumber);
$obj->setAppParent($appParent);
$obj->setAppStatus($appStatus);
$obj->setProUid($proUid);
$obj->setAppProcStatus($appProcStatus);
$obj->setAppProcCode($appProcCode);
$obj->setAppParallel($appParallel);
$obj->setAppInitUser($appInitUser);
$obj->setAppCurUser($appCurUser);
$obj->setAppCreateDate($appCreateDate);
$obj->setAppInitDate($appInitDate);
$obj->setAppFinishDate($appFinishDate);
$obj->setAppUpdateDate($appUpdateDate);
$obj->setAppData($appData);
$obj->setAppPin($appPin);
$obj->save();
} catch (Exception $e) {
throw new RestException(412, $e->getMessage());
}
}
/**
* Implementation for 'PUT' method for Rest API
*
* @param mixed $appUid Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function put($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
{
try {
$obj = ApplicationPeer::retrieveByPK($appUid);
$obj->setAppNumber($appNumber);
$obj->setAppParent($appParent);
$obj->setAppStatus($appStatus);
$obj->setProUid($proUid);
$obj->setAppProcStatus($appProcStatus);
$obj->setAppProcCode($appProcCode);
$obj->setAppParallel($appParallel);
$obj->setAppInitUser($appInitUser);
$obj->setAppCurUser($appCurUser);
$obj->setAppCreateDate($appCreateDate);
$obj->setAppInitDate($appInitDate);
$obj->setAppFinishDate($appFinishDate);
$obj->setAppUpdateDate($appUpdateDate);
$obj->setAppData($appData);
$obj->setAppPin($appPin);
$obj->save();
} catch (Exception $e) {
throw new RestException(412, $e->getMessage());
}
}
/**
* Implementation for 'DELETE' method for Rest API
*
* @param mixed $appUid Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function delete($appUid)
{
$conn = Propel::getConnection(ApplicationPeer::DATABASE_NAME);
try {
$conn->begin();
$obj = ApplicationPeer::retrieveByPK($appUid);
if (! is_object($obj)) {
throw new RestException(412, 'Record does not exist.');
}
$obj->delete();
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
throw new RestException(412, $e->getMessage());
}
}
}

View File

@@ -63,5 +63,81 @@ class Services_Rest_Translation
return $result;
}
/**
* Implementation for 'POST' method for Rest API
*
* @param mixed $trnCategory, $trnId, $trnLang Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function post($trnCategory, $trnId, $trnLang, $trnValue, $trnUpdateDate)
{
try {
$result = array();
$obj = new Translation();
$obj->setTrnCategory($trnCategory);
$obj->setTrnId($trnId);
$obj->setTrnLang($trnLang);
$obj->setTrnValue($trnValue);
$obj->setTrnUpdateDate($trnUpdateDate);
$obj->save();
} catch (Exception $e) {
throw new RestException(412, $e->getMessage());
}
}
/**
* Implementation for 'PUT' method for Rest API
*
* @param mixed $trnCategory, $trnId, $trnLang Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function put($trnCategory, $trnId, $trnLang, $trnValue, $trnUpdateDate)
{
try {
$obj = TranslationPeer::retrieveByPK($trnCategory, $trnId, $trnLang);
$obj->setTrnValue($trnValue);
$obj->setTrnUpdateDate($trnUpdateDate);
$obj->save();
} catch (Exception $e) {
throw new RestException(412, $e->getMessage());
}
}
/**
* Implementation for 'DELETE' method for Rest API
*
* @param mixed $trnCategory, $trnId, $trnLang Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function delete($trnCategory, $trnId, $trnLang)
{
$conn = Propel::getConnection(TranslationPeer::DATABASE_NAME);
try {
$conn->begin();
$obj = TranslationPeer::retrieveByPK($trnCategory, $trnId, $trnLang);
if (! is_object($obj)) {
throw new RestException(412, 'Record does not exist.');
}
$obj->delete();
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
throw new RestException(412, $e->getMessage());
}
}
}