本文整理汇总了PHP中BatchJob::createChild方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJob::createChild方法的具体用法?PHP BatchJob::createChild怎么用?PHP BatchJob::createChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchJob
的用法示例。
在下文中一共展示了BatchJob::createChild方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFileSyncImportJob
/**
* @param string $entryId
* @param FileSync $object
* @param int $fileSyncId
* @param string $sourceFileUrl
* @return BatchJob
*/
public static function addFileSyncImportJob($entryId, FileSync $fileSync, $sourceFileUrl, BatchJob $parentJob = null, $fileSize = null)
{
$partnerId = $fileSync->getPartnerId();
$fileSyncId = $fileSync->getId();
$dc = $fileSync->getDc();
KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
$fileSyncImportData = new kFileSyncImportJobData();
$fileSyncImportData->setSourceUrl($sourceFileUrl);
$fileSyncImportData->setFilesyncId($fileSyncId);
$fileSyncImportData->setFileSize($fileSize);
// tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild(BatchJobType::FILESYNC_IMPORT, null, true, $dc);
} else {
$batchJob = new BatchJob();
$batchJob->setDc($dc);
$batchJob->setEntryId($entryId);
$batchJob->setPartnerId($partnerId);
}
$batchJob->setObjectId($fileSyncId);
$batchJob->setObjectType(BatchJobObjectType::FILE_SYNC);
//In case file sync is of type data and holds flavor asset than we need to check if its the source asset that is being synced and raise it sync priority
if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $fileSync->getObjectSubType() == entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA && $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) {
$assetdb = assetPeer::retrieveById($fileSync->getObjectId());
if ($assetdb) {
$isSourceAsset = $assetdb->getIsOriginal();
if ($isSourceAsset) {
$fileSyncImportData->setIsSourceAsset(true);
}
}
}
KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId} size: {$fileSize}");
return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
}
示例2: addParseCaptionAssetJob
/**
* @param CaptionAsset $captionAsset
* @param BatchJob $parentJob
* @throws kCoreException FILE_NOT_FOUND
* @return BatchJob
*/
public function addParseCaptionAssetJob(CaptionAsset $captionAsset, BatchJob $parentJob = null)
{
$syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if (!$fileSync) {
if (!PermissionPeer::isValidForPartner(CaptionPermissionName::IMPORT_REMOTE_CAPTION_FOR_INDEXING, $captionAsset->getPartnerId())) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
$fullPath = myContentStorage::getFSUploadsPath() . '/' . $captionAsset->getId() . '.tmp';
if (!kFile::downloadUrlToFile($fileSync->getExternalUrl($captionAsset->getEntryId()), $fullPath)) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
kFileSyncUtils::moveFromFile($fullPath, $syncKey, true, false, true);
}
$jobData = new kParseCaptionAssetJobData();
$jobData->setCaptionAssetId($captionAsset->getId());
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild();
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($captionAsset->getEntryId());
$batchJob->setPartnerId($captionAsset->getPartnerId());
}
return kJobsManager::addJob($batchJob, $jobData, CaptionSearchPlugin::getBatchJobTypeCoreValue(CaptionSearchBatchJobType::PARSE_CAPTION_ASSET));
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:36,代码来源:kCaptionSearchFlowManager.php
示例3: addEventNotificationDispatchJob
/**
* @param int $eventNotificationType
* @param kEventNotificationDispatchJobData $jobData
* @param string $partnerId
* @param string $entryId
* @param BatchJob $parentJob
* @return BatchJob
*/
public static function addEventNotificationDispatchJob($eventNotificationType, kEventNotificationDispatchJobData $jobData, $partnerId = null, $entryId = null, BatchJob $parentJob = null)
{
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild(false);
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($entryId);
if (!$partnerId) {
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
}
$batchJob->setPartnerId($partnerId ? $partnerId : kCurrentContext::$partner_id);
}
KalturaLog::log("Creating event notification dispatch job on template id [" . $jobData->getTemplateId() . "] engine[{$eventNotificationType}]");
$jobType = EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER);
return kJobsManager::addJob($batchJob, $jobData, $jobType, $eventNotificationType);
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:25,代码来源:kEventNotificationFlowManager.php
示例4: addVirusScanJob
/**
* @param BatchJob $parentJob
* @param int $partnerId
* @param string $entryId
* @param string $flavorAssetId
* @param string $srcFilePath
* @param VirusScanEngineType $virusScanEngine
* @param int $scanProfileId
* @return BatchJob
*/
public static function addVirusScanJob(BatchJob $parentJob = null, $partnerId, $entryId, $flavorAssetId, $srcFilePath, $virusScanEngine, $virusFoundAction)
{
$jobData = new kVirusScanJobData();
$jobData->setSrcFilePath($srcFilePath);
$jobData->setFlavorAssetId($flavorAssetId);
$jobData->setVirusFoundAction($virusFoundAction);
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild();
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($entryId);
$batchJob->setPartnerId($partnerId);
}
$jobType = VirusScanPlugin::getBatchJobTypeCoreValue(VirusScanBatchJobType::VIRUS_SCAN);
return self::addJob($batchJob, $jobData, $jobType, $virusScanEngine);
}
示例5: addEventNotificationDispatchJob
/**
* @param int $eventNotificationType
* @param kEventNotificationDispatchJobData $jobData
* @param string $partnerId
* @param string $entryId
* @param BatchJob $parentJob
* @return BatchJob
*/
protected function addEventNotificationDispatchJob($eventNotificationType, kEventNotificationDispatchJobData $jobData, $partnerId = null, $entryId = null, BatchJob $parentJob = null)
{
$jobType = EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER);
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild($jobType, $eventNotificationType, false);
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($entryId);
if (!$partnerId) {
$partnerId = kCurrentContext::getCurrentPartnerId();
}
$batchJob->setPartnerId($partnerId);
}
KalturaLog::log("Creating event notification dispatch job on template id [" . $jobData->getTemplateId() . "] engine[{$eventNotificationType}]");
$batchJob->setObjectId($entryId);
$batchJob->setObjectType(BatchJobObjectType::ENTRY);
$batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
$batchJob = kJobsManager::addJob($batchJob, $jobData, $jobType, $eventNotificationType);
$jobData->setJobId($batchJob->getId());
$batchJob->setData($jobData);
return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
}
示例6: addFileSyncImportJob
/**
* @param string $entryId
* @param FileSync $object
* @param int $fileSyncId
* @param string $sourceFileUrl
* @return BatchJob
*/
public static function addFileSyncImportJob($entryId, FileSync $fileSync, $sourceFileUrl, BatchJob $parentJob = null, $fileSize = null)
{
$partnerId = $fileSync->getPartnerId();
$fileSyncId = $fileSync->getId();
$dc = $fileSync->getDc();
KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
$fileSyncImportData = new kFileSyncImportJobData();
$fileSyncImportData->setSourceUrl($sourceFileUrl);
$fileSyncImportData->setFilesyncId($fileSyncId);
// tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild(true, $dc);
} else {
$batchJob = new BatchJob();
$batchJob->setDc($dc);
$batchJob->setEntryId($entryId);
$batchJob->setPartnerId($partnerId);
}
$batchJob->setFileSize($fileSize);
KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId} size: {$fileSize}");
return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
}
示例7: decideAddEntryFlavor
/**
* batch decideAddEntryFlavor is the decision layer for adding a single flavor conversion to an entry
*
* @param BatchJob $parentJob
* @param int $entryId
* @param int $flavorParamsId
* @param string $errDescription
* @param string $flavorAssetId
* @return BatchJob
*/
public static function decideAddEntryFlavor(BatchJob $parentJob = null, $entryId, $flavorParamsId, &$errDescription)
{
KalturaLog::log("entryId [{$entryId}], flavorParamsId [{$flavorParamsId}]");
$originalFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entryId);
if (is_null($originalFlavorAsset)) {
$errDescription = 'Original flavor asset not found';
KalturaLog::log(__METHOD__ . " - " . $errDescription);
return null;
}
if ($originalFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$errDescription = 'Original flavor asset not ready';
KalturaLog::log(__METHOD__ . " - " . $errDescription);
return null;
}
$mediaInfoId = null;
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
if ($mediaInfo) {
$mediaInfoId = $mediaInfo->getId();
}
$flavorParams = flavorParamsPeer::retrieveByPK($flavorParamsId);
$flavor = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
if (is_null($flavor)) {
KalturaLog::log(__METHOD__ . " - Failed to validate media info [{$errDescription}]");
return null;
}
if ($parentJob) {
// prefer the partner id from the parent job, although it should be the same
$partnerId = $parentJob->getPartnerId();
} else {
$partnerId = $originalFlavorAsset->getPartnerId();
}
$flavorAssetId = null;
$flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entryId, $flavorParamsId);
if ($flavorAsset) {
$flavorAssetId = $flavorAsset->getId();
}
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$flavor->_force = true;
// force to convert the flavor, even if none complied
$flavor->setReadyBehavior(flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE);
// should not be taken in completion rules check
$flavorAsset = kBatchManager::createFlavorAsset($flavor, $partnerId, $entryId, $flavorAssetId);
if (!$flavorAsset) {
KalturaLog::err(__METHOD__ . " - Failed to create flavor asset");
return null;
}
$flavorAssetId = $flavorAsset->getId();
$collectionTag = $flavor->getCollectionTag();
if ($collectionTag) {
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
throw new APIException(APIErrors::INVALID_ENTRY, $parentJob, $entryId);
}
$dbConvertCollectionJob = null;
if ($parentJob) {
$dbConvertCollectionJob = $parentJob->createChild(false);
$dbConvertCollectionJob->setEntryId($entryId);
$dbConvertCollectionJob->save();
}
$flavorAssets = flavorAssetPeer::retrieveByEntryId($entryId);
$flavorAssets = flavorAssetPeer::filterByTag($flavorAssets, $collectionTag);
$flavors = array();
foreach ($flavorAssets as $tagedFlavorAsset) {
if ($tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE || $tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
continue;
}
$flavorParamsOutput = flavorParamsOutputPeer::retrieveByFlavorAssetId($tagedFlavorAsset->getId());
if (is_null($flavorParamsOutput)) {
KalturaLog::log("Creating flavor params output for asset [" . $tagedFlavorAsset->getId() . "]");
$flavorParams = flavorParamsPeer::retrieveByPK($tagedFlavorAsset->getId());
$flavorParamsOutput = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
if (is_null($flavorParamsOutput)) {
KalturaLog::log(__METHOD__ . " - Failed to validate media info [{$errDescription}]");
continue;
}
}
if ($flavorParamsOutput) {
KalturaLog::log("Adding Collection flavor [" . $flavorParamsOutput->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
$flavors[$tagedFlavorAsset->getId()] = flavorParamsOutputPeer::retrieveByFlavorAssetId($tagedFlavorAsset->getId());
}
}
if ($flavorAssetId) {
KalturaLog::log("Updating Collection flavor [" . $flavor->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
$flavors[$flavorAssetId] = $flavor;
}
switch ($collectionTag) {
case flavorParams::TAG_ISM:
KalturaLog::log("Calling addConvertIsmCollectionJob with [" . count($flavors) . "] flavor params");
return kJobsManager::addConvertIsmCollectionJob($collectionTag, $srcSyncKey, $entry, $parentJob, $flavors, $dbConvertCollectionJob);
default:
//.........这里部分代码省略.........
示例8: handleBulkDownloadFinished
public static function handleBulkDownloadFinished(BatchJob $dbBatchJob, kBulkDownloadJobData $data, BatchJob $twinJob = null)
{
if ($dbBatchJob->getAbort()) {
return $dbBatchJob;
}
$partner = PartnerPeer::retrieveByPK($dbBatchJob->getPartnerId());
if (!$partner) {
KalturaLog::err("Partner id [" . $dbBatchJob->getPartnerId() . "] not found, not sending mail");
return $dbBatchJob;
}
$adminName = $partner->getAdminName();
$entryIds = explode(",", $data->getEntryIds());
$flavorParamsId = $data->getFlavorParamsId();
$links = array();
foreach ($entryIds as $entryId) {
$entry = entryPeer::retrieveByPK($entryId);
if (is_null($entry)) {
continue;
}
$link = $entry->getDownloadAssetUrl($flavorParamsId);
if (is_null($link)) {
$link = "Failed to prepare";
} else {
$link = '<a href="' . $link . '">Download</a>';
}
$links[] = $entry->getName() . " - " . $link;
}
$linksHtml = implode("<br />", $links);
// add mail job
$jobData = new kMailJobData();
$jobData->setIsHtml(true);
$jobData->setMailPriority(kMailJobData::MAIL_PRIORITY_NORMAL);
$jobData->setStatus(kMailJobData::MAIL_STATUS_PENDING);
if (count($links) <= 1) {
$jobData->setMailType(62);
} else {
$jobData->setMailType(63);
}
$jobData->setBodyParamsArray(array($adminName, $linksHtml));
$jobData->setFromEmail(kConf::get("batch_download_video_sender_email"));
$jobData->setFromName(kConf::get("batch_download_video_sender_name"));
$kuser = kuserPeer::getKuserByPartnerAndUid($dbBatchJob->getPartnerId(), $data->getPuserId());
if ($kuser) {
$recipientEmail = $kuser->getEmail();
} else {
KalturaLog::err('Cannot find kuser with puserId [' . $dbBatchJob->getPartnerId() . '] and partnerId [' . $data->getPuserId() . ']. Sending mail to admin user instead.');
$recipientEmail = $partner->getAdminEmail();
}
$jobData->setRecipientEmail($recipientEmail);
$jobData->setSubjectParamsArray(array());
kJobsManager::addJob($dbBatchJob->createChild(), $jobData, BatchJobType::MAIL, $jobData->getMailType());
return $dbBatchJob;
}
示例9: addNotificationJob
public static function addNotificationJob(BatchJob $parentJob = null, $entryId, $partnerId, $notificationType, $sendType, $puserId, $objectId, $notificationData)
{
$jobData = new kNotificationJobData();
$jobData->setType($notificationType);
$jobData->setSendType($sendType);
$jobData->setUserId($puserId);
$jobData->setObjectId($objectId);
$jobData->setData($notificationData);
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild(BatchJobType::NOTIFICATION, $notificationType);
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($entryId);
$batchJob->setPartnerId($partnerId);
}
if ($sendType == kNotificationJobData::NOTIFICATION_MGR_NO_SEND || $sendType == kNotificationJobData::NOTIFICATION_MGR_SEND_SYNCH) {
$batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
}
return self::addJob($batchJob, $jobData, BatchJobType::NOTIFICATION, $notificationType);
}
示例10: handleBulkDownloadFinished
public static function handleBulkDownloadFinished(BatchJob $dbBatchJob, kBulkDownloadJobData $data)
{
if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
return $dbBatchJob;
}
$partner = PartnerPeer::retrieveByPK($dbBatchJob->getPartnerId());
if (!$partner) {
KalturaLog::err("Partner id [" . $dbBatchJob->getPartnerId() . "] not found, not sending mail");
return $dbBatchJob;
}
$entryIds = explode(",", $data->getEntryIds());
$flavorParamsId = $data->getFlavorParamsId();
$links = array();
foreach ($entryIds as $entryId) {
$entry = entryPeer::retrieveByPK($entryId);
if (is_null($entry)) {
continue;
}
if ($entry->getType() != entryType::MEDIA_CLIP) {
KalturaLog::info("This entry cannot be downloaded {$entryId}");
continue;
}
$link = $entry->getDownloadAssetUrl($flavorParamsId);
if (is_null($link)) {
$link = "Failed to prepare";
} else {
$link = '<a href="' . $link . '">Download</a>';
}
$links[] = $entry->getName() . " - " . $link;
}
$linksHtml = implode("<br />", $links);
// add mail job
$jobData = new kMailJobData();
$jobData->setIsHtml(true);
$jobData->setMailPriority(kMailJobData::MAIL_PRIORITY_NORMAL);
$jobData->setStatus(kMailJobData::MAIL_STATUS_PENDING);
if (count($links) <= 1) {
$jobData->setMailType(62);
} else {
$jobData->setMailType(63);
}
$jobData->setFromEmail(kConf::get("batch_download_video_sender_email"));
$jobData->setFromName(kConf::get("batch_download_video_sender_name"));
$adminName = $partner->getAdminName();
$recipientEmail = $partner->getAdminEmail();
$kuser = kuserPeer::getKuserByPartnerAndUid($dbBatchJob->getPartnerId(), $data->getPuserId());
if ($kuser) {
$recipientEmail = $kuser->getEmail();
$adminName = $kuser->getFullName();
}
if (!$adminName) {
$adminName = $recipientEmail;
}
$jobData->setSeparator(self::BULK_DOWNLOAD_EMAIL_PARAMS_SEPARATOR);
$jobData->setBodyParamsArray(array($adminName, $linksHtml));
$jobData->setRecipientEmail($recipientEmail);
$jobData->setSubjectParamsArray(array());
kJobsManager::addJob($dbBatchJob->createChild(BatchJobType::MAIL, $jobData->getMailType()), $jobData, BatchJobType::MAIL, $jobData->getMailType());
return $dbBatchJob;
}
示例11: alert
protected static function alert(BatchJob $dbBatchJob, Exception $exception)
{
$jobData = new kMailJobData();
$jobData->setMailPriority(kMailJobData::MAIL_PRIORITY_HIGH);
$jobData->setStatus(kMailJobData::MAIL_STATUS_PENDING);
KalturaLog::alert("Error in job [{$dbBatchJob->getId()}]\n" . $exception);
$jobData->setMailType(90);
// is the email template
$jobData->setBodyParamsArray(array($dbBatchJob->getId(), $exception->getFile(), $exception->getLine(), $exception->getMessage(), $exception->getTraceAsString()));
$jobData->setFromEmail(kConf::get("batch_alert_email"));
$jobData->setFromName(kConf::get("batch_alert_name"));
$jobData->setRecipientEmail(kConf::get("batch_alert_email"));
$jobData->setSubjectParamsArray(array());
kJobsManager::addJob($dbBatchJob->createChild(BatchJobType::MAIL, $jobData->getMailType()), $jobData, BatchJobType::MAIL, $jobData->getMailType());
}