Package org.pentaho.platform.scheduler2.quartz

Examples of org.pentaho.platform.scheduler2.quartz.QuartzScheduler


      createUnderlyingJob().execute( jobExecutionContext );
    }
  }

  IBlockoutManager getBlockoutManager() throws SchedulerException {
    return new PentahoBlockoutManager();
  }
View Full Code Here


      // send email
      SimpleRepositoryFileData data =
          repo.getDataForRead( sourceFile.getId(), SimpleRepositoryFileData.class );     
     
      // if email is setup and we have tos, then do it
      Emailer emailer = new Emailer();
      if ( !emailer.setup() ) {
        // email not configured
        return;
      }
      String to = (String) actionParams.get( "_SCH_EMAIL_TO" );
      String cc = (String) actionParams.get( "_SCH_EMAIL_CC" );
      String bcc = (String) actionParams.get( "_SCH_EMAIL_BCC" );
      if ( ( to == null || "".equals( to ) ) && ( cc == null || "".equals( cc ) )
          && ( bcc == null || "".equals( bcc ) ) ) {
        // no destination
        return;
      }
      emailer.setTo( to );
      emailer.setCc( cc );
      emailer.setBcc( bcc );
      emailer.setAttachment( data.getInputStream() );
      emailer.setAttachmentName( "attachment" );
      String attachmentName = (String) actionParams.get( "_SCH_EMAIL_ATTACHMENT_NAME" );
      if ( attachmentName != null && !"".equals( attachmentName ) ) {
        String path = filePath;
        if ( path.endsWith( ".*" ) ) {
          path = path.replace( ".*", "" );
        }
        String extension = MimeHelper.getExtension( data.getMimeType() );
        if ( extension == null ) {
          extension = ".bin";
        }
        if ( !attachmentName.endsWith( extension ) ) {
          emailer.setAttachmentName( attachmentName + extension );
        } else {
          emailer.setAttachmentName( attachmentName );
        }
      } else if ( data != null ) {
        String path = filePath;
        if ( path.endsWith( ".*" ) ) {
          path = path.replace( ".*", "" );
        }
        String extension = MimeHelper.getExtension( data.getMimeType() );
        if ( extension == null ) {
          extension = ".bin";
        }
        path = path.substring( path.lastIndexOf( "/" ) + 1, path.length() );
        if ( !path.endsWith( extension ) ) {
          emailer.setAttachmentName( path + extension );
        } else {
          emailer.setAttachmentName( path );
        }
      }
      if ( data == null || data.getMimeType() == null || "".equals( data.getMimeType() ) ) {
        emailer.setAttachmentMimeType( "binary/octet-stream" );
      } else {
        emailer.setAttachmentMimeType( data.getMimeType() );
      }
      String subject = (String) actionParams.get( "_SCH_EMAIL_SUBJECT" );
      if ( subject != null && !"".equals( subject ) ) {
        emailer.setSubject( subject );
      } else {
        emailer.setSubject( "Pentaho Scheduler: " + emailer.getAttachmentName() );
      }
      String message = (String) actionParams.get( "_SCH_EMAIL_MESSAGE" );
      if ( subject != null && !"".equals( subject ) ) {
        emailer.setBody( message );
      }
      emailer.send();
    } catch ( Exception e ) {
      log.warn( e.getMessage(), e );
    }     
  }
View Full Code Here

    if ( scheduler instanceof QuartzScheduler ) {
      try {

        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();
View Full Code Here

  @Test
  public void testHappyPathKey() throws SchedulerException {
    //
    // Generate a new key based on client-provided job name and username
    //
    QuartzJobKey key = new QuartzJobKey( TEST_JOBNAME, TEST_USER );
    assertEquals( "Quartz job group is wrong", TEST_JOBNAME, key.getJobName() );
    assertEquals( "Username is wrong", TEST_USER, key.getUserName() );

    //
    // Now parse the jobId back into the key object
    //
    String jobId = key.toString();
    QuartzJobKey parsedKey = QuartzJobKey.parse( jobId );
    assertEquals( "Quartz job group is wrong", TEST_JOBNAME, parsedKey.getJobName() );
    assertEquals( "Username is wrong", TEST_USER, parsedKey.getUserName() );
  }
View Full Code Here

    assertEquals( "Username is wrong", TEST_USER, parsedKey.getUserName() );
  }

  @Test( expected = SchedulerException.class )
  public void testKeyMissingJobName() throws SchedulerException {
    new QuartzJobKey( null, TEST_USER );
  }
View Full Code Here

    new QuartzJobKey( null, TEST_USER );
  }

  @Test( expected = SchedulerException.class )
  public void testKeyMissingUsername() throws SchedulerException {
    new QuartzJobKey( TEST_JOBNAME, null );
  }
View Full Code Here

    assert(delimiter.equals("\t") || delimiter.equals( ":" ));
   
    //
    // Generate a new key based on client-provided job name and username
    //
    QuartzJobKey jobKey = QuartzJobKey.parse( user + delimiter + jobName + delimiter + "1234567890" );
    assertEquals( "Incorrect User", user, jobKey.getUserName() );
    assertEquals( "Incorrect Job Name", jobName, jobKey.getJobName() );
   
    //
    // Now parse the jobId back into the key object (should always be tab delimited)
    //
    String jobId = jobKey.toString();
    assertEquals( "Incorrect Returned Job Id", user + "\t" + jobName + "\t" + "1234567890" , jobId);
  }
View Full Code Here

  private HashMap<String, Serializable> jobParams;

  @Before
  public void init() throws SchedulerException, PlatformInitializationException {
    scheduler = new QuartzScheduler();
    scheduler.start();

    TestAction.reset();
    TestAction2.reset();
    TestAction3.reset();
View Full Code Here

    Assert.assertEquals( 0, scheduler.getJobs( null ).size() );
  }

  @Test
  public void testGetJobs() throws SchedulerException {
    QuartzScheduler testGetJobsSchduler = new QuartzScheduler();

    Assert.assertEquals( 0, testGetJobsSchduler.getJobs( null ).size() );

    String PARAM_KEY = "testGetJobsKey";

    jobParams.put( PARAM_KEY, "testParam1-value" );
    Calendar calendar = Calendar.getInstance();
    int startingMin = calendar.get( Calendar.MINUTE );
    int startingSec = calendar.get( Calendar.SECOND ) + 10;
    if ( startingSec > 59 ) {
      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() );

    Job theJob = jobs.get( 0 );
    Assert.assertTrue( theJob.getJobParams().containsKey( PARAM_KEY ) );
    Assert.assertTrue( theJob.getJobName().contains( "getJobsTestJob" ) );
View Full Code Here

  private static final int WORKER_THREAD_COUNT = 3;

  @Before
  public void init() throws SchedulerException, PlatformInitializationException, org.quartz.SchedulerException,
    IOException {
    scheduler = new QuartzScheduler();

    Properties props = new Properties();
    props.put( "org.quartz.scheduler.makeSchedulerThreadDaemon", "true" );
    props.put( "org.quartz.threadPool.makeThreadsDaemons", "true" );
    props.put( "org.quartz.scheduler.instanceName", SCHEDULER_NAME );
View Full Code Here

TOP

Related Classes of org.pentaho.platform.scheduler2.quartz.QuartzScheduler

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.