Search in sources :

Example 91 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class BaseJobServlet method copyJobParameters.

private void copyJobParameters(Job job, Map<String, String> params) throws UnknownParamException {
    JobMeta jobMeta = job.getJobMeta();
    // Also copy the parameters over...
    job.copyParametersFrom(jobMeta);
    job.clearParameters();
    String[] parameterNames = job.listParameters();
    for (String parameterName : parameterNames) {
        // Grab the parameter value set in the job entry
        String thisValue = params.get(parameterName);
        if (!StringUtils.isBlank(thisValue)) {
            // Set the value as specified by the user in the job entry
            jobMeta.setParameterValue(parameterName, thisValue);
        }
    }
    jobMeta.activateParameters();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta)

Example 92 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class ExecuteJobServlet method loadJob.

private JobMeta loadJob(Repository repository, String job) throws KettleException {
    if (repository == null) {
        // Without a repository it's a filename --> file:///foo/bar/job.kjb
        // 
        JobMeta jobMeta = new JobMeta(job, repository);
        return jobMeta;
    } else {
        // With a repository we need to load it from /foo/bar/Job
        // We need to extract the folder name from the path in front of the name...
        // 
        String directoryPath;
        String name;
        int lastSlash = job.lastIndexOf(RepositoryDirectory.DIRECTORY_SEPARATOR);
        if (lastSlash < 0) {
            directoryPath = "/";
            name = job;
        } else {
            directoryPath = job.substring(0, lastSlash);
            name = job.substring(lastSlash + 1);
        }
        RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree().findDirectory(directoryPath);
        if (directory == null) {
            throw new KettleException("Unable to find directory path '" + directoryPath + "' in the repository");
        }
        ObjectId jobID = repository.getJobId(name, directory);
        if (jobID == null) {
            throw new KettleException("Unable to find job '" + name + "' in directory :" + directory);
        }
        JobMeta jobMeta = repository.loadJob(jobID, null);
        return jobMeta;
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) ObjectId(org.pentaho.di.repository.ObjectId)

Example 93 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class RegisterPackageServlet method generateBody.

@Override
WebResult generateBody(HttpServletRequest request, HttpServletResponse response, boolean useXML) throws KettleException, IOException {
    FileObject tempFile = KettleVFS.createTempFile("export", ".zip", System.getProperty("java.io.tmpdir"));
    OutputStream out = KettleVFS.getOutputStream(tempFile, false);
    IOUtils.copy(request.getInputStream(), out);
    out.flush();
    IOUtils.closeQuietly(out);
    String archiveUrl = tempFile.getName().toString();
    // the resource to load
    String load = request.getParameter(PARAMETER_LOAD);
    if (!Utils.isEmpty(load)) {
        String fileUrl = MessageFormat.format(ZIP_CONT, archiveUrl, load);
        boolean isJob = TYPE_JOB.equalsIgnoreCase(request.getParameter(PARAMETER_TYPE));
        String resultId;
        if (isJob) {
            Node node = getConfigNodeFromZIP(archiveUrl, Job.CONFIGURATION_IN_EXPORT_FILENAME, JobExecutionConfiguration.XML_TAG);
            JobExecutionConfiguration jobExecutionConfiguration = new JobExecutionConfiguration(node);
            JobMeta jobMeta = new JobMeta(fileUrl, jobExecutionConfiguration.getRepository());
            JobConfiguration jobConfiguration = new JobConfiguration(jobMeta, jobExecutionConfiguration);
            Job job = createJob(jobConfiguration);
            resultId = job.getContainerObjectId();
        } else {
            Node node = getConfigNodeFromZIP(archiveUrl, Trans.CONFIGURATION_IN_EXPORT_FILENAME, TransExecutionConfiguration.XML_TAG);
            TransExecutionConfiguration transExecutionConfiguration = new TransExecutionConfiguration(node);
            TransMeta transMeta = new TransMeta(fileUrl, transExecutionConfiguration.getRepository());
            TransConfiguration transConfiguration = new TransConfiguration(transMeta, transExecutionConfiguration);
            Trans trans = createTrans(transConfiguration);
            resultId = trans.getContainerObjectId();
        }
        return new WebResult(WebResult.STRING_OK, fileUrl, resultId);
    }
    return null;
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) OutputStream(java.io.OutputStream) Node(org.w3c.dom.Node) TransMeta(org.pentaho.di.trans.TransMeta) JobExecutionConfiguration(org.pentaho.di.job.JobExecutionConfiguration) TransConfiguration(org.pentaho.di.trans.TransConfiguration) TransExecutionConfiguration(org.pentaho.di.trans.TransExecutionConfiguration) FileObject(org.apache.commons.vfs2.FileObject) Job(org.pentaho.di.job.Job) Trans(org.pentaho.di.trans.Trans) JobConfiguration(org.pentaho.di.job.JobConfiguration)

Example 94 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method shareObject.

protected void shareObject(SharedObjectInterface sharedObject) {
    sharedObject.setShared(true);
    EngineMetaInterface meta = getActiveMeta();
    try {
        if (meta != null) {
            SharedObjects sharedObjects = null;
            if (meta instanceof TransMeta) {
                sharedObjects = ((TransMeta) meta).getSharedObjects();
            }
            if (meta instanceof JobMeta) {
                sharedObjects = ((JobMeta) meta).getSharedObjects();
            }
            if (sharedObjects != null) {
                sharedObjects.storeObject(sharedObject);
                sharedObjects.saveToFile();
            }
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Message"), e);
    }
    refreshTree();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SharedObjects(org.pentaho.di.shared.SharedObjects) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException)

Example 95 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method deleteJobEntryCopies.

public void deleteJobEntryCopies() {
    final JobMeta jobMeta = (JobMeta) selectionObjectParent;
    final JobEntryCopy jobEntry = (JobEntryCopy) selectionObject;
    deleteJobEntryCopies(jobMeta, jobEntry);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy)

Aggregations

JobMeta (org.pentaho.di.job.JobMeta)254 Test (org.junit.Test)88 TransMeta (org.pentaho.di.trans.TransMeta)69 KettleException (org.pentaho.di.core.exception.KettleException)62 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)48 Job (org.pentaho.di.job.Job)45 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)27 Repository (org.pentaho.di.repository.Repository)25 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)25 Point (org.pentaho.di.core.gui.Point)24 ArrayList (java.util.ArrayList)23 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)22 SlaveServer (org.pentaho.di.cluster.SlaveServer)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 FileObject (org.apache.commons.vfs2.FileObject)16 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)16 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)15 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)15 PrintWriter (java.io.PrintWriter)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12