Package org.syncany.database.dao
Class FileHistorySqlDao
- java.lang.Object
-
- org.syncany.database.dao.AbstractSqlDao
-
- org.syncany.database.dao.FileHistorySqlDao
-
public class FileHistorySqlDao extends AbstractSqlDao
The file history DAO queries and modifies the filehistory in the SQL database. This table corresponds to the Java objectPartialFileHistory.
-
-
Field Summary
-
Fields inherited from class org.syncany.database.dao.AbstractSqlDao
connection
-
-
Constructor Summary
Constructors Constructor Description FileHistorySqlDao(java.sql.Connection connection, FileVersionSqlDao fileVersionDao)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory>createFileHistoriesFromResult(java.sql.ResultSet resultSet)PartialFileHistory.FileHistoryIdexpandFileHistoryId(PartialFileHistory.FileHistoryId fileHistoryIdPrefix)java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory>getFileHistories(java.util.List<PartialFileHistory.FileHistoryId> fileHistoryIds)java.util.Collection<PartialFileHistory>getFileHistoriesByChecksumSizeAndModifiedDate(java.lang.String filecontentChecksum, long size, java.util.Date modifiedDate)This function returns FileHistories with the last version for which this last version matches the given checksum, size and modified date.java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory>getFileHistoriesWithFileVersions()java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory>getFileHistoriesWithFileVersions(VectorClock databaseVersionVectorClock, int maxCount)Note: Also selects versions marked asDIRTYjava.util.List<PartialFileHistory>getFileHistoriesWithLastVersion()PartialFileHistorygetFileHistoryWithLastVersionByPath(java.lang.String path)This function returns a FileHistory, with as last version a FileVersion with the given path.voidremoveDirtyFileHistories()voidremoveUnreferencedFileHistories()Removes unreferencedPartialFileHistorys from the database table filehistory.voidwriteFileHistories(java.sql.Connection connection, long databaseVersionId, java.util.Collection<PartialFileHistory> fileHistories)Writes a list ofPartialFileHistorys to the database table filehistory usingINSERTs and the given connection.-
Methods inherited from class org.syncany.database.dao.AbstractSqlDao
getConnection, getStatement, getStatement, runScript
-
-
-
-
Constructor Detail
-
FileHistorySqlDao
public FileHistorySqlDao(java.sql.Connection connection, FileVersionSqlDao fileVersionDao)
-
-
Method Detail
-
writeFileHistories
public void writeFileHistories(java.sql.Connection connection, long databaseVersionId, java.util.Collection<PartialFileHistory> fileHistories) throws java.sql.SQLException
Writes a list ofPartialFileHistorys to the database table filehistory usingINSERTs and the given connection. In addition, this method also writes the correspondingFileVersions of each file history to the database usingFileVersionSqlDao#writeFileVersions.Note: This method executes, but does not commit the queries.
- Parameters:
connection- The connection used to execute the statementsdatabaseVersionId- References thePartialFileHistoryto which the list of file versions belongsfileHistories- List ofPartialFileHistorys to be written to the database- Throws:
java.sql.SQLException- If the SQL statement fails
-
removeDirtyFileHistories
public void removeDirtyFileHistories() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
removeUnreferencedFileHistories
public void removeUnreferencedFileHistories() throws java.sql.SQLException
Removes unreferencedPartialFileHistorys from the database table filehistory. This method does not remove the correspondingFileVersions.Note: This method executes, but does not commit the query.
- Throws:
java.sql.SQLException- If the SQL statement fails
-
getFileHistoriesWithFileVersions
public java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory> getFileHistoriesWithFileVersions(VectorClock databaseVersionVectorClock, int maxCount)
Note: Also selects versions marked asDIRTY
-
expandFileHistoryId
public PartialFileHistory.FileHistoryId expandFileHistoryId(PartialFileHistory.FileHistoryId fileHistoryIdPrefix)
-
getFileHistories
public java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory> getFileHistories(java.util.List<PartialFileHistory.FileHistoryId> fileHistoryIds)
-
getFileHistoriesByChecksumSizeAndModifiedDate
public java.util.Collection<PartialFileHistory> getFileHistoriesByChecksumSizeAndModifiedDate(java.lang.String filecontentChecksum, long size, java.util.Date modifiedDate)
This function returns FileHistories with the last version for which this last version matches the given checksum, size and modified date.- Returns:
- An empty Collection is returned if none exist.
-
getFileHistoryWithLastVersionByPath
public PartialFileHistory getFileHistoryWithLastVersionByPath(java.lang.String path)
This function returns a FileHistory, with as last version a FileVersion with the given path. If the last FileVersion referring to this path is not the last in the FileHistory, or no such FileVersion exists, null is returned.
-
getFileHistoriesWithFileVersions
public java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory> getFileHistoriesWithFileVersions()
-
createFileHistoriesFromResult
protected java.util.Map<PartialFileHistory.FileHistoryId,PartialFileHistory> createFileHistoriesFromResult(java.sql.ResultSet resultSet) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getFileHistoriesWithLastVersion
public java.util.List<PartialFileHistory> getFileHistoriesWithLastVersion()
-
-