Package org.pentaho.platform.api.scheduler2

Examples of org.pentaho.platform.api.scheduler2.ComplexJobTrigger


    assertFalse( this.blockOutManager.isPartiallyBlocked( falseSchedule1 ) );

    /*
     * Complex Schedule Triggers
     */
    IJobTrigger trueComplexScheduleTrigger = new ComplexJobTrigger();
    trueComplexScheduleTrigger.setStartTime( trueScheduleStartDate1.getTime() );
    trueComplexScheduleTrigger.setCronString( "0 0 1 ? * 2-3 *" ); //$NON-NLS-1$

    IJobTrigger falseComplexScheduleTrigger = new ComplexJobTrigger();
    falseComplexScheduleTrigger.setStartTime( trueScheduleStartDate1.getTime() );
    falseComplexScheduleTrigger.setCronString( "0 0 1 ? * 2 *" ); //$NON-NLS-1$

    assertTrue( this.blockOutManager.isPartiallyBlocked( trueComplexScheduleTrigger ) );
    assertFalse( this.blockOutManager.isPartiallyBlocked( falseComplexScheduleTrigger ) );

    /*
     * Complex Block Out IJobTrigger
     */
    deleteJob( blockOutJob.getJobId() );
    blockOutTrigger = new ComplexJobTrigger();
    blockOutTrigger.setStartTime( blockOutStartDate.getTime() );
    blockOutTrigger.setCronString( "0 0 0 ? * 3 *" ); //$NON-NLS-1$
    blockOutTrigger.setDuration( duration );
    addBlockOutJob( blockOutTrigger );

