FOSSology  4.4.0
Open Source License Compliance by Open Source Software
CompatibilityDatabaseHandler Class Reference

#include <CompatibilityDatabaseHandler.hpp>

Inheritance diagram for CompatibilityDatabaseHandler:
Inheritance graph
Collaboration diagram for CompatibilityDatabaseHandler:
Collaboration graph

Public Member Functions

 CompatibilityDatabaseHandler (fo::DbManager dbManager)
 
 CompatibilityDatabaseHandler (CompatibilityDatabaseHandler &&other)
 
CompatibilityDatabaseHandler spawn () const
 
std::vector< unsigned long > queryFileIdsForUpload (int uploadId)
 
std::vector< unsigned long > queryFileIdsForScan (int uploadId, int agentId)
 
std::vector< unsigned long > queryScannerIdsForUpload (int uploadId)
 Get the agent id of latest scanners run on the upload. More...
 
std::vector< unsigned long > queryLicIdsFromPfile (unsigned long pFileId, vector< unsigned long > agentIds)
 to get the license id from the file id More...
 
std::vector< unsigned long > queryMainLicenseForUpload (int uploadId, int groupId)
 Get the main licenses for the upload. More...
 
std::vector< std::tuple< unsigned long, std::string > > queryLicDetails (const std::vector< unsigned long > &licId)
 store the id and type of that respective license in vector of tuple for all the licenses More...
 
CompatibilityStatus queryRule1 (tuple< unsigned long, string > lic1, tuple< unsigned long, string > lic2) const
 This rule uses id of both the licenses to find the compatibility. More...
 
CompatibilityStatus queryRule2 (std::tuple< unsigned long, std::string > lic1, std::tuple< unsigned long, std::string > lic2) const
 This rule uses license type of both the licenses to find the compatibility. More...
 
CompatibilityStatus queryRule3 (std::tuple< unsigned long, std::string > lic1, std::tuple< unsigned long, std::string > lic2) const
 This rule uses license id and license type to find the compatibility. More...
 
bool queryInsertResult (unsigned long pFileId, int a_id, unsigned long id1, unsigned long id2, const string &comp)
 insert the compatibility result in the comp_result table More...
 
bool check (unsigned long id1, unsigned long id2, unsigned long pFileId)
 Checking whether the data is already present in database or not, to prevent redundancy. More...
 
CompatibilityStatus getDefaultRule () const
 Get the default rule from DB as CompatibilityStatus. 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...
 

Additional Inherited Members

- Protected Attributes inherited from fo::AgentDatabaseHandler
DbManager dbManager
 DbManager to use.
 

Detailed Description

Database handler for COMPATIBILITY agent

Definition at line 64 of file CompatibilityDatabaseHandler.hpp.

Constructor & Destructor Documentation

◆ CompatibilityDatabaseHandler()

CompatibilityDatabaseHandler::CompatibilityDatabaseHandler ( fo::DbManager  dbManager)

Default constructor for CompatibilityDatabaseHandler

Parameters
dbManagerDBManager to be used

Definition at line 27 of file CompatibilityDatabaseHandler.cc.

Member Function Documentation

◆ check()

bool CompatibilityDatabaseHandler::check ( unsigned long  id1,
unsigned long  id2,
unsigned long  pFileId 
)

Checking whether the data is already present in database or not, to prevent redundancy.

Parameters
id1holding license 1 information
id2holding license 2 information
Returns
boolean

Definition at line 249 of file CompatibilityDatabaseHandler.cc.

◆ getDefaultRule()

CompatibilityStatus CompatibilityDatabaseHandler::getDefaultRule ( ) const

Get the default rule from DB as CompatibilityStatus.

Returns
COMPATIBLE if default rule not found, otherwise the value from DB

Definition at line 305 of file CompatibilityDatabaseHandler.cc.

◆ queryFileIdsForScan()

vector< unsigned long > CompatibilityDatabaseHandler::queryFileIdsForScan ( int  uploadId,
int  agentId 
)

Get a vector of all file id for a given upload id which are not scanned by the given agentId.

Parameters
uploadIdUpload ID to be queried
agentIdID of the agent
Returns
List of all pfiles for the given upload

