medi.db
Class Provider

java.lang.Object
  |
  +--medi.db.Provider

public class Provider
extends java.lang.Object

The main class to make simple operations on the database.


Constructor Summary
Provider(DbDatabase db)
          Creates new Provider
 
Method Summary
 void addContainerValidator(Validator val)
          Adds a new container validator.
 void addFileTypeValidator(Validator val)
          Adds a validator to control whether the table FILE_TYPE has been changed.
 java.lang.String buildGenrePath(java.lang.Integer genreID)
          Builds a genre path for a given genre.
 java.lang.String buildPath(java.lang.String finalPath, java.lang.Integer volumeID, java.lang.Integer fatherSessionID)
          Creates a complete path for a given session.
 void createAuthorTelephone(java.lang.Integer authorID, java.lang.String telephone)
          Creates a new author telephone number.
 void createEditorTelephone(java.lang.Integer editorID, java.lang.String telephone)
          Creates a new editor telephone number.
 int createEmptyAuthor()
          Creates a new empty author.
 int createEmptyContainer()
          Creates a new empty container.
 long createEmptyDataSet()
          Creates a new empty data.
 int createEmptyEditor()
          Creates a new empty editor.
 int createEmptyFileType()
          Creates a new empty file type.
 int createEmptyGenre(java.lang.Integer fatherGenreID)
          Creates a new empty genre.
 long createEmptyProgram()
          Creates an empty program.
 int createEmptySession(java.lang.Integer volumeID, java.lang.Integer fatherSessionID)
          Creates a new empty session.
 int createEmptyVolume(java.lang.Integer containerID)
          Creates a new empty volume.
 int createNewAuthor(java.lang.String name, java.lang.String minit, java.lang.String surname, java.lang.String address, java.lang.String eMail, java.lang.String homepage, java.lang.String description)
          Creates a new author.
 int createNewContainer(java.lang.String containerType, java.lang.String containerLocation)
          Creates a new container.
 long createNewData(java.lang.Integer fileTypeID, java.lang.String dataName, java.lang.String fileName, java.lang.String date, java.lang.Long dimension)
          Creates a new data.
 long createNewData(java.lang.Integer fileTypeID, java.lang.String dataName, java.lang.String fileName, java.lang.String date, java.lang.Long dimension, java.lang.String description, java.lang.Integer duration, java.lang.Integer samplingBits, java.lang.Integer frequency, java.lang.Integer stereo, java.lang.Integer bitrate, java.lang.Integer dimx, java.lang.Integer dimy)
          Creates a new data item.
 long createNewDataSet(java.lang.String name, java.lang.String description)
          Creates a new data set.
 int createNewFileType(java.lang.String fileTypeName, java.lang.String extension, java.lang.Integer sw, java.lang.String description)
          Creates a new file type.
 int createNewGenre(java.lang.Integer fatherGenreID, java.lang.String name, java.lang.String description)
          Creates a new Genre.
 int createNewSession(java.lang.Integer volumeID, java.lang.Integer fatherSessionID, java.lang.String sessionName, java.lang.String sessionType)
          Creates a new session.
 int createNewVolume(java.lang.Integer containerID, java.lang.String volumeName, java.lang.String volumeType)
          Creates a new volume.
 java.lang.Integer findSessionID(java.lang.Integer volumeID, java.lang.String path)
          Finds a session ID by searching its path.
 DbTable getAuthors(java.lang.Integer authorID)
          Returns a list of authors.
 java.util.Iterator getAuthorsByData(java.lang.Long[] dataIDs)
          Returns a list of authors that realized the specific data.
 DbTable getAuthorsReduced(java.lang.Integer authorID)
          Returns a list of authors in a sorted way.
 DbTable getAuthorsSorted(java.lang.Integer authorID)
          Returns a list of authors in a sorted way.
 DbTable getAuthorTelephone(java.lang.Integer authorID)
          Returns a list of telephone numbers of the specified author.
 boolean getAutomaticChecking()
          Gets the automatic checking flag.
 boolean getConstraintEmulation()
          Returns the value for the constraint emulation.
 DbTable getContainerAndVolumeByVolume(java.lang.Integer volumeID)
          Returns a joined-table with container and volume info.
 DbTable getContainers(java.lang.Integer containerID)
          Returns the containers.
 DbTable getContainersReduced(java.lang.Integer containerID)
          Returns a list of containers in a sorted way.
 DbTable getContainersSorted(java.lang.Integer containerID)
          Returns a list of containers in a sorted way.
 DbTable getData(java.lang.Long dataID)
          Returns info about a specific row of Data.
 DbDatabase getDatabase()
          Returns the database that this object is using.
 java.util.Iterator getDataByAuthor(java.lang.Integer authorID)
          Returns data realized by an author.
 DbTable getDataByAuthorReduced(java.lang.Integer authorID)
          Returns data realized by a specified author (in a sorted way).
 DbTable getDataByAuthorSorted(java.lang.Integer authorID)
          Returns data realized by a specified author (in a sorted way).
 java.util.Iterator getDataByDataSet(java.lang.Long dataSetID)
          Returns data contained in a data set.
 DbTable getDataByDataSetReduced(java.lang.Long dataSetID)
          Returns data contained in a specified data set (in a sorted way).
 DbTable getDataByDataSetSorted(java.lang.Long dataSetID)
          Returns data contained in a specified data set (in a sorted way).
 java.util.Iterator getDataByEditor(java.lang.Integer editorID)
          Returns data published by an editor.
 DbTable getDataByEditorReduced(java.lang.Integer editorID)
          Returns a list of data published by a specified editor (in a sorted way).
 DbTable getDataByEditorSorted(java.lang.Integer editorID)
          Returns a list of data published by a specified editor (in a sorted way).
 DbTable getDataByFileType(java.lang.Integer fileTypeID)
          Returns all data of a certain file type.
 DbTable getDataByFileTypeReduced(java.lang.Integer fileTypeID)
          Returns a list of data whose file type is the one specified (in a sorted way).
 DbTable getDataByFileTypeSorted(java.lang.Integer fileTypeID)
          Returns a list of data whose file type is the one specified (in a sorted way).
 java.util.Iterator getDataByGenre(java.lang.Integer genreID)
          Returns the data under a specific genre.
 DbTable getDataByGenreReduced(java.lang.Integer genreID)
          Returns a list of data whose genre is the one needed (in a sorted way).
 DbTable getDataByGenreSorted(java.lang.Integer genreID)
          Returns a list of data whose genre is the one needed (in a sorted way).
 java.util.Iterator getDataBySession(java.lang.Integer volumeID, java.lang.Integer sessionID)
          Returns data contained in a session.
 DbTable getDataBySessionReduced(java.lang.Integer volumeID, java.lang.Integer sessionID)
          Returns data contained in a session in a sorted way.
 DbTable getDataBySessionSorted(java.lang.Integer volumeID, java.lang.Integer sessionID)
          Returns data contained in a session in a sorted way.
 java.util.Iterator getDataSetByData(java.lang.Long[] dataIDs)
          Returns a list of data sets that contain the specified data IDs.
 DbTable getDataSets(java.lang.Long dataSetID)
          Returns a list of data sets.
 DbTable getDataSetsByName(java.lang.String name)
          Returns a list of data sets whose name is specified.
 DbTable getDataSetsReduced(java.lang.Long dataSetID)
          Returns a list of data sets in a sorted way.
 DbTable getDataSetsSorted(java.lang.Long dataSetID)
          Returns a list of data sets in a sorted way.
 java.text.SimpleDateFormat getDateFormat()
          Returns the date formatter that the database uses.
 DbTable getDefaultProgram(java.lang.Integer fileTypeID)
          Returns the default programs for the specified file type.
 DbTable getDefaultProgramByData(java.lang.Long dataID)
          Returns the default program for the specified data.
 DbTable getEditors(java.lang.Integer editorID)
          Returns a list of editors.
 java.util.Iterator getEditorsByData(java.lang.Long[] dataIDs)
          Returns a list of editors that published the specified data.
 DbTable getEditorsReduced(java.lang.Integer editorID)
          Returns a list of editors in a sorted way.
 DbTable getEditorsSorted(java.lang.Integer editorID)
          Returns a list of editors in a sorted way.
 DbTable getEditorTelephone(java.lang.Integer editorID)
          Returns a list of telephone numbers of the specified editor.
 DbTable getFathers(java.lang.Long dataID)
          Returns the fathers of a specific data ID.
 DbTable getFileTypes(java.lang.Integer fileTypeID)
          Returns a list of file types.
 DbTable getFileTypesByExtension(java.lang.String extension)
          Retunrs a list of file types which accept the specified extension.
 DbTable getFileTypesByProgram(java.lang.Long programID)
          Returns the file types that are managed by the specified program.
 DbTable getFileTypesReduced(java.lang.Integer fileTypeID)
          Returns a list of file types in a sorted way.
 DbTable getFileTypesSorted(java.lang.Integer fileTypeID)
          Returns a list of file types in a sorted way.
 DbTable getGenres(java.lang.Integer genreID)
          Returns a list of genres, regardless of te super-genre.
 DbTable getGenres(java.lang.Integer genreID, java.lang.Integer superGenreID)
          Returns a list of genres.
 java.util.Iterator getGenresByData(java.lang.Long[] dataIDs)
          Returns a list of genres of a specific data.
 DbTable getGenresByName(java.lang.String name)
          Returns a list of genres whose name is specified.
 DbTable getGenresReduced(java.lang.Integer genreID, java.lang.Integer superGenreID)
          Returns a list of genres in a sorted way.
 DbTable getGenresSorted(java.lang.Integer genreID, java.lang.Integer superGenreID)
          Returns a list of genres in a sorted way.
 java.util.Iterator getLocationsByData(java.lang.Long dataID)
          Returns a list of locations for the given data.
 int getMaxAuthorID()
          Returns the max author ID.
 int getMaxContainerID()
          Returns the max container ID.
 long getMaxDataID()
          Returns the max data ID.
 long getMaxDataSetID()
          Returns the max data set ID.
 int getMaxEditorID()
          Returns the max editor ID.
 int getMaxFileTypeID()
          Returns the max file type ID.
 int getMaxGenreID()
          Returns the max genre ID.
 long getMaxProgramID()
          Returns the maximum program ID.
 int getMaxSessionID(java.lang.Integer volumeID)
          Returns the max session ID for a given volume.
 int getMaxVolumeID()
          Returns the max volume ID.
 DbTable getOneVolume(java.lang.Integer volumeID)
          Returns info about ONE volume.
 DbTable getPrograms(java.lang.Long programID)
          Returns a list of programs.
 DbTable getProgramsByData(java.lang.Long dataID)
          Returns the programs that can manage the specified data.
 DbTable getProgramsByFileType(java.lang.Integer fileTypeID)
          Returns programs that manage the specified file type.
 DbTable getProgramsReduced(java.lang.Long programID)
          Returns a list of programs in a sorted way.
 DbTable getProgramsSorted(java.lang.Long programID)
          Returns a list of programs in a sorted way.
 DbTable getSessionByName(java.lang.Integer volumeID, java.lang.Integer fatherSessionID, java.lang.String sessionName)
          Returns the session whose name is specified.
 DbTable getSessions(java.lang.Integer volumeID, java.lang.Integer sessionID)
          Returns a list of session, without caring of super-session ID field.
 DbTable getSessions(java.lang.Integer volumeID, java.lang.Integer sessionID, java.lang.Integer superSession)
          Returns the session list.
 DbTable getSessionsByData(java.lang.Long dataID)
          Returns sessions that contain the specified data.
 DbTable getSessionsReduced(java.lang.Integer volumeID, java.lang.Integer sessionID, java.lang.Integer superSession)
          Returns the list of sessions in a sorted way.
 DbTable getSessionsSorted(java.lang.Integer volumeID, java.lang.Integer sessionID, java.lang.Integer superSession)
          Returns the list of sessions in a sorted way.
 DbTable getSons(java.lang.Long dataID)
          Returns the sons of a specified data.
 DbTable getSonsReduced(java.lang.Long dataID)
          Returns the sons of a specified data.
 DbTable getVolumeByName(java.lang.String volumeName)
          Returns a volume list as a DbTable by searching its name.
 DbTable getVolumeLocation(java.lang.Integer volumeID)
          Returns a volume's location.
 DbTable getVolumes(java.lang.Integer containerID, java.lang.Integer volumeID)
          Returns the volumes.
 DbTable getVolumesReduced(java.lang.Integer containerID, java.lang.Integer volumeID)
          Returns a list of volumes in a sorted way.
 DbTable getVolumesSorted(java.lang.Integer containerID, java.lang.Integer volumeID)
          Returns a list of volumes in a sorted way.
 boolean isGenreDescendent(java.lang.Integer genreID1, java.lang.Integer genreID2)
          Checks if a genre is a descendent of another genre.
 boolean isSessionDescendent(java.lang.Integer volumeID, java.lang.Integer sessionID1, java.lang.Integer sessionID2)
          Checks if a session is a descendent of an another session.
 void linkDataToAuthor(java.lang.Long dataID, java.lang.Integer authorID)
          Assigns a data to an author.
 void linkDataToDataSet(java.lang.Long dataID, java.lang.Long dataSetID)
          Assigns a data to a data set.
 void linkDataToEditor(java.lang.Long dataID, java.lang.Integer editorID)
          Assigns a data to an editor.
 void linkDataToFileType(java.lang.Long dataID, java.lang.Integer fileTypeID)
          Links a data item to a specified file type.
 void linkDataToGenre(java.lang.Long dataID, java.lang.Integer genreID)
          Assigns a data to a genre.
 void linkDataToSession(java.lang.Long dataID, java.lang.Integer volumeID, java.lang.Integer sessionID)
          Assigns a data to a session.
 void linkFileTypeToProgram(java.lang.Integer fileTypeID, java.lang.Long programID, java.lang.Integer isDefault)
          Links a file type to a program.
 void moveLinkDataToAuthor(java.lang.Long dataID, java.lang.Integer oldAuthorID, java.lang.Integer newAuthorID)
          Changes author assignment for a data item.
 void moveLinkDataToDataSet(java.lang.Long dataID, java.lang.Long oldDataSetID, java.lang.Long newDataSetID)
          Changes data set assignment for a data item.
 void moveLinkDataToEditor(java.lang.Long dataID, java.lang.Integer oldEditorID, java.lang.Integer newEditorID)
          Changes editor assignment for a data item.
 void moveLinkDataToGenre(java.lang.Long dataID, java.lang.Integer oldGenreID, java.lang.Integer newGenreID)
          Changes genre assignment for a data item.
 void moveLinkDataToSession(java.lang.Long dataID, java.lang.Integer oldVolumeID, java.lang.Integer oldSessionID, java.lang.Integer newVolumeID, java.lang.Integer newSessionID)
          Changes session assignment for a data item.
 void moveLinkFileTypeToProgram(java.lang.Integer fileTypeID, java.lang.Long oldProgramID, java.lang.Long newProgramID)
          Replaces a manager program for a specified file type.
 void moveLinkParentGenre(java.lang.Integer genreID, java.lang.Integer fatherGenreID)
          Changes parent genre for a genre.
 void moveLinkProgramToFileType(java.lang.Long programID, java.lang.Integer oldFileTypeID, java.lang.Integer newFileTypeID)
          Replaces a managed file type of a program with another one.
 java.lang.Integer moveLinkSessionToFatherSession(java.lang.Integer volumeID, java.lang.Integer sessionID, java.lang.Integer newVolumeID, java.lang.Integer fatherSessionID)
          Changes father session for a session, or puts it as a root session for a volume.
 void moveLinkVolumeToContainer(java.lang.Integer containerID, java.lang.Integer volumeID)
          Move a volume to another container (or to no container).
 void optimize()
          Optimizes the database.
 void removeAuthor(java.lang.Integer authorID)
          Deletes an author.
 void removeAuthorTelephones(java.lang.Integer authorID)
          Clears all author's telephones.
 void removeContainer(int containerID)
          Deletes a container.
 void removeData(java.lang.Long dataID)
          Deletes a data item.
 void removeDataSet(java.lang.Long dataSetID)
          Deletes a data set.
 void removeEditor(java.lang.Integer editorID)
          Deletes an editor.
 void removeEditorTelephones(java.lang.Integer editorID)
          Removes all editor's telephone numbers.
 void removeFileType(java.lang.Integer fileTypeID)
          Deletes a file type.
 void removeGenre(java.lang.Integer genreID)
          Deletes a genre.
 void removeProgram(java.lang.Long programID)
          Deletes a program.
 void removeSession(java.lang.Integer volumeID, java.lang.Integer sessionID)
          Deletes a session.
 void removeSessionClean(java.lang.Integer volumeID, java.lang.Integer sessionID)
          Removes a session in a clean way.
 void removeVolume(java.lang.Integer volumeID)
          Deletes a volume.
 void removeVolumeClean(java.lang.Integer volumeID)
          Removes a volume in a clean way.
 DbTable searchData(java.util.List dataName, java.util.List fileName, java.util.List authorList, java.util.List editorList, java.util.List genreList, java.util.List dataSetList, java.lang.Integer[] fileTypes)
          Searches the data with some criteria.
 void setAutomaticChecking(boolean value)
          Controls the automatic additional checking in performing database operations.
 void setConstraintEmulation(boolean value)
          Sets the constraint emulation value.
 void setDefaultProgram(java.lang.Integer fileTypeID, java.lang.Long programID)
          Sets the default program for a specified file type.
 void unlinkDataFromAuthor(java.lang.Long dataID, java.lang.Integer authorID)
          Un-assigns a data to an author.
 void unlinkDataFromDataSet(java.lang.Long dataID, java.lang.Long dataSetID)
          Un-assigns a data to a data set.
 void unlinkDataFromEditor(java.lang.Long dataID, java.lang.Integer editorID)
          Un-assigns a data to an editor.
 void unlinkDataFromGenre(java.lang.Long dataID, java.lang.Integer genreID)
          Un-assigns a data to a genre.
 void unlinkDataFromSession(java.lang.Long dataID, java.lang.Integer volumeID, java.lang.Integer sessionID)
          Un-assigns a data to a session.
 void unlinkFileTypeFromProgram(java.lang.Integer fileTypeID, java.lang.Long programID)
          Unlinks a file type from a program.
 void updateAuthor(java.lang.Integer authorID, java.lang.String authorName, java.lang.String authorMinit, java.lang.String authorSurname)
          Updates an author.
 void updateAuthor(java.lang.Integer authorID, java.lang.String authorName, java.lang.String authorMinit, java.lang.String authorSurname, java.lang.String address, java.lang.String eMail, java.lang.String homepage, java.lang.String description)
          Updates an author.
 void updateContainer(int containerID, java.lang.String type, java.lang.String position)
          Updates a container.
 void updateData(java.lang.Long dataID, java.lang.Integer fileTypeID, java.lang.String dataName, java.lang.String fileName, java.lang.String date, java.lang.Long dimension, java.lang.String description, java.lang.Integer duration, java.lang.Integer samplingBits, java.lang.Integer frequency, java.lang.Integer stereo, java.lang.Integer bitrate, java.lang.Integer dimx, java.lang.Integer dimy)
          Updates a data item.
 void updateDataFileType(java.lang.Long dataID, java.lang.Integer fileTypeID)
          Updates the file type of a data item.
 void updateDataSet(java.lang.Long dataSetID, java.lang.String dataSetName)
          Updates a data set.
 void updateDataSet(java.lang.Long dataSetID, java.lang.String dataSetName, java.lang.String description)
          Updates a data set.
 void updateEditor(java.lang.Integer editorID, java.lang.String firmName)
          Updates an editor.
 void updateEditor(java.lang.Integer editorID, java.lang.String firmName, java.lang.String address, java.lang.String eMail, java.lang.String homepage, java.lang.String description)
          Updates an editor.
 void updateFileType(java.lang.Integer fileTypeID, java.lang.String fileTypeName, java.lang.String extension, java.lang.Integer sw)
          Updates a file type.
 void updateFileType(java.lang.Integer fileTypeID, java.lang.String fileTypeName, java.lang.String extension, java.lang.Integer sw, java.lang.String description)
          Updates a file type.
 void updateGenre(java.lang.Integer genreID, java.lang.String genreName)
          Updates a genre.
 void updateGenre(java.lang.Integer genreID, java.lang.String genreName, java.lang.String description)
          Updates a genre.
 void updateProgram(java.lang.Long programID, java.lang.String programName, java.lang.String commandLine, java.lang.String finalOptions)
          Updates program data.
 void updateSession(java.lang.Integer volumeID, java.lang.Integer sessionID, java.lang.String sessionName, java.lang.String sessionType)
          Updates a session.
 void updateVolume(java.lang.Integer volumeID, java.lang.Integer containerID, java.lang.String name, java.lang.String type)
          Updates a volume, changing container assignment too.
 void updateVolume(java.lang.Integer volumeID, java.lang.String name, java.lang.String type)
          Updates a volume.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Provider

