Set the identity of the Job which should be fired by the produced
Trigger, by extracting the JobKey from the given job.

@param JobDetail $jobDetail the Job to fire.

@return TriggerBuilder

@see Trigger#getJobKey()
771260
public function forJobDetail(JobDetail $jobDetail)
    {
        if(null == $key = $jobDetail->getKey()) {
            throw new InvalidArgumentException('The given job has not yet had a key assigned to it.');
        }

        $this->jobKey = clone $key;

        return $this;
    }
620349
public function withDetails($info): self
    {
        if ($info instanceof AWSRoleCredential) {
            $this->withType(CredentialEnum::TYPE_AWS_ROLE);
            $this->awsRole = $info;
            $this->awsStatic = new AWSStaticCredential;
            $this->privateKey = new PrivateKeyCredential;

        } elseif ($info instanceof AWSStaticCredential) {
            $this->withType(CredentialEnum::TYPE_AWS_STATIC);
            $this->awsRole = new AWSRoleCredential;
            $this->awsStatic = $info;
            $this->privateKey = new PrivateKeyCredential;

        } elseif ($info instanceof PrivateKeyCredential) {
            $this->withType(CredentialEnum::TYPE_PRIVATEKEY);
            $this->awsRole = new AWSRoleCredential;
            $this->awsStatic = new AWSStaticCredential;
            $this->privateKey = $info;

        } else {
            $this->withType(CredentialEnum::TYPE_AWS_STATIC);
            $this->awsRole = new AWSRoleCredential;
            $this->awsStatic = new AWSStaticCredential;
            $this->privateKey = new PrivateKeyCredential;
        }

        return $this;
    }
983463
public function setId($id)
    {
        if ($this->hasData(self::P_ID)) {
            throw new JobException('Cant set id cause it is already sets!');
        }

        return $this->setData(self::P_ID, $id);
    }
879600
public void triggerJob (final JobKey jobKey, final JobDataMap data) throws SchedulerException
  {
    validateState ();

    final IOperableTrigger trig = (IOperableTrigger) newTrigger ().withIdentity (_newTriggerId (),
                                                                                 IScheduler.DEFAULT_GROUP)
                                                                  .forJob (jobKey)
                                                                  .build ();
    trig.computeFirstFireTime (null);
    if (data != null)
    {
      trig.setJobDataMap (data);
    }

    boolean collision = true;
    while (collision)
    {
      try
      {
        m_aResources.getJobStore ().storeTrigger (trig, false);
        collision = false;
      }
      catch (final ObjectAlreadyExistsException oaee)
      {
        trig.setKey (new TriggerKey (_newTriggerId (), IScheduler.DEFAULT_GROUP));
      }
    }

    notifySchedulerThread (trig.getNextFireTime ().getTime ());
    notifySchedulerListenersSchduled (trig);
  }
1298154
public function runJob(JobDefinition $job)
    {
        $this->output->writeln(
            [
                "\n",
                sprintf(
                    '<info>Running the %s job</info><comment>%s</comment>',
                    $job->getName(),
                    $job->getDescription() !== '' ? " > ".$job->getDescription() : ''
                )
            ]
        );

        foreach ($job->getTasks() as $task) {
            $preTaskEvent = new PreTaskEvent($job, $task);
            $this->dispatcher->dispatch(Event::PRE_TASK, $preTaskEvent);

            if ($preTaskEvent->isPropagationStopped()) {
                continue;
            }

            $service = $this->taskRegistry->findTaskByType($task->getType());
            $this->prepareServiceForTask($service, $task);

            try {
                $service->run($this->output);
            } catch (TaskRuntimeException $e) {
                if (!$task->continueOnError()) {
                    throw $e;
                }

                /** @var FormatterHelper $formatter */
                $formatter = $this->helperSet->get('formatter');
                $this->output->writeln(
                    [
                        '',
                        $formatter->formatBlock(
                            [
                                sprintf('[Warning] Task: %s', $task->getType()),
                                sprintf('%s', $e->getMessage())
                            ],
                            'bg=yellow;fg=black',
                            true
                        ),
                        ''
                    ]
                );
            }
        }
    }
