Search in sources :

Example 6 with RepositoryObject

use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.

the class JobExecutorDialog method selectRepositoryJob.

private void selectRepositoryJob() {
    RepositoryObject repositoryObject = DialogHelper.selectRepositoryObject("*.kjb", log);
    try {
        if (repositoryObject != null) {
            loadRepositoryJob(repositoryObject.getName(), repositoryObject.getRepositoryDirectory());
            String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), executorJobMeta.getRepositoryDirectory().getPath());
            String fullPath = (path.equals("/") ? "/" : path + "/") + executorJobMeta.getName();
            wPath.setText(fullPath);
            specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorSelectingObject.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorSelectingObject.DialogMessage"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 7 with RepositoryObject

use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.

the class JobExecutorDialog method getByReferenceData.

private void getByReferenceData(ObjectId jobObjectId) {
    try {
        RepositoryObject jobInf = repository.getObjectInformation(jobObjectId, RepositoryObjectType.JOB);
        String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), jobInf.getRepositoryDirectory().getPath());
        String fullPath = Const.NVL(path, "") + "/" + Const.NVL(jobInf.getName(), "");
        wPath.setText(fullPath);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryJobDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "JobEntryJobDialog.Exception.UnableToReferenceObjectId.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Example 8 with RepositoryObject

use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.

the class JobEntryJob method getXML.

@Override
public String getXML() {
    StringBuilder retval = new StringBuilder(400);
    retval.append(super.getXML());
    // specificationMethod
    // 
    retval.append("      ").append(XMLHandler.addTagValue("specification_method", specificationMethod == null ? null : specificationMethod.getCode()));
    retval.append("      ").append(XMLHandler.addTagValue("job_object_id", jobObjectId == null ? null : jobObjectId.toString()));
    // 
    if (rep != null && jobObjectId != null) {
        try {
            RepositoryObject objectInformation = rep.getObjectInformation(jobObjectId, RepositoryObjectType.JOB);
            if (objectInformation != null) {
                jobname = objectInformation.getName();
                directory = objectInformation.getRepositoryDirectory().getPath();
            }
        } catch (KettleException e) {
        // Ignore object reference problems. It simply means that the reference is no longer valid.
        }
    }
    if (parentJobMeta != null) {
        parentJobMeta.getNamedClusterEmbedManager().registerUrl(filename);
    }
    retval.append("      ").append(XMLHandler.addTagValue("filename", filename));
    retval.append("      ").append(XMLHandler.addTagValue("jobname", jobname));
    if (directory != null) {
        retval.append("      ").append(XMLHandler.addTagValue("directory", directory));
    } else if (directoryPath != null) {
        retval.append("      ").append(XMLHandler.addTagValue("directory", directoryPath));
    }
    retval.append("      ").append(XMLHandler.addTagValue("arg_from_previous", argFromPrevious));
    retval.append("      ").append(XMLHandler.addTagValue("params_from_previous", paramsFromPrevious));
    retval.append("      ").append(XMLHandler.addTagValue("exec_per_row", execPerRow));
    retval.append("      ").append(XMLHandler.addTagValue("set_logfile", setLogfile));
    retval.append("      ").append(XMLHandler.addTagValue("logfile", logfile));
    retval.append("      ").append(XMLHandler.addTagValue("logext", logext));
    retval.append("      ").append(XMLHandler.addTagValue("add_date", addDate));
    retval.append("      ").append(XMLHandler.addTagValue("add_time", addTime));
    retval.append("      ").append(XMLHandler.addTagValue("loglevel", logFileLevel != null ? logFileLevel.getCode() : DEFAULT_LOG_LEVEL.getCode()));
    retval.append("      ").append(XMLHandler.addTagValue("slave_server_name", remoteSlaveServerName));
    retval.append("      ").append(XMLHandler.addTagValue("wait_until_finished", waitingToFinish));
    retval.append("      ").append(XMLHandler.addTagValue("follow_abort_remote", followingAbortRemotely));
    retval.append("      ").append(XMLHandler.addTagValue("expand_remote_job", expandingRemoteJob));
    retval.append("      ").append(XMLHandler.addTagValue("create_parent_folder", createParentFolder));
    retval.append("      ").append(XMLHandler.addTagValue("pass_export", passingExport));
    retval.append("      ").append(XMLHandler.addTagValue("run_configuration", runConfiguration));
    if (arguments != null) {
        for (int i = 0; i < arguments.length; i++) {
            // This is a very very bad way of making an XML file, don't use it (or
            // copy it). Sven Boden
            retval.append("      ").append(XMLHandler.addTagValue("argument" + i, arguments[i]));
        }
    }
    if (parameters != null) {
        retval.append("      ").append(XMLHandler.openTag("parameters"));
        retval.append("        ").append(XMLHandler.addTagValue("pass_all_parameters", passingAllParameters));
        for (int i = 0; i < parameters.length; i++) {
            // This is a better way of making the XML file than the arguments.
            retval.append("            ").append(XMLHandler.openTag("parameter"));
            retval.append("            ").append(XMLHandler.addTagValue("name", parameters[i]));
            retval.append("            ").append(XMLHandler.addTagValue("stream_name", parameterFieldNames[i]));
            retval.append("            ").append(XMLHandler.addTagValue("value", parameterValues[i]));
            retval.append("            ").append(XMLHandler.closeTag("parameter"));
        }
        retval.append("      ").append(XMLHandler.closeTag("parameters"));
    }
    retval.append("      ").append(XMLHandler.addTagValue("set_append_logfile", setAppendLogfile));
    return retval.toString();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 9 with RepositoryObject

use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.

the class KettleFileRepository method getTransformationObjects.

@Override
public List<RepositoryElementMetaInterface> getTransformationObjects(ObjectId idDirectory, boolean includeDeleted) throws KettleException {
    try {
        List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
        RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
        RepositoryDirectoryInterface directory = tree.findDirectory(idDirectory);
        String folderName = calcDirectoryName(directory);
        FileObject folder = KettleVFS.getFileObject(folderName);
        for (FileObject child : folder.getChildren()) {
            if (child.getType().equals(FileType.FILE)) {
                if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
                    String name = child.getName().getBaseName();
                    if (name.endsWith(EXT_TRANSFORMATION)) {
                        String transName = name.substring(0, name.length() - 4);
                        ObjectId id = new StringObjectId(calcObjectId(directory, transName, EXT_TRANSFORMATION));
                        Date date = new Date(child.getContent().getLastModifiedTime());
                        list.add(new RepositoryObject(id, transName, directory, "-", date, RepositoryObjectType.TRANSFORMATION, "", false));
                    }
                }
            }
        }
        return list;
    } catch (Exception e) {
        throw new KettleException("Unable to get list of transformations in folder with id : " + idDirectory, e);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) FileObject(org.apache.commons.vfs2.FileObject) StringObjectId(org.pentaho.di.repository.StringObjectId) Date(java.util.Date) KettleFileException(org.pentaho.di.core.exception.KettleFileException) FileSystemException(org.apache.commons.vfs2.FileSystemException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 10 with RepositoryObject

use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.

the class KettleFileRepository method getJobObjects.

@Override
public List<RepositoryElementMetaInterface> getJobObjects(ObjectId id_directory, boolean includeDeleted) throws KettleException {
    try {
        List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
        RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
        RepositoryDirectoryInterface directory = tree.findDirectory(id_directory);
        String folderName = calcDirectoryName(directory);
        FileObject folder = KettleVFS.getFileObject(folderName);
        for (FileObject child : folder.getChildren()) {
            if (child.getType().equals(FileType.FILE)) {
                if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
                    String name = child.getName().getBaseName();
                    if (name.endsWith(EXT_JOB)) {
                        String jobName = name.substring(0, name.length() - 4);
                        ObjectId id = new StringObjectId(calcObjectId(directory, jobName, EXT_JOB));
                        Date date = new Date(child.getContent().getLastModifiedTime());
                        list.add(new RepositoryObject(id, jobName, directory, "-", date, RepositoryObjectType.JOB, "", false));
                    }
                }
            }
        }
        return list;
    } catch (Exception e) {
        throw new KettleException("Unable to get list of jobs in folder with id : " + id_directory, e);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) FileObject(org.apache.commons.vfs2.FileObject) StringObjectId(org.pentaho.di.repository.StringObjectId) Date(java.util.Date) KettleFileException(org.pentaho.di.core.exception.KettleFileException) FileSystemException(org.apache.commons.vfs2.FileSystemException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Aggregations

RepositoryObject (org.pentaho.di.repository.RepositoryObject)46 KettleException (org.pentaho.di.core.exception.KettleException)31 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)15 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)11 StringObjectId (org.pentaho.di.repository.StringObjectId)9 ObjectId (org.pentaho.di.repository.ObjectId)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 Test (org.junit.Test)6 KettleFileException (org.pentaho.di.core.exception.KettleFileException)5 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)5 IOException (java.io.IOException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)4 FileObject (org.apache.commons.vfs2.FileObject)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)3 Serializable (java.io.Serializable)2 List (java.util.List)2