Commit 60a7c4f4 authored by Steven Murray's avatar Steven Murray
Browse files

WIP

parent 915d6115
......@@ -6566,13 +6566,10 @@ Catalogue::ArchiveFileItor RdbmsCatalogue::getArchiveFilesItor(const TapeFileSea
//------------------------------------------------------------------------------
// getDeletedArchiveFilesItor
//------------------------------------------------------------------------------
Catalogue::DeletedArchiveFileItor RdbmsCatalogue::getDeletedArchiveFilesItor(
const TapeFileSearchCriteria &searchCriteria) const {
checkTapeFileSearchCriteria(searchCriteria);
Catalogue::DeletedArchiveFileItor RdbmsCatalogue::getDeletedArchiveFilesItor() const {
try {
auto impl = new RdbmsCatalogueGetDeletedArchiveFilesItor(m_log, m_archiveFileListingConnPool, searchCriteria);
auto impl = new RdbmsCatalogueGetDeletedArchiveFilesItor(m_log, m_archiveFileListingConnPool);
return DeletedArchiveFileItor(impl);
} catch(exception::UserError &) {
throw;
......
......@@ -823,13 +823,12 @@ public:
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria &searchCriteria) const override;
/**
* Returns the specified deleted archive files. Please note that the list of files
* is ordered by archive file ID.
* Returns all the currently deleted archive files. Please note that the list
* of archive files is ordered by archive file ID.
*
* @param searchCriteria The search criteria.
* @return The deleted archive files.
* @return The deleted archive files ordered by archive file ID.
*/
DeletedArchiveFileItor getDeletedArchiveFilesItor(const TapeFileSearchCriteria& searchCriteria) const override;
DeletedArchiveFileItor getDeletedArchiveFilesItor() const override;
/**
* Returns the specified files in tape file sequence order.
......
......@@ -77,11 +77,9 @@ namespace catalogue {
//------------------------------------------------------------------------------
RdbmsCatalogueGetDeletedArchiveFilesItor::RdbmsCatalogueGetDeletedArchiveFilesItor(
log::Logger &log,
rdbms::ConnPool &connPool,
const TapeFileSearchCriteria &searchCriteria):
rdbms::ConnPool &connPool):
m_log(log),
m_connPool(connPool),
m_searchCriteria(searchCriteria),
m_rsetIsEmpty(true),
m_hasMoreHasBeenCalled(false),
m_archiveFileBuilder(log) {
......@@ -120,72 +118,14 @@ RdbmsCatalogueGetDeletedArchiveFilesItor::RdbmsCatalogueGetDeletedArchiveFilesIt
"INNER JOIN TAPE ON "
"TAPE_FILE_RECYCLE_BIN.VID = TAPE.VID "
"INNER JOIN TAPE_POOL ON "
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID";
const bool hideSuperseded = searchCriteria.showSuperseded ? !*searchCriteria.showSuperseded : false;
const bool thereIsAtLeastOneSearchCriteria =
searchCriteria.archiveFileId ||
searchCriteria.diskInstance ||
searchCriteria.vid ||
searchCriteria.diskFileIds ||
hideSuperseded;
if(thereIsAtLeastOneSearchCriteria) {
sql += " WHERE ";
}
bool addedAWhereConstraint = false;
if(searchCriteria.archiveFileId) {
sql += " ARCHIVE_FILE.ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID";
addedAWhereConstraint = true;
}
if(searchCriteria.diskInstance) {
if(addedAWhereConstraint) sql += " AND ";
sql += "ARCHIVE_FILE.DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME";
addedAWhereConstraint = true;
}
if(searchCriteria.vid) {
if(addedAWhereConstraint) sql += " AND ";
sql += "TAPE_FILE.VID = :VID";
addedAWhereConstraint = true;
}
if(searchCriteria.diskFileIds) {
if(addedAWhereConstraint) sql += " AND ";
sql += "ARCHIVE_FILE.DISK_FILE_ID IN ";
char delim = '(';
for(auto &diskFileId : searchCriteria.diskFileIds.value()) {
sql += delim + diskFileId;
delim = ',';
}
sql += ')';
addedAWhereConstraint = true;
}
if(hideSuperseded) {
if(addedAWhereConstraint) sql += " AND ";
sql += "TAPE_FILE.SUPERSEDED_BY_VID != ''";
addedAWhereConstraint = true;
}
// Order by FSEQ if we are listing the contents of a tape, else order by
// archive file ID
if(searchCriteria.vid) {
sql += " ORDER BY FSEQ";
} else {
sql += " ORDER BY ARCHIVE_FILE_ID, COPY_NB";
}
"TAPE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID "
// The following ORDER BY CLAUSE is required by the ArchiveFileBuilder
// which needs tape files with a common archive file to be adjacent to
// each other in the result set
"ORDER BY ARCHIVE_FILE_ID, COPY_NB";
m_conn = connPool.getConn();
m_stmt = m_conn.createStmt(sql);
if(searchCriteria.archiveFileId) {
m_stmt.bindUint64(":ARCHIVE_FILE_ID", searchCriteria.archiveFileId.value());
}
if(searchCriteria.diskInstance) {
m_stmt.bindString(":DISK_INSTANCE_NAME", searchCriteria.diskInstance.value());
}
if(searchCriteria.vid) {
m_stmt.bindString(":VID", searchCriteria.vid.value());
}
m_rset = m_stmt.executeQuery();
{
......
......@@ -20,7 +20,6 @@
#include "catalogue/ArchiveFileBuilder.hpp"
#include "catalogue/Catalogue.hpp"
#include "catalogue/TapeFileSearchCriteria.hpp"
#include "common/dataStructures/DeletedArchiveFile.hpp"
#include "common/log/Logger.hpp"
#include "rdbms/ConnPool.hpp"
......@@ -39,13 +38,8 @@ public:
*
* @param log Object representing the API to the CTA logging system.
* @param connPool The database connection pool.
* @param searchCriteria The search criteria to be used when listing archive
* files.
*/
RdbmsCatalogueGetDeletedArchiveFilesItor(
log::Logger &log,
rdbms::ConnPool &connPool,
const TapeFileSearchCriteria &searchCriteria);
RdbmsCatalogueGetDeletedArchiveFilesItor(log::Logger &log, rdbms::ConnPool &connPool);
/**
* Destructor.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment