![]() |
FOSSology
4.7.1
Open Source License Compliance by Open Source Software
|
Database handler for the reuser agent. More...
#include <ReuserDatabaseHandler.hpp>


Public Member Functions | |
| ReuserDatabaseHandler (fo::DbManager dbManager) | |
| ReuserDatabaseHandler (ReuserDatabaseHandler &&other)=default | |
| virtual ReuserDatabaseHandler | spawn () const |
| virtual bool | getParentItemBounds (int uploadId, ItemTreeBounds &out) |
| Fetch the parent item bounds for a given upload. More... | |
| virtual std::vector< ReuseTriple > | getReusedUploads (int uploadId, int groupId) |
Return the list of uploads that should be reused for uploadId. | |
| virtual std::map< int, int > | getClearingDecisionMapByPfile (int uploadId, int groupId) |
Build a pfile_fk to clearing_decision_pk map for uploadId. More... | |
| virtual std::map< int, std::vector< int > > | getUploadTreePksForPfiles (int uploadId, const std::vector< int > &pfileIds) |
| For a set of pfile ids, return a map pfile_fk to [uploadtree_pk]. | |
| virtual int | insertClearingEvent (int uploadId, int uploadTreeId, int userId, int groupId, int licenseId, bool removed, int type, const std::string &reportInfo, const std::string &comment, const std::string &ack, int jobId) |
| Insert a new clearing event and return its primary key (0 on error). More... | |
| virtual int | createDecisionFromEvents (int uploadId, int uploadTreeId, int userId, int groupId, int decType, int scope, const std::vector< int > &eventIds) |
Create a clearing_decision linked to eventIds. More... | |
| virtual int | createCopyOfClearingDecision (int uploadId, int newItemUploadTreePk, int userId, int groupId, int originalDecisionPk) |
| Copy an existing clearing decision to a new uploadtree item. More... | |
| virtual int | writeArsRecord (int agentId, int uploadId, int arsId=0, bool success=false) |
| Write (insert or update) an ARS record. More... | |
| virtual bool | processUploadReuse (int uploadId, int reusedUploadId, int groupId, int reusedGroupId, int userId) |
| virtual bool | processEnhancedUploadReuse (int uploadId, int reusedUploadId, int groupId, int reusedGroupId, int userId) |
| virtual bool | reuseMainLicense (int uploadId, int groupId, int reusedUploadId, int reusedGroupId) |
| virtual bool | reuseConfSettings (int uploadId, int reusedUploadId) |
| virtual bool | reuseCopyrights (int uploadId, int reusedUploadId, int userId) |
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... | |
Static Protected Member Functions | |
| static bool | isValidIdentifier (const std::string &s) |
Validate that s contains only characters safe for SQL identifiers. | |
| static std::string | replaceUnicodeControlChars (const std::string &input) |
Strip Unicode control characters (C0, C1, DEL) from input. | |
| static int | getDecisionTypePriority (int decisionType) |
| Priority for decision types during reuse conflict resolution. More... | |
Private Member Functions | |
| std::string | getRepoPathOfPfile (int pfileId) |
Static Private Member Functions | |
| static std::string | shellEscape (const std::string &s) |
| static int | diffLineCount (const std::string &a, const std::string &b) |
Additional Inherited Members | |
Protected Attributes inherited from fo::AgentDatabaseHandler | |
| DbManager | dbManager |
| DbManager to use. | |
Database handler for the reuser agent.
Extends fo::AgentDatabaseHandler (fossologyCPP) and consolidates all database operations previously spread across DBManager, ReuserDao, AgentDao, reuser_logic and reuser_worker.
Mirrors the design of OjosDatabaseHandler from the ojo agent.
Definition at line 26 of file ReuserDatabaseHandler.hpp.
|
virtual |
Copy an existing clearing decision to a new uploadtree item.
| uploadId | Upload owning newItemUploadTreePk. |
Definition at line 451 of file ReuserDatabaseHandler.cc.
|
virtual |
Create a clearing_decision linked to eventIds.
| uploadId | Upload owning uploadTreeId; used to pick the right uploadtree table. |
Definition at line 394 of file ReuserDatabaseHandler.cc.
|
virtual |
Build a pfile_fk to clearing_decision_pk map for uploadId.
Considers both ITEM-scope and (when enabled) REPO-scope decisions.
Reimplemented in MockReuserDatabaseHandler.
Definition at line 201 of file ReuserDatabaseHandler.cc.
|
staticprotected |
Priority for decision types during reuse conflict resolution.
Higher priority values indicate a stronger decision. Used when the same pfile has different decision types at different locations.
Definition at line 50 of file ReuserDatabaseHandler.cc.
|
virtual |
Fetch the parent item bounds for a given upload.
Reimplemented in MockReuserDatabaseHandler.
Definition at line 144 of file ReuserDatabaseHandler.cc.
|
private |
Return the repository file path for a pfile, or empty string on error.
Definition at line 129 of file ReuserDatabaseHandler.cc.
|
virtual |
Insert a new clearing event and return its primary key (0 on error).
| uploadId | Upload owning uploadTreeId; used to pick the right uploadtree table. |
Definition at line 332 of file ReuserDatabaseHandler.cc.
|
virtual |
Enhanced reuse: match by filename + diff threshold.
Reimplemented in MockReuserDatabaseHandler.
Definition at line 557 of file ReuserDatabaseHandler.cc.
|
virtual |
Standard reuse: copy clearing decisions matched by pfile id.
Reimplemented in MockReuserDatabaseHandler.
Definition at line 518 of file ReuserDatabaseHandler.cc.
|
virtual |
Copy report_info configuration from reused upload.
Reimplemented in MockReuserDatabaseHandler.
Definition at line 671 of file ReuserDatabaseHandler.cc.
|
virtual |
Copy copyright events from reused upload.
Reimplemented in MockReuserDatabaseHandler.
Definition at line 722 of file ReuserDatabaseHandler.cc.
|
virtual |
Copy main-license entries from reused upload.
Reimplemented in MockReuserDatabaseHandler.
Definition at line 627 of file ReuserDatabaseHandler.cc.
|
virtual |
Spawn a new handler sharing the same connection pool (for threads).
Definition at line 32 of file ReuserDatabaseHandler.cc.
|
virtual |
Write (insert or update) an ARS record.
Definition at line 509 of file ReuserDatabaseHandler.cc.