Search in sources :

Example 1 with Tree

use of org.pentaho.di.plugins.fileopensave.api.providers.Tree in project pentaho-kettle by pentaho.

the class RecentFileProvider method getTree.

@Override
public Tree getTree() {
    RecentTree recentTree = new RecentTree(NAME);
    PropsUI propsUI = getPropsUI();
    Date dateThreshold = getDateThreshold();
    List<LastUsedFile> lastUsedFiles = propsUI.getLastUsedFiles().stream().filter(lastUsedFile -> !lastUsedFile.getLastOpened().before(dateThreshold)).collect(Collectors.toList());
    for (LastUsedFile lastUsedFile : lastUsedFiles) {
        recentTree.addChild(RecentFile.create(lastUsedFile));
    }
    return recentTree;
}
Also used : LastUsedFile(org.pentaho.di.core.LastUsedFile) Date(java.util.Date) BaseFileProvider(org.pentaho.di.plugins.fileopensave.api.providers.BaseFileProvider) PropsUI(org.pentaho.di.ui.core.PropsUI) Tree(org.pentaho.di.plugins.fileopensave.api.providers.Tree) File(org.pentaho.di.plugins.fileopensave.api.providers.File) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) List(java.util.List) RecentTree(org.pentaho.di.plugins.fileopensave.providers.recents.model.RecentTree) Calendar(java.util.Calendar) RecentFile(org.pentaho.di.plugins.fileopensave.providers.recents.model.RecentFile) Collections(java.util.Collections) InputStream(java.io.InputStream) RecentTree(org.pentaho.di.plugins.fileopensave.providers.recents.model.RecentTree) Date(java.util.Date) LastUsedFile(org.pentaho.di.core.LastUsedFile) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 2 with Tree

use of org.pentaho.di.plugins.fileopensave.api.providers.Tree in project pentaho-kettle by pentaho.

the class FileController method load.

public List<Tree> load(String filter, List<String> connectionTypes) {
    List<Tree> trees = new ArrayList<>();
    List<String> filters = Utils.isEmpty(filter) || filter.equalsIgnoreCase(ProviderFilterType.DEFAULT.toString()) ? Arrays.asList(ProviderFilterType.getDefaults()) : Arrays.asList(filter.split("[,]"));
    // filter
    if (filters.contains(ProviderFilterType.ALL_PROVIDERS.toString())) {
        for (FileProvider fileProvider : providerService.get()) {
            if (fileProvider.isAvailable()) {
                trees.add(fileProvider.getTree(connectionTypes));
            }
        }
    } else {
        for (FileProvider fileProvider : providerService.get()) {
            if (fileProvider.isAvailable() && filters.contains(fileProvider.getType())) {
                trees.add(fileProvider.getTree(connectionTypes));
            }
        }
    }
    return trees;
}
Also used : FileProvider(org.pentaho.di.plugins.fileopensave.api.providers.FileProvider) ArrayList(java.util.ArrayList) Tree(org.pentaho.di.plugins.fileopensave.api.providers.Tree)

Aggregations

Tree (org.pentaho.di.plugins.fileopensave.api.providers.Tree)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 LastUsedFile (org.pentaho.di.core.LastUsedFile)1 BaseFileProvider (org.pentaho.di.plugins.fileopensave.api.providers.BaseFileProvider)1 File (org.pentaho.di.plugins.fileopensave.api.providers.File)1 FileProvider (org.pentaho.di.plugins.fileopensave.api.providers.FileProvider)1 FileException (org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException)1 RecentFile (org.pentaho.di.plugins.fileopensave.providers.recents.model.RecentFile)1 RecentTree (org.pentaho.di.plugins.fileopensave.providers.recents.model.RecentTree)1 PropsUI (org.pentaho.di.ui.core.PropsUI)1