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 $filter.
* @var string $sEventUID. Uid for Process * @var string $sEventUID. Uid for Process
* *
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com> * @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia * @copyright Colosa - Bolivia
* *
* @return boolean * @return array
*/ */
public function getEvents($sProcessUID, $filter = '', $sEventUID = '') public function getEvents($sProcessUID, $filter = '', $sEventUID = '')
{ {
@@ -50,7 +51,6 @@ class Event
$oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_TRIGGER"); $oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_TRIGGER");
break; break;
} }
$eventsArray = array(); $eventsArray = array();
$oDataset = \EventPeer::doSelectRS($oCriteria); $oDataset = \EventPeer::doSelectRS($oCriteria);
@@ -72,14 +72,68 @@ class Event
return $eventsArray; 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 * Delete Event
* *
* @param string $eventUid * @param string $eventUid
* *
* return void
*
* @access public * @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*/ */
public function deleteEvent($eventUid) 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 $projectUid {@min 1} {@max 32}
* @param string $filter {@choice message,conditional,,multiple} * @param string $filter {@choice message,conditional,,multiple}
* *
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com> * @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia * @copyright Colosa - Bolivia
*
* @return array * @return array
* *
* @url GET /:projectUid/events * @url GET /:projectUid/events
@@ -28,7 +30,7 @@ class Event extends Api
{ {
try { try {
$hiddenFields = array('pro_uid', 'evn_action_parameters', $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(); $event = new \BusinessModel\Event();
$response = $event->getEvents($projectUid, $filter); $response = $event->getEvents($projectUid, $filter);
@@ -48,26 +50,73 @@ class Event extends Api
/** /**
* @param string $projectUid {@min 1} {@max 32} * @param string $projectUid {@min 1} {@max 32}
* @param string $EventUid {@min 1} {@max 32} * @param string $EventUid {@min 1} {@max 32}
* @return array *
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com> * @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia * @copyright Colosa - Bolivia
* *
* @return array
*
* @url GET /:projectUid/event/:EventUid * @url GET /:projectUid/event/:EventUid
*/ */
public function doGetEvent($projectUid, $EventUid) public function doGetEvent($projectUid, $EventUid)
{ {
try { try {
$hiddenFields = array('pro_uid', 'evn_action_parameters', $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(); $event = new \BusinessModel\Event();
$response = $event->getEvents($projectUid, '', $EventUid); $response = $event->getEvents($projectUid, '', $EventUid);
foreach ($response as &$eventData) { foreach ($response as $key => $eventData) {
foreach ($eventData as $key => $value) {
if (in_array($key, $hiddenFields)) { if (in_array($key, $hiddenFields)) {
unset($eventData[$key]); 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; return $response;
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -80,9 +129,12 @@ class Event extends Api
* @param string $EventUid {@min 1} {@max 32} * @param string $EventUid {@min 1} {@max 32}
* @return void * @return void
* *
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com> * @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia * @copyright Colosa - Bolivia
* *
* @return void
*
* @url DELETE /:projectUid/event/:eventUid * @url DELETE /:projectUid/event/:eventUid
*/ */
public function doDeleteEvent($projectUid, $eventUid) public function doDeleteEvent($projectUid, $eventUid)