public Provider(DbDatabase db)
         throws DbException
Creates new Provider

Parameters:
db - The database to use.
Throws:
DbException - If something goes wrong.
Method Detail

getDatabase

public DbDatabase getDatabase()
Returns the database that this object is using.

Returns:
The database that is being used.

getDateFormat

public java.text.SimpleDateFormat getDateFormat()
Returns the date formatter that the database uses.

Returns:
The date formatter.

setAutomaticChecking

public void setAutomaticChecking(boolean value)
Controls the automatic additional checking in performing database operations.

Parameters:
value - true: additional checking will be made; false: it will not be made.

getAutomaticChecking

public boolean getAutomaticChecking()
Gets the automatic checking flag.

Returns:
The needed flag.

setConstraintEmulation

public void setConstraintEmulation(boolean value)
Sets the constraint emulation value.

Parameters:
value - true: the constraint is emulated (whether it is needed); false: the constraint is never emulated.

getConstraintEmulation

public boolean getConstraintEmulation()
Returns the value for the constraint emulation.

Returns:
true: the constraint is emulated (whether it is needed); false: the constraint is never emulated.

addFileTypeValidator

public void addFileTypeValidator(Validator val)
Adds a validator to control whether the table FILE_TYPE has been changed.

Parameters:
val - The validator.

