use of org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryFile in project pentaho-kettle by pentaho.
the class RepositoryBrowserController method getRecentFiles.
public List<RepositoryFile> getRecentFiles() {
if (spoonSupplier.get().rep == null) {
return Collections.emptyList();
}
PropsUI props = PropsUI.getInstance();
List<RepositoryFile> repositoryFiles = new ArrayList<>();
IUser userInfo = spoonSupplier.get().rep.getUserInfo();
String repoAndUser = spoonSupplier.get().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;
}
use of org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryFile in project pentaho-kettle by pentaho.
the class RepositoryBrowserController method search.
public List<org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryObject> search(String path, String filter) {
RepositoryDirectoryInterface repositoryDirectoryInterface = findDirectory(path);
List<org.pentaho.di.plugins.fileopensave.providers.repository.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().getId());
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().getId());
repositoryObjects.add(repositoryFile);
}
}
return repositoryObjects;
}
Aggregations