Package org.pentaho.platform.api.scheduler2

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


    QuartzJobKey jobKey = QuartzJobKey.parse( job.getJobId() );
    String groupName = jobKey.getUserName();

    if ( trigger instanceof SimpleTrigger ) {
      SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
      SimpleJobTrigger simpleJobTrigger = new SimpleJobTrigger();
      simpleJobTrigger.setStartTime( simpleTrigger.getStartTime() );
      simpleJobTrigger.setEndTime( simpleTrigger.getEndTime() );
      simpleJobTrigger.setUiPassParam( (String) job.getJobParams().get( RESERVEDMAPKEY_UIPASSPARAM ) );
      long interval = simpleTrigger.getRepeatInterval();
      if ( interval > 0 ) {
        interval /= 1000;
      }
      simpleJobTrigger.setRepeatInterval( interval );
      simpleJobTrigger.setRepeatCount( simpleTrigger.getRepeatCount() );
      job.setJobTrigger( simpleJobTrigger );
    } else if ( trigger instanceof CronTrigger ) {
      CronTrigger cronTrigger = (CronTrigger) trigger;
      ComplexJobTrigger complexJobTrigger = createComplexTrigger( cronTrigger.getCronExpression() );
      complexJobTrigger.setUiPassParam( (String) job.getJobParams().get( RESERVEDMAPKEY_UIPASSPARAM ) );
View Full Code Here


    deleteJobIfNecessary();

    Map<String, Serializable> parms = new HashMap<String, Serializable>();
    parms.put( VersionCheckerAction.VERSION_REQUEST_FLAGS, new Integer( versionRequestFlags ) );
    JobTrigger trigger = new SimpleJobTrigger( new Date(), null, -1, repeatSeconds );
    scheduler.createJob( EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME, VersionCheckerAction.class, parms,
        trigger );
  }
