Class FileContentSqlDao

  • public class FileContentSqlDao
    extends AbstractSqlDao
    The file content data access object (DAO) writes and queries the SQL database for information on FileContents. It translates the relational data in the filecontent table to Java objects.
    • Constructor Detail

    • Method Detail

      • writeFileContents

        public void writeFileContents​(java.sql.Connection connection,
                                      long databaseVersionId,
                                      java.util.Collection<FileContent> fileContents)
                               throws java.sql.SQLException
        Writes a list of FileContents to the database using INSERTs and the given connection. It fills two tables, the filecontent table (FileContent) and the filecontent_chunk table (ChunkEntry.ChunkChecksum).

        To do the latter (write chunk references), this method calls writeFileContentChunkRefs() for every FileContent.

        Note: This method executes, but does not commit the queries.

        connection - The connection used to execute the statements
        databaseVersionId -
        fileContents - List of FileContents to be inserted in the database
        java.sql.SQLException - If the SQL statement fails
      • removeUnreferencedFileContents

        public void removeUnreferencedFileContents()
                                            throws java.sql.SQLException
        Removes unreferenced FileContents from the database table filecontent, as well as the corresponding chunk references (list of ChunkEntry.ChunkChecksums) from the table filecontent_chunk.

        Note: This method executes, but does not commit the query.

        java.sql.SQLException - If the SQL statement fails
      • getFileContents

        public java.util.Map<FileContent.FileChecksum,​FileContentgetFileContents​(VectorClock vectorClock)
        Queries the SQL database for all FileContents that originally appeared in the database version identified by the given vector clock.

        Note: This method does not select all the file contents that are referenced in the database version. In particular, it does not return file contents that appeared in previous other database versions.

        vectorClock - Vector clock that identifies the database version
        Returns all FileContents that originally belong to a database version