Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.externalfiles

public Class UnlinkedFilesCrawler

extends BackgroundTask<UnlinkedFilesSearchResult>
Class Inheritance
Imports
java.io.IOException, java.nio.file.DirectoryStream, .DirectoryStream.Filter, .Files, .Path, java.util.ArrayList, .Collection, .HashMap, .HashSet, .List, .Map, .Set, java.util.stream.Collectors, .Stream, .StreamSupport, org.jabref.gui.frame.ExternalApplicationsPreferences, org.jabref.gui.util.FileNodeViewModel, org.jabref.logic.FilePreferences, org.jabref.logic.externalfiles.DateRange, .ExternalFileSorter, org.jabref.logic.util.BackgroundTask, org.jabref.logic.util.io.AutoLinkPreferences, .FileUtil, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, .LinkedFile, org.slf4j.Logger, .LoggerFactory

Util class for searching files on the file system which are not linked to a provided org.jabref.model.database.BibDatabase.

The result is used to determine whether to link the files to an existing related entry or to create a new entry, according to the user's choice.

Related: org.jabref.gui.externalfiles.AutoSetFileLinksUtil#findAssociatedNotLinkedFiles

Field Summary

Modifier and TypeField and Description
private final AutoLinkPreferences
private final BibDatabaseContext
private final DateRange
private final Path
private final ExternalApplicationsPreferences
private final DirectoryStream.Filter<Path>
private final FilePreferences
private static final Logger
private final ExternalFileSorter

Constructor Summary

AccessConstructor and Description
public
UnlinkedFilesCrawler(Path directory, DirectoryStream.Filter<Path> fileFilter, DateRange dateFilter, ExternalFileSorter sorter, BibDatabaseContext databaseContext, FilePreferences filePreferences, ExternalApplicationsPreferences externalApplicationsPreferences, AutoLinkPreferences autoLinkPreferences)

Method Summary

Modifier and TypeMethod and Description
public UnlinkedFilesSearchResult
private Map<Path, List<BibEntry>>
pack-priv FileNodeViewModel

Returns:

FileNodeViewModel containing the data of the current directory and all subdirectories
searchDirectory
(Path directory, UnlinkedPDFFileFilter
contains a BibDatabaseContext which is used to determine whether the file is linked
unlinkedPDFFileFilter
)

Searches recursively all files in the specified directory.

Field Detail

autoLinkPreferencesback to summary
private final AutoLinkPreferences autoLinkPreferences
databaseContextback to summary
private final BibDatabaseContext databaseContext
dateFilterback to summary
private final DateRange dateFilter
directoryback to summary
private final Path directory
externalApplicationsPreferencesback to summary
private final ExternalApplicationsPreferences externalApplicationsPreferences
fileFilterback to summary
private final DirectoryStream.Filter<Path> fileFilter
filePreferencesback to summary
private final FilePreferences filePreferences
LOGGERback to summary
private static final Logger LOGGER
sorterback to summary
private final ExternalFileSorter sorter

Constructor Detail

UnlinkedFilesCrawlerback to summary
public UnlinkedFilesCrawler(Path directory, DirectoryStream.Filter<Path> fileFilter, DateRange dateFilter, ExternalFileSorter sorter, BibDatabaseContext databaseContext, FilePreferences filePreferences, ExternalApplicationsPreferences externalApplicationsPreferences, AutoLinkPreferences autoLinkPreferences)

Method Detail

callback to summary
public UnlinkedFilesSearchResult call() throws IOException

impl->req~jabgui.externalfiles.unlinked-files.search.non-blocking-results~1

Annotations
@Override
findRelatedEntriesByFileback to summary
private Map<Path, List<BibEntry>> findRelatedEntriesByFile()
searchDirectoryback to summary
pack-priv FileNodeViewModel searchDirectory(Path directory, UnlinkedPDFFileFilter unlinkedPDFFileFilter) throws IOException

Searches recursively all files in the specified directory.

All files matched by the given UnlinkedPDFFileFilter are taken into the resulting tree.

The result will be a tree structure of nodes of the type javafx.scene.control.CheckBoxTreeItem.

The user objects that are attached to the nodes is the FileNodeViewModel, which wraps the java.io.File-Object.

For ensuring the capability to cancel the work of this recursive method, the first position in the integer array 'state' must be set to 1, to keep the recursion running. When the states value changes, the method will resolve its recursion and return what it has saved so far.

The files are filtered according to the DateRange filter value and then sorted according to the ExternalFileSorter value.

Parameters
unlinkedPDFFileFilter:UnlinkedPDFFileFilter

contains a BibDatabaseContext which is used to determine whether the file is linked

Returns:FileNodeViewModel

FileNodeViewModel containing the data of the current directory and all subdirectories

Exceptions
IOException:
if directory is not a directory or empty