View Full Code Here

      try {
        requiresUpdate = SecurityHelper.getInstance().runAsUser( actionUser, actionBeanRunner );
      } catch ( Throwable t ) {
        Object restartFlag = jobParams.get( QuartzScheduler.RESERVEDMAPKEY_RESTART_FLAG );
        if ( restartFlag == null ) {
          final SimpleJobTrigger trigger = new SimpleJobTrigger( new Date(), null, 0, 0 );
          final Class<IAction> iaction = (Class<IAction>) actionBean.getClass();
          // recreate the job in the context of the original creator
          SecurityHelper.getInstance().runAsUser( actionUser, new Callable<Void>() {
            @Override
            public Void call() throws Exception {
View Full Code Here

    doReturn( true ).when( schedulerService ).isPdiFile( any( RepositoryFile.class ) );

    SchedulerOutputPathResolver schedulerOutputPathResolver = mock( SchedulerOutputPathResolver.class );
    doReturn( "outputFile" ).when( schedulerOutputPathResolver ).resolveOutputFilePath();

    SimpleJobTrigger simpleJobTrigger = mock( SimpleJobTrigger.class );
    ComplexJobTriggerProxy complexJobTriggerProxy = mock( ComplexJobTriggerProxy.class );
    CronJobTrigger cronJobTrigger = mock( CronJobTrigger.class );

    RepositoryFile repositoryFile = mock( RepositoryFile.class );
    doReturn( "file.ext" ).when( repositoryFile ).getName();
View Full Code Here

    doReturn( true ).when( schedulerService ).isPdiFile( any( RepositoryFile.class ) );

    SchedulerOutputPathResolver schedulerOutputPathResolver = mock( SchedulerOutputPathResolver.class );
    doReturn( "outputFile" ).when( schedulerOutputPathResolver ).resolveOutputFilePath();

    SimpleJobTrigger simpleJobTrigger = mock( SimpleJobTrigger.class );
    ComplexJobTriggerProxy complexJobTriggerProxy = mock( ComplexJobTriggerProxy.class );
    CronJobTrigger cronJobTrigger = mock( CronJobTrigger.class );

    RepositoryFile repositoryFile = mock( RepositoryFile.class );
    doReturn( "file.ext" ).when( repositoryFile ).getName();
View Full Code Here

    Assert.assertTrue( "Job did not run.", TestAction3.counter > 3 );
  }

  @Test
  public void editJobTest() throws SchedulerException {
    SimpleJobTrigger repeater = new SimpleJobTrigger();
    repeater.setStartTime( new Date() );
    repeater.setRepeatInterval( 5 );
    repeater.setRepeatCount( 20 );

    Job job = scheduler.createJob( "testName", TestAction.class, new HashMap<String, Serializable>(), repeater );

    sleep( 12 );

    Assert.assertTrue( "Job did not run the correct number of times", TestAction.counter >= 2 );

    repeater = new SimpleJobTrigger();
    repeater.setStartTime( new Date() );
    repeater.setRepeatInterval( 20 );
    repeater.setRepeatCount( 3 );

    int count = TestAction.counter;
    System.out.println( "updating job! " + new Date() );
    scheduler.updateJob( job.getJobId(), new HashMap<String, Serializable>(), repeater );
    List<Job> jobs = scheduler.getJobs( null );
    Assert.assertEquals( "Unexpected number of scheduled jobs", 1, jobs.size() );
    SimpleJobTrigger simpleJobTrigger = (SimpleJobTrigger) jobs.get( 0 ).getJobTrigger();
    Assert.assertEquals( 20, simpleJobTrigger.getRepeatInterval() );
    Assert.assertEquals( 3, simpleJobTrigger.getRepeatCount() );
    sleep( 5 );
    Assert.assertEquals( "Job did not run the correct number of times", count + 1, TestAction.counter );
    count = TestAction.counter;
    sleep( 10 );
    Assert.assertEquals( "Job ran unexpectedly", count, TestAction.counter );
View Full Code Here

    Assert.assertTrue( "Job did not run the correct number of times", count < TestAction.counter );
  }

  @Test
  public void runTenTimesJobTest() throws SchedulerException {
    SimpleJobTrigger repeater = new SimpleJobTrigger();
    repeater.setStartTime( new Date() );
    repeater.setRepeatInterval( 1 );
    repeater.setRepeatCount( 9 );

    scheduler.createJob( "testName", TestAction.class, new HashMap<String, Serializable>(), repeater );

    sleep( 5 );
    Assert.assertTrue( "Job did not run the correct number of times", TestAction.counter > 3 );
View Full Code Here

    Assert.assertEquals( 0, jobs.size() );
  }

  @Test
  public void testJobRunsAsSchedulingUser() throws SchedulerException {
    SimpleJobTrigger RUN_ONCE_IN_2_SECS = JobTrigger.ONCE_NOW;
    RUN_ONCE_IN_2_SECS.setStartTime( new Date( System.currentTimeMillis() + 2000L ) );

    scheduler.createJob( "testName", TestAction.class, new HashMap<String, Serializable>(), RUN_ONCE_IN_2_SECS );

    SecurityHelper.getInstance().becomeUser( "Ima Wronguser" );
View Full Code Here

      startingSec = startingSec % 60;
      startingMin++;
    }
    calendar.set( Calendar.MINUTE, startingMin );
    calendar.set( Calendar.SECOND, startingSec );
    SimpleJobTrigger jobTrigger = new SimpleJobTrigger( calendar.getTime(), null, 0, 0 );
    testGetJobsSchduler.createJob( "getJobsTestJob", TestAction.class, jobParams, jobTrigger );

    List<Job> jobs = testGetJobsSchduler.getJobs( null );
    Assert.assertEquals( 1, jobs.size() );
View Full Code Here

@SuppressWarnings( "nls" )
public class SimpleTriggerTest {

  @Test
  public void defaultValidTest() {
    SimpleJobTrigger trigger = new SimpleJobTrigger();
    Assert.assertNull( trigger.getStartTime() );
    Assert.assertNull( trigger.getEndTime() );
    Assert.assertFalse( trigger.getRepeatCount() != 0 && trigger.getRepeatInterval() < 1 );
  }
View Full Code Here

TOP

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

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.