36102
protected function doStoreTrigger(Trigger $newTrigger, $replaceExisting = false, $state = Trigger::STATE_WAITING)
    {
        $triggerKey = $newTrigger->getKey();
        $existingTrigger = $this->retrieveTrigger($triggerKey);

        if ($existingTrigger && false == $replaceExisting) {
            throw ObjectAlreadyExistsException::create($newTrigger);
        }

        $shouldBePaused = $this->isTriggerGroupPaused($triggerKey->getGroup());

        if (false == $shouldBePaused) {
            $shouldBePaused = $this->isTriggerGroupPaused(self::ALL_GROUPS_PAUSED);

            if ($shouldBePaused) {
                $this->insertPausedTriggerGroup($triggerKey->getGroup());
            }
        }

        if ($shouldBePaused && ($state == Trigger::STATE_WAITING || $state == Trigger::STATE_ACQUIRED)) {
            $state = Trigger::STATE_PAUSED;
        }

        $newTrigger->setState($state);

//        if (null == $job) {
//            $job = $this->retrieveJob($newTrigger->getJobKey());
//        }
//
//        if (null == $job) {
//            throw new JobPersistenceException(sprintf('The job referenced by the trigger does not exist. trigger: "%s", job: "%s"',
//                $triggerKey, $newTrigger->getJobKey()));
//        }

        if ($existingTrigger) {
            $id = get_object_id($existingTrigger);
            $values = get_values($newTrigger);

            set_values($existingTrigger, $values);
            set_object_id($existingTrigger, $id);

            $result = $this->res->getTriggerStorage()->update($existingTrigger, [
                'name' => $triggerKey->getName(),
                'group' => $triggerKey->getGroup()
            ], ['upsert' => false]);

            if ($result && (false == $result->isAcknowledged() || false == $result->getModifiedCount())) {
                throw new JobPersistenceException(sprintf('Couldn\'t store trigger.  Update failed: "%s"', $triggerKey));
            }
        } else {
            $result = $this->res->getTriggerStorage()->update($newTrigger, [
                'name' => $triggerKey->getName(),
                'group' => $triggerKey->getGroup()
            ], ['upsert' => true]);

            if ($result && (false == $result->isAcknowledged() || false == $result->getUpsertedCount())) {
                throw new JobPersistenceException(sprintf('Couldn\'t store trigger.  Insert failed: "%s"', $triggerKey));
            }
        }
    }
864547
public IJobDetail getJobDetail (final JobKey jobKey) throws SchedulerException
  {
    validateState ();

    return m_aResources.getJobStore ().retrieveJob (jobKey);
  }
1350969
@Nonnull
  public TriggerBuilder <T> forJob (@Nonnull final IJobDetail jobDetail)
  {
    final JobKey k = jobDetail.getKey ();
    if (k.getName () == null)
      throw new IllegalArgumentException ("The given job has not yet had a name assigned to it.");
    m_aJobKey = k;
    return this;
  }
454390
protected function doPauseTrigger(Key $triggerKey)
    {
        if (false == $trigger = $this->retrieveTrigger($triggerKey)) {
            return;
        }

        if (false == in_array($trigger->getState(), [Trigger::STATE_WAITING, Trigger::STATE_ACQUIRED], true)) {
            return;
        }

        $trigger->setState(Trigger::STATE_PAUSED);
        $result = $this->res->getTriggerStorage()->update($trigger);

        if (false == $result->isAcknowledged() || false == $result->getModifiedCount()) {
            throw new JobPersistenceException(sprintf('Couldn\'t pause trigger: "%s"', $triggerKey));
        }
    }
1185161
public function getJob($jobName)
    {
        $jobName = $this->jobPrefix . $jobName;

        foreach ($this->workers as $worker) {

            if (is_array($worker['jobs'])) {

                foreach ($worker['jobs'] as $job) {

                    if ($jobName === $job['realCallableName']) {

                        $worker['job'] = $job;

                        return $worker;
                    }
                }
            }
        }

        throw new JobDoesNotExistException();
    }
