Adicion para la url POST en events

This commit is contained in:
Brayan Osmar Pereyra Suxo
2014-01-06 16:54:36 -04:00
parent afdfff2e78
commit f4103e15e1
2 changed files with 118 additions and 15 deletions

View File

@@ -13,10 +13,11 @@ class Event
* @var string $filter.
* @var string $sEventUID. Uid for Process
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return boolean
* @return array
*/
public function getEvents($sProcessUID, $filter = '', $sEventUID = '')
{
@@ -50,7 +51,6 @@ class Event
$oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_TRIGGER");
break;
}
$eventsArray = array();
$oDataset = \EventPeer::doSelectRS($oCriteria);
@@ -72,14 +72,68 @@ class Event
return $eventsArray;
}
/**
* Save Event Post Put
*
* @param string $eventUid
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return array
*/
public function saveEvents($sProcessUID, $dataEvent, $create = false)
{
if ( ($sProcessUID == '') || (count($dataEvent) == 0) ) {
return false;
}
$dataEvent = array_change_key_case($dataEvent, CASE_UPPER);
if ( $create && (isset($dataEvent['ENV_UID'])) ) {
unset($dataEvent['ENV_UID']);
}
$dataEvent['PRO_UID'] = $sProcessUID;
$oEvent = new \Event();
$uidNewEvent = $oEvent->create( $dataEvent );
$dataEvent = $this->getEvents($sProcessUID, '', $uidNewEvent);
$dataEvent = array_change_key_case($dataEvent, CASE_LOWER);
return $dataEvent;
}
/**
* Update Event Put
*
* @param string $eventUid
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*/
public function updateEvent($dataEvent)
{
$dataEvent = array_change_key_case($dataEvent, CASE_UPPER);
try {
$oEvent = new \Event();
$oEvent->update( $dataEvent );
} catch (Exception $e) {
throw $e;
}
}
/**
* Delete Event
*
* @param string $eventUid
*
* return void
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*/
public function deleteEvent($eventUid)
{
@@ -91,8 +145,5 @@ class Event
}
}
}

View File

@@ -18,8 +18,10 @@ class Event extends Api
* @param string $projectUid {@min 1} {@max 32}
* @param string $filter {@choice message,conditional,,multiple}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return array
*
* @url GET /:projectUid/events
@@ -28,7 +30,7 @@ class Event extends Api
{
try {
$hiddenFields = array('pro_uid', 'evn_action_parameters',
'evn_posx', 'evn_posy', 'evn_type', 'tas_evn_uid'
'evn_posx', 'evn_posy', 'evn_type', 'tas_evn_uid', 'evn_max_attempts'
);
$event = new \BusinessModel\Event();
$response = $event->getEvents($projectUid, $filter);
@@ -48,25 +50,72 @@ class Event extends Api
/**
* @param string $projectUid {@min 1} {@max 32}
* @param string $EventUid {@min 1} {@max 32}
* @return array
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return array
*
* @url GET /:projectUid/event/:EventUid
*/
public function doGetEvent($projectUid, $EventUid)
{
try {
$hiddenFields = array('pro_uid', 'evn_action_parameters',
'evn_posx', 'evn_posy', 'evn_type', 'tas_evn_uid'
'evn_posx', 'evn_posy', 'evn_type', 'tas_evn_uid', 'evn_max_attempts'
);
$event = new \BusinessModel\Event();
$response = $event->getEvents($projectUid, '', $EventUid);
foreach ($response as &$eventData) {
foreach ($eventData as $key => $value) {
if (in_array($key, $hiddenFields)) {
unset($eventData[$key]);
}
foreach ($response as $key => $eventData) {
if (in_array($key, $hiddenFields)) {
unset($response[$key]);
}
}
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $projectUid {@min 1} {@max 32}
* @param array $request_data
* @param string $evn_description {@from body} {@min 1}
* @param string $evn_status {@from body} {@choice ACTIVE,INACTIVE}
* @param string $evn_action {@from body} {@choice SEND_MESSAGE,EXECUTE_CONDITIONAL_TRIGGER,EXECUTE_TRIGGER}
* @param string $evn_related_to {@from body} {@choice SINGLE,MULTIPLE}
* @param string $tas_uid {@from body} {@min 1}
* @param string $evn_tas_uid_from {@from body} {@min 1}
* @param string $evn_tas_estimated_duration {@from body} {@min 1}
* @param string $evn_time_unit {@from body} {@choice DAYS,HOURS}
* @param string $evn_when {@from body} {@type float}
* @param string $evn_when_occurs {@from body} {@choice AFTER_TIME,TASK_STARTED}
* @param string $tri_uid {@from body} {@min 1}
* @param string $evn_tas_uid_to {@from body}
* @param string $evn_conditions {@from body}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return array
*
* @url POST /:projectUid/event
*/
public function doPostEvent($projectUid, $request_data, $evn_description, $evn_status, $evn_action,
$evn_related_to, $tas_uid, $evn_tas_uid_from, $evn_tas_estimated_duration,
$evn_time_unit, $evn_when, $evn_when_occurs, $tri_uid, $evn_tas_uid_to = '', $evn_conditions = '')
{
try {
$hiddenFields = array('pro_uid', 'evn_action_parameters',
'evn_posx', 'evn_posy', 'evn_type', 'tas_evn_uid', 'evn_max_attempts'
);
$event = new \BusinessModel\Event();
$response = $event->saveEvents($projectUid, $request_data, true);
foreach ($response as $key => $eventData) {
if (in_array($key, $hiddenFields)) {
unset($response[$key]);
}
}
return $response;
@@ -80,9 +129,12 @@ class Event extends Api
* @param string $EventUid {@min 1} {@max 32}
* @return void
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*
* @url DELETE /:projectUid/event/:eventUid
*/
public function doDeleteEvent($projectUid, $eventUid)