public class DatabaseStore extends java.lang.Object implements IStore
This source supports the following parameters:
Constructor and Description |
---|
DatabaseStore(Controller controller)
The constructor
|
Modifier and Type | Method and Description |
---|---|
void |
aboutToRenamedFile(java.io.File rootMediaDir,
java.io.File oldFile,
java.io.File newFile)
This is used when a file that holds a episode or film is about to be renamed
|
protected void |
beginTransaction() |
void |
cacheEpisode(java.io.File rootMediaDir,
java.io.File episodeFile,
java.io.File oldFileName,
IEpisode episode)
This is used to write a episode or special too the store
|
protected void |
cacheEpisodeNoTrans(java.io.File rootMediaDir,
java.io.File episodeFile,
java.io.File oldFileName,
IEpisode episode) |
void |
cacheFilm(java.io.File rootMediaDir,
java.io.File filmFile,
java.io.File oldFileName,
IFilm film,
java.lang.Integer part)
This is used to write a film to the store.
|
void |
cacheSeason(java.io.File rootMediaDir,
java.io.File episodeFile,
ISeason season)
This is used to write a season too the store.
|
protected void |
cacheSeasonNoTrans(java.io.File rootMediaDir,
java.io.File episodeFile,
ISeason season) |
void |
cacheShow(java.io.File rootMediaDir,
java.io.File episodeFile,
IShow show)
This is used to write a show too the store.
|
protected void |
cacheShowNoTrans(java.io.File rootMediaDir,
java.io.File episodeFile,
IShow show) |
protected void |
close() |
protected void |
commitTransaction() |
void |
fileDeleted(MediaDirectory dir,
java.io.File file)
This is called when a file is deleted from a media directory
|
boolean |
fileKnownByStore(MediaDirectory mediaDirectory,
java.io.File file)
Used to check that a media file is known by a store
|
void |
fileUpdated(MediaDirectory mediaDirectory,
java.io.File file)
This is called when a file is updated within a media directory.
|
protected Controller |
getController() |
IEpisode |
getEpisode(java.io.File rootMediaDir,
java.io.File episodeFile,
ISeason season,
java.util.List<java.lang.Integer> episodeNums)
This gets a episode from the store.
|
IEpisode |
getEpisode(MediaDirectory dir,
java.io.File file)
This is used to get a episode from a store via it's file name.
|
IFilm |
getFilm(java.io.File rootMediaDir,
java.io.File filmFile,
java.lang.String filmId)
This will get a film from the store.
|
IFilm |
getFilm(MediaDirectory dir,
java.io.File file)
This is used to get a film from a store via it's file name.
|
java.lang.String |
getParameter(java.lang.String key)
Used to get the value of a source parameter.
|
ISeason |
getSeason(java.io.File rootMediaDir,
java.io.File episodeFile,
IShow show,
int seasonNum)
This will get a season from the store.
|
IShow |
getShow(java.io.File rootMediaDir,
java.io.File episodeFile,
java.lang.String showId)
This will get a show from the store.
|
IEpisode |
getSpecial(java.io.File rootMediaDir,
java.io.File episodeFile,
ISeason season,
java.util.List<java.lang.Integer> specialNumbers)
This gets a special episode from the store.
|
void |
init()
Called to initialise the stores and check all their resources can be found.
|
protected void |
init(DBResource resource) |
java.util.Collection<IEpisode> |
listEpisodes(MediaDirConfig dirConfig,
IProgressMonitor monitor)
This is used to list all the episodes within the store if the store supports the operation.
|
java.util.Collection<IFilm> |
listFilms(MediaDirConfig dirConfig,
IProgressMonitor monitor)
This is used to list all the films within the store if the store supports the operation.
|
void |
performedActions(MediaDirectory dir)
This is called after all the actions on all the media files have been performed so that
the store can clean up any stale data.
|
void |
renamedFile(java.io.File rootMediaDir,
java.io.File oldFile,
java.io.File newFile)
This is used when a file that holds a episode or film has been renamed
|
SearchResult |
searchMedia(java.lang.String name,
Mode mode,
java.lang.Integer part,
MediaDirConfig dirConfig,
java.io.File mediaFile)
Used to search for store for media
|
void |
setParameter(java.lang.String key,
java.lang.String value)
Used to set source parameters.
|
protected void |
updateEpisode(IEpisode episode,
DBEpisode dbEpisode,
java.io.File episodeFile,
java.io.File oldFileName,
java.io.File rootMediaDir) |
protected void |
updateSeason(ISeason season,
DBSeason dbSeason) |
protected void |
updateShow(IShow show,
DBShow foundShow) |
void |
upgrade(MediaDirectory mediaDirectory)
This is called to check if a upgrade is needed and perform the upgrade if required
|
public DatabaseStore(Controller controller)
controller
- The controllerpublic void cacheEpisode(java.io.File rootMediaDir, java.io.File episodeFile, java.io.File oldFileName, IEpisode episode) throws StoreException
cacheEpisode
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.episodeFile
- the file witch the episode is stored inoldFileName
- The name of the file before it was moved into the storeepisode
- The episode or special too writeStoreException
- Thrown if their is a problem with the storeprotected void cacheEpisodeNoTrans(java.io.File rootMediaDir, java.io.File episodeFile, java.io.File oldFileName, IEpisode episode) throws StoreException
StoreException
protected void commitTransaction()
protected void beginTransaction() throws StoreException
StoreException
protected void updateEpisode(IEpisode episode, DBEpisode dbEpisode, java.io.File episodeFile, java.io.File oldFileName, java.io.File rootMediaDir)
public void cacheSeason(java.io.File rootMediaDir, java.io.File episodeFile, ISeason season) throws StoreException
cacheSeason
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.episodeFile
- The file the episode is stored inseason
- The season too writeStoreException
- Thrown if their is a problem with the storeprotected void cacheSeasonNoTrans(java.io.File rootMediaDir, java.io.File episodeFile, ISeason season) throws StoreException
StoreException
public void cacheShow(java.io.File rootMediaDir, java.io.File episodeFile, IShow show) throws StoreException
IStore
cacheShow
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.episodeFile
- The file the episode is stored inshow
- The show too writeStoreException
- Thrown if their is a problem with the storeprotected void cacheShowNoTrans(java.io.File rootMediaDir, java.io.File episodeFile, IShow show)
public java.util.Collection<IFilm> listFilms(MediaDirConfig dirConfig, IProgressMonitor monitor) throws StoreException
listFilms
in interface IStore
dirConfig
- The media directory configurationmonitor
- The progress monitorStoreException
- Thrown if their are any problemspublic IFilm getFilm(java.io.File rootMediaDir, java.io.File filmFile, java.lang.String filmId) throws StoreException, java.net.MalformedURLException, java.io.IOException
getFilm
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.filmFile
- The file the film is located in.filmId
- The id of the filmStoreException
- Thrown if their is a problem retrieving the datajava.net.MalformedURLException
- Thrown if their is a problem creating URL'sjava.io.IOException
- Thrown if their is a I/O related problem.public IFilm getFilm(MediaDirectory dir, java.io.File file) throws StoreException
getFilm
in interface IStore
dir
- The media directoryfile
- The media fileStoreException
- Thrown if their are any problemspublic void cacheFilm(java.io.File rootMediaDir, java.io.File filmFile, java.io.File oldFileName, IFilm film, java.lang.Integer part) throws StoreException
cacheFilm
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.filmFile
- The file which the film is stored inoldFileName
- The name of the file before it was moved into the storefilm
- The film to writepart
- The part number of the filmStoreException
- Thrown if their is a problem with the storepublic IEpisode getEpisode(java.io.File rootMediaDir, java.io.File episodeFile, ISeason season, java.util.List<java.lang.Integer> episodeNums) throws StoreException, java.net.MalformedURLException, java.io.IOException
getEpisode
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.episodeFile
- the file which the episode is stored inseason
- The season the episode belongs tooepisodeNums
- The numbers of the episode too getStoreException
- Thrown if their is a problem with the storejava.net.MalformedURLException
- Thrown if their is a problem creating URL'sjava.io.IOException
- Thrown if their is a I/O related problem.public ISeason getSeason(java.io.File rootMediaDir, java.io.File episodeFile, IShow show, int seasonNum) throws StoreException, java.io.IOException
getSeason
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.episodeFile
- the file which the episode is stored inshow
- The show the season belongs tooseasonNum
- The number of the season that is to be fetchedStoreException
- Thrown if their is a problem with the storejava.io.IOException
- Thrown if their is a I/O related problem.public IShow getShow(java.io.File rootMediaDir, java.io.File episodeFile, java.lang.String showId) throws StoreException, java.net.MalformedURLException, java.io.IOException
getShow
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.episodeFile
- the file which the episode is stored inshowId
- The id of the show to get.StoreException
- Thrown if their is a problem with the storejava.net.MalformedURLException
- Thrown if their is a problem creating URL'sjava.io.IOException
- Thrown if their is a I/O related problem.public IEpisode getSpecial(java.io.File rootMediaDir, java.io.File episodeFile, ISeason season, java.util.List<java.lang.Integer> specialNumbers) throws java.net.MalformedURLException, java.io.IOException, StoreException
getSpecial
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.episodeFile
- the file which the episode is stored inseason
- The season the special episode belongs toospecialNumbers
- The numbers of the special episode too getjava.net.MalformedURLException
- Thrown if their is a problem creating URL'sjava.io.IOException
- Thrown if their is a I/O related problem.StoreException
- Thrown if their is a problem with the storepublic SearchResult searchMedia(java.lang.String name, Mode mode, java.lang.Integer part, MediaDirConfig dirConfig, java.io.File mediaFile) throws StoreException
searchMedia
in interface IStore
name
- The search termmode
- The mode of the searchpart
- The part number to search fordirConfig
- The Media directory configurationmediaFile
- The media file the search is associated withStoreException
- Thrown if their is a problem with the storepublic void renamedFile(java.io.File rootMediaDir, java.io.File oldFile, java.io.File newFile) throws StoreException
renamedFile
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.oldFile
- The old filenewFile
- The new fileStoreException
- Thrown if their is a problem renaming filespublic void setParameter(java.lang.String key, java.lang.String value) throws StoreException
Used to set source parameters. If the key is not supported by this source, then a SourceException
is thrown.
setParameter
in interface IStore
key
- The key of the parametervalue
- The value of the parameterStoreException
- Throw if the key is not supported by this store.public java.lang.String getParameter(java.lang.String key) throws StoreException
Used to get the value of a source parameter. If the key is not supported by this source, then a SourceException
is thrown.
getParameter
in interface IStore
key
- The key of the parameterStoreException
- Throw if the key is not supported by this store.public void performedActions(MediaDirectory dir) throws StoreException
performedActions
in interface IStore
dir
- The media directoryStoreException
- Thrown if their is a problempublic void fileDeleted(MediaDirectory dir, java.io.File file) throws StoreException
fileDeleted
in interface IStore
dir
- The media directoryfile
- The fileStoreException
- Thrown if their is a problempublic IEpisode getEpisode(MediaDirectory dir, java.io.File file) throws StoreException
getEpisode
in interface IStore
dir
- The media directoryfile
- The media fileStoreException
- Thrown if their are any problemspublic void init() throws StoreException
init
in interface IStore
StoreException
- Thrown if their are any problemsprotected void init(DBResource resource) throws StoreException
StoreException
public java.util.Collection<IEpisode> listEpisodes(MediaDirConfig dirConfig, IProgressMonitor monitor) throws StoreException
listEpisodes
in interface IStore
dirConfig
- The media directory configurationmonitor
- The progress monitorStoreException
- Thrown if their are any problemspublic void upgrade(MediaDirectory mediaDirectory) throws StoreException
upgrade
in interface IStore
mediaDirectory
- The media directory been upgradedStoreException
- Thrown if thier are any problemspublic void fileUpdated(MediaDirectory mediaDirectory, java.io.File file) throws StoreException
fileUpdated
in interface IStore
mediaDirectory
- The media directory the file belongs tofile
- The media fileStoreException
- Thrown if their are any problemspublic boolean fileKnownByStore(MediaDirectory mediaDirectory, java.io.File file) throws StoreException
fileKnownByStore
in interface IStore
mediaDirectory
- The media directoryfile
- The media file to checkStoreException
protected Controller getController()
public void aboutToRenamedFile(java.io.File rootMediaDir, java.io.File oldFile, java.io.File newFile) throws StoreException
aboutToRenamedFile
in interface IStore
rootMediaDir
- This is the directory which is the root of media, this can be the current directory if
it was not specified on the command line.oldFile
- The old filenewFile
- The new fileStoreException
- Thrown if their is a problem renaming filesprotected void close()