Build the actual Trigger -- NOT intended to be invoked by end users, but
will rather be invoked by a TriggerBuilder which this ScheduleBuilder is
given to.

@see TriggerBuilder#withSchedule(IScheduleBuilder)
186169
@Nonnull
  public CronTrigger build ()
  {
    final CronTrigger ct = new CronTrigger ();
    ct.setCronExpression (m_aCronExpression);
    ct.setTimeZone (m_aCronExpression.getTimeZone ());
    ct.setMisfireInstruction (m_nMisfireInstruction);
    return ct;
  }
1024644
public function build()
    {
        $trigger = new DailyTimeIntervalTrigger();
        $trigger->setRepeatInterval($this->interval);
        $trigger->setRepeatIntervalUnit($this->intervalUnit);
        $trigger->setMisfireInstruction($this->misfireInstruction);
        $trigger->setRepeatCount($this->repeatCount);

        if (null != $this->daysOfWeek) {
            $trigger->setDaysOfWeek($this->daysOfWeek);
        } else {
            $trigger->setDaysOfWeek(DailyTimeIntervalTrigger::ALL_DAYS_OF_THE_WEEK);
        }

        $now = new \DateTime();

        if (null != $this->startTimeOfDay) {
            $trigger->setStartTimeOfDay($this->startTimeOfDay);
        } else {
            $startTimeOfDay = clone $now;
            $startTimeOfDay->setTime(0, 0, 0);

            $trigger->setStartTimeOfDay($startTimeOfDay);
        }

        if(null != $this->endTimeOfDay) {
            $trigger->setEndTimeOfDay($this->endTimeOfDay);
        } else {
            $endTimeOfDay = clone $now;
            $endTimeOfDay->setTime(23, 59, 59);
        }

        return $trigger;
    }
611773
public Trigger getCronTrigger(String cronExpression) {
    CronScheduleBuilder cronScheduleBuilder = null;
    Trigger cronTrigger = null;
    try {
      cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
      cronScheduleBuilder.withMisfireHandlingInstructionFireAndProceed();
      TriggerBuilder<Trigger> cronTtriggerBuilder = TriggerBuilder.newTrigger();
      cronTtriggerBuilder.withSchedule(cronScheduleBuilder);
      cronTrigger = cronTtriggerBuilder.build();
    } catch (Exception pe) {
      logger.error("Error occurred while builiding the cronTrigger : " + pe.getMessage(), pe);
    }
    return cronTrigger;
  }
677419
public synchronized void insertSchedule(final Schedule s) {
    final Schedule exist = this.scheduleIdentityPairMap.get(s.getScheduleIdentityPair());
    if (s.updateTime()) {
      try {
        if (exist == null) {
          this.loader.insertSchedule(s);
          internalSchedule(s);
        } else {
          s.setScheduleId(exist.getScheduleId());
          this.loader.updateSchedule(s);
          internalSchedule(s);
        }
      } catch (final ScheduleManagerException e) {
        logger.error(e);
      }
    } else {
      logger
          .error("The provided schedule is non-recurring and the scheduled time already passed. "
              + s.getScheduleName());
    }
  }
601229
void execute() {
    boolean scheduleTaskRunner = false;
    synchronized (this) {
      if (!isThreadScheduled) {
        isThreadScheduled = true;
        scheduleTaskRunner = true;
      }
    }
    if (scheduleTaskRunner) {
      try {
        executor.execute(this);
      } catch (RuntimeException e) {
        // reset state in case of an error so that later calls to execute will actually do something
        synchronized (this) {
          isThreadScheduled = false;
        }
        // Log it and keep going.
        logger.log(
            Level.SEVERE,
            "Exception while running callbacks for " + listener + " on " + executor, 
            e);
        throw e;
      }
    }
  }
158715
@Override
    public void run() {
        try {
            ScheduledEventQueue queue = ScheduledEventQueue.getSingleton();
            int batch_size = PropertyManager.getIntegerProperty(PropertyNames.SCHEDULED_EVENTS_BATCH_SIZE, 1000);
            int count = 0;
            Date now = new Date(DatabaseAccess.getCurrentTime());
            logger.log(LogLevel.TRACE, "Processing scheduled events at: " + now);
            ScheduledEvent event = queue.getNextReadyEvent(now);
            while (event!=null && count < batch_size) {
                count++;
                queue.processEvent(event, now);
                event = queue.getNextReadyEvent(now);
            }
        }
        catch (Throwable t) {
            logger.severeException(t.getMessage(), t);
        }
    }
857626
@Override
  public IScheduleBuilder <IDailyTimeIntervalTrigger> getScheduleBuilder ()
  {

    final DailyTimeIntervalScheduleBuilder cb = DailyTimeIntervalScheduleBuilder.dailyTimeIntervalSchedule ()
                                                                                .withInterval (getRepeatInterval (),
                                                                                               getRepeatIntervalUnit ())
                                                                                .onDaysOfTheWeek (getDaysOfWeek ())
                                                                                .startingDailyAt (getStartTimeOfDay ())
                                                                                .endingDailyAt (getEndTimeOfDay ());

    switch (getMisfireInstruction ())
    {
      case MISFIRE_INSTRUCTION_DO_NOTHING:
        cb.withMisfireHandlingInstructionDoNothing ();
        break;
      case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW:
        cb.withMisfireHandlingInstructionFireAndProceed ();
        break;
    }

    return cb;
  }