addContainerValidator

public void addContainerValidator(Validator val)
Adds a new container validator.

Parameters:
val - The validator.

optimize

public void optimize()
              throws DbException
Optimizes the database.

Throws:
DbException - If something goes wrong.

getContainers

public DbTable getContainers(java.lang.Integer containerID)
                      throws DbException
Returns the containers.

Parameters:
containerID - The container ID to find. It can be null (find ALL containers).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getContainersSorted

public DbTable getContainersSorted(java.lang.Integer containerID)
                            throws DbException
Returns a list of containers in a sorted way.

Parameters:
containerID - The container ID. It can be null (all containers).
Returns:
The list of containers as a DbTable.
Throws:
DbException - It something goes wrong.

getContainersReduced

public DbTable getContainersReduced(java.lang.Integer containerID)
                             throws DbException
Returns a list of containers in a sorted way.

Parameters:
containerID - The container ID. It can be null (all containers).
Returns:
The list of containers as a DbTable.
Throws:
DbException - It something goes wrong.

getContainerAndVolumeByVolume

public DbTable getContainerAndVolumeByVolume(java.lang.Integer volumeID)
                                      throws DbException
Returns a joined-table with container and volume info.

Parameters:
volumeID - The volume ID to find (not null).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getVolumeLocation

public DbTable getVolumeLocation(java.lang.Integer volumeID)
                          throws DbException
Returns a volume's location.

Parameters:
volumeID - The volume ID to find
Returns:
The location as a DbTable.
Throws:
DbException - If something goes wrong.

getVolumes

public DbTable getVolumes(java.lang.Integer containerID,
                          java.lang.Integer volumeID)
                   throws DbException
Returns the volumes.

Parameters:
containerID - The container ID. It can be null (find ALL containers).
volumeID - The volume ID. It can be null (fine ALL volumes).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getVolumesSorted

public DbTable getVolumesSorted(java.lang.Integer containerID,
                                java.lang.Integer volumeID)
                         throws DbException
Returns a list of volumes in a sorted way.

Parameters:
containerID - The container ID. It can be null (unassigned container).
volumeID - The volume ID. It can be null (all volumes in that container).
Returns:
The list of volumes as a DbTable.
Throws:
DbException - If something goes wrong.

getVolumesReduced

public DbTable getVolumesReduced(java.lang.Integer containerID,
                                 java.lang.Integer volumeID)
                          throws DbException
Returns a list of volumes in a sorted way.

Parameters:
containerID - The container ID. It can be null (unassigned container).
volumeID - The volume ID. It can be null (all volumes in that container).
Returns:
The list of volumes as a DbTable.
Throws:
DbException - If something goes wrong.

getOneVolume

public DbTable getOneVolume(java.lang.Integer volumeID)
                     throws DbException
Returns info about ONE volume.

Parameters:
volumeID - The volume ID to find (not null).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getVolumeByName

public DbTable getVolumeByName(java.lang.String volumeName)
                        throws DbException
Returns a volume list as a DbTable by searching its name.

Parameters:
volumeName - The name of the volume.
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getSessions

public DbTable getSessions(java.lang.Integer volumeID,
                           java.lang.Integer sessionID,
                           java.lang.Integer superSession)
                    throws DbException
Returns the session list.

Parameters:
volumeID - The volume ID to use. It can be null (find ALL volumes).
sessionID - The session ID to use. It can be null (find ALL sessions).
superSession - The super-session ID to use. If it is null, it means that is a root session.
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getSessionsSorted

public DbTable getSessionsSorted(java.lang.Integer volumeID,
                                 java.lang.Integer sessionID,
                                 java.lang.Integer superSession)
                          throws DbException
Returns the list of sessions in a sorted way.

Parameters:
volumeID - The volume ID. It cannot be null.
sessionID - The session ID. It can be null (all session in that volume).
superSession - The super-session ID. It can be null (root sessions only).
Returns:
The list of sessions as a DbTable.
Throws:
DbException - If something goes wrong.

getSessionsReduced

public DbTable getSessionsReduced(java.lang.Integer volumeID,
                                  java.lang.Integer sessionID,
                                  java.lang.Integer superSession)
                           throws DbException
