diff --git a/tests/unit/backend/services/AppOwnerTest.php b/tests/unit/backend/services/AppOwnerTest.php new file mode 100644 index 000000000..150d2be5e --- /dev/null +++ b/tests/unit/backend/services/AppOwnerTest.php @@ -0,0 +1,171 @@ +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"); + } +} diff --git a/tests/unit/backend/services/ApplicationTest.php b/tests/unit/backend/services/ApplicationTest.php index 7b50fad82..d23487916 100644 --- a/tests/unit/backend/services/ApplicationTest.php +++ b/tests/unit/backend/services/ApplicationTest.php @@ -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(); } } + diff --git a/tests/unit/backend/services/Rest/CURLMessage.php b/tests/unit/backend/services/Rest/CURLMessage.php index a65f15993..08e56e8fa 100644 --- a/tests/unit/backend/services/Rest/CURLMessage.php +++ b/tests/unit/backend/services/Rest/CURLMessage.php @@ -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(); diff --git a/tests/unit/backend/services/Rest/fixtures/application.xml b/tests/unit/backend/services/Rest/fixtures/application.xml new file mode 100644 index 000000000..4de4dd037 --- /dev/null +++ b/tests/unit/backend/services/Rest/fixtures/application.xml @@ -0,0 +1,33 @@ + + + + SLA_UID + PRO_UID + SLA_NAME + SLA_DESCRIPTION + SLA_TYPE + SLA_TAS_START + SLA_TAS_END + SLA_TIME_DURATION + SLA_TIME_DURATION_MODE + SLA_CONDITIONS + SLA_PEN_ENABLED + SLA_PEN_TIME + SLA_PEN_TIME_MODE + SLA_PEN_VALUE + SLA_PEN_VALUE_UNIT + SLA_STATUS +
+ + APP_UID + SLA_UID + APP_SLA_INIT_DATE + APP_SLA_DUE_DATE + APP_SLA_FINISH_DATE + APP_SLA_DURATION + APP_SLA_REMAINING + APP_SLA_EXCEEDED + APP_SLA_PEN_VALUE + APP_SLA_STATUS +
+
\ No newline at end of file diff --git a/tests/unit/backend/services/TranslationTest.php b/tests/unit/backend/services/TranslationTest.php new file mode 100644 index 000000000..103452b52 --- /dev/null +++ b/tests/unit/backend/services/TranslationTest.php @@ -0,0 +1,169 @@ +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"); + } +} diff --git a/tests/unit/backend/services/UsersPropertiesTest.php b/tests/unit/backend/services/UsersPropertiesTest.php new file mode 100644 index 000000000..d3104506a --- /dev/null +++ b/tests/unit/backend/services/UsersPropertiesTest.php @@ -0,0 +1,169 @@ +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");*/ + } +} diff --git a/workflow/engine/services/rest/crud/AppOwner.php b/workflow/engine/services/rest/crud/AppOwner.php index 66e5d42d6..2f40ca739 100644 --- a/workflow/engine/services/rest/crud/AppOwner.php +++ b/workflow/engine/services/rest/crud/AppOwner.php @@ -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()); + } + } + } diff --git a/workflow/engine/services/rest/crud/Application.php b/workflow/engine/services/rest/crud/Application.php index 23d7a55a0..d2314e57a 100644 --- a/workflow/engine/services/rest/crud/Application.php +++ b/workflow/engine/services/rest/crud/Application.php @@ -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()); + } + } + } diff --git a/workflow/engine/services/rest/crud/Translation.php b/workflow/engine/services/rest/crud/Translation.php index 072387d0a..1c571a36d 100644 --- a/workflow/engine/services/rest/crud/Translation.php +++ b/workflow/engine/services/rest/crud/Translation.php @@ -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()); + } + } + }