Merged in cochalo/processmaker (pull request #277)
Correcion de DEPARTAMENTS a DEPARTMENTS
This commit is contained in:
@@ -9,10 +9,10 @@ use \DepartmentPeer;
|
|||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||||
* @copyright Colosa - Bolivia
|
* @copyright Colosa - Bolivia
|
||||||
*/
|
*/
|
||||||
class Departament
|
class Department
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get list for Departaments
|
* Get list for Departments
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||||
@@ -20,10 +20,10 @@ class Departament
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getDepartaments()
|
public function getDepartments()
|
||||||
{
|
{
|
||||||
$oDepartament = new \Department();
|
$oDepartment = new \Department();
|
||||||
$aDepts = $oDepartament->getDepartments('');
|
$aDepts = $oDepartment->getDepartments('');
|
||||||
foreach ($aDepts as &$depData) {
|
foreach ($aDepts as &$depData) {
|
||||||
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
|
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
|
||||||
$depData = array_change_key_case($depData, CASE_LOWER);
|
$depData = array_change_key_case($depData, CASE_LOWER);
|
||||||
@@ -32,8 +32,8 @@ class Departament
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list for Departaments
|
* Get list for Departments
|
||||||
* @var string $dep_uid. Uid for Departament
|
* @var string $dep_uid. Uid for Department
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||||
@@ -41,7 +41,7 @@ class Departament
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getDepartament($dep_uid)
|
public function getDepartment($dep_uid)
|
||||||
{
|
{
|
||||||
$dep_uid = Validator::depUid($dep_uid);
|
$dep_uid = Validator::depUid($dep_uid);
|
||||||
$criteria = new \Criteria( 'workflow' );
|
$criteria = new \Criteria( 'workflow' );
|
||||||
@@ -86,7 +86,7 @@ class Departament
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save Departament
|
* Save Department
|
||||||
* @var string $dep_data. Data for Process
|
* @var string $dep_data. Data for Process
|
||||||
* @var string $create. Flag for create or update
|
* @var string $create. Flag for create or update
|
||||||
*
|
*
|
||||||
@@ -96,11 +96,11 @@ class Departament
|
|||||||
*
|
*
|
||||||
* @return array
|
* @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);
|
$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'] != '') {
|
if (isset($dep_data['DEP_UID']) && $dep_data['DEP_UID'] != '') {
|
||||||
Validator::depUid($dep_data['DEP_UID']);
|
Validator::depUid($dep_data['DEP_UID']);
|
||||||
}
|
}
|
||||||
@@ -119,17 +119,17 @@ class Departament
|
|||||||
|
|
||||||
if (!$create) {
|
if (!$create) {
|
||||||
$dep_data['DEPO_TITLE'] = $dep_data['DEP_TITLE'];
|
$dep_data['DEPO_TITLE'] = $dep_data['DEP_TITLE'];
|
||||||
$oDepartament->update($dep_data);
|
$oDepartment->update($dep_data);
|
||||||
$oDepartament->updateDepartmentManager($dep_data['DEP_UID']);
|
$oDepartment->updateDepartmentManager($dep_data['DEP_UID']);
|
||||||
} else {
|
} else {
|
||||||
$dep_uid = $oDepartament->create($dep_data);
|
$dep_uid = $oDepartment->create($dep_data);
|
||||||
$response = $this->getDepartament($dep_uid);
|
$response = $this->getDepartment($dep_uid);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete departament
|
* Delete department
|
||||||
* @var string $dep_uid. Uid for department
|
* @var string $dep_uid. Uid for department
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
@@ -138,11 +138,11 @@ class Departament
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function deleteDepartament($dep_uid)
|
public function deleteDepartment($dep_uid)
|
||||||
{
|
{
|
||||||
$dep_uid = Validator::depUid($dep_uid);
|
$dep_uid = Validator::depUid($dep_uid);
|
||||||
$oDepartament = new \Department();
|
$oDepartment = new \Department();
|
||||||
$oDepartament->remove($dep_uid);
|
$oDepartment->remove($dep_uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,8 +159,8 @@ class Departament
|
|||||||
{
|
{
|
||||||
$children = array();
|
$children = array();
|
||||||
if ((int)$dataDep['HAS_CHILDREN'] > 0) {
|
if ((int)$dataDep['HAS_CHILDREN'] > 0) {
|
||||||
$oDepartament = new \Department();
|
$oDepartment = new \Department();
|
||||||
$aDepts = $oDepartament->getDepartments($dataDep['DEP_UID']);
|
$aDepts = $oDepartment->getDepartments($dataDep['DEP_UID']);
|
||||||
foreach ($aDepts as &$depData) {
|
foreach ($aDepts as &$depData) {
|
||||||
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
|
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
|
||||||
$depData = array_change_key_case($depData, CASE_LOWER);
|
$depData = array_change_key_case($depData, CASE_LOWER);
|
||||||
@@ -6,14 +6,14 @@ use \Luracast\Restler\RestException;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Departament Api Controller
|
* Department Api Controller
|
||||||
*
|
*
|
||||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||||
* @copyright Colosa - Bolivia
|
* @copyright Colosa - Bolivia
|
||||||
*
|
*
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
class Departament extends Api
|
class Department extends Api
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @access public
|
* @access public
|
||||||
@@ -24,11 +24,11 @@ class Departament extends Api
|
|||||||
*
|
*
|
||||||
* @url GET
|
* @url GET
|
||||||
*/
|
*/
|
||||||
public function doGetDepartaments()
|
public function doGetDepartments()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oDepartament = new \BusinessModel\Departament();
|
$oDepartment = new \BusinessModel\Department();
|
||||||
$response = $oDepartament->getDepartaments();
|
$response = $oDepartment->getDepartments();
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
@@ -46,11 +46,11 @@ class Departament extends Api
|
|||||||
*
|
*
|
||||||
* @url GET /:dep_uid
|
* @url GET /:dep_uid
|
||||||
*/
|
*/
|
||||||
public function doGetDepartament($dep_uid)
|
public function doGetDepartment($dep_uid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oDepartament = new \BusinessModel\Departament();
|
$oDepartment = new \BusinessModel\Department();
|
||||||
$response = $oDepartament->getDepartament($dep_uid);
|
$response = $oDepartment->getDepartment($dep_uid);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
@@ -73,8 +73,8 @@ class Departament extends Api
|
|||||||
public function doPost($request_data, $dep_title)
|
public function doPost($request_data, $dep_title)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oDepartament = new \BusinessModel\Departament();
|
$oDepartment = new \BusinessModel\Department();
|
||||||
$response = $oDepartament->saveDepartament($request_data);
|
$response = $oDepartment->saveDepartment($request_data);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
@@ -98,8 +98,8 @@ class Departament extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$request_data['dep_uid'] = $dep_uid;
|
$request_data['dep_uid'] = $dep_uid;
|
||||||
$oDepartament = new \BusinessModel\Departament();
|
$oDepartment = new \BusinessModel\Department();
|
||||||
$response = $oDepartament->saveDepartament($request_data, false);
|
$response = $oDepartment->saveDepartment($request_data, false);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
@@ -120,8 +120,8 @@ class Departament extends Api
|
|||||||
public function doDelete($dep_uid)
|
public function doDelete($dep_uid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oDepartament = new \BusinessModel\Departament();
|
$oDepartment = new \BusinessModel\Department();
|
||||||
$oDepartament->deleteDepartament($dep_uid);
|
$oDepartment->deleteDepartment($dep_uid);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
25
workflow/engine/src/Tests/BusinessModel/DepartmentTest.php
Normal file
25
workflow/engine/src/Tests/BusinessModel/DepartmentTest.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user