Search in sources :

Example 1 with RepositoryFile

use of org.pentaho.repo.model.RepositoryFile in project pentaho-kettle by pentaho.

the class RepositoryBrowserController 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.repo.model.RepositoryFile) RepositoryObjectInterface(org.pentaho.di.repository.RepositoryObjectInterface) Date(java.util.Date)

Example 2 with RepositoryFile

use of org.pentaho.repo.model.RepositoryFile in project pentaho-kettle by pentaho.

the class RepositoryBrowserController method populateFilesLazy.

public void populateFilesLazy(RepositoryDirectory repositoryDirectory, String filter) {
    RepositoryRequest repositoryRequest = new RepositoryRequest();
    repositoryRequest.setPath(repositoryDirectory.getPath());
    repositoryRequest.setDepth(1);
    repositoryRequest.setShowHidden(true);
    repositoryRequest.setTypes(RepositoryRequest.FILES_TYPE_FILTER.FILES);
    repositoryRequest.setChildNodeFilter(filter);
    RepositoryFileTree tree = getRepository().getUnderlyingRepository().getTree(repositoryRequest);
    for (RepositoryFileTree repositoryFileTree : tree.getChildren()) {
        org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile = repositoryFileTree.getFile();
        RepositoryFile repositoryFile1 = RepositoryFile.build(repositoryDirectory.getPath(), repositoryFile, isAdmin());
        repositoryDirectory.addChild(repositoryFile1);
    }
}
Also used : RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFile(org.pentaho.repo.model.RepositoryFile) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Example 3 with RepositoryFile

use of org.pentaho.repo.model.RepositoryFile in project pentaho-kettle by pentaho.

the class RepositoryBrowserController method getRecentFiles.

public List<RepositoryFile> getRecentFiles() {
    PropsUI props = PropsUI.getInstance();
    List<RepositoryFile> repositoryFiles = new ArrayList<>();
    IUser userInfo = Spoon.getInstance().rep.getUserInfo();
    String repoAndUser = Spoon.getInstance().rep.getName() + ":" + (userInfo != null ? userInfo.getLogin() : "");
    List<LastUsedFile> lastUsedFiles = props.getLastUsedRepoFiles().getOrDefault(repoAndUser, Collections.emptyList());
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -30);
    Date dateBefore = calendar.getTime();
    for (int i = 0; i < lastUsedFiles.size(); i++) {
        LastUsedFile lastUsedFile = lastUsedFiles.get(i);
        if (lastUsedFile.getLastOpened().before(dateBefore)) {
            continue;
        }
        if (lastUsedFile.getRepositoryName() != null && lastUsedFile.getRepositoryName().equals(Spoon.getInstance().rep.getName())) {
            RepositoryFile repositoryFile = new RepositoryFile();
            final String index = String.valueOf(i);
            repositoryFile.setObjectId(() -> index);
            repositoryFile.setType(lastUsedFile.isTransformation() ? TRANSFORMATION : JOB);
            repositoryFile.setName(lastUsedFile.getFilename());
            repositoryFile.setPath(lastUsedFile.getDirectory());
            repositoryFile.setDate(lastUsedFile.getLastOpened());
            repositoryFile.setRepository(lastUsedFile.getRepositoryName());
            repositoryFile.setUsername(lastUsedFile.getUsername());
            repositoryFiles.add(repositoryFile);
        }
    }
    return repositoryFiles;
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) IUser(org.pentaho.di.repository.IUser) RepositoryFile(org.pentaho.repo.model.RepositoryFile) LastUsedFile(org.pentaho.di.core.LastUsedFile) Date(java.util.Date) PropsUI(org.pentaho.di.ui.core.PropsUI)

Aggregations

RepositoryFile (org.pentaho.repo.model.RepositoryFile)3 Date (java.util.Date)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 LastUsedFile (org.pentaho.di.core.LastUsedFile)1 IUser (org.pentaho.di.repository.IUser)1 RepositoryExtended (org.pentaho.di.repository.RepositoryExtended)1 RepositoryObject (org.pentaho.di.repository.RepositoryObject)1 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)1 PropsUI (org.pentaho.di.ui.core.PropsUI)1 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)1 RepositoryRequest (org.pentaho.platform.api.repository2.unified.RepositoryRequest)1