Returns the list of sessions in a sorted way.

Parameters:
volumeID - The volume ID. It cannot be null.
sessionID - The session ID. It can be null (all session in that volume).
superSession - The super-session ID. It can be null (root sessions only).
Returns:
The list of sessions as a DbTable.
Throws:
DbException - If something goes wrong.

getSessions

public DbTable getSessions(java.lang.Integer volumeID,
                           java.lang.Integer sessionID)
                    throws DbException
Returns a list of session, without caring of super-session ID field.

Parameters:
volumeID - The volume ID to use. It can be null (find ALL volumes).
sessionID - The session ID to use. It can be null (find ALL sessions).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getSessionByName

public DbTable getSessionByName(java.lang.Integer volumeID,
                                java.lang.Integer fatherSessionID,
                                java.lang.String sessionName)
                         throws DbException
Returns the session whose name is specified.

Parameters:
volumeID - The volume ID.
fatherSessionID - The eventual father session ID (null means that the session is a subdirectory of the root).
sessionName - The name of the session.
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getData

public DbTable getData(java.lang.Long dataID)
                throws DbException
Returns info about a specific row of Data.

Parameters:
dataID - The data ID (not null).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getDataBySession

public java.util.Iterator getDataBySession(java.lang.Integer volumeID,
                                           java.lang.Integer sessionID)
                                    throws DbException
Returns data contained in a session.

Parameters:
volumeID - The volume ID to use. It can be null (find ALL volumes).
sessionID - The session ID to use. It can be null (find ALL sessions).
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getDataBySessionSorted

public DbTable getDataBySessionSorted(java.lang.Integer volumeID,
                                      java.lang.Integer sessionID)
                               throws DbException
Returns data contained in a session in a sorted way.

Parameters:
volumeID - The volume ID. It cannot be null.
sessionID - The session ID. It cannot be null.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataBySessionReduced

public DbTable getDataBySessionReduced(java.lang.Integer volumeID,
                                       java.lang.Integer sessionID)
                                throws DbException
Returns data contained in a session in a sorted way.

Parameters:
volumeID - The volume ID. It cannot be null.
sessionID - The session ID. It cannot be null.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByGenre

public java.util.Iterator getDataByGenre(java.lang.Integer genreID)
                                  throws DbException
Returns the data under a specific genre.

Parameters:
genreID - The genre ID to use. It can be null (find ALL genres).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByGenreSorted

public DbTable getDataByGenreSorted(java.lang.Integer genreID)
                             throws DbException
Returns a list of data whose genre is the one needed (in a sorted way).

Parameters:
genreID - The genre ID to search in.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByGenreReduced

public DbTable getDataByGenreReduced(java.lang.Integer genreID)
                              throws DbException
Returns a list of data whose genre is the one needed (in a sorted way).

Parameters:
genreID - The genre ID to search in.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByAuthor

public java.util.Iterator getDataByAuthor(java.lang.Integer authorID)
                                   throws DbException
Returns data realized by an author.

Parameters:
authorID - The author ID to use. It can be null (find ALL authors).
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getDataByAuthorSorted

public DbTable getDataByAuthorSorted(java.lang.Integer authorID)
                              throws DbException
Returns data realized by a specified author (in a sorted way).

Parameters:
authorID - The author ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByAuthorReduced

public DbTable getDataByAuthorReduced(java.lang.Integer authorID)
                               throws DbException
Returns data realized by a specified author (in a sorted way).

Parameters:
authorID - The author ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByEditor

public java.util.Iterator getDataByEditor(java.lang.Integer editorID)
                                   throws DbException
Returns data published by an editor.

Parameters:
editorID - The editor ID to use. It can be null (find ALL editors).
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getDataByEditorSorted

public DbTable getDataByEditorSorted(java.lang.Integer editorID)
                              throws DbException
Returns a list of data published by a specified editor (in a sorted way).

Parameters:
editorID - The editor ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByEditorReduced

public DbTable getDataByEditorReduced(java.lang.Integer editorID)
                               throws DbException
Returns a list of data published by a specified editor (in a sorted way).

Parameters:
editorID - The editor ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByFileType

public DbTable getDataByFileType(java.lang.Integer fileTypeID)
                          throws DbException
Returns all data of a certain file type.

Parameters:
fileTypeID - The file type ID to use. It can be null (find ALL file types).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByFileTypeSorted

public DbTable getDataByFileTypeSorted(java.lang.Integer fileTypeID)
                                throws DbException
Returns a list of data whose file type is the one specified (in a sorted way).

Parameters:
fileTypeID - The file type ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByFileTypeReduced

public DbTable getDataByFileTypeReduced(java.lang.Integer fileTypeID)
                                 throws DbException
Returns a list of data whose file type is the one specified (in a sorted way).

Parameters:
fileTypeID - The file type ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByDataSet

public java.util.Iterator getDataByDataSet(java.lang.Long dataSetID)
                                    throws DbException
Returns data contained in a data set.

Parameters:
dataSetID - The data set ID. It can be null (find ALL data sets).
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getDataByDataSetSorted

public DbTable getDataByDataSetSorted(java.lang.Long dataSetID)
                               throws DbException
Returns data contained in a specified data set (in a sorted way).

Parameters:
dataSetID - The data set ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getDataByDataSetReduced

public DbTable getDataByDataSetReduced(java.lang.Long dataSetID)
                                throws DbException
Returns data contained in a specified data set (in a sorted way).

Parameters:
dataSetID - The data set ID to use.
Returns:
The list of data as a DbTable.
Throws:
DbException - If something goes wrong.

getLocationsByData

public java.util.Iterator getLocationsByData(java.lang.Long dataID)
                                      throws DbException
Returns a list of locations for the given data.

Parameters:
dataID - The data ID to use (not null).
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getSessionsByData

public DbTable getSessionsByData(java.lang.Long dataID)
                          throws DbException
Returns sessions that contain the specified data.

Parameters:
dataID - The data ID to use.
Returns:
The list of sessions as a DbTable.
Throws:
DbException - If something goes wrong.

getGenresByData

public java.util.Iterator getGenresByData(java.lang.Long[] dataIDs)
                                   throws DbException
Returns a list of genres of a specific data.

Parameters:
dataIDs - The data IDs to use.
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getAuthorsByData

public java.util.Iterator getAuthorsByData(java.lang.Long[] dataIDs)
                                    throws DbException
Returns a list of authors that realized the specific data.

Parameters:
dataIDs - The data IDs to use.
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getEditorsByData

public java.util.Iterator getEditorsByData(java.lang.Long[] dataIDs)
                                    throws DbException
Returns a list of editors that published the specified data.

Parameters:
dataIDs - The dataIDs to use.
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getDataSetByData

public java.util.Iterator getDataSetByData(java.lang.Long[] dataIDs)
                                    throws DbException
Returns a list of data sets that contain the specified data IDs.

Parameters:
dataIDs - The data IDs to use.
Returns:
The result as an Iterator.
Throws:
DbException - If something goes wrong.

getFathers

public DbTable getFathers(java.lang.Long dataID)
                   throws DbException
Returns the fathers of a specific data ID.

Parameters:
dataID - The data ID to use.
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getSons

public DbTable getSons(java.lang.Long dataID)
                throws DbException
Returns the sons of a specified data.

Parameters:
dataID - The data ID to use.
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getSonsReduced

public DbTable getSonsReduced(java.lang.Long dataID)
                       throws DbException
Returns the sons of a specified data.

Parameters:
dataID - The data ID to use.
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getGenres

public DbTable getGenres(java.lang.Integer genreID,
                         java.lang.Integer superGenreID)
                  throws DbException
Returns a list of genres.

Parameters:
genreID - The genre ID to use. It can be null (find ALL genres).
superGenreID - The super-genre ID. If it is null, it means "root genre".
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getGenresSorted

public DbTable getGenresSorted(java.lang.Integer genreID,
                               java.lang.Integer superGenreID)
                        throws DbException
Returns a list of genres in a sorted way.

Parameters:
genreID - The genre ID. It can be null (all genres).
superGenreID - The super-genre ID. It can be null (root genres).
Returns:
The list of genres as a DbTable.
Throws:
DbException - If something goes wrong.

getGenresReduced

public DbTable getGenresReduced(java.lang.Integer genreID,
                                java.lang.Integer superGenreID)
                         throws DbException
Returns a list of genres in a sorted way.

Parameters:
genreID - The genre ID. It can be null (all genres).
superGenreID - The super-genre ID. It can be null (root genres).
Returns:
The list of genres as a DbTable.
Throws:
DbException - If something goes wrong.

getGenres

public DbTable getGenres(java.lang.Integer genreID)
                  throws DbException
Returns a list of genres, regardless of te super-genre.

