protected function addTypeElements(Kaltura_Client_EventNotification_Type_EventNotificationTemplate $eventNotificationTemplate) { if (!$eventNotificationTemplate instanceof Kaltura_Client_BusinessProcessNotification_Type_BusinessProcessNotificationTemplate) { return; } $client = Infra_ClientHelper::getClient(); $businessProcessNotificationPlugin = Kaltura_Client_BusinessProcessNotification_Plugin::get($client); $pager = new Kaltura_Client_Type_FilterPager(); $pager->pageSize = 500; $serversList = $businessProcessNotificationPlugin->businessProcessServer->listAction(null, $pager); /* @var $serversList Kaltura_Client_BusinessProcessNotification_Type_BusinessProcessServerListResponse */ $businessProcessProvider = null; $servers = array('' => 'Select Server'); foreach ($serversList->objects as $server) { /* @var $server Kaltura_Client_BusinessProcessNotification_Type_BusinessProcessServer */ $servers[$server->id] = $server->name; if ($server->id == $eventNotificationTemplate->serverId) { $businessProcessProvider = kBusinessProcessProvider::get($server); } } $processes = array(); if ($businessProcessProvider) { $processes = $businessProcessProvider->listBusinessProcesses(); asort($processes); } $this->addElement('select', 'server_id', array('label' => 'Server:', 'multiOptions' => $servers, 'default' => $eventNotificationTemplate->serverId)); $this->addElement('select', 'process_id', array('label' => 'Business-Process:', 'multiOptions' => $processes, 'default' => $eventNotificationTemplate->processId)); if ($eventNotificationTemplate instanceof Kaltura_Client_BusinessProcessNotification_Type_BusinessProcessSignalNotificationTemplate) { $this->addElement('text', 'message', array('label' => 'Message:', 'filters' => array('StringTrim'), 'required' => true)); $this->addElement('text', 'event_id', array('label' => 'Event ID:', 'filters' => array('StringTrim'), 'required' => true)); } if ($eventNotificationTemplate instanceof Kaltura_Client_BusinessProcessNotification_Type_BusinessProcessStartNotificationTemplate) { $this->addElement('checkbox', 'abort_on_deletion', array('label' => 'Abort on deletion:', 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')), array('HtmlTag', array('tag' => 'dt'))))); } }
public function doAction(Zend_Controller_Action $action) { $action->getHelper('viewRenderer')->setNoRender(); $serverId = $this->_getParam('server_id'); $client = Infra_ClientHelper::getClient(); $businessProcessNotificationPlugin = Kaltura_Client_BusinessProcessNotification_Plugin::get($client); $partnerId = $this->_getParam('partner_id'); if ($partnerId) { Infra_ClientHelper::impersonate($partnerId); } try { $server = $businessProcessNotificationPlugin->businessProcessServer->get($serverId); /* @var $server Kaltura_Client_BusinessProcessNotification_Type_BusinessProcessServer */ $businessProcessProvider = kBusinessProcessProvider::get($server); $processes = $businessProcessProvider->listBusinessProcesses(); asort($processes); } catch (Exception $e) { KalturaLog::err($e->getMessage() . "\n" . $e->getTraceAsString()); echo $action->getHelper('json')->sendJson($e->getMessage(), false); } echo $action->getHelper('json')->sendJson($processes, false); }
/** * @param KalturaBusinessProcessStartNotificationTemplate $template * @param KalturaBusinessProcessNotificationDispatchJobData $data */ public function abortCase(KalturaBusinessProcessStartNotificationTemplate $template, KalturaBusinessProcessNotificationDispatchJobData &$data) { $provider = kBusinessProcessProvider::get($data->server); KalturaLog::debug("Aborting business-process [{$template->processId}] case [{$data->caseId}]"); $provider->abortCase($data->caseId); }
/** * @param KalturaBusinessProcessServer $server * @return kBusinessProcessProvider */ public function getBusinessProcessProvider(KalturaBusinessProcessServer $server) { $provider = kBusinessProcessProvider::get($data->server); $provider->enableDebug(true); return $provider; }
/** * list business-process cases * * @action list * @param KalturaEventNotificationEventObjectType $objectType * @param string $objectId * @return KalturaBusinessProcessCaseArray * * @throws KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_CASE_NOT_FOUND * @throws KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_SERVER_NOT_FOUND */ public function listAction($objectType, $objectId) { $dbObject = kEventNotificationFlowManager::getObject($objectType, $objectId); if (!$dbObject) { throw new KalturaAPIException(KalturaErrors::OBJECT_NOT_FOUND); } $templatesIds = BusinessProcessNotificationTemplate::getCaseTemplatesIds($dbObject); if (!count($templatesIds)) { throw new KalturaAPIException(KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_CASE_NOT_FOUND); } $array = new KalturaBusinessProcessCaseArray(); foreach ($templatesIds as $templateId) { $dbTemplate = EventNotificationTemplatePeer::retrieveByPK($templateId); if (!$dbTemplate || !$dbTemplate instanceof BusinessProcessStartNotificationTemplate) { KalturaLog::info("Template [{$templateId}] not found"); continue; } $caseIds = $dbTemplate->getCaseIds($dbObject, false); if (!count($caseIds)) { KalturaLog::info("No cases found"); continue; } $dbBusinessProcessServer = BusinessProcessServerPeer::retrieveByPK($dbTemplate->getServerId()); if (!$dbBusinessProcessServer) { KalturaLog::info("Business-Process server [" . $dbTemplate->getServerId() . "] not found"); continue; } $businessProcessServer = KalturaBusinessProcessServer::getInstanceByType($dbBusinessProcessServer->getType()); $businessProcessServer->fromObject($dbBusinessProcessServer); $provider = kBusinessProcessProvider::get($businessProcessServer); if (!$provider) { KalturaLog::info("Provider [" . $businessProcessServer->type . "] not found"); continue; } foreach ($caseIds as $caseId) { try { $case = $provider->getCase($caseId); $businessProcessCase = new KalturaBusinessProcessCase(); $businessProcessCase->businessProcessStartNotificationTemplateId = $templateId; $businessProcessCase->fromObject($case); $array[] = $businessProcessCase; } catch (ActivitiClientException $e) { KalturaLog::err("Case [{$caseId}] not found: " . $e->getMessage()); } } } return $array; }