Search in sources :

Example 1 with CarteObjectEntry

use of org.pentaho.di.www.CarteObjectEntry in project pentaho-kettle by pentaho.

the class CarteResource method getJobsDetails.

@GET
@Path("/jobs/detailed")
@Produces({ MediaType.APPLICATION_JSON })
public List<JobStatus> getJobsDetails() {
    List<CarteObjectEntry> jobEntries = CarteSingleton.getInstance().getJobMap().getJobObjects();
    List<JobStatus> details = new ArrayList<JobStatus>();
    JobResource jobRes = new JobResource();
    for (CarteObjectEntry entry : jobEntries) {
        details.add(jobRes.getJobStatus(entry.getId()));
    }
    return details;
}
Also used : ArrayList(java.util.ArrayList) CarteObjectEntry(org.pentaho.di.www.CarteObjectEntry) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with CarteObjectEntry

use of org.pentaho.di.www.CarteObjectEntry in project pentaho-kettle by pentaho.

the class CarteResource method getCarteObjectEntry.

public static CarteObjectEntry getCarteObjectEntry(String id) {
    List<CarteObjectEntry> transList = CarteSingleton.getInstance().getTransformationMap().getTransformationObjects();
    for (CarteObjectEntry entry : transList) {
        if (entry.getId().equals(id)) {
            return entry;
        }
    }
    List<CarteObjectEntry> jobList = CarteSingleton.getInstance().getJobMap().getJobObjects();
    for (CarteObjectEntry entry : jobList) {
        if (entry.getId().equals(id)) {
            return entry;
        }
    }
    return null;
}
Also used : CarteObjectEntry(org.pentaho.di.www.CarteObjectEntry)

Example 3 with CarteObjectEntry

use of org.pentaho.di.www.CarteObjectEntry in project pentaho-kettle by pentaho.

the class CarteResource method getTransformationsDetails.

@GET
@Path("/transformations/detailed")
@Produces({ MediaType.APPLICATION_JSON })
public List<TransformationStatus> getTransformationsDetails() {
    List<CarteObjectEntry> transEntries = CarteSingleton.getInstance().getTransformationMap().getTransformationObjects();
    List<TransformationStatus> details = new ArrayList<TransformationStatus>();
    TransformationResource transRes = new TransformationResource();
    for (CarteObjectEntry entry : transEntries) {
        details.add(transRes.getTransformationStatus(entry.getId()));
    }
    return details;
}
Also used : ArrayList(java.util.ArrayList) CarteObjectEntry(org.pentaho.di.www.CarteObjectEntry) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with CarteObjectEntry

use of org.pentaho.di.www.CarteObjectEntry in project pentaho-kettle by pentaho.

the class JobResource method startJob.

// change from GET to UPDATE/POST for proper REST method
@GET
@Path("/start/{id : .+}")
@Produces({ MediaType.APPLICATION_JSON })
public JobStatus startJob(@PathParam("id") String id) {
    Job job = CarteResource.getJob(id);
    CarteObjectEntry entry = CarteResource.getCarteObjectEntry(id);
    try {
        if (job.isInitialized() && !job.isActive()) {
            // 
            if (job.getRep() != null && !job.getRep().isConnected()) {
                if (job.getRep().getUserInfo() != null) {
                    job.getRep().connect(job.getRep().getUserInfo().getLogin(), job.getRep().getUserInfo().getPassword());
                } else {
                    job.getRep().connect(null, null);
                }
            }
            // 
            synchronized (this) {
                JobConfiguration jobConfiguration = CarteSingleton.getInstance().getJobMap().getConfiguration(entry);
                String carteObjectId = UUID.randomUUID().toString();
                SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(getClass().getName(), LoggingObjectType.CARTE, null);
                servletLoggingObject.setContainerObjectId(carteObjectId);
                Job newJob = new Job(job.getRep(), job.getJobMeta(), servletLoggingObject);
                newJob.setLogLevel(job.getLogLevel());
                // Discard old log lines from the old job
                // 
                KettleLogStore.discardLines(job.getLogChannelId(), true);
                CarteSingleton.getInstance().getJobMap().replaceJob(entry, newJob, jobConfiguration);
                job = newJob;
            }
        }
        job.start();
    } catch (KettleException e) {
        e.printStackTrace();
    }
    return getJobStatus(id);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Job(org.pentaho.di.job.Job) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) JobConfiguration(org.pentaho.di.job.JobConfiguration) CarteObjectEntry(org.pentaho.di.www.CarteObjectEntry) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with CarteObjectEntry

use of org.pentaho.di.www.CarteObjectEntry in project pentaho-kettle by pentaho.

the class JobResource method getJobStatus.

@GET
@Path("/status/{id : .+}")
@Produces({ MediaType.APPLICATION_JSON })
public JobStatus getJobStatus(@PathParam("id") String id) {
    JobStatus status = new JobStatus();
    // find job
    Job job = CarteResource.getJob(id);
    CarteObjectEntry entry = CarteResource.getCarteObjectEntry(id);
    status.setId(entry.getId());
    status.setName(entry.getName());
    status.setStatus(job.getStatus());
    return status;
}
Also used : Job(org.pentaho.di.job.Job) CarteObjectEntry(org.pentaho.di.www.CarteObjectEntry) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

CarteObjectEntry (org.pentaho.di.www.CarteObjectEntry)10 GET (javax.ws.rs.GET)8 Path (javax.ws.rs.Path)8 Produces (javax.ws.rs.Produces)6 Job (org.pentaho.di.job.Job)3 Trans (org.pentaho.di.trans.Trans)3 ArrayList (java.util.ArrayList)2 KettleException (org.pentaho.di.core.exception.KettleException)2 Before (org.junit.Before)1 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)1 JobConfiguration (org.pentaho.di.job.JobConfiguration)1 TransConfiguration (org.pentaho.di.trans.TransConfiguration)1 TransExecutionConfiguration (org.pentaho.di.trans.TransExecutionConfiguration)1 StepInterface (org.pentaho.di.trans.step.StepInterface)1 StepStatus (org.pentaho.di.trans.step.StepStatus)1 TransformationMap (org.pentaho.di.www.TransformationMap)1