Search in sources :

Example 1 with RepositoryObject

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

the class JobEntryTransDialog method selectTransformation.

private void selectTransformation() {
    RepositoryObject repositoryObject = DialogHelper.selectRepositoryObject("*.ktr", log);
    if (repositoryObject != null) {
        String path = DialogUtils.getPath(jobMeta.getRepositoryDirectory().getPath(), repositoryObject.getRepositoryDirectory().getPath());
        String fullPath = (path.equals("/") ? "/" : path + "/") + repositoryObject.getName();
        wPath.setText(fullPath);
    }
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject)

Example 2 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 3 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)

Example 4 with RepositoryObject

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

the class RepositoryFileProvider method populateFiles.

private void populateFiles(RepositoryDirectory repositoryDirectory, RepositoryDirectoryInterface repositoryDirectoryInterface, String filter) throws KettleException {
    if (getRepository() instanceof RepositoryExtended && !repositoryDirectory.getPath().equals("/")) {
        populateFilesLazy(repositoryDirectory, filter);
    } else {
        Date latestDate = null;
        for (RepositoryObjectInterface repositoryObject : getRepositoryElements(repositoryDirectoryInterface)) {
            org.pentaho.di.repository.RepositoryObject ro = (org.pentaho.di.repository.RepositoryObject) repositoryObject;
            String extension = ro.getObjectType().getExtension();
            if (!Util.isFiltered(extension, filter)) {
                RepositoryFile repositoryFile = RepositoryFile.build(ro);
                repositoryDirectory.addChild(repositoryFile);
            }
            if (latestDate == null || ro.getModifiedDate().after(latestDate)) {
                latestDate = ro.getModifiedDate();
            }
        }
        repositoryDirectory.setDate(latestDate);
    }
}
Also used : RepositoryObject(org.pentaho.di.repository.RepositoryObject) RepositoryObject(org.pentaho.di.repository.RepositoryObject) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) RepositoryFile(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryFile) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface) Date(java.util.Date)

Example 5 with RepositoryObject

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

the class RepositoryFileProvider method setFileProperties.

@Override
public void setFileProperties(FileDetails fileDetails, FileDialogOperation fileDialogOperation) {
    RepositoryObject repositoryObject = new RepositoryObject();
    repositoryObject.setObjectId(fileDetails::getObjectId);
    repositoryObject.setName(fileDetails.getName());
    try {
        repositoryObject.setRepositoryDirectory(getRepository().findDirectory(fileDetails.getParentPath()));
    } catch (KettleException ignored) {
    // Don't set directory if not found
    }
    if (fileDetails.getType() != null) {
        repositoryObject.setObjectType(fileDetails.getType().equals(TRANSFORMATION) ? RepositoryObjectType.TRANSFORMATION : RepositoryObjectType.JOB);
    }
    fileDialogOperation.setRepositoryObject(repositoryObject);
    fileDialogOperation.setProvider(fileDetails.getProvider());
    fileDialogOperation.setFilename(fileDetails.getName());
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject)

Aggregations

RepositoryObject (org.pentaho.di.repository.RepositoryObject)53 KettleException (org.pentaho.di.core.exception.KettleException)34 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)15 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)15 StringObjectId (org.pentaho.di.repository.StringObjectId)9 Test (org.junit.Test)8 ObjectId (org.pentaho.di.repository.ObjectId)8 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)8 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)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 RepositoryExtended (org.pentaho.di.repository.RepositoryExtended)4 FileObject (org.apache.commons.vfs2.FileObject)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)3 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)3