Parameters:
genreID - The genre ID to find. It can be null (find ALL genres).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getGenresByName

public DbTable getGenresByName(java.lang.String name)
                        throws DbException
Returns a list of genres whose name is specified.

Parameters:
name - The name of the genre.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getAuthors

public DbTable getAuthors(java.lang.Integer authorID)
                   throws DbException
Returns a list of authors.

Parameters:
authorID - The author ID to find. It can be null (find ALL authors).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getAuthorsSorted

public DbTable getAuthorsSorted(java.lang.Integer authorID)
                         throws DbException
Returns a list of authors in a sorted way.

Parameters:
authorID - The author ID. It can be null (all authors).
Returns:
The list of authors as a DbTable.
Throws:
DbException - If something goes wrong.

getAuthorsReduced

public DbTable getAuthorsReduced(java.lang.Integer authorID)
                          throws DbException
Returns a list of authors in a sorted way.

Parameters:
authorID - The author ID. It can be null (all authors).
Returns:
The list of authors as a DbTable.
Throws:
DbException - If something goes wrong.

getAuthorTelephone

public DbTable getAuthorTelephone(java.lang.Integer authorID)
                           throws DbException
Returns a list of telephone numbers of the specified author.

Parameters:
authorID - The author ID to use.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getEditors

public DbTable getEditors(java.lang.Integer editorID)
                   throws DbException
Returns a list of editors.

Parameters:
editorID - The editor ID to find. It can be null (find ALL editors).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getEditorsSorted

public DbTable getEditorsSorted(java.lang.Integer editorID)
                         throws DbException
Returns a list of editors in a sorted way.

Parameters:
editorID - The editor ID. It can be null (all editors).
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getEditorsReduced

public DbTable getEditorsReduced(java.lang.Integer editorID)
                          throws DbException
Returns a list of editors in a sorted way.

Parameters:
editorID - The editor ID. It can be null (all editors).
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getEditorTelephone

public DbTable getEditorTelephone(java.lang.Integer editorID)
                           throws DbException
Returns a list of telephone numbers of the specified editor.

Parameters:
editorID - The editor ID to use.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getFileTypes

public DbTable getFileTypes(java.lang.Integer fileTypeID)
                     throws DbException
Returns a list of file types.

Parameters:
fileTypeID - The file type ID. It can be null (find ALL file types).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getFileTypesSorted

public DbTable getFileTypesSorted(java.lang.Integer fileTypeID)
                           throws DbException
Returns a list of file types in a sorted way.

Parameters:
fileTypeID - The file type ID. It can be null (all file types).
Returns:
The list of file types as a DbTable.
Throws:
DbException - If something goes wrong.

getFileTypesReduced

public DbTable getFileTypesReduced(java.lang.Integer fileTypeID)
                            throws DbException
Returns a list of file types in a sorted way.

Parameters:
fileTypeID - The file type ID. It can be null (all file types).
Returns:
The list of file types as a DbTable.
Throws:
DbException - If something goes wrong.

getDataSets

public DbTable getDataSets(java.lang.Long dataSetID)
                    throws DbException
Returns a list of data sets.

Parameters:
dataSetID - The data set ID to find. It can be null (find ALL data sets).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getDataSetsSorted

public DbTable getDataSetsSorted(java.lang.Long dataSetID)
                          throws DbException
Returns a list of data sets in a sorted way.

Parameters:
dataSetID - The data set ID. It can be null (all data sets).
Returns:
The list of data sets as a DbTable.
Throws:
DbException - If something goes wrong.

getDataSetsReduced

public DbTable getDataSetsReduced(java.lang.Long dataSetID)
                           throws DbException
Returns a list of data sets in a sorted way.

Parameters:
dataSetID - The data set ID. It can be null (all data sets).
Returns:
The list of data sets as a DbTable.
Throws:
DbException - If something goes wrong.

getDataSetsByName

public DbTable getDataSetsByName(java.lang.String name)
                          throws DbException
Returns a list of data sets whose name is specified.

Parameters:
name - The name to find out.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getFileTypesByExtension

public DbTable getFileTypesByExtension(java.lang.String extension)
                                throws DbException
Retunrs a list of file types which accept the specified extension.

Parameters:
extension - The extension to find (not null).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getPrograms

public DbTable getPrograms(java.lang.Long programID)
                    throws DbException
Returns a list of programs.

Parameters:
programID - The program ID. It can be null (all programs).
Returns:
The list of programs as a DbTable.
Throws:
DbException - If something goes wrong.

getProgramsSorted

public DbTable getProgramsSorted(java.lang.Long programID)
                          throws DbException
Returns a list of programs in a sorted way.

Parameters:
programID - The program ID. It can be null (all programs).
Returns:
The list of programs as a DbTable.
Throws:
DbException - If something goes wrong.

getProgramsReduced

public DbTable getProgramsReduced(java.lang.Long programID)
                           throws DbException
Returns a list of programs in a sorted way.

Parameters:
programID - The program ID. It can be null (all programs).
Returns:
The list of programs as a DbTable.
Throws:
DbException - If something goes wrong.

getProgramsByFileType

public DbTable getProgramsByFileType(java.lang.Integer fileTypeID)
                              throws DbException
Returns programs that manage the specified file type.

Parameters:
fileTypeID - The file type ID to use.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getDefaultProgram

public DbTable getDefaultProgram(java.lang.Integer fileTypeID)
                          throws DbException
Returns the default programs for the specified file type.

Parameters:
fileTypeID - The file type ID to use.
Returns:
The needed default program as a DbTable.
Throws:
DbException - If something goes wrong.

getFileTypesByProgram

public DbTable getFileTypesByProgram(java.lang.Long programID)
                              throws DbException
Returns the file types that are managed by the specified program.

Parameters:
programID - The program ID to use.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getProgramsByData

public DbTable getProgramsByData(java.lang.Long dataID)
                          throws DbException
Returns the programs that can manage the specified data.

Parameters:
dataID - The data ID to use.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

getDefaultProgramByData

public DbTable getDefaultProgramByData(java.lang.Long dataID)
                                throws DbException
Returns the default program for the specified data.

Parameters:
dataID - The data ID to use.
Returns:
The needed list as a DbTable.
Throws:
DbException - If something goes wrong.

searchData

public DbTable searchData(java.util.List dataName,
                          java.util.List fileName,
                          java.util.List authorList,
                          java.util.List editorList,
                          java.util.List genreList,
                          java.util.List dataSetList,
                          java.lang.Integer[] fileTypes)
                   throws DbException
Searches the data with some criteria. All the list are lists of words to be found (with an AND clause).

Parameters:
dataName - The data name.
fileName - The file name.
authorList - The list of authors
editorList - The list of editors.
genreList - The list of genres.
dataSetList - The list of data sets.
fileTypes - The list of file types (with OR clause).
Returns:
The result as a DbTable.
Throws:
DbException - If something goes wrong.

getMaxContainerID

public int getMaxContainerID()
                      throws DbException
Returns the max container ID.

Returns:
The maximum container ID.
Throws:
DbException - If something goes wrong.

getMaxVolumeID

public int getMaxVolumeID()
                   throws DbException
Returns the max volume ID.

Returns:
The maximum volume ID.
Throws:
DbException - If something goes wrong.

getMaxSessionID

public int getMaxSessionID(java.lang.Integer volumeID)
                    throws DbException
Returns the max session ID for a given volume.

Parameters:
volumeID - The volume ID in which search will be made (not null).
Returns:
The maximum session ID.
Throws:
DbException - If something goes wrong.

getMaxGenreID

public int getMaxGenreID()
                  throws DbException
Returns the max genre ID.

Returns:
The maximum genre ID.
Throws:
DbException - If something goes wrong.

getMaxAuthorID

public int getMaxAuthorID()
                   throws DbException
Returns the max author ID.

Returns:
The maximum author ID.
Throws:
DbException - If something goes wrong.

getMaxEditorID

public int getMaxEditorID()
                   throws DbException
Returns the max editor ID.

Returns:
The maximum editor ID.
Throws:
DbException - If something goes wrong.

getMaxFileTypeID

public int getMaxFileTypeID()
                     throws DbException
Returns the max file type ID.

Returns:
The maximum file type ID.
Throws:
DbException - If something goes wrong.

getMaxDataSetID

public long getMaxDataSetID()
                     throws DbException
Returns the max data set ID.

Returns:
The max data set ID.
Throws:
DbException - If something goes wrong.

getMaxDataID

public long getMaxDataID()
                  throws DbException
Returns the max data ID.

Returns:
The maximum data ID.
Throws:
DbException - If something goes wrong.

getMaxProgramID

public long getMaxProgramID()
                     throws DbException
Returns the maximum program ID.

Returns:
The maximum program ID.
Throws:
DbException - If something goes wrong.

createEmptyContainer

public int createEmptyContainer()
                         throws DbException
Creates a new empty container.

Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewContainer

