Examples of CScheduleConfig


Examples of org.sonatype.nexus.configuration.model.CScheduleConfig

      storeableTask.addProperty(props);
    }

    Schedule schedule = task.getSchedule();
    CScheduleConfig storeableSchedule = new CScheduleConfig();

    if (schedule != null) {
      if (CronSchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_ADVANCED);

        storeableSchedule.setCronCommand(((CronSchedule) schedule).getCronString());
      }
      else if (MonthlySchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_MONTHLY);

        storeableSchedule.setStartDate(((MonthlySchedule) schedule).getStartDate().getTime());

        Date endDate = ((MonthlySchedule) schedule).getEndDate();

        if (endDate != null) {
          storeableSchedule.setEndDate(endDate.getTime());
        }

        for (Iterator iter = ((MonthlySchedule) schedule).getDaysToRun().iterator(); iter.hasNext(); ) {
          // TODO: String.valueOf is used because currently the days to run are integers in the monthly
          // schedule
          // needs to be string
          storeableSchedule.addDaysOfMonth(String.valueOf(iter.next()));
        }
      }
      else if (WeeklySchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_WEEKLY);

        storeableSchedule.setStartDate(((WeeklySchedule) schedule).getStartDate().getTime());

        Date endDate = ((WeeklySchedule) schedule).getEndDate();

        if (endDate != null) {
          storeableSchedule.setEndDate(endDate.getTime());
        }

        for (Iterator iter = ((WeeklySchedule) schedule).getDaysToRun().iterator(); iter.hasNext(); ) {
          // TODO: String.valueOf is used because currently the days to run are integers in the weekly
          // schedule
          // needs to be string
          storeableSchedule.addDaysOfWeek(String.valueOf(iter.next()));
        }
      }
      else if (DailySchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_DAILY);

        storeableSchedule.setStartDate(((DailySchedule) schedule).getStartDate().getTime());

        Date endDate = ((DailySchedule) schedule).getEndDate();

        if (endDate != null) {
          storeableSchedule.setEndDate(endDate.getTime());
        }
      }
      else if (HourlySchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_HOURLY);

        storeableSchedule.setStartDate(((HourlySchedule) schedule).getStartDate().getTime());

        Date endDate = ((HourlySchedule) schedule).getEndDate();

        if (endDate != null) {
          storeableSchedule.setEndDate(endDate.getTime());
        }
      }
      else if (OnceSchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_ONCE);

        storeableSchedule.setStartDate(((OnceSchedule) schedule).getStartDate().getTime());
      }
      else if (RunNowSchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_RUN_NOW);
      }
      else if (ManualRunSchedule.class.isAssignableFrom(schedule.getClass())) {
        storeableSchedule.setType(CScheduleConfig.TYPE_MANUAL);
      }
      else {
        throw new IllegalArgumentException("Unknown Schedule type: " + schedule.getClass().getName());
      }
    }
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CScheduleConfig

    cst.setType(TestNexusTask.class.getName());
    cst.setNextRun(new SimpleDateFormat("yyyy-MM-DD hh:mm:ss").parse("2099-01-01 20:00:00").getTime());

    // System.out.println( new Date( cst.getNextRun() ) );

    final CScheduleConfig csc = new CScheduleConfig();
    csc.setType(SCHEDULE_TYPE_ADVANCED);
    csc.setCronCommand("0 0 20 ? * TUE,THU,SAT");
    cst.setSchedule(csc);

    defaultManager.initializeTasks(defaultScheduler, Arrays.asList(cst));

    final ScheduledTask<?> task = defaultScheduler.getTaskById(cst.getId());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.