Class ImagesDirectoryParser
java.lang.Object
be.gaudry.model.file.AbstractFileParser<Long>
be.gaudry.bibliobrol.dao.derby.tools.ImagesDirectoryParser
- All Implemented Interfaces:
PropertyChangeListener,EventListener
- Direct Known Subclasses:
ItemCoverParser,PersonPictureParser
Allows an asynchonous parsing a directory to read images to store into the
Derby database.
In this second version, for each matching or conflict file, an action is done(inserting into database or not, after calling the
- The images name must respect this format x.ext where x is the item identifier in the database.
- If an image exists in the database, default behavior does not replace the
database image. Override the
confirmReplacement(File, int)method to provide different behavior.
OutOfMemoryError: Java heap
space may occurs.In this second version, for each matching or conflict file, an action is done(inserting into database or not, after calling the
confirmReplacement(File, int) method if the file is a possible
conflict file).- Since:
- 1.0 4 févr. 2009
- Author:
- Steph GAUDRY
-
Field Summary
Fields inherited from class be.gaudry.model.file.AbstractFileParser
validPreviousProgress -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanconfirmReplacement(File file, int id)Override this method if you want to display some GUI confirmation.abstract PreparedStatementabstract StringReturns the query to load the identifiers from a database table for which * an associated image is found (conflict).
The general contract ofgetSelectConflictIdsQueryis that the first column of the results is the identifier value asINTEGERSQL data type.
Example of query:abstract StringReturns the query to load the identifiers from a database table for which there is not yet an associated image.
The general contract ofgetSelectConflictIdsQueryis that the first column of the results is the identifier value asINTEGERSQL data type.
Example of query:abstract PreparedStatementlongparse(AbstractBrolWorker<Long> bgw)Parses files from the definedstart path, and call theAbstractFileParser.performOnFile(AbstractBrolWorker, File, int, int)on each file.protected booleanperformOnFile(AbstractBrolWorker<Long> bgw, File file, int progressPercent, int subDirDeep)Do something on each filevoidreadIds(AbstractBrolWorker<Long> bgw)Methods inherited from class be.gaudry.model.file.AbstractFileParser
equals, finalize, getProgressMax, getStartPath, hashCode, init, isIncludeHiddenFiles, isIncludeSubFolders, isPauseProcessing, isPreCalcProgress, isPreCalculated, parseFiles, performOnDirectory, propertyChange, setIncludeHiddenFiles, setIncludeSubFolders, setLanguage, setPreCalcProgress, setStartPath, togglePause
-
Constructor Details
-
ImagesDirectoryParser
public ImagesDirectoryParser()
-
-
Method Details
-
getInsertImageStatement
- Returns:
- the insertImageStatement
-
getUpdateImageStatement
- Returns:
- the updateImageStatement
-
getSelectMatchingIdsQuery
Returns the query to load the identifiers from a database table for which there is not yet an associated image.
The general contract ofgetSelectConflictIdsQueryis that the first column of the results is the identifier value asINTEGERSQL data type.
Example of query:SELECT itemId FROM item WHERE itemImage IS NULL
- Returns:
- the selectMatchingIdsQuery
-
getSelectConflictIdsQuery
Returns the query to load the identifiers from a database table for which * an associated image is found (conflict).
The general contract ofgetSelectConflictIdsQueryis that the first column of the results is the identifier value asINTEGERSQL data type.
Example of query:SELECT itemId FROM item WHERE itemImage IS NOT NULL
- Returns:
- the selectConflictIdsQuery
-
confirmReplacement
Override this method if you want to display some GUI confirmation.- Parameters:
file- possible matching file.id- matching id, but with an existing file.- Returns:
- always
falsein this basic implementation.
-
parse
Description copied from class:AbstractFileParserParses files from the definedstart path, and call theAbstractFileParser.performOnFile(AbstractBrolWorker, File, int, int)on each file.- Overrides:
parsein classAbstractFileParser<Long>- Returns:
- the size of the matching files, not the size of the parsed directory
-
readIds
-
performOnFile
protected boolean performOnFile(AbstractBrolWorker<Long> bgw, File file, int progressPercent, int subDirDeep)Description copied from class:AbstractFileParserDo something on each file- Specified by:
performOnFilein classAbstractFileParser<Long>- Parameters:
bgw-AbstractBrolWorkerto perform cancel if needed, and report progressfile- file to checkprogressPercent- Progress percentagesubDirDeep- Deep of the directory in comparison with start directory- Returns:
- true if we must stop the parsing of current directory (ie. if we have a vob file, we don't check the other files in this directory) false otherwise
-