public int createNewContainer(java.lang.String containerType,
                              java.lang.String containerLocation)
                       throws DbException
Creates a new container.

Parameters:
containerType - The container type to use.
containerLocation - The container location.
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createEmptyVolume

public int createEmptyVolume(java.lang.Integer containerID)
                      throws DbException
Creates a new empty volume.

Parameters:
containerID - The container ID for this volume. It can be null (container not assigned).
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewVolume

public int createNewVolume(java.lang.Integer containerID,
                           java.lang.String volumeName,
                           java.lang.String volumeType)
                    throws DbException
Creates a new volume.

Parameters:
containerID - The container ID to put the volume into. It can be null (container not assigned).
volumeName - The volume name.
volumeType - The volume type.
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createEmptySession

public int createEmptySession(java.lang.Integer volumeID,
                              java.lang.Integer fatherSessionID)
                       throws DbException
Creates a new empty session.

Parameters:
volumeID - The volume ID of the session (not null).
fatherSessionID - The father session ID. It can be null (root session).
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewSession

public int createNewSession(java.lang.Integer volumeID,
                            java.lang.Integer fatherSessionID,
                            java.lang.String sessionName,
                            java.lang.String sessionType)
                     throws DbException
Creates a new session.

Parameters:
volumeID - The volume ID of the session.
fatherSessionID - The father session ID. It can be null (root session).
sessionName - The session name.
sessionType - The session type.
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createEmptyGenre

public int createEmptyGenre(java.lang.Integer fatherGenreID)
                     throws DbException
Creates a new empty genre.

Parameters:
fatherGenreID - The father genre ID. It can be null (root genre).
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewGenre

public int createNewGenre(java.lang.Integer fatherGenreID,
                          java.lang.String name,
                          java.lang.String description)
                   throws DbException
Creates a new Genre.

Parameters:
fatherGenreID - The father-genre ID. It can be null (root genre).
name - The genre name.
description - The genre description.
Returns:
The newly created genre ID.
Throws:
DbException - If something goes wrong.

createEmptyAuthor

public int createEmptyAuthor()
                      throws DbException
Creates a new empty author.

Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewAuthor

public int createNewAuthor(java.lang.String name,
                           java.lang.String minit,
                           java.lang.String surname,
                           java.lang.String address,
                           java.lang.String eMail,
                           java.lang.String homepage,
                           java.lang.String description)
                    throws DbException
Creates a new author.

Parameters:
name - The name.
minit - The middle name initial.
surname - The surname.
address - The physical address.
eMail - The E-Mail.
homepage - The homepage on the web.
description - The description.
Returns:
The newly created author ID.
Throws:
DbException - If something goes wrong.

createAuthorTelephone

public void createAuthorTelephone(java.lang.Integer authorID,
                                  java.lang.String telephone)
                           throws DbException
Creates a new author telephone number.

Parameters:
authorID - The author ID to use.
telephone - The telephone number to store.
Throws:
DbException - If something goes wrong.

createEmptyEditor

public int createEmptyEditor()
                      throws DbException
Creates a new empty editor.

Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createEditorTelephone

public void createEditorTelephone(java.lang.Integer editorID,
                                  java.lang.String telephone)
                           throws DbException
Creates a new editor telephone number.

Parameters:
editorID - The editor ID to use.
telephone - The telephone number to store.
Throws:
DbException - If something goes wrong.

createEmptyFileType

public int createEmptyFileType()
                        throws DbException
Creates a new empty file type.

Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewFileType

public int createNewFileType(java.lang.String fileTypeName,
                             java.lang.String extension,
                             java.lang.Integer sw,
                             java.lang.String description)
                      throws DbException
Creates a new file type.

Parameters:
fileTypeName - The file type name.
extension - The extension.
sw - The switch of the file type (see tables documentation).
description - The description.
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createEmptyDataSet

public long createEmptyDataSet()
                        throws DbException
Creates a new empty data.

Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewDataSet

public long createNewDataSet(java.lang.String name,
                             java.lang.String description)
                      throws DbException
Creates a new data set.

Parameters:
name - The name.
description - The description.
Returns:
The newly created data set ID.
Throws:
DbException - If something goes wrong.

createNewData

public long createNewData(java.lang.Integer fileTypeID,
                          java.lang.String dataName,
                          java.lang.String fileName,
                          java.lang.String date,
                          java.lang.Long dimension)
                   throws DbException
Creates a new data.

Parameters:
fileTypeID - The file type ID. It can be null (not assigned).
dataName - The name.
fileName - The file name.
date - The date (as a string). It should be formatted according to the date formatter given from getDateFormat() method.
dimension - The dimension.
Returns:
The ID of the newly created row.
Throws:
DbException - If something goes wrong.

createNewData

public long createNewData(java.lang.Integer fileTypeID,
                          java.lang.String dataName,
                          java.lang.String fileName,
                          java.lang.String date,
                          java.lang.Long dimension,
                          java.lang.String description,
                          java.lang.Integer duration,
                          java.lang.Integer samplingBits,
                          java.lang.Integer frequency,
                          java.lang.Integer stereo,
                          java.lang.Integer bitrate,
                          java.lang.Integer dimx,
                          java.lang.Integer dimy)
                   throws DbException
Creates a new data item.

Parameters:
fileTypeID - The file type ID.
dataName - The name.
fileName - The file name.
date - The date.
dimension - The size in bytes.
description - The description.
duration - The duration of the data item in seconds.
samplingBits - The number of sampling bits.
frequency - The frequency in Hertz.
stereo - 0: mono; 1: stereo.
bitrate - The bitrate in kByte/second.
dimx - The horizontal dimension.
dimy - The vertical dimension.
Returns:
The newly created data ID.
Throws:
DbException - If something goes wrong.

createEmptyProgram

public long createEmptyProgram()
                        throws DbException
Creates an empty program.

Returns:
The newly created program ID.
Throws:
DbException - If something goes wrong.

linkDataToSession

public void linkDataToSession(java.lang.Long dataID,
                              java.lang.Integer volumeID,
                              java.lang.Integer sessionID)
                       throws DbException
Assigns a data to a session.

Parameters:
dataID - The data ID (not null).
volumeID - The volume ID (not null).
sessionID - The session ID (not null).
Throws:
DbException - If something goes wrong.

linkDataToGenre

public void linkDataToGenre(java.lang.Long dataID,
                            java.lang.Integer genreID)
                     throws DbException
Assigns a data to a genre.

Parameters:
dataID - The data ID (not null).
genreID - The genre ID (not null).
Throws:
DbException - If something goes wrong.

linkDataToAuthor

public void linkDataToAuthor(java.lang.Long dataID,
                             java.lang.Integer authorID)
                      throws DbException
Assigns a data to an author.

Parameters:
dataID - The data ID.
authorID - The author ID.
Throws:
DbException - If something goes wrong.

linkDataToEditor

public void linkDataToEditor(java.lang.Long dataID,
                             java.lang.Integer editorID)
                      throws DbException
Assigns a data to an editor.

Parameters:
dataID - The data ID (not null).
editorID - The editor ID (not null).
Throws:
DbException - If something goes wrong.

linkDataToDataSet

public void linkDataToDataSet(java.lang.Long dataID,
                              java.lang.Long dataSetID)
                       throws DbException
Assigns a data to a data set.

Parameters:
dataID - The data ID (not null).
dataSetID - The data set ID (not null).
Throws:
DbException - If something goes wrong.

linkDataToFileType

public void linkDataToFileType(java.lang.Long dataID,
                               java.lang.Integer fileTypeID)
                        throws DbException
Links a data item to a specified file type.

Parameters:
dataID - The data ID to use.
fileTypeID - The file type ID to be put.
Throws:
DbException - If something goes wrong.

linkFileTypeToProgram

public void linkFileTypeToProgram(java.lang.Integer fileTypeID,
                                  java.lang.Long programID,
                                  java.lang.Integer isDefault)
                           throws DbException
Links a file type to a program.

Parameters:
fileTypeID - The file type ID to use.
programID - The program ID to use.
isDefault - 1: it's its default program; 0: it is not.
Throws:
DbException - If something goes wrong.

removeContainer

public void removeContainer(int containerID)
                     throws DbException
Deletes a container.

Parameters:
containerID - The container ID (not null).
Throws:
DbException - If something goes wrong.

removeVolume

public void removeVolume(java.lang.Integer volumeID)
                  throws DbException
Deletes a volume.

Parameters:
volumeID - The volume ID (not null).
Throws:
DbException - If something goes wrong.

removeVolumeClean

public void removeVolumeClean(java.lang.Integer volumeID)
                       throws DbException
Removes a volume in a clean way.

Parameters:
volumeID - The volume to remove.
Throws:
DbException - If something goes wrong.

removeSession

public void removeSession(java.lang.Integer volumeID,
                          java.lang.Integer sessionID)
                   throws DbException
