Search in sources :

Example 1 with RepositoryObjectInterface

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

the class PurRepository method getChildren.

@Override
public List<RepositoryObjectInterface> getChildren(String path, String filter) {
    RepositoryRequest repoRequest = new RepositoryRequest();
    repoRequest.setDepth(-1);
    repoRequest.setChildNodeFilter("*" + filter + "*");
    repoRequest.setIncludeAcls(false);
    repoRequest.setTypes(FILES_TYPE_FILTER.FILES_FOLDERS);
    repoRequest.setPath(path);
    repoRequest.setShowHidden(false);
    List<RepositoryFile> repositoryFiles = pur.getChildren(repoRequest);
    List<RepositoryObjectInterface> repositoryElementInterfaces = new ArrayList<>();
    for (RepositoryFile repositoryFile : repositoryFiles) {
        if (repositoryFile.isFolder()) {
            RepositoryDirectoryInterface repositoryDirectory = new RepositoryDirectory();
            repositoryDirectory.setName(repositoryFile.getName());
            repositoryDirectory.setObjectId(() -> repositoryFile.getId().toString());
            repositoryElementInterfaces.add(repositoryDirectory);
        } else {
            RepositoryObject repositoryObject = new RepositoryObject();
            repositoryObject.setName(repositoryFile.getName());
            repositoryObject.setObjectId(() -> repositoryFile.getId().toString());
            RepositoryObjectType repositoryObjectType = RepositoryObjectType.UNKNOWN;
            if (repositoryFile.getName().endsWith(".ktr")) {
                repositoryObjectType = RepositoryObjectType.TRANSFORMATION;
            }
            if (repositoryFile.getName().endsWith(".kjb")) {
                repositoryObjectType = RepositoryObjectType.JOB;
            }
            repositoryObject.setObjectType(repositoryObjectType);
            repositoryElementInterfaces.add(repositoryObject);
        }
    }
    return repositoryElementInterfaces;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) RepositoryObject(org.pentaho.di.repository.RepositoryObject) EERepositoryObject(org.pentaho.di.repository.pur.model.EERepositoryObject) ArrayList(java.util.ArrayList) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface)

Example 2 with RepositoryObjectInterface

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

the class RepositoryBrowserController method populateFiles.

private void populateFiles(RepositoryDirectory repositoryDirectory, RepositoryDirectoryInterface repositoryDirectoryInterface, String filter) throws KettleException {
    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) RepositoryFile(org.pentaho.repo.model.RepositoryFile) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface) Date(java.util.Date)

Example 3 with RepositoryObjectInterface

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

the class RepositoryBrowserController method search.

public List<org.pentaho.repo.model.RepositoryObject> search(String path, String filter) {
    RepositoryDirectoryInterface repositoryDirectoryInterface = findDirectory(path);
    List<org.pentaho.repo.model.RepositoryObject> repositoryObjects = new ArrayList<>();
    List<RepositoryObjectInterface> repositoryObjects1 = ((RepositoryExtended) getRepository()).getChildren(repositoryDirectoryInterface.getObjectId().getId(), filter);
    for (RepositoryObjectInterface repositoryObject : repositoryObjects1) {
        if (repositoryObject instanceof RepositoryDirectoryInterface) {
            RepositoryDirectory repositoryDirectory = new RepositoryDirectory();
            repositoryDirectory.setPath(path + "/" + repositoryObject.getName());
            repositoryDirectory.setName(repositoryObject.getName());
            repositoryDirectory.setObjectId(repositoryObject.getObjectId());
            repositoryObjects.add(repositoryDirectory);
        } else {
            RepositoryFile repositoryFile = new RepositoryFile();
            repositoryFile.setPath(path + "/" + repositoryObject.getName());
            repositoryFile.setName(repositoryObject.getName());
            repositoryFile.setType(((RepositoryObject) repositoryObject).getObjectType() == RepositoryObjectType.TRANSFORMATION ? TRANSFORMATION : JOB);
            repositoryFile.setObjectId(repositoryObject.getObjectId());
            repositoryObjects.add(repositoryFile);
        }
    }
    return repositoryObjects;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.repo.model.RepositoryDirectory) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ArrayList(java.util.ArrayList) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) RepositoryFile(org.pentaho.repo.model.RepositoryFile) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface)

Example 4 with RepositoryObjectInterface

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

the class RepositoryVfsFileObject method getChildren.

@Override
public FileObject[] getChildren() throws FileSystemException {
    try {
        RepositoryDirectoryInterface dir = provider.getRepo().findDirectory(path);
        if (dir == null) {
            return null;
        }
        List<RepositoryObjectInterface> ch = new ArrayList<>();
        ch.addAll(dir.getChildren());
        ch.addAll(dir.getRepositoryObjects());
        FileObject[] result = new RepositoryVfsFileObject[ch.size()];
        for (int i = 0; i < ch.size(); i++) {
            result[i] = new RepositoryVfsFileObject(provider, path + '/' + ch.get(i).getName());
        }
        return result;
    } catch (Exception ex) {
        throw new FileSystemException(ex);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) FileSystemException(org.apache.commons.vfs2.FileSystemException) ArrayList(java.util.ArrayList) FileObject(org.apache.commons.vfs2.FileObject) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface) KettleException(org.pentaho.di.core.exception.KettleException) FileSystemException(org.apache.commons.vfs2.FileSystemException) NotImplementedException(org.apache.commons.lang.NotImplementedException)

Aggregations

RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)4 ArrayList (java.util.ArrayList)3 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)3 RepositoryObject (org.pentaho.di.repository.RepositoryObject)3 RepositoryFile (org.pentaho.repo.model.RepositoryFile)2 Date (java.util.Date)1 NotImplementedException (org.apache.commons.lang.NotImplementedException)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)1 RepositoryExtended (org.pentaho.di.repository.RepositoryExtended)1 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)1 EERepositoryObject (org.pentaho.di.repository.pur.model.EERepositoryObject)1 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1 RepositoryRequest (org.pentaho.platform.api.repository2.unified.RepositoryRequest)1 RepositoryDirectory (org.pentaho.repo.model.RepositoryDirectory)1