View Full Code Here


    Calendar falseBlockOutStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 9 );
    IJobTrigger falseBlockOutTrigger =
        new SimpleJobTrigger( falseBlockOutStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
    falseBlockOutTrigger.setDuration( duration );

    IJobTrigger trueComplexBlockOutTrigger = new ComplexJobTrigger();
    trueComplexBlockOutTrigger.setStartTime( trueBlockOutStartDate.getTime() );
    trueComplexBlockOutTrigger.setCronString( "0 0 0 ? * 2 *" ); //$NON-NLS-1$
    trueComplexBlockOutTrigger.setDuration( duration );

    IJobTrigger falseComplexBlockOutTrigger = new ComplexJobTrigger();
    falseComplexBlockOutTrigger.setStartTime( falseBlockOutStartDate.getTime() );
    falseComplexBlockOutTrigger.setCronString( "0 0 0 ? * WED *" ); //$NON-NLS-1$
    falseComplexBlockOutTrigger.setDuration( duration );

    Calendar scheduleStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 7, 1, 0, 0 );
    IJobTrigger scheduleTrigger = new SimpleJobTrigger( scheduleStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
    addJob( scheduleTrigger, "scheduleTrigger" ); //$NON-NLS-1$

    assertEquals( 1, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
    assertEquals( 1, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
    assertEquals( 0, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
    assertEquals( 0, this.blockOutManager.willBlockSchedules( falseComplexBlockOutTrigger ).size() );

    IJobTrigger cronTrigger = new ComplexJobTrigger();
    cronTrigger.setStartTime( scheduleStartDate.getTime() );
    cronTrigger.setCronString( "0 0 1 ? * 2-3 *" ); //$NON-NLS-1$
    addJob( cronTrigger, "cronTrigger" ); //$NON-NLS-1$

    assertEquals( 2, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
    assertEquals( 2, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
    assertEquals( 0, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
    assertEquals( 0, this.blockOutManager.willBlockSchedules( falseComplexBlockOutTrigger ).size() );

    IJobTrigger complexJobTrigger1 = new ComplexJobTrigger( null, null, null, ComplexJobTrigger.MONDAY, 0 );
    complexJobTrigger1.setStartTime( scheduleStartDate.getTime() );
    addJob( complexJobTrigger1, "complexJobTrigger1" ); //$NON-NLS-1$

    assertEquals( 3, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
    assertEquals( 3, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
    assertEquals( 0, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
    assertEquals( 0, this.blockOutManager.willBlockSchedules( falseComplexBlockOutTrigger ).size() );

    // Test non-standard interval
    IJobTrigger complexJobTrigger2 = new ComplexJobTrigger( null, null, 1, null, 0 );
    complexJobTrigger2.setStartTime( scheduleStartDate.getTime() );
    addJob( complexJobTrigger2, "complexJobTrigger2" ); //$NON-NLS-1$

    assertEquals( 4, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
    assertEquals( 4, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
    assertEquals( 1, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
View Full Code Here

  }

  @Test
  public void testCreateComplexJob() throws SchedulerException {
    int startingMinute = ( Calendar.getInstance().get( Calendar.MINUTE ) ) % 60;
    ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
    jobTrigger.setMinuteRecurrence( new IncrementalRecurrence( startingMinute, 1 ) );
    jobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    System.out.println( jobTrigger.toString() );

    schedulerSvc.createComplexJob( "test job", jobParams, jobTrigger );

    int tries = 0;
    do {
View Full Code Here

  @Test( timeout = 1000 * 5 * 60 )
  public void testUpdateComplexJob() throws SchedulerException {
  long start  = System.currentTimeMillis() + 1000;
  long end = System.currentTimeMillis() + 1000 + 5*60*60*100;
    int startingMinute = ( Calendar.getInstance().get( Calendar.MINUTE ) + 10 ) % 60;
    ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
    jobTrigger.setStartTime( new Date(start) );
    jobTrigger.setEndTime( new Date(end) );
    jobTrigger.setMinuteRecurrence( new IncrementalRecurrence( startingMinute, 1 ) );
    jobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    System.out.println( jobTrigger.toString() );

    String jobId = schedulerSvc.createComplexJob( "test job", jobParams, jobTrigger );

    Assert.assertEquals( 1, schedulerSvc.getJobs().length );

    jobTrigger = new ComplexJobTrigger();

  start  = System.currentTimeMillis() + 2*1000;
  end = System.currentTimeMillis() + 1000 + 7*60*60*100;

    jobTrigger.setStartTime( new Date(start) );
    jobTrigger.setEndTime( new Date(end) );

    startingMinute = ( Calendar.getInstance().get( Calendar.MINUTE ) + 20 ) % 60;
    jobTrigger.setMinuteRecurrence( new IncrementalRecurrence( startingMinute, 5 ) );
    jobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    System.out.println( jobTrigger.toString() );

    HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>( jobParams );
    newJobParams.put( "newKey", new StringParamValue( "" ) );
    schedulerSvc.updateJobToUseComplexTrigger( jobId, newJobParams, jobTrigger );

    Assert.assertEquals( 1, schedulerSvc.getJobs().length );
    Job job = schedulerSvc.getJobs()[0];
    jobTrigger = (ComplexJobTrigger) job.getJobTrigger();
    Assert.assertEquals( (Integer) startingMinute,
        ( (IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get( 0 ) ).getStartingValue() );
    Assert.assertEquals( (Integer) 5, ( (IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get( 0 ) )
        .getIncrement() );
    Assert.assertTrue( job.getJobParams().containsKey( "newKey" ) );

    Assert.assertEquals( new Date(start), jobTrigger.getStartTime() );

    Assert.assertEquals( new Date(end), jobTrigger.getEndTime() );
  }
View Full Code Here

  Integer[] list = { 7, 11 };

  @Before
  public void init() {
    trigger = new ComplexJobTrigger();
  }
View Full Code Here

        List<Date> dates = new ArrayList<Date>();
        boolean endDateIsNull = jobTrigger.getEndTime() == null;
        Trigger trigger = QuartzScheduler.createQuartzTrigger( jobTrigger, new QuartzJobKey( "test", "test" ) ); //$NON-NLS-1$ //$NON-NLS-2$

        // add previous trigger (it might be currently active)
        IBlockoutManager manager = PentahoSystem.get( IBlockoutManager.class, "IBlockoutManager", null ); //$NON-NLS-1$;
        if ( manager != null ) {
          List<Job> blockouts = manager.getBlockOutJobs();
          for ( Job blockout : blockouts ) {
            if ( blockout.getLastRun() != null ) {
              dates.add( blockout.getLastRun() );
            }
          }
View Full Code Here

    IPentahoSession session = getSession();
    final String principalName = session.getName(); // this authentication wasn't matching with the job user name,
    // changed to get name via the current session
    final Boolean canAdminister = canAdminister( session );

    List<Job> jobs = getScheduler().getJobs( new IJobFilter() {
      public boolean accept( Job job ) {
        if ( canAdminister ) {
          return !IBlockoutManager.BLOCK_OUT_JOB_NAME.equals( job.getJobName() );
        }
        return principalName.equals( job.getUserName() );
View Full Code Here

        trigger );
  }

  protected void deleteJobIfNecessary() throws SchedulerException {
    IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$
    IJobFilter filter = new IJobFilter() {
      public boolean accept( Job job ) {
        return job.getJobName().contains( EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME );
      }
    };
View Full Code Here

  }

  @Override
  public List<Job> getBlockOutJobs() {
    try {
      List<Job> jobs = scheduler.getJobs( new IJobFilter() {
        public boolean accept( Job job ) {
          if ( BLOCK_OUT_JOB_NAME.equals( job.getJobName() ) ) {
            job.getJobTrigger().setDuration( ( (Number) job.getJobParams().get( DURATION_PARAM ) ).longValue() );
            return true;
          }
View Full Code Here

  public List<IJobTrigger> willBlockSchedules( IJobTrigger testBlockOutJobTrigger ) {
    List<IJobTrigger> blockedSchedules = new ArrayList<IJobTrigger>();

    List<Job> scheduledJobs = new ArrayList<Job>();
    try {
      scheduledJobs = this.scheduler.getJobs( new IJobFilter() {

        @Override
        public boolean accept( Job job ) {
          return !BLOCK_OUT_JOB_NAME.equals( job.getJobName() );
        }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.scheduler2.ComplexJobTrigger

Copyright © 2018 www.massapicom. 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.