Deletes a session.

Parameters:
volumeID - The volume ID (not null).
sessionID - The session ID (not null).
Throws:
DbException - If something goes wrong.

removeSessionClean

public void removeSessionClean(java.lang.Integer volumeID,
                               java.lang.Integer sessionID)
                        throws DbException
Removes a session in a clean way.

Parameters:
volumeID - The volume ID of the session.
sessionID - The session to remove.
Throws:
DbException - If something goes wrong.

removeGenre

public void removeGenre(java.lang.Integer genreID)
                 throws DbException
Deletes a genre.

Parameters:
genreID - The genre ID (not null).
Throws:
DbException - If something goes wrong.

removeAuthor

public void removeAuthor(java.lang.Integer authorID)
                  throws DbException
Deletes an author.

Parameters:
authorID - The author ID (not null).
Throws:
DbException - If something goes wrong.

removeAuthorTelephones

public void removeAuthorTelephones(java.lang.Integer authorID)
                            throws DbException
Clears all author's telephones.

Parameters:
authorID - The author ID to use.
Throws:
DbException - If something goes wrong.

removeEditor

public void removeEditor(java.lang.Integer editorID)
                  throws DbException
Deletes an editor.

Parameters:
editorID - The editor ID (not null).
Throws:
DbException - If something goes wrong.

removeEditorTelephones

public void removeEditorTelephones(java.lang.Integer editorID)
                            throws DbException
Removes all editor's telephone numbers.

Parameters:
editorID - The editor ID to use.
Throws:
DbException - If something goes wrong.

removeFileType

public void removeFileType(java.lang.Integer fileTypeID)
                    throws DbException
Deletes a file type.

Parameters:
fileTypeID - The file type ID (not null).
Throws:
DbException - If something goes wrong.

removeDataSet

public void removeDataSet(java.lang.Long dataSetID)
                   throws DbException
Deletes a data set.

Parameters:
dataSetID - The data set ID (not null).
Throws:
DbException - If something goes wrong.

removeProgram

public void removeProgram(java.lang.Long programID)
                   throws DbException
Deletes a program.

Parameters:
programID - The program ID to delete.
Throws:
DbException - If something goes wrong.

removeData

public void removeData(java.lang.Long dataID)
                throws DbException
Deletes a data item.

Parameters:
dataID - The data ID to delete.
Throws:
DbException - If something goes wrong.

unlinkDataFromSession

public void unlinkDataFromSession(java.lang.Long dataID,
                                  java.lang.Integer volumeID,
                                  java.lang.Integer sessionID)
                           throws DbException
Un-assigns a data to a session.

Parameters:
dataID - The data ID (not null).
volumeID - The volume ID (not null).
sessionID - The session ID (not null).
Throws:
DbException - If something goes wrong.

unlinkDataFromGenre

public void unlinkDataFromGenre(java.lang.Long dataID,
                                java.lang.Integer genreID)
                         throws DbException
Un-assigns a data to a genre.

Parameters:
dataID - The data ID (not null).
genreID - The genre ID (not null).
Throws:
DbException - If something goes wrong.

unlinkDataFromAuthor

public void unlinkDataFromAuthor(java.lang.Long dataID,
                                 java.lang.Integer authorID)
                          throws DbException
Un-assigns a data to an author.

Parameters:
dataID - The data ID (not null).
authorID - The author ID (not null).
Throws:
DbException - If something goes wrong.

unlinkDataFromEditor

public void unlinkDataFromEditor(java.lang.Long dataID,
                                 java.lang.Integer editorID)
                          throws DbException
Un-assigns a data to an editor.

Parameters:
dataID - The data ID (not null).
editorID - The editor ID (not null).
Throws:
DbException - If something goes wrong.

unlinkDataFromDataSet

public void unlinkDataFromDataSet(java.lang.Long dataID,
                                  java.lang.Long dataSetID)
                           throws DbException
Un-assigns a data to a data set.

Parameters:
dataID - The data ID (not null).
dataSetID - The data set ID (not null).
Throws:
DbException - If something goes wrong.

unlinkFileTypeFromProgram

public void unlinkFileTypeFromProgram(java.lang.Integer fileTypeID,
                                      java.lang.Long programID)
                               throws DbException
Unlinks a file type from a program.

Parameters:
fileTypeID - The file type ID to use.
programID - The program ID to use.
Throws:
DbException - If something goes wrong.

updateContainer

public void updateContainer(int containerID,
                            java.lang.String type,
                            java.lang.String position)
                     throws DbException
Updates a container.

Parameters:
containerID - The contained ID (not null).
type - The type.
position - The position.
Throws:
DbException - If something goes wrong.

updateVolume

public void updateVolume(java.lang.Integer volumeID,
                         java.lang.String name,
                         java.lang.String type)
                  throws DbException
Updates a volume.

Parameters:
volumeID - The volume ID (not null).
name - The name.
type - The type.
Throws:
DbException - If something goes wrong.

updateVolume

public void updateVolume(java.lang.Integer volumeID,
                         java.lang.Integer containerID,
                         java.lang.String name,
                         java.lang.String type)
                  throws DbException
Updates a volume, changing container assignment too.

Parameters:
volumeID - The volume ID (not null).
containerID - The container ID. It can be null (container not assigned).
name - The name.
type - The type.
Throws:
DbException - If something goes wrong.

updateSession

public void updateSession(java.lang.Integer volumeID,
                          java.lang.Integer sessionID,
                          java.lang.String sessionName,
                          java.lang.String sessionType)
                   throws DbException
Updates a session.

Parameters:
volumeID - The volume ID (not null).
sessionID - The session ID (not null).
sessionName - The name.
sessionType - The type.
Throws:
DbException - If something goes wrong.

updateGenre

public void updateGenre(java.lang.Integer genreID,
                        java.lang.String genreName)
                 throws DbException
Updates a genre.

Parameters:
genreID - The genre ID (not null).
genreName - The name.
Throws:
DbException - If something goes wrong.

updateGenre

public void updateGenre(java.lang.Integer genreID,
                        java.lang.String genreName,
                        java.lang.String description)
                 throws DbException
Updates a genre.

Parameters:
genreID - The genre ID (not null).
genreName - The name.
description - The description.
Throws:
DbException - If something goes wrong.

updateAuthor

public void updateAuthor(java.lang.Integer authorID,
                         java.lang.String authorName,
                         java.lang.String authorMinit,
                         java.lang.String authorSurname)
                  throws DbException
Updates an author.

Parameters:
authorID - The author ID (not null).
authorName - The name.
authorMinit - The mid initial.
authorSurname - The surname.
Throws:
DbException - If something goes wrong.

updateAuthor

public void updateAuthor(java.lang.Integer authorID,
                         java.lang.String authorName,
                         java.lang.String authorMinit,
                         java.lang.String authorSurname,
                         java.lang.String address,
                         java.lang.String eMail,
                         java.lang.String homepage,
                         java.lang.String description)
                  throws DbException
Updates an author.

Parameters:
authorID - The author ID (not null).
authorName - The name.
authorMinit - The mid initial.
authorSurname - The surname.
address - The address.
eMail - The eMail.
homepage - The homepage.
description - The description.
Throws:
DbException - If something goes wrong.

updateEditor

public void updateEditor(java.lang.Integer editorID,
                         java.lang.String firmName)
                  throws DbException
Updates an editor.

Parameters:
editorID - The editor ID.
firmName - The name.
Throws:
DbException - If something goes wrong.

updateEditor

public void updateEditor(java.lang.Integer editorID,
                         java.lang.String firmName,
                         java.lang.String address,
                         java.lang.String eMail,
                         java.lang.String homepage,
                         java.lang.String description)
                  throws DbException
Updates an editor.

Parameters:
editorID - The editor ID.
firmName - The name.
address - The address.
eMail - The eMail.
homepage - The homepage.
description - The description.
Throws:
DbException - If something goes wrong.

updateFileType

public void updateFileType(java.lang.Integer fileTypeID,
                           java.lang.String fileTypeName,
                           java.lang.String extension,
                           java.lang.Integer sw)
                    throws DbException
Updates a file type.

Parameters:
fileTypeID - The file type ID (not null).
fileTypeName - The name.
extension - The extension.
sw - The switch (see table documentation).
Throws:
DbException - If something goes wrong.

updateFileType

public void updateFileType(java.lang.Integer fileTypeID,
                           java.lang.String fileTypeName,
                           java.lang.String extension,
                           java.lang.Integer sw,
                           java.lang.String description)
                    throws DbException
Updates a file type.

Parameters:
fileTypeID - The file type ID (not null).
fileTypeName - The name.
extension - The extension.
sw - The switch (see table documentation).
description - The description.
Throws:
DbException - If something goes wrong.

updateDataSet

public void updateDataSet(java.lang.Long dataSetID,
                          java.lang.String dataSetName)
                   throws DbException
