Exemplo n.º 1
0
  public SimpleTrigger generateImportTrigger(
      FormProcessor fp,
      UserAccountBean userAccount,
      StudyBean study,
      Date startDateTime,
      String locale) {

    String jobName = fp.getString(JOB_NAME);

    String email = fp.getString(EMAIL);
    String jobDesc = fp.getString(JOB_DESC);
    String directory = fp.getString(DIRECTORY);

    // what kinds of periods do we have? hourly, daily, weekly?
    long interval = 0;
    int hours = fp.getInt("hours");
    int minutes = fp.getInt("minutes");
    if (hours > 0) {
      long hoursInt = hours * 3600000;
      interval = interval + hoursInt;
    }
    if (minutes > 0) {
      long minutesInt = minutes * 60000;
      interval = interval + minutesInt;
    }
    SimpleTrigger trigger = new SimpleTrigger(jobName, IMPORT_TRIGGER, 64000, interval);
    trigger.setDescription(jobDesc);
    // set just the start date
    trigger.setStartTime(startDateTime);
    trigger.setName(jobName); // + datasetId);
    trigger.setGroup(IMPORT_TRIGGER); // + datasetId);
    trigger.setMisfireInstruction(
        SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT);
    // set job data map
    JobDataMap jobDataMap = new JobDataMap();

    jobDataMap.put(EMAIL, email);
    jobDataMap.put(USER_ID, userAccount.getId());
    jobDataMap.put(STUDY_NAME, study.getName());
    jobDataMap.put(STUDY_OID, study.getOid());
    jobDataMap.put(DIRECTORY, directory);
    jobDataMap.put(ExampleSpringJob.LOCALE, locale);
    jobDataMap.put("hours", hours);
    jobDataMap.put("minutes", minutes);

    trigger.setJobDataMap(jobDataMap);
    trigger.setVolatility(false);
    return trigger;
  }
Exemplo n.º 2
0
  @Deprecated
  public void scheduleLoanArrearsAndPortfolioAtRisk(
      Date initialTime,
      long delay,
      JobRegistry jobRegistry,
      final JobRepository jobRepository,
      Map<String, Object> jobData,
      ResourcelessTransactionManager transactionManager)
      throws TaskSystemException {
    final String jobName = "LoanArrearsAndPortfolioAtRiskTask";
    try {
      final TaskletStep step1 = new TaskletStep();
      step1.setName("LoanArrearsAndPortfolioAtRiskTask-step-1");
      step1.setTasklet(
          (Tasklet)
              Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + getHelperName("LoanArrearsTask"))
                  .newInstance());
      step1.setJobRepository(jobRepository);
      step1.setTransactionManager(transactionManager);
      step1.afterPropertiesSet();

      final TaskletStep step2 = new TaskletStep();
      step2.setName("LoanArrearsAndPortfolioAtRiskTask-step-2");
      step2.setTasklet(
          (Tasklet)
              Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + getHelperName("PortfolioAtRiskTask"))
                  .newInstance());
      step2.setJobRepository(jobRepository);
      step2.setTransactionManager(transactionManager);
      step2.afterPropertiesSet();
      jobRegistry.register(
          new JobFactory() {

            @Override
            public Job createJob() {
              SimpleJob job = new SimpleJob(jobName + "Job");
              job.setJobRepository(jobRepository);
              job.setRestartable(true);
              job.registerJobExecutionListener(new BatchJobListener());
              job.addStep(step1);
              job.addStep(step2);
              return job;
            }

            @Override
            public String getJobName() {
              return jobName + "Job";
            }
          });
    } catch (Exception e) {
      throw new TaskSystemException(e);
    }

    JobDetailBean jobDetailBean = new JobDetailBean();
    jobDetailBean.setJobDataAsMap(jobData);
    try {
      jobDetailBean.setJobClass(Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + "PortfolioAtRiskTask"));
    } catch (ClassNotFoundException cnfe) {
      throw new TaskSystemException(cnfe);
    }
    jobDetailBean.setName(jobName + "Job");
    jobDetailBean.setGroup(Scheduler.DEFAULT_GROUP);
    jobDetailBean.afterPropertiesSet();

    SimpleTrigger trigger = new SimpleTrigger();
    trigger.setName(jobName + "Job");
    trigger.setGroup(Scheduler.DEFAULT_GROUP);
    trigger.setStartTime(initialTime);
    trigger.setRepeatInterval(delay);
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    try {
      scheduler.scheduleJob(jobDetailBean, trigger);
    } catch (SchedulerException se) {
      throw new TaskSystemException(se);
    }
  }
Exemplo n.º 3
0
  public SimpleTrigger generateTrigger(
      FormProcessor fp, UserAccountBean userAccount, StudyBean study, String locale) {
    Date startDateTime = fp.getDateTime(DATE_START_JOB);
    // check the above?
    int datasetId = fp.getInt(DATASET_ID);
    String period = fp.getString(PERIOD);
    String email = fp.getString(EMAIL);
    String jobName = fp.getString(JOB_NAME);
    String jobDesc = fp.getString(JOB_DESC);
    String spss = fp.getString(SPSS);
    String tab = fp.getString(TAB);
    String cdisc = fp.getString(CDISC);
    String cdisc12 = fp.getString(ExampleSpringJob.CDISC12);
    String cdisc13 = fp.getString(ExampleSpringJob.CDISC13);
    String cdisc13oc = fp.getString(ExampleSpringJob.CDISC13OC);
    BigInteger interval = new BigInteger("0");
    if ("monthly".equalsIgnoreCase(period)) {
      interval = new BigInteger("2419200000"); // how many
      // milliseconds in
      // a month? should
      // be 24192000000
    } else if ("weekly".equalsIgnoreCase(period)) {
      interval = new BigInteger("604800000"); // how many
      // milliseconds in
      // a week? should
      // be 6048000000
    } else { // daily
      interval = new BigInteger("86400000"); // how many
      // milliseconds in a
      // day?
    }
    // set up and commit job here

    SimpleTrigger trigger = new SimpleTrigger(jobName, "DEFAULT", 64000, interval.longValue());

    // set the job detail name,
    // based on our choice of format above
    // what if there is more than one detail?
    // what is the number of times it should repeat?
    // arbitrary large number, 64K should be enough :)

    trigger.setDescription(jobDesc);
    // set just the start date
    trigger.setStartTime(startDateTime);
    trigger.setName(jobName); // + datasetId);
    trigger.setGroup("DEFAULT"); // + datasetId);
    trigger.setMisfireInstruction(
        SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT);
    // set job data map
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put(DATASET_ID, datasetId);
    jobDataMap.put(PERIOD, period);
    jobDataMap.put(EMAIL, email);
    jobDataMap.put(TAB, tab);
    jobDataMap.put(CDISC, cdisc);
    jobDataMap.put(ExampleSpringJob.CDISC12, cdisc12);
    jobDataMap.put(ExampleSpringJob.LOCALE, locale);
    // System.out.println("found 1.2: " +
    // jobDataMap.get(ExampleSpringJob.CDISC12));
    jobDataMap.put(ExampleSpringJob.CDISC13, cdisc13);
    // System.out.println("found 1.3: " +
    // jobDataMap.get(ExampleSpringJob.CDISC13));
    jobDataMap.put(ExampleSpringJob.CDISC13OC, cdisc13oc);
    // System.out.println("found 1.3oc: " +
    // jobDataMap.get(ExampleSpringJob.CDISC13OC));
    jobDataMap.put(SPSS, spss);
    jobDataMap.put(USER_ID, userAccount.getId());
    // StudyDAO studyDAO = new StudyDAO();
    jobDataMap.put(STUDY_ID, study.getId());
    jobDataMap.put(STUDY_NAME, study.getName());
    jobDataMap.put(STUDY_OID, study.getOid());

    trigger.setJobDataMap(jobDataMap);
    // trigger.setRepeatInterval(interval.longValue());
    // System.out.println("default for volatile: " + trigger.isVolatile());
    trigger.setVolatility(false);
    return trigger;
  }