Definition at line 51 of file CompatibilityDatabaseHandler.cc.

◆ queryFileIdsForUpload()

vector< unsigned long > CompatibilityDatabaseHandler::queryFileIdsForUpload ( int  uploadId)

Get a vector of all file id for a given upload id.

Parameters
uploadIdUpload ID to be queried
Returns
List of all pfiles for the given upload

Definition at line 38 of file CompatibilityDatabaseHandler.cc.

◆ queryInsertResult()

bool CompatibilityDatabaseHandler::queryInsertResult ( unsigned long  pFileId,
int  a_id,
unsigned long  id1,
unsigned long  id2,
const string &  comp 
)

insert the compatibility result in the comp_result table

Parameters
pFileIdfile id
a_idagent id
id1first license id
id2second license id
compstoring the compatibility result
Returns
boolean

Definition at line 273 of file CompatibilityDatabaseHandler.cc.

◆ queryLicDetails()

vector< tuple< unsigned long, string > > CompatibilityDatabaseHandler::queryLicDetails ( const std::vector< unsigned long > &  licId)

store the id and type of that respective license in vector of tuple for all the licenses

Parameters
licId
Returns
vector of tuple

Definition at line 109 of file CompatibilityDatabaseHandler.cc.

◆ queryLicIdsFromPfile()

std::vector< unsigned long > CompatibilityDatabaseHandler::queryLicIdsFromPfile ( unsigned long  pFileId,
vector< unsigned long >  agentIds 
)

to get the license id from the file id

Parameters
pFileId
Returns
List of licenses for the given file id

Definition at line 77 of file CompatibilityDatabaseHandler.cc.

◆ queryMainLicenseForUpload()

std::vector< unsigned long > CompatibilityDatabaseHandler::queryMainLicenseForUpload ( int  uploadId,
int  groupId 
)

Get the main licenses for the upload.

Parameters
uploadIdUpload ID
Returns
Vector of main licenses

Definition at line 352 of file CompatibilityDatabaseHandler.cc.

◆ queryRule1()

CompatibilityStatus CompatibilityDatabaseHandler::queryRule1 ( tuple< unsigned long, string >  lic1,
tuple< unsigned long, string >  lic2 
) const

This rule uses id of both the licenses to find the compatibility.

Parameters
lic1holding license 2 information i.e. license id and license type
lic2holding license 2 information i.e. license id and license type
Returns
Compatibility status

Definition at line 133 of file CompatibilityDatabaseHandler.cc.

◆ queryRule2()

CompatibilityStatus CompatibilityDatabaseHandler::queryRule2 ( std::tuple< unsigned long, std::string >  lic1,
std::tuple< unsigned long, std::string >  lic2 
) const

This rule uses license type of both the licenses to find the compatibility.

Parameters
lic1holding license 1 information
lic2holding license 2 information
Returns
Compatibility status

Definition at line 169 of file CompatibilityDatabaseHandler.cc.

◆ queryRule3()

CompatibilityStatus CompatibilityDatabaseHandler::queryRule3 ( std::tuple< unsigned long, std::string >  lic1,
std::tuple< unsigned long, std::string >  lic2 
) const

This rule uses license id and license type to find the compatibility.

Parameters
lic1holding license 1 information
lic2holding license 2 information
Returns
Compatibility status

Definition at line 205 of file CompatibilityDatabaseHandler.cc.

◆ queryScannerIdsForUpload()

std::vector< unsigned long > CompatibilityDatabaseHandler::queryScannerIdsForUpload ( int  uploadId)

Get the agent id of latest scanners run on the upload.

Parameters
uploadIdUpload ID
Returns
Vectory of latest agent ids of scanners run on the upload

Definition at line 330 of file CompatibilityDatabaseHandler.cc.

◆ spawn()

CompatibilityDatabaseHandler CompatibilityDatabaseHandler::spawn ( ) const

Spawn a new DbManager object.

Used to create new objects for threads.

Returns
DbManager object for threads.

Definition at line 295 of file CompatibilityDatabaseHandler.cc.


The documentation for this class was generated from the following files: