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