本文整理汇总了PHP中BatchJob::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJob::setData方法的具体用法?PHP BatchJob::setData怎么用?PHP BatchJob::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchJob
的用法示例。
在下文中一共展示了BatchJob::setData方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addJob
/**
* @param string $puser_id
* @param string $entry
* @param string $version
* @param string $file_format
* @return BatchJob
*/
public static function addJob($puser_id, $entry, $version, $file_format)
{
$entryId = $entry->getId();
$entryIntId = $entry->getIntId();
$entryVersion = $version ? $version : $entry->getVersion();
if ($entry) {
$partner = $entry->getPartner();
$email = $partner->getAdminEmail();
}
$data = json_encode(array('puserId' => $puser_id, 'entryId' => $entryId, 'entryIntId' => $entryIntId, 'entryVersion' => $entryVersion, 'fileFormat' => $file_format, 'email' => $email));
$job = new BatchJob();
$job->setJobType(BatchJobType::FLATTEN);
$job->setData($data, true);
$job->setStatus(BatchJob::BATCHJOB_STATUS_PENDING);
$job->setCheckAgainTimeout(time() + 10);
$job->setProgress(0);
$job->setMessage('Queued');
$job->setDescription('Queued, waiting to run');
$job->setUpdatesCount(0);
$job->setEntryId($entryId);
$job->setPartnerId($entry->getPartnerId());
$job->setSubpId($entry->getSubpId());
$job->save();
return $job;
}
示例2: executeImpl
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
$prefix = null;
$notData = new kNotificationJobData();
$notData->setData('');
$notData->setType(kNotificationJobData::NOTIFICATION_TYPE_TEST);
$notData->setUserId($puser_id);
$job = new BatchJob();
$job->setId(kNotificationJobData::NOTIFICATION_TYPE_TEST + (int) time());
$job->setData($notData);
$job->setPartnerId($partner_id);
$partner = PartnerPeer::retrieveByPK($partner_id);
list($url, $signature_key) = myNotificationMgr::getPartnerNotificationInfo($partner);
list($params, $raw_siganture) = myNotificationMgr::prepareNotificationData($url, $signature_key, $job, $prefix);
$this->send($url, $params);
}
示例3: handleCaptureThumbFinished
/**
* @param BatchJob $dbBatchJob
* @param kCaptureThumbJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function handleCaptureThumbFinished(BatchJob $dbBatchJob, kCaptureThumbJobData $data, BatchJob $twinJob = null)
{
KalturaLog::debug("Captire thumbnail finished with destination file: " . $data->getThumbPath());
if ($dbBatchJob->getAbort()) {
return $dbBatchJob;
}
// verifies that thumb asset created
if (!$data->getThumbAssetId()) {
throw new APIException(APIErrors::INVALID_THUMB_ASSET_ID, $data->getThumbAssetId());
}
$thumbAsset = thumbAssetPeer::retrieveById($data->getThumbAssetId());
// verifies that thumb asset exists
if (!$thumbAsset) {
throw new APIException(APIErrors::INVALID_THUMB_ASSET_ID, $data->getThumbAssetId());
}
$thumbAsset->incrementVersion();
$thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_READY);
if (file_exists($data->getThumbPath())) {
list($width, $height, $type, $attr) = getimagesize($data->getThumbPath());
$thumbAsset->setWidth($width);
$thumbAsset->setHeight($height);
$thumbAsset->setSize(filesize($data->getThumbPath()));
}
$logPath = $data->getThumbPath() . '.log';
if (file_exists($logPath)) {
$thumbAsset->incLogFileVersion();
$thumbAsset->save();
// creats the file sync
$logSyncKey = $thumbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
try {
kFileSyncUtils::moveFromFile($logPath, $logSyncKey);
} catch (Exception $e) {
$err = 'Saving conversion log: ' . $e->getMessage();
KalturaLog::err($err);
$desc = $dbBatchJob->getDescription() . "\n" . $err;
$dbBatchJob->getDescription($desc);
}
} else {
$thumbAsset->save();
}
$syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($data->getThumbPath(), $syncKey);
$data->setThumbPath(kFileSyncUtils::getLocalFilePathForKey($syncKey));
KalturaLog::debug("Thumbnail archived file to: " . $data->getThumbPath());
// save the data changes to the db
$dbBatchJob->setData($data);
$dbBatchJob->save();
if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$entry = $dbBatchJob->getEntry(false, false);
if (!$entry) {
throw new APIException(APIErrors::INVALID_ENTRY, $dbBatchJob, $dbBatchJob->getEntryId());
}
// increment thumbnail version
$entry->setThumbnail(".jpg");
$entry->save();
$entrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
$syncFile = kFileSyncUtils::createSyncFileLinkForKey($entrySyncKey, $syncKey, false);
if ($syncFile) {
// removes the DEFAULT_THUMB tag from all other thumb assets
$entryThumbAssets = thumbAssetPeer::retrieveByEntryId($thumbAsset->getEntryId());
foreach ($entryThumbAssets as $entryThumbAsset) {
if ($entryThumbAsset->getId() == $thumbAsset->getId()) {
continue;
}
if (!$entryThumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
continue;
}
$entryThumbAsset->removeTags(array(thumbParams::TAG_DEFAULT_THUMB));
$entryThumbAsset->save();
}
}
}
if (!is_null($thumbAsset->getFlavorParamsId())) {
kFlowHelper::generateThumbnailsFromFlavor($dbBatchJob->getEntryId(), $dbBatchJob, $thumbAsset->getFlavorParamsId());
}
return $dbBatchJob;
}
示例4: onDistributionDeleteJobUpdated
/**
* @param BatchJob $dbBatchJob
* @param kDistributionDeleteJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function onDistributionDeleteJobUpdated(BatchJob $dbBatchJob, kDistributionDeleteJobData $data, BatchJob $twinJob = null)
{
if ($data->getResults() || $data->getSentData()) {
$entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
if (!$entryDistribution) {
KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
return $dbBatchJob;
}
if ($data->getResults()) {
$entryDistribution->incrementDeleteResultsVersion();
}
if ($data->getSentData()) {
$entryDistribution->incrementDeleteDataVersion();
}
$entryDistribution->save();
if ($data->getResults()) {
$key = $entryDistribution->getSyncKey(EntryDistribution::FILE_SYNC_ENTRY_DISTRIBUTION_DELETE_RESULTS);
kFileSyncUtils::file_put_contents($key, $data->getResults());
$data->setResults(null);
}
if ($data->getSentData()) {
$key = $entryDistribution->getSyncKey(EntryDistribution::FILE_SYNC_ENTRY_DISTRIBUTION_DELETE_DATA);
kFileSyncUtils::file_put_contents($key, $data->getSentData());
$data->setSentData(null);
}
$dbBatchJob->setData($data);
$dbBatchJob->save();
}
switch ($dbBatchJob->getStatus()) {
case BatchJob::BATCHJOB_STATUS_PENDING:
return self::onDistributionDeleteJobPending($dbBatchJob, $data, $twinJob);
case BatchJob::BATCHJOB_STATUS_FINISHED:
return self::onDistributionDeleteJobFinished($dbBatchJob, $data, $twinJob);
case BatchJob::BATCHJOB_STATUS_FAILED:
case BatchJob::BATCHJOB_STATUS_FATAL:
return self::onDistributionDeleteJobFailed($dbBatchJob, $data, $twinJob);
default:
return $dbBatchJob;
}
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:46,代码来源:kContentDistributionFlowManager.php
示例5: handleConvertFailed
public static function handleConvertFailed(BatchJob $dbBatchJob, $engineType, $flavorAssetId, $flavorParamsOutputId, $mediaInfoId)
{
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
// verifies that flavor asset exists
if (!$flavorAsset) {
throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId);
}
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->save();
// try to create a convert job with the next engine
if (!is_null($engineType)) {
$data = $dbBatchJob->getData();
if ($data instanceof kConvartableJobData) {
$data->incrementOperationSet();
$dbBatchJob->setData($data);
$dbBatchJob->save();
}
$newDbBatchJob = kBusinessPreConvertDL::redecideFlavorConvert($flavorAssetId, $flavorParamsOutputId, $mediaInfoId, $dbBatchJob, $engineType);
if ($newDbBatchJob) {
return true;
}
}
// find the root job
$rootBatchJob = $dbBatchJob->getRootJob();
if (!$rootBatchJob) {
return false;
}
// the root is already failed
if ($rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) {
return false;
}
// bulk download root job no need to handle
if ($rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
kJobsManager::failBatchJob($rootBatchJob, "Convert job " . $dbBatchJob->getId() . " failed");
return false;
}
if (is_null($flavorParamsOutputId)) {
kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
return false;
}
$readyBehavior = $dbBatchJob->getData()->getReadyBehavior();
if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
return false;
}
// failing the root profile job if all child jobs failed
if ($rootBatchJob->getJobType() != BatchJobType::CONVERT_PROFILE) {
return false;
}
$siblingJobs = $rootBatchJob->getChildJobs();
foreach ($siblingJobs as $siblingJob) {
/* @var $siblingJob BatchJob */
// not conversion job and should be ignored
if ($siblingJob->getJobType() != BatchJobType::CONVERT && $siblingJob->getJobType() != BatchJobType::POSTCONVERT) {
continue;
}
$jobData = $siblingJob->getData();
if (!$jobData || !$jobData instanceof kConvertJobData && !$jobData instanceof kPostConvertJobData) {
KalturaLog::err("Job id [" . $siblingJob->getId() . "] has no valid job data");
continue;
}
// found child flavor asset that hasn't failed, no need to fail the root job
$siblingFlavorAssetId = $jobData->getFlavorAssetId();
$siblingFlavorAsset = assetPeer::retrieveById($siblingFlavorAssetId);
if ($siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_ERROR && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
return false;
}
}
// all conversions failed, should fail the root job
kJobsManager::failBatchJob($rootBatchJob, "All conversions failed");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
return false;
}
示例6: toData
//.........这里部分代码省略.........
$this->data = KalturaProvisionJobData::getJobDataInstance($jobSubType);
}
break;
case KalturaBatchJobType::CONVERT_COLLECTION:
$dbData = new kConvertCollectionJobData();
if (is_null($this->data)) {
$this->data = new KalturaConvertCollectionJobData();
}
break;
case KalturaBatchJobType::STORAGE_EXPORT:
$dbData = new kStorageExportJobData();
if (is_null($this->data)) {
$this->data = new KalturaStorageExportJobData();
}
break;
case KalturaBatchJobType::MOVE_CATEGORY_ENTRIES:
$dbData = new kMoveCategoryEntriesJobData();
if (is_null($this->data)) {
$this->data = new KalturaMoveCategoryEntriesJobData();
}
break;
case KalturaBatchJobType::STORAGE_DELETE:
$dbData = new kStorageDeleteJobData();
if (is_null($this->data)) {
$this->data = new KalturaStorageDeleteJobData();
}
break;
case KalturaBatchJobType::CAPTURE_THUMB:
$dbData = new kCaptureThumbJobData();
if (is_null($this->data)) {
$this->data = new KalturaCaptureThumbJobData();
}
break;
case KalturaBatchJobType::INDEX:
$dbData = new kIndexJobData();
if (is_null($this->data)) {
$this->data = new KalturaIndexJobData();
}
break;
case KalturaBatchJobType::COPY:
$dbData = new kCopyJobData();
if (is_null($this->data)) {
$this->data = new KalturaCopyJobData();
}
break;
case KalturaBatchJobType::DELETE:
$dbData = new kDeleteJobData();
if (is_null($this->data)) {
$this->data = new KalturaDeleteJobData();
}
break;
case KalturaBatchJobType::DELETE_FILE:
$dbData = new kDeleteFileJobData();
if (is_null($this->data)) {
$this->data = new KalturaDeleteFileJobData();
}
break;
case KalturaBatchJobType::CONVERT_LIVE_SEGMENT:
$dbData = new kConvertLiveSegmentJobData();
if (is_null($this->data)) {
$this->data = new KalturaConvertLiveSegmentJobData();
}
break;
case KalturaBatchJobType::CONCAT:
$dbData = new kConcatJobData();
if (is_null($this->data)) {
$this->data = new KalturaConcatJobData();
}
break;
case KalturaBatchJobType::COPY_PARTNER:
$dbData = new kCopyPartnerJobData();
if (is_null($this->data)) {
$this->data = new KalturaCopyPartnerJobData();
}
break;
case KalturaBatchJobType::RECALCULATE_CACHE:
switch ($dbBatchJob->getJobSubType()) {
case RecalculateCacheType::RESPONSE_PROFILE:
$dbData = new kRecalculateResponseProfileCacheJobData();
if (is_null($this->data)) {
$this->data = new KalturaRecalculateResponseProfileCacheJobData();
}
break;
}
break;
default:
$dbData = KalturaPluginManager::loadObject('kJobData', $dbBatchJob->getJobType());
if (is_null($this->data)) {
$this->data = KalturaPluginManager::loadObject('KalturaJobData', $this->jobType);
}
}
if (is_null($dbBatchJob->getData())) {
$dbBatchJob->setData($dbData);
}
if ($this->data instanceof KalturaJobData) {
$dbData = $this->data->toObject($dbBatchJob->getData());
$dbBatchJob->setData($dbData);
}
return $dbData;
}
示例7: addExportLiveReportJob
public static function addExportLiveReportJob($reportType, KalturaLiveReportExportParams $params)
{
KalturaLog::debug("adding Export Live Report job");
// Calculate time offset from server time to UTC
$dateTimeZoneServer = new DateTimeZone(kConf::get('date_default_timezone'));
$dateTimeZoneUTC = new DateTimeZone("UTC");
$dateTimeUTC = new DateTime("now", $dateTimeZoneUTC);
$timeOffsetSeconds = -1 * $dateTimeZoneServer->getOffset($dateTimeUTC);
// Create job data
$jobData = new kLiveReportExportJobData();
$jobData->entryIds = $params->entryIds;
$jobData->recipientEmail = $params->recpientEmail;
$jobData->timeZoneOffset = $timeOffsetSeconds - $params->timeZoneOffset * 60;
// Convert minutes to seconds
$jobData->timeReference = time();
$jobData->applicationUrlTemplate = $params->applicationUrlTemplate;
$job = new BatchJob();
$job->setPartnerId(kCurrentContext::getCurrentPartnerId());
$job->setJobType(BatchJobType::LIVE_REPORT_EXPORT);
$job->setJobSubType($reportType);
$job->setData($jobData);
return self::addJob($job, $jobData, BatchJobType::LIVE_REPORT_EXPORT, $reportType);
}
示例8: onBulkUploadJobStatusUpdated
private function onBulkUploadJobStatusUpdated(BatchJob $dbBatchJob)
{
$xmlDropFolderFile = DropFolderFilePeer::retrieveByPK($dbBatchJob->getObjectId());
if (!$xmlDropFolderFile) {
return;
}
KalturaLog::debug('object id ' . $dbBatchJob->getObjectId());
switch ($dbBatchJob->getStatus()) {
case BatchJob::BATCHJOB_STATUS_QUEUED:
$jobData = $dbBatchJob->getData();
if (!is_null($jobData->getFilePath())) {
$syncKey = $dbBatchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD);
try {
kFileSyncUtils::moveFromFile($jobData->getFilePath(), $syncKey, true);
} catch (Exception $e) {
KalturaLog::err($e);
throw new APIException(APIErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR);
}
$filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$jobData->setFilePath($filePath);
//save new info on the batch job
$dbBatchJob->setData($jobData);
$dbBatchJob->save();
}
break;
case BatchJob::BATCHJOB_STATUS_FINISHED:
case BatchJob::BATCHJOB_STATUS_FINISHED_PARTIALLY:
KalturaLog::debug("Handling Bulk Upload finished");
$xmlDropFolderFile->setStatus(DropFolderFileStatus::HANDLED);
$xmlDropFolderFile->save();
break;
case BatchJob::BATCHJOB_STATUS_FAILED:
case BatchJob::BATCHJOB_STATUS_FATAL:
KalturaLog::debug("Handling Bulk Upload failed");
$relatedFiles = DropFolderFilePeer::retrieveByLeadIdAndStatuses($xmlDropFolderFile->getId(), array(DropFolderFileStatus::PROCESSING));
foreach ($relatedFiles as $relatedFile) {
$this->setFileError($relatedFile, DropFolderFileStatus::ERROR_HANDLING, DropFolderXmlBulkUploadPlugin::getErrorCodeCoreValue(DropFolderXmlBulkUploadErrorCode::ERROR_IN_BULK_UPLOAD), DropFolderXmlBulkUploadPlugin::ERROR_IN_BULK_UPLOAD_MESSAGE);
}
break;
}
}
示例9: handleConvertFailed
public static function handleConvertFailed(BatchJob $dbBatchJob, $engineType, $flavorAssetId, $flavorParamsOutputId, $mediaInfoId)
{
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
// verifies that flavor asset exists
if (!$flavorAsset) {
throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId);
}
/*
* On Webex error, roll back the inter-src asset version in order to allow the retry to get ARF as a source,
* rather than the invlaid WMV file (product of bad nbrplayer session)
*/
if ($dbBatchJob->getErrNumber() == BatchJobAppErrors::BLACK_OR_SILENT_CONTENT) {
$prevVer = $flavorAsset->getPreviousVersion();
$currVer = $flavorAsset->getVersion();
KalturaLog::log("Webex conversion - Garbled Audio or Black frame or Silence. Rolling back asset/file-sync version - curr({$currVer}), prev({$prevVer})");
if (isset($prevVer)) {
$syncKey = $flavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $currVer);
if (isset($syncKey)) {
kFileSyncUtils::deleteSyncFileForKey($syncKey, false, true);
$flavorAsset->setVersion($prevVer);
$flavorAsset->setPreviousVersion(null);
KalturaLog::log("Webex conversion - Rolled back");
}
}
}
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->save();
// try to create a convert job with the next engine
if (!is_null($engineType)) {
$data = $dbBatchJob->getData();
if ($data instanceof kConvartableJobData) {
$data->incrementOperationSet();
$dbBatchJob->setData($data);
$dbBatchJob->save();
}
$newDbBatchJob = kBusinessPreConvertDL::redecideFlavorConvert($flavorAssetId, $flavorParamsOutputId, $mediaInfoId, $dbBatchJob, $engineType);
if ($newDbBatchJob) {
return true;
}
}
// find the root job
$rootBatchJob = $dbBatchJob->getRootJob();
if (!$rootBatchJob) {
return false;
}
// the root is already failed
if ($rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) {
return false;
}
// bulk download root job no need to handle
if ($rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
kJobsManager::failBatchJob($rootBatchJob, "Convert job " . $dbBatchJob->getId() . " failed");
return false;
}
if (is_null($flavorParamsOutputId)) {
kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
return false;
}
$readyBehavior = $dbBatchJob->getData()->getReadyBehavior();
if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
return false;
}
// failing the root profile job if all child jobs failed
if ($rootBatchJob->getJobType() != BatchJobType::CONVERT_PROFILE) {
return false;
}
$siblingJobs = $rootBatchJob->getChildJobs();
foreach ($siblingJobs as $siblingJob) {
/* @var $siblingJob BatchJob */
// not conversion job and should be ignored
if ($siblingJob->getJobType() != BatchJobType::CONVERT && $siblingJob->getJobType() != BatchJobType::POSTCONVERT) {
continue;
}
$jobData = $siblingJob->getData();
if (!$jobData || !$jobData instanceof kConvertJobData && !$jobData instanceof kPostConvertJobData) {
KalturaLog::err("Job id [" . $siblingJob->getId() . "] has no valid job data");
continue;
}
// found child flavor asset that hasn't failed, no need to fail the root job
$siblingFlavorAssetId = $jobData->getFlavorAssetId();
$siblingFlavorAsset = assetPeer::retrieveById($siblingFlavorAssetId);
if ($siblingFlavorAsset && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_ERROR && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
return false;
}
}
// all conversions failed, should fail the root job
kJobsManager::failBatchJob($rootBatchJob, "All conversions failed");
kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
return false;
}
示例10: addJob
/**
* @param BatchJob $batchJob
* @param $data
* @param int $type
* @param int $subType
* @return BatchJob
*/
public static function addJob(BatchJob $batchJob, $data, $type, $subType = null)
{
$batchJob->setJobType($type);
$batchJob->setJobSubType($subType);
$batchJob->setData($data);
if (!$batchJob->getParentJobId() && $batchJob->getEntryId()) {
$currentJob = kBatchManager::getCurrentUpdatingJob();
if ($currentJob && $currentJob->getEntryId() == $batchJob->getEntryId()) {
$batchJob->setParentJobId($currentJob->getId());
$batchJob->setBulkJobId($currentJob->getBulkJobId());
$batchJob->setRootJobId($currentJob->getRootJobId());
} else {
$entry = entryPeer::retrieveByPKNoFilter($batchJob->getEntryId());
// some jobs could be on deleted entry
if ($entry) {
$batchJob->setRootJobId($entry->getBulkUploadId());
$batchJob->setBulkJobId($entry->getBulkUploadId());
}
}
}
// validate partner id
$partnerId = $batchJob->getPartnerId();
// if(!$partnerId)
// throw new APIException(APIErrors::PARTNER_NOT_SET);
// validate that partner exists
$partner = PartnerPeer::retrieveByPK($partnerId);
if (!$partner) {
KalturaLog::err("Invalid partner id [{$partnerId}]");
throw new APIException(APIErrors::INVALID_PARTNER_ID, $partnerId);
}
// set the priority and work group
$batchJob->setPriority($partner->getPriority($batchJob->getBulkJobId()));
$batchJob = self::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
// look for identical jobs
$twinJobs = BatchJobPeer::retrieveDuplicated($type, $data);
$twinJob = null;
if (count($twinJobs)) {
foreach ($twinJobs as $currentTwinJob) {
if ($currentTwinJob->getId() != $batchJob->getId()) {
$twinJob = reset($twinJobs);
}
}
}
if (!is_null($twinJob)) {
$batchJob->setTwinJobId($twinJob->getId());
if (!kConf::get("batch_ignore_duplication")) {
$batchJob = self::updateBatchJob($batchJob, $twinJob->getStatus(), $twinJob);
} else {
$batchJob->save();
}
}
return $batchJob;
}
示例11: toData
//.........这里部分代码省略.........
case KalturaBatchJobType::EXTRACT_MEDIA:
$dbData = new kExtractMediaJobData();
if (is_null($this->data)) {
$this->data = new KalturaExtractMediaJobData();
}
break;
case KalturaBatchJobType::IMPORT:
$dbData = new kImportJobData();
if (is_null($this->data)) {
$this->data = new KalturaImportJobData();
}
break;
case KalturaBatchJobType::POSTCONVERT:
$dbData = new kPostConvertJobData();
if (is_null($this->data)) {
$this->data = new KalturaPostConvertJobData();
}
break;
case KalturaBatchJobType::PULL:
$dbData = new kPullJobData();
if (is_null($this->data)) {
$this->data = new KalturaPullJobData();
}
break;
case KalturaBatchJobType::REMOTE_CONVERT:
$dbData = new kRemoteConvertJobData();
if (is_null($this->data)) {
$this->data = new KalturaRemoteConvertJobData();
}
break;
case KalturaBatchJobType::MAIL:
$dbData = new kMailJobData();
if (is_null($this->data)) {
$this->data = new KalturaMailJobData();
}
break;
case KalturaBatchJobType::NOTIFICATION:
$dbData = new kNotificationJobData();
if (is_null($this->data)) {
$this->data = new KalturaNotificationJobData();
}
break;
case KalturaBatchJobType::BULKDOWNLOAD:
$dbData = new kBulkDownloadJobData();
if (is_null($this->data)) {
$this->data = new KalturaBulkDownloadJobData();
}
break;
case KalturaBatchJobType::FLATTEN:
$dbData = new kFlattenJobData();
if (is_null($this->data)) {
$this->data = new KalturaFlattenJobData();
}
break;
case KalturaBatchJobType::PROVISION_PROVIDE:
case KalturaBatchJobType::PROVISION_DELETE:
$dbData = new kProvisionJobData();
if (is_null($this->data)) {
$this->data = new KalturaProvisionJobData();
}
break;
case KalturaBatchJobType::CONVERT_COLLECTION:
$dbData = new kConvertCollectionJobData();
if (is_null($this->data)) {
$this->data = new KalturaConvertCollectionJobData();
}
break;
case KalturaBatchJobType::STORAGE_EXPORT:
$dbData = new kStorageExportJobData();
if (is_null($this->data)) {
$this->data = new KalturaStorageExportJobData();
}
break;
case KalturaBatchJobType::STORAGE_DELETE:
$dbData = new kStorageDeleteJobData();
if (is_null($this->data)) {
$this->data = new KalturaStorageDeleteJobData();
}
break;
case KalturaBatchJobType::CAPTURE_THUMB:
$dbData = new kCaptureThumbJobData();
if (is_null($this->data)) {
$this->data = new KalturaCaptureThumbJobData();
}
break;
default:
$dbData = KalturaPluginManager::loadObject('kJobData', $dbBatchJob->getJobType());
if (is_null($this->data)) {
$this->data = KalturaPluginManager::loadObject('KalturaJobData', $this->jobType);
}
}
if (is_null($dbBatchJob->getData())) {
$dbBatchJob->setData($dbData);
}
if ($this->data instanceof KalturaJobData) {
$dbData = $this->data->toObject($dbBatchJob->getData());
$dbBatchJob->setData($dbData);
}
return $dbData;
}