Merged in cochalo/processmaker (pull request #277)

Correcion de DEPARTAMENTS a DEPARTMENTS
This commit is contained in:
erik ao
2014-03-06 12:12:02 -04:00
3 changed files with 60 additions and 35 deletions

View File

@@ -9,10 +9,10 @@ use \DepartmentPeer;
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
class Departament
class Department
{
/**
* Get list for Departaments
* Get list for Departments
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
@@ -20,10 +20,10 @@ class Departament
*
* @return array
*/
public function getDepartaments()
public function getDepartments()
{
$oDepartament = new \Department();
$aDepts = $oDepartament->getDepartments('');
$oDepartment = new \Department();
$aDepts = $oDepartment->getDepartments('');
foreach ($aDepts as &$depData) {
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
$depData = array_change_key_case($depData, CASE_LOWER);
@@ -32,8 +32,8 @@ class Departament
}
/**
* Get list for Departaments
* @var string $dep_uid. Uid for Departament
* Get list for Departments
* @var string $dep_uid. Uid for Department
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
@@ -41,7 +41,7 @@ class Departament
*
* @return array
*/
public function getDepartament($dep_uid)
public function getDepartment($dep_uid)
{
$dep_uid = Validator::depUid($dep_uid);
$criteria = new \Criteria( 'workflow' );
@@ -86,7 +86,7 @@ class Departament
}
/**
* Save Departament
* Save Department
* @var string $dep_data. Data for Process
* @var string $create. Flag for create or update
*
@@ -96,11 +96,11 @@ class Departament
*
* @return array
*/
public function saveDepartament($dep_data, $create = true)
public function saveDepartment($dep_data, $create = true)
{
$dep_data = array_change_key_case($dep_data, CASE_UPPER);
$oDepartament = new \Department();
$oDepartment = new \Department();
if (isset($dep_data['DEP_UID']) && $dep_data['DEP_UID'] != '') {
Validator::depUid($dep_data['DEP_UID']);
}
@@ -119,17 +119,17 @@ class Departament
if (!$create) {
$dep_data['DEPO_TITLE'] = $dep_data['DEP_TITLE'];
$oDepartament->update($dep_data);
$oDepartament->updateDepartmentManager($dep_data['DEP_UID']);
$oDepartment->update($dep_data);
$oDepartment->updateDepartmentManager($dep_data['DEP_UID']);
} else {
$dep_uid = $oDepartament->create($dep_data);
$response = $this->getDepartament($dep_uid);
$dep_uid = $oDepartment->create($dep_data);
$response = $this->getDepartment($dep_uid);
return $response;
}
}
/**
* Delete departament
* Delete department
* @var string $dep_uid. Uid for department
*
* @access public
@@ -138,11 +138,11 @@ class Departament
*
* @return array
*/
public function deleteDepartament($dep_uid)
public function deleteDepartment($dep_uid)
{
$dep_uid = Validator::depUid($dep_uid);
$oDepartament = new \Department();
$oDepartament->remove($dep_uid);
$oDepartment = new \Department();
$oDepartment->remove($dep_uid);
}
/**
@@ -159,8 +159,8 @@ class Departament
{
$children = array();
if ((int)$dataDep['HAS_CHILDREN'] > 0) {
$oDepartament = new \Department();
$aDepts = $oDepartament->getDepartments($dataDep['DEP_UID']);
$oDepartment = new \Department();
$aDepts = $oDepartment->getDepartments($dataDep['DEP_UID']);
foreach ($aDepts as &$depData) {
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
$depData = array_change_key_case($depData, CASE_LOWER);

View File

@@ -6,14 +6,14 @@ use \Luracast\Restler\RestException;
/**
* Departament Api Controller
* Department Api Controller
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @protected
*/
class Departament extends Api
class Department extends Api
{
/**
* @access public
@@ -24,11 +24,11 @@ class Departament extends Api
*
* @url GET
*/
public function doGetDepartaments()
public function doGetDepartments()
{
try {
$oDepartament = new \BusinessModel\Departament();
$response = $oDepartament->getDepartaments();
$oDepartment = new \BusinessModel\Department();
$response = $oDepartment->getDepartments();
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -46,11 +46,11 @@ class Departament extends Api
*
* @url GET /:dep_uid
*/
public function doGetDepartament($dep_uid)
public function doGetDepartment($dep_uid)
{
try {
$oDepartament = new \BusinessModel\Departament();
$response = $oDepartament->getDepartament($dep_uid);
$oDepartment = new \BusinessModel\Department();
$response = $oDepartment->getDepartment($dep_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -73,8 +73,8 @@ class Departament extends Api
public function doPost($request_data, $dep_title)
{
try {
$oDepartament = new \BusinessModel\Departament();
$response = $oDepartament->saveDepartament($request_data);
$oDepartment = new \BusinessModel\Department();
$response = $oDepartment->saveDepartment($request_data);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -98,8 +98,8 @@ class Departament extends Api
{
try {
$request_data['dep_uid'] = $dep_uid;
$oDepartament = new \BusinessModel\Departament();
$response = $oDepartament->saveDepartament($request_data, false);
$oDepartment = new \BusinessModel\Department();
$response = $oDepartment->saveDepartment($request_data, false);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
@@ -120,8 +120,8 @@ class Departament extends Api
public function doDelete($dep_uid)
{
try {
$oDepartament = new \BusinessModel\Departament();
$oDepartament->deleteDepartament($dep_uid);
$oDepartment = new \BusinessModel\Department();
$oDepartment->deleteDepartment($dep_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Tests\BusinessModel;
if (!class_exists("Propel")) {
include_once (__DIR__ . "/../bootstrap.php");
}
/**
* Class Department Test
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @protected
* @package Tests\BusinessModel
*/
class DepartmentTest extends \PHPUnit_Framework_TestCase
{
public function testGetDepartments()
{
$oDepartment = new \BusinessModel\Department();
$arrayDepartments = $oDepartment->getDepartments();
}
}