FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Manages database related requests for agent. More...
#include <database.hpp>
Classes | |
struct | ColumnDef |
Holds the column related data for table creation. More... | |
Public Member Functions | |
CopyrightDatabaseHandler (fo::DbManager manager) | |
Constructor to initialize database handler. | |
CopyrightDatabaseHandler (const CopyrightDatabaseHandler &)=delete | |
CopyrightDatabaseHandler (CopyrightDatabaseHandler &&other) | |
CopyrightDatabaseHandler | spawn () const |
Spawn/fork a new database handler and return it. More... | |
bool | createTables () const |
Create tables required by agent. More... | |
bool | insertInDatabase (DatabaseEntry &entry) const |
Insert a finding in database. More... | |
std::vector< unsigned long > | queryFileIdsForUpload (int agentId, int uploadId, bool ignoreFilesWithMimeType) |
Get the list of pfile ids on which the given agent has no findings for a given upload. More... | |
Public Member Functions inherited from fo::AgentDatabaseHandler | |
AgentDatabaseHandler (DbManager dbManager) | |
AgentDatabaseHandler (AgentDatabaseHandler &&other) | |
AgentDatabaseHandler (const AgentDatabaseHandler &)=delete | |
virtual | ~AgentDatabaseHandler () |
AgentDatabaseHandler | operator= (const AgentDatabaseHandler &)=delete |
bool | begin () const |
BEGIN a transaction block in DB. More... | |
bool | commit () const |
COMMIT a transaction block in DB. More... | |
bool | rollback () const |
ROLLBACK a transaction block in DB. More... | |
char * | getPFileNameForFileId (unsigned long pfileId) const |
Get the file name of a give pfile id. More... | |
std::string | queryUploadTreeTableName (int uploadId) |
Get the upload tree table name for a given upload id. More... | |
std::vector< unsigned long > | queryFileIdsVectorForUpload (int uploadId, bool ignoreFilesWithMimeType) const |
Get pfile ids for a given upload id. More... | |
std::vector< unsigned long > | queryFileIdsVectorForUpload (int uploadId, int agentId, bool ignoreFilesWithMimeType) const |
Get pfile ids for a given upload id which agent has not scanned. More... | |
Private Member Functions | |
bool | createTableAgentFindings () const |
Create table to store agent find data. More... | |
bool | createTableClearing () const |
Create table to store user decisions. More... | |
std::string | getColumnListString (const ColumnDef in[], size_t size) const |
Given a list of ColumnDef, return a comma separated list of column names. More... | |
std::string | getColumnCreationString (const ColumnDef in[], size_t size) const |
Return a comma delimited string with column elements separated by space. The string is used for database creation. More... | |
Static Private Attributes | |
static const ColumnDef | columns [] |
Columns required by agent in database. More... | |
static const ColumnDef | columnsDecision [] |
Columns required to store user decisions in database. More... | |
Additional Inherited Members | |
Protected Attributes inherited from fo::AgentDatabaseHandler | |
DbManager | dbManager |
DbManager to use. | |
Manages database related requests for agent.
Definition at line 52 of file database.hpp.
|
private |
Create table to store agent find data.
Definition at line 157 of file database.cc.
|
private |
Create table to store user decisions.
Definition at line 237 of file database.cc.
bool CopyrightDatabaseHandler::createTables | ( | ) | const |
Create tables required by agent.
Calls createTableAgentFindings() and createTableClearing() to create the tables required by the agent to work.
The function tries to create table in maximum of MAX_TABLE_CREATION_RETRIES attempts.
Definition at line 100 of file database.cc.
|
private |
Return a comma delimited string with column elements separated by space. The string is used for database creation.
in | List of column to be parsed |
size | Number of elements in the list |
Definition at line 74 of file database.cc.
|
private |
Given a list of ColumnDef, return a comma separated list of column names.
in | List to parse |
size | Number of elements in the list |
Definition at line 54 of file database.cc.
bool CopyrightDatabaseHandler::insertInDatabase | ( | DatabaseEntry & | entry | ) | const |
Insert a finding in database.
entry | Entry to be inserted in the database |
Definition at line 353 of file database.cc.
std::vector< unsigned long > CopyrightDatabaseHandler::queryFileIdsForUpload | ( | int | agentId, |
int | uploadId, | ||
bool | ignoreFilesWithMimeType | ||
) |
Get the list of pfile ids on which the given agent has no findings for a given upload.
agentId | Agent id to be removed from result |
uploadId | Upload id to scan for files |
ignoreFilesWithMimeType | to exclude filetypes with particular mimetype |
Definition at line 306 of file database.cc.
CopyrightDatabaseHandler CopyrightDatabaseHandler::spawn | ( | ) | const |
Spawn/fork a new database handler and return it.
Definition at line 41 of file database.cc.
|
staticprivate |
Columns required by agent in database.
Definition at line 77 of file database.hpp.
|
staticprivate |
Columns required to store user decisions in database.
Definition at line 78 of file database.hpp.