FOSSology
3.2.0rc1
Open Source License Compliance by Open Source Software
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
database.hpp
1
/*
2
* Copyright (C) 2014, Siemens AG
3
* Author: Daniele Fognini
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2
7
* as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
*/
18
19
#ifndef DATABASE_HPP
20
#define DATABASE_HPP
21
22
#include <string>
23
#include <vector>
24
25
#include "
libfossdbmanagerclass.hpp
"
26
#include "
libfossAgentDatabaseHandler.hpp
"
27
#include "cleanEntries.hpp"
28
29
#define MAX_TABLE_CREATION_RETRIES 5
30
35
class
DatabaseEntry
36
{
37
public
:
38
DatabaseEntry
();
39
40
long
agent_fk
;
41
long
pfile_fk
;
42
std::string
content
;
43
std::string
hash
;
54
std::string
type
;
55
int
copy_startbyte
;
56
int
copy_endbyte
;
57
};
58
63
class
CopyrightDatabaseHandler
:
public
fo::AgentDatabaseHandler
64
{
65
public
:
66
CopyrightDatabaseHandler
(
fo::DbManager
manager);
67
CopyrightDatabaseHandler
(
const
CopyrightDatabaseHandler
&) =
delete
;
68
CopyrightDatabaseHandler
(
CopyrightDatabaseHandler
&& other) :
fo::AgentDatabaseHandler
(std::move(other)) {};
// = default
69
CopyrightDatabaseHandler
spawn()
const
;
70
71
bool
createTables()
const
;
72
bool
insertInDatabase(
DatabaseEntry
& entry)
const
;
73
bool
insertNoResultInDatabase(
long
agentId,
long
pFileId)
const
;
74
std::vector<unsigned long>
queryFileIdsForUpload
(
int
agentId,
int
uploadId,
bool
ignoreFilesWithMimeType);
75
76
private
:
82
typedef
struct
83
{
84
const
char
*
name
;
85
const
char
*
type
;
86
const
char
*
creationFlags
;
87
}
ColumnDef
;
88
89
static
const
ColumnDef
columns[];
90
static
const
ColumnDef
columnsDecision[];
91
92
bool
createTableAgentFindings()
const
;
93
bool
createTableClearing()
const
;
94
std::string getColumnListString(
const
ColumnDef
in[],
size_t
size)
const
;
95
std::string getColumnCreationString(
const
ColumnDef
in[],
size_t
size)
const
;
96
};
97
98
#endif // DATABASE_HPP
fo::DbManager
DB wrapper for agents.
Definition:
libfossdbmanagerclass.hpp:61
CopyrightDatabaseHandler::ColumnDef
Holds the column related data for table creation.
Definition:
database.hpp:82
DatabaseEntry::agent_fk
long agent_fk
Definition:
database.hpp:40
CopyrightDatabaseHandler::ColumnDef::type
const char * type
Definition:
database.hpp:85
CopyrightDatabaseHandler::ColumnDef::name
const char * name
Definition:
database.hpp:84
libfossdbmanagerclass.hpp
DB wrapper for agents.
CopyrightDatabaseHandler::ColumnDef::creationFlags
const char * creationFlags
Definition:
database.hpp:86
DatabaseEntry::copy_endbyte
int copy_endbyte
Definition:
database.hpp:56
CopyrightDatabaseHandler
Manages database related requests for agent.
Definition:
database.hpp:63
fo::AgentDatabaseHandler
Database handler for agents.
Definition:
libfossAgentDatabaseHandler.hpp:36
DatabaseEntry::type
std::string type
Type of statement found.
Definition:
database.hpp:54
DatabaseEntry::DatabaseEntry
DatabaseEntry()
Default constructor for DatabaseEntry.
Definition:
database.cc:37
DatabaseEntry::hash
std::string hash
Definition:
database.hpp:43
DatabaseEntry::content
std::string content
Definition:
database.hpp:42
DatabaseEntry::copy_startbyte
int copy_startbyte
Definition:
database.hpp:55
DatabaseEntry::pfile_fk
long pfile_fk
Definition:
database.hpp:41
queryFileIdsForUpload
PGresult * queryFileIdsForUpload(fo_dbManager *dbManager, int uploadId, bool ignoreFilesWithMimeType)
Get all file IDs (pfile_fk) for a given upload.
Definition:
libfossagent.c:73
libfossAgentDatabaseHandler.hpp
DB utility functions for agents.
DatabaseEntry
Maps agent data to database schema.
Definition:
database.hpp:35
src
copyright
agent
database.hpp
Generated on Mon Jun 29 2020 12:03:42 for FOSSology by
1.8.11