Package org.pentaho.platform.api.scheduler2

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


      jobTrigger = simpleJobTrigger;

    } else if ( scheduleRequest.getComplexJobTrigger() != null ) {

      ComplexJobTriggerProxy proxyTrigger = scheduleRequest.getComplexJobTrigger();
      ComplexJobTrigger complexJobTrigger = new ComplexJobTrigger();
      complexJobTrigger.setStartTime( proxyTrigger.getStartTime() );
      complexJobTrigger.setEndTime( proxyTrigger.getEndTime() );

      if ( proxyTrigger.getDaysOfWeek().length > 0 ) {
        if ( proxyTrigger.getWeeksOfMonth().length > 0 ) {
          for ( int dayOfWeek : proxyTrigger.getDaysOfWeek() ) {
            for ( int weekOfMonth : proxyTrigger.getWeeksOfMonth() ) {

              QualifiedDayOfWeek qualifiedDayOfWeek = new QualifiedDayOfWeek();
              qualifiedDayOfWeek.setDayOfWeek( DayOfWeek.values()[dayOfWeek] );

              if ( weekOfMonth == JobScheduleRequest.LAST_WEEK_OF_MONTH ) {
                qualifiedDayOfWeek.setQualifier( DayOfWeekQualifier.LAST );
              } else {
                qualifiedDayOfWeek.setQualifier( DayOfWeekQualifier.values()[weekOfMonth] );
              }
              complexJobTrigger.addDayOfWeekRecurrence( qualifiedDayOfWeek );
            }
          }
        } else {
          for ( int dayOfWeek : proxyTrigger.getDaysOfWeek() ) {
            complexJobTrigger.addDayOfWeekRecurrence( dayOfWeek + 1 );
          }
        }
      } else if ( proxyTrigger.getDaysOfMonth().length > 0 ) {

        for ( int dayOfMonth : proxyTrigger.getDaysOfMonth() ) {
          complexJobTrigger.addDayOfMonthRecurrence( dayOfMonth );
        }
      }

      for ( int month : proxyTrigger.getMonthsOfYear() ) {
        complexJobTrigger.addMonthlyRecurrence( month + 1 );
      }

      for ( int year : proxyTrigger.getYears() ) {
        complexJobTrigger.addYearlyRecurrence( year );
      }

      Calendar calendar = Calendar.getInstance();
      calendar.setTime( complexJobTrigger.getStartTime() );
      complexJobTrigger.setHourlyRecurrence( calendar.get( Calendar.HOUR_OF_DAY ) );
      complexJobTrigger.setMinuteRecurrence( calendar.get( Calendar.MINUTE ) );
      complexJobTrigger.setUiPassParam( scheduleRequest.getComplexJobTrigger().getUiPassParam() );
      jobTrigger = complexJobTrigger;

    } else if ( scheduleRequest.getCronJobTrigger() != null ) {

      if ( scheduler instanceof QuartzScheduler ) {
        String cronString = scheduleRequest.getCronJobTrigger().getCronString();

        String delims = "[ ]+"; //$NON-NLS-1$
        String[] tokens = cronString.split( delims );
        if ( tokens.length < 7 ) {
          cronString += " *";
        }

        ComplexJobTrigger complexJobTrigger = QuartzScheduler.createComplexTrigger( cronString );
        complexJobTrigger.setStartTime( scheduleRequest.getCronJobTrigger().getStartTime() );
        complexJobTrigger.setEndTime( scheduleRequest.getCronJobTrigger().getEndTime() );
        complexJobTrigger.setUiPassParam( scheduleRequest.getCronJobTrigger().getUiPassParam() );
        jobTrigger = complexJobTrigger;
      } else {
        throw new IllegalArgumentException();
      }
    }
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

      }
    }

    Job job = null;

    IJobTrigger jobTrigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger( scheduleRequest, scheduler );

    HashMap<String, Serializable> parameterMap = new HashMap<String, Serializable>();
    for ( JobScheduleParam param : scheduleRequest.getJobParameters() ) {
      parameterMap.put( param.getName(), param.getValue() );
    }
View Full Code Here

    }
    throw new IllegalArgumentException();
  }

  public BlockStatusProxy getBlockStatus( JobScheduleRequest jobScheduleRequest ) throws SchedulerException {
    IJobTrigger trigger = convertScheduleRequestToJobTrigger( jobScheduleRequest );
    Boolean totallyBlocked = false;
    Boolean partiallyBlocked = getBlockoutManager().isPartiallyBlocked( trigger );
    if ( partiallyBlocked ) {
      totallyBlocked = !getBlockoutManager().willFire( trigger );
    }
View Full Code Here

    boolean runInBackground =
        scheduleRequest.getSimpleJobTrigger() == null && scheduleRequest.getComplexJobTrigger() == null
            && scheduleRequest.getCronJobTrigger() == null;

    // add 10 seconds to the RIB to ensure execution (see PPP-3264)
    IJobTrigger jobTrigger =
        runInBackground ? new SimpleJobTrigger( new Date( System.currentTimeMillis() + 10000 ), null, 0, 0 ) : scheduleRequest.getSimpleJobTrigger();

    if ( scheduleRequest.getSimpleJobTrigger() != null ) {
      SimpleJobTrigger simpleJobTrigger = scheduleRequest.getSimpleJobTrigger();
View Full Code Here

  @Test
  public void testBlockoutWillFire() throws Exception {
    JobScheduleRequest mockJobScheduleRequest = mock( JobScheduleRequest.class );

    IJobTrigger mockJobTrigger = mock( IJobTrigger.class );
    doReturn( mockJobTrigger ).when( schedulerResource ).convertScheduleRequestToJobTrigger( mockJobScheduleRequest );

    Boolean willFire = Boolean.FALSE;
    doReturn( willFire ).when( schedulerResource.schedulerService ).willFire( mockJobTrigger );
View Full Code Here

    return true;
  }

  private void scheduleJob( int intervalInSeconds ) throws Exception {

    IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$
    JobTrigger trigger = new SimpleJobTrigger( new Date(), null, -1, intervalInSeconds );

    jobMap.put( "transFileName", getTransFileName() );
    scheduler.createJob( GatherStatsListener.JOB_NAME, GatherStatsAction.class, jobMap, trigger );
    logger.info( "Statistics gathering jop has been scheduled." );
  }
View Full Code Here

          throw new IllegalAccessException();
        }
      }
    }

    Job job = null;

    IJobTrigger jobTrigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger( scheduleRequest, scheduler );

    HashMap<String, Serializable> parameterMap = new HashMap<String, Serializable>();
    for ( JobScheduleParam param : scheduleRequest.getJobParameters() ) {
View Full Code Here

    return job;
  }

  public Job triggerNow( String jobId ) throws SchedulerException {
    Job job = getScheduler().getJob( jobId );
    if ( getPolicy().isAllowed( SchedulerAction.NAME ) ) {
      getScheduler().triggerNow( jobId );
    } else {
      if ( getSession().getName().equals( job.getUserName() ) ) {
        getScheduler().triggerNow( jobId );
      }
    }
    // udpate job state
    job = getScheduler().getJob( jobId );
View Full Code Here

    }
    return getScheduler().getStatus().name();
  }

  public JobState pauseJob( String jobId ) throws SchedulerException {
    Job job = getJob( jobId );
    if ( isScheduleAllowed() || PentahoSessionHolder.getSession().getName().equals( job.getUserName() ) ) {
      getScheduler().pauseJob( jobId );
    }
    job = getJob( jobId );
    return job.getState();
  }
View Full Code Here

TOP

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

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.