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);
}
}
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);
}
}
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;
}
Aggregations