Adicion de las urls GET y DELETE para events
This commit is contained in:
92
workflow/engine/src/BusinessModel/Event.php
Normal file
92
workflow/engine/src/BusinessModel/Event.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace BusinessModel;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
class Event
|
||||
{
|
||||
/**
|
||||
* Get list for Events
|
||||
* @var string $sProcessUID. Uid for Process
|
||||
* @var string $filter.
|
||||
* @var string $sEventUID. Uid for Process
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getEvents($sProcessUID, $filter = '', $sEventUID = '')
|
||||
{
|
||||
$sDelimiter = \DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(\EventPeer::EVN_UID);
|
||||
$oCriteria->addSelectColumn(\EventPeer::EVN_ACTION);
|
||||
$oCriteria->addSelectColumn(\EventPeer::EVN_STATUS);
|
||||
$oCriteria->addSelectColumn(\EventPeer::EVN_WHEN_OCCURS);
|
||||
$oCriteria->addSelectColumn(\EventPeer::EVN_RELATED_TO);
|
||||
|
||||
$oCriteria->addAsColumn('EVN_DESCRIPTION', \ContentPeer::CON_VALUE);
|
||||
$aConditions = array();
|
||||
$aConditions[] = array(\EventPeer::EVN_UID, \ContentPeer::CON_ID );
|
||||
$aConditions[] = array(\ContentPeer::CON_CATEGORY, $sDelimiter . 'EVN_DESCRIPTION' . $sDelimiter );
|
||||
$aConditions[] = array(\ContentPeer::CON_LANG, $sDelimiter . SYS_LANG . $sDelimiter );
|
||||
$oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
|
||||
$oCriteria->add(\EventPeer::PRO_UID, $sProcessUID);
|
||||
if ($sEventUID != '') {
|
||||
$oCriteria->add(\EventPeer::EVN_UID, $sEventUID);
|
||||
}
|
||||
|
||||
switch ($filter) {
|
||||
case 'message':
|
||||
$oCriteria->add(\EventPeer::EVN_ACTION, "SEND_MESSAGE");
|
||||
break;
|
||||
case 'conditional':
|
||||
$oCriteria->add(\EventPeer::EVN_ACTION, "SEND_MESSAGE");
|
||||
break;
|
||||
case 'multiple':
|
||||
$oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_TRIGGER");
|
||||
break;
|
||||
}
|
||||
|
||||
$eventsArray = array();
|
||||
|
||||
$oDataset = \EventPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oEvent = new \Event();
|
||||
$aFields = $oEvent->load( $aRow['EVN_UID'] );
|
||||
$aRow = array_merge($aRow, $aFields);
|
||||
$eventsArray[] = array_change_key_case($aRow, CASE_LOWER);
|
||||
$oDataset->next();
|
||||
}
|
||||
return $eventsArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Event
|
||||
*
|
||||
* @param string $eventUid
|
||||
*
|
||||
* return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function deleteEvent($eventUid)
|
||||
{
|
||||
try {
|
||||
$oEvent = new \Event();
|
||||
$oEvent->remove( $eventUid );
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker\Project;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Project\Activity\Step\Event Api Controller
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class Event extends Api
|
||||
{
|
||||
/**
|
||||
* @param string $projectUid {@min 1} {@max 32}
|
||||
* @param string $filter {@choice message,conditional,,multiple}
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
*
|
||||
* @url GET /:projectUid/events
|
||||
*/
|
||||
public function doGetEvents($projectUid, $filter = '')
|
||||
{
|
||||
try {
|
||||
$hiddenFields = array('pro_uid', 'evn_action_parameters',
|
||||
'evn_posx', 'evn_posy', 'evn_type', 'tas_evn_uid'
|
||||
);
|
||||
$event = new \BusinessModel\Event();
|
||||
$response = $event->getEvents($projectUid, $filter);
|
||||
foreach ($response as &$eventData) {
|
||||
foreach ($eventData as $key => $value) {
|
||||
if (in_array($key, $hiddenFields)) {
|
||||
unset($eventData[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $projectUid {@min 1} {@max 32}
|
||||
* @param string $EventUid {@min 1} {@max 32}
|
||||
* @return array
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @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'
|
||||
);
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $projectUid {@min 1} {@max 32}
|
||||
* @param string $EventUid {@min 1} {@max 32}
|
||||
* @return void
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url DELETE /:projectUid/event/:eventUid
|
||||
*/
|
||||
public function doDeleteEvent($projectUid, $eventUid)
|
||||
{
|
||||
try {
|
||||
$event = new \BusinessModel\Event();
|
||||
$response = $event->deleteEvent($eventUid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ debug = 1
|
||||
trigger = "Services\Api\ProcessMaker\Project\Activity\Step\Trigger"
|
||||
project = "Services\Api\ProcessMaker\Project"
|
||||
trigger2 = "Services\Api\ProcessMaker\Project\Trigger"
|
||||
event = "Services\Api\ProcessMaker\Project\Event"
|
||||
input-document = "Services\Api\ProcessMaker\Project\InputDocument"
|
||||
output-documents = "Services\Api\ProcessMaker\Project\OutputDocuments"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user