Package org.syncany.database.dao
Class FileVersionSqlDao
- java.lang.Object
-
- org.syncany.database.dao.AbstractSqlDao
-
- org.syncany.database.dao.FileVersionSqlDao
-
public class FileVersionSqlDao extends AbstractSqlDao
The file version DAO queries and modifies the fileversion in the SQL database. This table corresponds to the Java objectFileVersion
.
-
-
Field Summary
-
Fields inherited from class org.syncany.database.dao.AbstractSqlDao
connection
-
-
Constructor Summary
Constructors Constructor Description FileVersionSqlDao(java.sql.Connection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileVersion
createFileVersionFromRow(java.sql.ResultSet resultSet)
java.util.Map<java.lang.String,FileVersion>
getCurrentFileTree()
Queries the database for the currently activeFileVersion
s and returns it as a map.java.util.Map<PartialFileHistory.FileHistoryId,FileVersion>
getDeletedFileVersionsBefore(long timestamp)
java.util.Map<PartialFileHistory.FileHistoryId,java.util.List<FileVersion>>
getFileHistoriesToPurgeBefore(long timestamp)
java.util.Map<PartialFileHistory.FileHistoryId,java.util.List<FileVersion>>
getFileHistoriesToPurgeInInterval(long beginTimestamp, long endTimestamp, CleanupOperationOptions.TimeUnit timeUnit)
java.util.List<FileVersion>
getFileHistory(PartialFileHistory.FileHistoryId fileHistoryId)
java.util.List<FileVersion>
getFileList(java.lang.String pathExpression, java.util.Date date, boolean fileHistoryId, boolean recursive, boolean deleted, java.util.Set<FileVersion.FileType> fileTypes)
FileVersion
getFileVersion(PartialFileHistory.FileHistoryId fileHistoryId, long version)
void
removeDirtyFileVersions()
RemovesFileVersion
s from the database table fileversion for which the the corresponding database is markedDIRTY
.void
removeFileVersions(java.util.Map<PartialFileHistory.FileHistoryId,FileVersion> purgeFileVersions)
Removes all file versions with versions lower or equal than the given file version.void
removeSpecificFileVersions(java.util.Map<PartialFileHistory.FileHistoryId,java.util.List<FileVersion>> purgeFileVersions)
void
writeFileVersions(java.sql.Connection connection, PartialFileHistory.FileHistoryId fileHistoryId, long databaseVersionId, java.util.Collection<FileVersion> fileVersions)
Writes a list ofFileVersion
to the database table fileversion usingINSERT
s and the given connection.-
Methods inherited from class org.syncany.database.dao.AbstractSqlDao
getConnection, getStatement, getStatement, runScript
-
-
-
-
Constructor Detail
-
FileVersionSqlDao
public FileVersionSqlDao(java.sql.Connection connection)
-
-
Method Detail
-
writeFileVersions
public void writeFileVersions(java.sql.Connection connection, PartialFileHistory.FileHistoryId fileHistoryId, long databaseVersionId, java.util.Collection<FileVersion> fileVersions) throws java.sql.SQLException
Writes a list ofFileVersion
to the database table fileversion usingINSERT
s and the given connection.Note: This method executes, but does not commit the queries.
- Parameters:
connection
- The connection used to execute the statementsfileHistoryId
- References thePartialFileHistory
to which the list of file versions belongsdatabaseVersionId
- References thePartialFileHistory
to which the list of file versions belongsfileVersions
- List ofFileVersion
s to be written to the database- Throws:
java.sql.SQLException
- If the SQL statement fails
-
removeDirtyFileVersions
public void removeDirtyFileVersions() throws java.sql.SQLException
RemovesFileVersion
s from the database table fileversion for which the the corresponding database is markedDIRTY
.Note: This method executes, but does not commit the query.
- Throws:
java.sql.SQLException
- If the SQL statement fails
-
removeFileVersions
public void removeFileVersions(java.util.Map<PartialFileHistory.FileHistoryId,FileVersion> purgeFileVersions) throws java.sql.SQLException
Removes all file versions with versions lower or equal than the given file version.Note that this method does not just delete the given file version, but also all of its previous versions.
- Throws:
java.sql.SQLException
-
removeSpecificFileVersions
public void removeSpecificFileVersions(java.util.Map<PartialFileHistory.FileHistoryId,java.util.List<FileVersion>> purgeFileVersions) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getCurrentFileTree
public java.util.Map<java.lang.String,FileVersion> getCurrentFileTree()
Queries the database for the currently activeFileVersion
s and returns it as a map. If the current file tree (on the disk) has not changed, the result will match the files on the disk.Keys in the returned map correspond to the file version's relative file path, and values to the actual
FileVersion
object.- Returns:
- Returns the current file tree as a map of relative paths to
FileVersion
objects
-
getFileHistory
public java.util.List<FileVersion> getFileHistory(PartialFileHistory.FileHistoryId fileHistoryId)
-
getFileList
public java.util.List<FileVersion> getFileList(java.lang.String pathExpression, java.util.Date date, boolean fileHistoryId, boolean recursive, boolean deleted, java.util.Set<FileVersion.FileType> fileTypes)
-
getFileHistoriesToPurgeInInterval
public java.util.Map<PartialFileHistory.FileHistoryId,java.util.List<FileVersion>> getFileHistoriesToPurgeInInterval(long beginTimestamp, long endTimestamp, CleanupOperationOptions.TimeUnit timeUnit)
-
getFileHistoriesToPurgeBefore
public java.util.Map<PartialFileHistory.FileHistoryId,java.util.List<FileVersion>> getFileHistoriesToPurgeBefore(long timestamp)
-
getDeletedFileVersionsBefore
public java.util.Map<PartialFileHistory.FileHistoryId,FileVersion> getDeletedFileVersionsBefore(long timestamp)
-
getFileVersion
public FileVersion getFileVersion(PartialFileHistory.FileHistoryId fileHistoryId, long version)
-
createFileVersionFromRow
public FileVersion createFileVersionFromRow(java.sql.ResultSet resultSet) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-