FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
libfossAgentDatabaseHandler.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013-2014, Siemens AG
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License version 2
6  as published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty
10  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  See the GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software Foundation,
15  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17 
20 #include "libfossUtils.hpp"
21 
22 extern "C" {
23 #include "libfossagent.h"
24 }
25 
36  dbManager(_dbManager)
37 {
38 }
39 
44  dbManager(other.dbManager)
45 {
46 }
47 
52 {
53 }
54 
61 {
62  return dbManager.begin();
63 }
64 
71 {
72  return dbManager.commit();
73 }
74 
81 {
82  return dbManager.rollback();
83 }
84 
91 char* fo::AgentDatabaseHandler::getPFileNameForFileId(unsigned long pfileId) const
92 {
94 }
95 
103 std::vector<unsigned long> fo::AgentDatabaseHandler::queryFileIdsVectorForUpload(int uploadId, bool ignoreFilesWithMimeType) const
104 {
105  QueryResult queryResult(queryFileIdsForUpload(dbManager.getStruct_dbManager(), uploadId, ignoreFilesWithMimeType));
106  return queryResult.getSimpleResults(0, fo::stringToUnsignedLong);
107 }
108 
115 {
116  return std::string(getUploadTreeTableName(dbManager.getStruct_dbManager(), uploadId));
117 }
std::vector< unsigned long > queryFileIdsVectorForUpload(int uploadId, bool ignoreFilesWithMimeType) const
Get pfile ids for a given upload id.
char * queryPFileForFileId(fo_dbManager *dbManager, long fileId)
Get the pfile name for a given file ID.
Definition: libfossagent.c:136
DB wrapper for agents.
bool commit() const
COMMIT a transaction block in DB.
char * getUploadTreeTableName(fo_dbManager *dbManager, int uploadId)
Get the upload tree table name for a given upload.
Definition: libfossagent.c:37
bool rollback() const
ROLLBACK a transaction block in DB.
DB wrapper for agents.
char * getPFileNameForFileId(unsigned long pfileId) const
Get the file name of a give pfile id.
fo_dbManager * getStruct_dbManager() const
unsigned long stringToUnsignedLong(const char *string)
Definition: libfossUtils.cc:31
Database handler for agents.
std::string queryUploadTreeTableName(int uploadId)
Get the upload tree table name for a given upload id.
Wrapper for DB result.
bool rollback() const
bool begin() const
BEGIN a transaction block in DB.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:28
General utility functions for CPP.
std::vector< T > getSimpleResults(int columnN, T(functionP)(const char *)) const
Get vector of a single column from query result.
DbManager dbManager
DbManager to use.
PGresult * queryFileIdsForUpload(fo_dbManager *dbManager, int uploadId, bool ignoreFilesWithMimeType)
Get all file IDs (pfile_fk) for a given upload.
Definition: libfossagent.c:73
DB utility functions for agents.
AgentDatabaseHandler(DbManager dbManager)