protected function doFromObject($dbObject, KalturaDetachedResponseProfile $responseProfile = null)
 {
     /* @var $dbObject kBusinessProcessNotificationDispatchJobData */
     parent::doFromObject($dbObject, $responseProfile);
     $server = $dbObject->getServer();
     $this->server = KalturaBusinessProcessServer::getInstanceByType($server->getType());
     $this->server->fromObject($server);
 }
 public function toObject($dbObject = null, $propertiesToSkip = array())
 {
     if (is_null($dbObject)) {
         $dbObject = new ActivitiBusinessProcessServer();
     }
     return parent::toObject($dbObject, $propertiesToSkip);
 }
 public static function fromDbArray($arr)
 {
     $newArr = new KalturaBusinessProcessServerArray();
     if ($arr == null) {
         return $newArr;
     }
     foreach ($arr as $obj) {
         /* @var $obj BusinessProcessServer */
         $nObj = KalturaBusinessProcessServer::getInstanceByType($obj->getType());
         if (!$nObj) {
             KalturaLog::err("Business-Process server could not find matching type for [" . $obj->getType() . "]");
             continue;
         }
         $nObj->fromObject($obj);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
 /**
  * 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;
 }
 /**
  * Update Business-Process server status by id
  * 
  * @action updateStatus
  * @param int $id
  * @param KalturaBusinessProcessServerStatus $status
  * @return KalturaBusinessProcessServer
  * 
  * @throws KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_SERVER_NOT_FOUND
  */
 function updateStatusAction($id, $status)
 {
     // get the object
     $dbBusinessProcessServer = BusinessProcessServerPeer::retrieveByPK($id);
     if (!$dbBusinessProcessServer) {
         throw new KalturaAPIException(KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_SERVER_NOT_FOUND, $id);
     }
     if ($status == BusinessProcessServerStatus::ACTIVE) {
         //Check uniqueness of new object's system name
         $systemNameServers = BusinessProcessServerPeer::retrieveBySystemName($dbBusinessProcessServer->getSystemName());
         if (count($systemNameServers)) {
             throw new KalturaAPIException(KalturaBusinessProcessNotificationErrors::BUSINESS_PROCESS_SERVER_DUPLICATE_SYSTEM_NAME, $dbBusinessProcessServer->getSystemName());
         }
     }
     // save the object
     $dbBusinessProcessServer->setStatus($status);
     $dbBusinessProcessServer->save();
     // return the saved object
     $businessProcessServer = KalturaBusinessProcessServer::getInstanceByType($dbBusinessProcessServer->getType());
     $businessProcessServer->fromObject($dbBusinessProcessServer);
     return $businessProcessServer;
 }