Updates a data set.

Parameters:
dataSetID - The data set ID (not null).
dataSetName - The name.
Throws:
DbException - If something goes wrong.

updateDataSet

public void updateDataSet(java.lang.Long dataSetID,
                          java.lang.String dataSetName,
                          java.lang.String description)
                   throws DbException
Updates a data set.

Parameters:
dataSetID - The data set ID (not null).
dataSetName - The name.
description - The description.
Throws:
DbException - If something goes wrong.

updateData

public void updateData(java.lang.Long dataID,
                       java.lang.Integer fileTypeID,
                       java.lang.String dataName,
                       java.lang.String fileName,
                       java.lang.String date,
                       java.lang.Long dimension,
                       java.lang.String description,
                       java.lang.Integer duration,
                       java.lang.Integer samplingBits,
                       java.lang.Integer frequency,
                       java.lang.Integer stereo,
                       java.lang.Integer bitrate,
                       java.lang.Integer dimx,
                       java.lang.Integer dimy)
                throws DbException
Updates a data item.

Parameters:
dataID - The data ID (not null).
fileTypeID - The file type ID. It can be null (file type not assigned).
dataName - The name.
fileName - The file name.
date - The date (as a string). It should be formatted according to the date formatter given from getDateFormat() method.
dimension - The dimension.
description - The description
duration - The duration.
samplingBits - The sampling bits.
frequency - The frequency.
stereo - The stereo switch (true=stereo, false=mono).
bitrate - The bitrate.
dimx - The x dimension.
dimy - The y dimension.
Throws:
DbException - If something goes wrong.

updateDataFileType

public void updateDataFileType(java.lang.Long dataID,
                               java.lang.Integer fileTypeID)
                        throws DbException
Updates the file type of a data item.

Parameters:
dataID - The data ID.
fileTypeID - The new file type ID.
Throws:
DbException - If something goes wrong.

updateProgram

public void updateProgram(java.lang.Long programID,
                          java.lang.String programName,
                          java.lang.String commandLine,
                          java.lang.String finalOptions)
                   throws DbException
Updates program data.

Parameters:
programID - The program ID to use.
programName - The name.
commandLine - The command line.
finalOptions - The final options.
Throws:
DbException - If something goes wrong.

moveLinkVolumeToContainer

public void moveLinkVolumeToContainer(java.lang.Integer containerID,
                                      java.lang.Integer volumeID)
                               throws DbException
Move a volume to another container (or to no container).

Parameters:
containerID - The new container ID (null means unassigned).
volumeID - The volume ID to move.
Throws:
DbException - If something goes wrong.

moveLinkSessionToFatherSession

public java.lang.Integer moveLinkSessionToFatherSession(java.lang.Integer volumeID,
                                                        java.lang.Integer sessionID,
                                                        java.lang.Integer newVolumeID,
                                                        java.lang.Integer fatherSessionID)
                                                 throws DbException
Changes father session for a session, or puts it as a root session for a volume.

Parameters:
volumeID - The old volume ID
sessionID - The session ID to move.
newVolumeID - The new volume ID.
fatherSessionID - The new father session ID.
Returns:
The new session ID.
Throws:
DbException - If something goes wrong.

moveLinkParentGenre

public void moveLinkParentGenre(java.lang.Integer genreID,
                                java.lang.Integer fatherGenreID)
                         throws DbException
Changes parent genre for a genre.

Parameters:
genreID - The genre ID to move.
fatherGenreID - The new father genre ID.
Throws:
DbException - If something goes wrong.

moveLinkDataToSession

public void moveLinkDataToSession(java.lang.Long dataID,
                                  java.lang.Integer oldVolumeID,
                                  java.lang.Integer oldSessionID,
                                  java.lang.Integer newVolumeID,
                                  java.lang.Integer newSessionID)
                           throws DbException
Changes session assignment for a data item.

Parameters:
dataID - The data ID to move.
oldVolumeID - The old volume ID.
oldSessionID - The old session ID.
newVolumeID - The new volume ID.
newSessionID - The new session ID.
Throws:
DbException - If something goes wrong.

moveLinkDataToGenre

public void moveLinkDataToGenre(java.lang.Long dataID,
                                java.lang.Integer oldGenreID,
                                java.lang.Integer newGenreID)
                         throws DbException
Changes genre assignment for a data item.

Parameters:
dataID - The data ID to move.
oldGenreID - The old genre ID.
newGenreID - The new genre ID.
Throws:
DbException - If something goes wrong.

moveLinkDataToAuthor

public void moveLinkDataToAuthor(java.lang.Long dataID,
                                 java.lang.Integer oldAuthorID,
                                 java.lang.Integer newAuthorID)
                          throws DbException
Changes author assignment for a data item.

Parameters:
dataID - The data ID to move.
oldAuthorID - The old author ID.
newAuthorID - The new author ID.
Throws:
DbException - If something goes wrong.

moveLinkDataToEditor

public void moveLinkDataToEditor(java.lang.Long dataID,
                                 java.lang.Integer oldEditorID,
                                 java.lang.Integer newEditorID)
                          throws DbException
Changes editor assignment for a data item.

Parameters:
dataID - The data ID to move.
oldEditorID - The old editor ID.
newEditorID - The new editor ID.
Throws:
DbException - If something goes wrong.

moveLinkDataToDataSet

public void moveLinkDataToDataSet(java.lang.Long dataID,
                                  java.lang.Long oldDataSetID,
                                  java.lang.Long newDataSetID)
                           throws DbException
Changes data set assignment for a data item.

Parameters:
dataID - The data ID to move.
oldDataSetID - The old data set ID.
newDataSetID - The new data set ID.
Throws:
DbException - If something goes wrong.

moveLinkFileTypeToProgram

public void moveLinkFileTypeToProgram(java.lang.Integer fileTypeID,
                                      java.lang.Long oldProgramID,
                                      java.lang.Long newProgramID)
                               throws DbException
Replaces a manager program for a specified file type.

Parameters:
fileTypeID - The file type ID to use.
oldProgramID - The program ID to be replaced.
newProgramID - The program ID to be put.
Throws:
DbException - If something goes wrong.

moveLinkProgramToFileType

public void moveLinkProgramToFileType(java.lang.Long programID,
                                      java.lang.Integer oldFileTypeID,
                                      java.lang.Integer newFileTypeID)
                               throws DbException
Replaces a managed file type of a program with another one.

Parameters:
programID - The program ID to use.
oldFileTypeID - The file type ID to be replaced.
newFileTypeID - The file type ID to be put.
Throws:
DbException - If something goes wrong.

setDefaultProgram

public void setDefaultProgram(java.lang.Integer fileTypeID,
                              java.lang.Long programID)
                       throws DbException
Sets the default program for a specified file type.

Parameters:
fileTypeID - The file type ID to use.
programID - The program ID that will be the default.
Throws:
DbException - If something goes wrong.

buildPath

public java.lang.String buildPath(java.lang.String finalPath,
                                  java.lang.Integer volumeID,
                                  java.lang.Integer fatherSessionID)
                           throws DbException
Creates a complete path for a given session.

Parameters:
finalPath - A string representing a suffix to add at the end.
volumeID - The volume ID.
fatherSessionID - The session ID to start from.
Returns:
The path of the given session.
Throws:
DbException - If something goes wrong.

buildGenrePath

public java.lang.String buildGenrePath(java.lang.Integer genreID)
                                throws DbException
Builds a genre path for a given genre.

Parameters:
genreID - The genre ID to start from.
Returns:
The path for the genre.
Throws:
DbException - If something goes wrong.

findSessionID

public java.lang.Integer findSessionID(java.lang.Integer volumeID,
                                       java.lang.String path)
                                throws DbException
Finds a session ID by searching its path.

Parameters:
volumeID - The volume ID to use.
path - The path of the session.
Returns:
The session ID.
Throws:
DbException - If something goes wrong.

isSessionDescendent

public boolean isSessionDescendent(java.lang.Integer volumeID,
                                   java.lang.Integer sessionID1,
                                   java.lang.Integer sessionID2)
                            throws DbException
Checks if a session is a descendent of an another session.

Parameters:
volumeID - The volume ID.
sessionID1 - The session to check if it is a descendent of sessionID2.
sessionID2 - The session to check if it is an ascendent of sessionID1.
Returns:
true: sessionID1 is a descendent of sessionID2; false: otherwise.
Throws:
DbException - If something goes wrong.

isGenreDescendent

public boolean isGenreDescendent(java.lang.Integer genreID1,
                                 java.lang.Integer genreID2)
                          throws DbException
Checks if a genre is a descendent of another genre.

Parameters:
genreID1 - The genre ID to check if it is a descendent of genreID2.
genreID2 - The genre ID to check if it is an ascendent of genreID1.
Returns:
true: genreID1 is a descendent of genreID2; false: otherwise.
Throws:
DbException - If something goes wrong.