/**
  * @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;
 }
 /**
  * Will investigate a single entry
  */
 public function execute()
 {
     $mode = $this->getP("mode", "get");
     $c = new Criteria();
     //		$c->add ( BatchJobPeer::JOB_TYPE , BatchJobType::DELETE );
     $peer = new BatchJobPeer();
     $location_id = "loc1";
     $server_id = "ser1";
     $execution_time = 400;
     $number_of_objects = 1;
     if ($mode == "free") {
         $id = $this->getP("id");
         $this->res = kBatchExclusiveLock::freeExclusive($id, $peer, $location_id, $server_id);
     } elseif ($mode == "update") {
         $id = $this->getP("id");
         $obj = new BatchJob();
         $obj->setProgress(77);
         $this->res = kBatchExclusiveLock::updateExclusive($id, $peer, $location_id, $server_id, $obj);
     } else {
         $partner_group = new myPartnerGroups("+1;0;-3,4");
         $this->res = null;
         $cloned_c = clone $c;
         while ($partner_group->applyPartnerGroupToCriteria($cloned_c, $peer)) {
             $this->res = kBatchExclusiveLock::getExclusive($cloned_c, $peer, $location_id, $server_id, $execution_time, $number_of_objects);
             if ($this->res) {
                 break;
             }
             $cloned_c = clone $c;
         }
     }
 }
Exemplo n.º 3
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getPM("entry_id");
     $entry = entryPeer::retrieveByPK($entry_id);
     if (!$entry) {
         $this->addError(APIErrors::INVALID_ENTRY_ID, "entry", $entry_id);
     } else {
         $job = new BatchJob();
         $job->setJobType(BatchJobType::DVDCREATOR);
         $job->setStatus(BatchJob::BATCHJOB_STATUS_PENDING);
         $job->setCheckAgainTimeout(time() + 10);
         $job->setProgress(0);
         $job->setUpdatesCount(0);
         $job->setEntryId($entry_id);
         $job->setPartnerId($entry->getPartnerId());
         $job->setSubpId($entry->getSubpId());
         $job->save();
         $wrapper = objectWrapperBase::getWrapperClass($job, objectWrapperBase::DETAIL_LEVEL_DETAILED);
         // TODO - remove this code when cache works properly when saving objects (in their save method)
         $wrapper->removeFromCache("batch_job", $job->getId());
         $this->addMsg("batchjob", $wrapper);
     }
 }