/** * Delete an Business-Process server object * * @action delete * @param int $id * * @throws KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_SERVER_NOT_FOUND */ public function deleteAction($id) { // get the object $dbBusinessProcessServer = BusinessProcessServerPeer::retrieveByPK($id); if (!$dbBusinessProcessServer) { throw new KalturaAPIException(KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_SERVER_NOT_FOUND, $id); } // set the object status to deleted $dbBusinessProcessServer->setStatus(BusinessProcessServerStatus::DELETED); $dbBusinessProcessServer->save(); }
/** * 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; }
/** * @return BusinessProcessServer */ public function getServer() { return BusinessProcessServerPeer::retrieveByPK($this->serverId); }