118425
public function prepareOrderDetailsGroupedByCustomer($orderDetails)
    {
        $preparedOrderDetails = [];
        foreach ($orderDetails as $orderDetail) {
            $key = $orderDetail->id_customer;
            $preparedOrderDetails[$key]['sum_price'] = $orderDetail->sum_price;
            $preparedOrderDetails[$key]['sum_amount'] = $orderDetail->sum_amount;
            $preparedOrderDetails[$key]['sum_deposit'] = $orderDetail->sum_deposit;
            $preparedOrderDetails[$key]['order_detail_count'] = $orderDetail->order_detail_count;
            $preparedOrderDetails[$key]['customer_id'] = $key;
            $preparedOrderDetails[$key]['name'] = Configure::read('app.htmlHelper')->getNameRespectingIsDeleted($orderDetail->customer);
            $preparedOrderDetails[$key]['email'] = '';
            if ($orderDetail->customer) {
                $preparedOrderDetails[$key]['email'] = $orderDetail->customer->email;
            }
            $productsPickedUp = false;
            if (!empty($orderDetail->pickup_day_entity)) {
                $preparedOrderDetails[$key]['comment'] = $orderDetail->pickup_day_entity->comment;
                $preparedOrderDetails[$key]['products_picked_up_tmp'] = $orderDetail->pickup_day_entity->products_picked_up;
            }
            @$preparedOrderDetails[$key]['timebased_currency_order_detail_seconds_sum'] = $orderDetail->timebased_currency_order_detail_seconds_sum;
            if (isset($preparedOrderDetails[$key]['products_picked_up_tmp']) && $preparedOrderDetails[$key]['products_picked_up_tmp']) {
                $productsPickedUp = true;
                $preparedOrderDetails[$key]['row_class'] = ['selected'];
            }
            $preparedOrderDetails[$key]['products_picked_up'] = $productsPickedUp;
            unset($preparedOrderDetails[$key]['products_picked_up_tmp']);
        }
        
        foreach($preparedOrderDetails as &$orderDetail) {
            $orderDetail['order_detail_count'] = $this->getCountByCustomerId($orderDetail['customer_id']);
        }
        return $preparedOrderDetails;
    }
24760
public function setJobRowClass($jobRowClass)
    {
        if (!in_array('Zend_Db_Table_Row_Abstract', class_parents($jobRowClass))) {
            throw new \InvalidArgumentException(sprintf('Job row class must be instance of Zend_Db_Table_Row_Abstract, given %s.', get_class($historyRowClass)));
        }
 
        $this->jobRowClass = $jobRowClass;
        return $this;
    }
475866
public function get($job_id)
    {
        $result = null;
        $this->hook->attach('job.get.before', $job_id, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $result = $this->getSession($job_id);
        $this->hook->attach('job.get.after', $job_id, $result, $this);
        return $result;
    }
202594
protected function setFieldNumbers($fieldDetails, $outputFormated = false)
    {
        $sRtrn = $this->setFieldSpecific($fieldDetails);
        if ($outputFormated) {
            foreach ($sRtrn as $key => $value) {
                $sRtrn[$key] = $this->setNumberFormat($value);
            }
        }
        return $sRtrn;
    }
322609
public function triggerJob(Key $jobKey, array $jobDataMap = [])
    {
        $trigger = TriggerBuilder::newTrigger()->forJobKey($jobKey)->build();
        $trigger->setJobDataMap($jobDataMap);
        $trigger->computeFirstFireTime();

        $this->store->storeTrigger($trigger);

        $this->notify(Event::JOB_SCHEDULED, new TriggerEvent($trigger));
    }
486041
public Date scheduleJob (final IJobDetail jobDetail, final ITrigger trigger) throws SchedulerException
  {
    return m_aSched.scheduleJob (jobDetail, trigger);
  }
256561
public function addTransactionDetail($amount, $buyOrder, $commerceCode = null)
    {
        $detail = new TransactionDetail();
        $detail->amount = $amount;
        $detail->buyOrder = $buyOrder;
        $detail->commerceCode = $commerceCode ? $commerceCode : SecurityHelper::getCommonName(
            $this->service->getCertificationBag()->getClientCertificate()
        );
        $this->transactionDetails[] = $detail;

        return $this;
    }