1009965
def trigger(action_class, *args)
      if uses_concurrency_control
        trigger_with_concurrency_control(action_class, *args)
      else
        world.trigger { world.plan_with_options(action_class: action_class, args: args, caller_action: self) }
      end
    end
286365
public static <T> Observable.Transformer<T, T> applySchedulers(final Scheduler subscribeScheduler) {
        return new Observable.Transformer<T, T>() {
            @Override
            public Observable<T> call(Observable<T> observable) {
                return observable.subscribeOn(subscribeScheduler)
                        .observeOn(AndroidSchedulers.mainThread());
            }
        };
    }
305623
public Database asynchronous(final Scheduler nonTransactionalScheduler) {
        return asynchronous(new Func0<Scheduler>() {
            @Override
            public Scheduler call() {
                return nonTransactionalScheduler;
            }
        });
    }
944515
private synchronized void updateLocal() throws ScheduleManagerException {
    final List<Schedule> updates = this.loader.loadUpdatedSchedules();
    for (final Schedule s : updates) {
      if (s.getStatus().equals(TriggerStatus.EXPIRED.toString())) {
        onScheduleExpire(s);
      } else {
        internalSchedule(s);
      }
    }
  }
537047
public synchronized void schedule(ScheduledJob scheduledJob) {
    String id = scheduledJob.getId();
    String cronExpression = scheduledJob.getCronExpression();
    String name = scheduledJob.getName();

    // Validate cron expression
    if (!CronExpression.isValidExpression(cronExpression)) {
      throw new MolgenisValidationException(
          singleton(
              new ConstraintViolation("Invalid cronexpression '" + cronExpression + "'", null)));
    }

    try {
      // If already scheduled, remove it from the quartzScheduler
      if (quartzScheduler.checkExists(new JobKey(id, SCHEDULED_JOB_GROUP))) {
        unschedule(id);
      }

      // If not active, do not schedule it
      if (!scheduledJob.getBoolean(ScheduledJobMetadata.ACTIVE)) {
        return;
      }

      // Schedule with 'cron' trigger
      Trigger trigger =
          newTrigger()
              .withIdentity(id, SCHEDULED_JOB_GROUP)
              .withSchedule(cronSchedule(cronExpression))
              .build();
      schedule(scheduledJob, trigger);

      LOG.info("Scheduled Job '{}' with trigger '{}'", name, trigger);
    } catch (SchedulerException e) {
      LOG.error("Error schedule job", e);
      throw new ScheduledJobException("Error schedule job", e);
    }
  }
645834
@Override
    @Transactional
    public synchronized void startAlertScheduling() {
        requireNotDisposed();
        if (_alertSchedulingThread != null && _alertSchedulingThread.isAlive()) {
            _logger.info("Request to start alert scheduling aborted as it is already running.");
        } else {
            _logger.info("Starting alert scheduling thread.");
            _alertSchedulingThread = new SchedulingThread("schedule-alerts", LockType.ALERT_SCHEDULING);
            _alertSchedulingThread.start();
            _logger.info("Alert scheduling thread started.");
        }
    }
275525
public void scheduleJobs(Scheduler sched) throws SchedulerException {

    List<JobDetail> jobs = new LinkedList<JobDetail>(getLoadedJobs());
    List<OperableTrigger> triggers = new LinkedList<OperableTrigger>(getLoadedTriggers());

    logger.info("Adding " + jobs.size() + " jobs, " + triggers.size() + " triggers.");

    for (JobDetail jobDetail : jobs) {
      logger.info("Scheduled job: {} ", jobDetail);

      sched.addJob(jobDetail);
    }

    for (OperableTrigger trigger : triggers) {

      logger.info("Scheduled trigger: {}", trigger);

      if (trigger.getStartTime() == null) {
        trigger.setStartTime(new Date());
      }

      Trigger dupeT = sched.getTrigger(trigger.getName());
      if (dupeT != null) { // if trigger with name already exists

        if (!dupeT.getJobName().equals(trigger.getJobName())) {
          logger.warn(
              "Possibly duplicately named ({}) triggers in jobs xml file! ", trigger.getName());
        }

        sched.rescheduleJob(trigger.getName(), trigger);
      } else {
        logger.debug(
            "Scheduling job: " + trigger.getJobName() + " with trigger: " + trigger.getName());

        try {
          sched.scheduleJob(trigger);
        } catch (ObjectAlreadyExistsException e) {
          logger.debug(
              "Adding trigger: "
                  + trigger.getName()
                  + " for job: "
                  + trigger.getJobName()
                  + " failed because the trigger already existed.");
        }
      }
    }
  }
302456
private function needsSchedulingForDirtyCheck()
    {
        return $this->owner && $this->dm && $this->mapping->isOwningSide
            && $this->dm->getClassMetadata(get_class($this->owner))->isChangeTrackingNotify();
    }
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;
  }
342014
public boolean schedulePolling() {
        if(isDisabled())    return false;
        SCMTrigger scmt = getTrigger(SCMTrigger.class);
        if(scmt==null)      return false;
        scmt.run();
        return true;
    }