use of org.pentaho.metaverse.util.VfsDateRangeFilter in project pentaho-metaverse by pentaho.
the class VfsLineageCollector method listArtifacts.
@Override
public List<String> listArtifacts(final String startingDate, final String endingDate) throws IllegalArgumentException {
List<String> paths = new ArrayList<>();
try {
FileSystemOptions opts = new FileSystemOptions();
FileObject lineageRootFolder = KettleVFS.getFileObject(getOutputFolder(), opts);
FileSelector dateRangeFilter = new VfsDateRangeFilter(format, startingDate, endingDate);
FileSelector depthFilter = new FileDepthSelector(1, 256);
if (lineageRootFolder.exists() && lineageRootFolder.getType() == FileType.FOLDER) {
// get the folders that come on or after the startingDate
FileObject[] dayFolders = lineageRootFolder.findFiles(dateRangeFilter);
for (FileObject dayFolder : dayFolders) {
FileObject[] listThisFolder = dayFolder.findFiles(depthFilter);
for (FileObject currentFile : listThisFolder) {
if (currentFile.getType() == FileType.FILE) {
paths.add(currentFile.getName().getPath());
}
}
}
}
return paths;
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
use of org.pentaho.metaverse.util.VfsDateRangeFilter in project pentaho-metaverse by pentaho.
the class VfsLineageCollector method listArtifactsForFile.
@Override
public List<String> listArtifactsForFile(String pathToArtifact, String startingDate, String endingDate) throws IllegalArgumentException {
List<String> paths = new ArrayList<>();
try {
FileSystemOptions opts = new FileSystemOptions();
FileObject lineageRootFolder = KettleVFS.getFileObject(getOutputFolder(), opts);
FileSelector dateRangeFilter = new VfsDateRangeFilter(format, startingDate, endingDate);
FileSelector depthFilter = new FileDepthSelector(1, 256);
if (lineageRootFolder.exists() && lineageRootFolder.getType() == FileType.FOLDER) {
// get all of the date folders of lineage we have
FileObject[] dayFolders = lineageRootFolder.findFiles(dateRangeFilter);
for (FileObject dayFolder : dayFolders) {
FileObject[] listThisFolder = dayFolder.findFiles(depthFilter);
for (FileObject currentFile : listThisFolder) {
FileObject requested = currentFile.resolveFile(pathToArtifact);
if (requested.exists() && requested.getType() == FileType.FOLDER) {
FileObject[] requestedChildren = requested.getChildren();
for (FileObject requestedChild : requestedChildren) {
if (requestedChild.getType() == FileType.FILE) {
paths.add(requestedChild.getName().getPath());
}
}
}
}
}
}
return paths;
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
Aggregations