Search in sources :

Example 61 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class SchedulerService method getContentCleanerJob.

public Job getContentCleanerJob() throws SchedulerException {
    IPentahoSession session = getSession();
    // this authentication wasn't matching with the job user name,
    final String principalName = session.getName();
    // changed to get name via the current session
    final Boolean canAdminister = getPolicy().isAllowed(AdministerSecurityAction.NAME);
    List<Job> jobs = getScheduler().getJobs(getJobFilter(canAdminister, principalName));
    if (jobs.size() > 0) {
        return jobs.get(0);
    }
    return null;
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Job(org.pentaho.platform.api.scheduler2.Job)

Example 62 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class SchedulerService method triggerNow.

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);
    return job;
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job)

Example 63 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class SchedulerService method getJobs.

public List<Job> getJobs() throws SchedulerException {
    IPentahoSession session = getSession();
    // this authentication wasn't matching with the job user name,
    final String principalName = session.getName();
    // changed to get name via the current session
    final Boolean canAdminister = canAdminister(session);
    List<Job> jobs = getScheduler().getJobs(new IJobFilter() {

        @Override
        public boolean accept(Job job) {
            if (canAdminister) {
                return !IBlockoutManager.BLOCK_OUT_JOB_NAME.equals(job.getJobName());
            }
            return principalName.equals(job.getUserName());
        }
    });
    return jobs;
}
Also used : IJobFilter(org.pentaho.platform.api.scheduler2.IJobFilter) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Job(org.pentaho.platform.api.scheduler2.Job)

Example 64 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class SchedulerService method getJobInfo.

public Job getJobInfo(String jobId) throws SchedulerException {
    Job job = getJob(jobId);
    if (job == null) {
        return null;
    }
    if (canAdminister() || getSession().getName().equals(job.getUserName())) {
        for (String key : job.getJobParams().keySet()) {
            Serializable value = job.getJobParams().get(key);
            if (value != null && value.getClass() != null && value.getClass().isArray()) {
                String[] sa = (new String[0]).getClass().cast(value);
                ArrayList<String> list = new ArrayList<>();
                for (int i = 0; i < sa.length; i++) {
                    list.add(sa[i]);
                }
                job.getJobParams().put(key, list);
            }
        }
        return job;
    } else {
        throw new RuntimeException("Job not found or improper credentials for access");
    }
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) Job(org.pentaho.platform.api.scheduler2.Job)

Example 65 with Job

use of com.google.cloud.dataproc.v1beta2.Job in project pentaho-platform by pentaho.

the class RepositoryCleanerSystemListener method unscheduleJob.

private void unscheduleJob(IScheduler scheduler, List<Job> jobs) throws SchedulerException {
    for (Job job : jobs) {
        logger.info("Removing job with id: " + job.getJobId());
        scheduler.removeJob(job.getJobId());
    }
}
Also used : Job(org.pentaho.platform.api.scheduler2.Job)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)69 Serializable (java.io.Serializable)25 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 HashMap (java.util.HashMap)20 ArrayList (java.util.ArrayList)19 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)13 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)12 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 AudioStream (com.google.cloud.video.transcoder.v1.AudioStream)8 JobConfig (com.google.cloud.video.transcoder.v1.JobConfig)8 VideoStream (com.google.cloud.video.transcoder.v1.VideoStream)8 Map (java.util.Map)8 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)8