FOSSology  4.4.0
Open Source License Compliance by Open Source Software
OjosDatabaseHandler.hpp
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2019 Siemens AG
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
11 #ifndef OJOS_AGENT_DATABASE_HANDLER_HPP
12 #define OJOS_AGENT_DATABASE_HANDLER_HPP
13 
14 #include <unordered_map>
15 #include <algorithm>
16 #include <string>
17 #include <iostream>
18 
19 #include "libfossUtils.hpp"
22 #include "ojomatch.hpp"
23 
24 extern "C" {
25 #include "libfossology.h"
26 }
27 
33 {
42  const unsigned long int license_fk, agent_fk, pfile_fk;
49  OjoDatabaseEntry(const unsigned long int l, const unsigned long int a,
50  const unsigned long int p) :
51  license_fk(l), agent_fk(a), pfile_fk(p)
52  {
53  }
54 };
55 
61 {
62  public:
65  fo::AgentDatabaseHandler(std::move(other))
66  {
67  }
68  ;
69  OjosDatabaseHandler spawn() const;
70 
71  std::vector<unsigned long> queryFileIdsForUpload(int uploadId, int agentId,
72  bool ignoreFilesWithMimeType);
73  unsigned long saveLicenseToDatabase(OjoDatabaseEntry &entry) const;
74  bool insertNoResultInDatabase(OjoDatabaseEntry &entry) const;
76  const unsigned long fl_fk) const;
77 
78  unsigned long getLicenseIdForName(std::string const &rfShortName,
79  const int groupId,
80  const int userId);
81 
82  private:
83  unsigned long getCachedLicenseIdForName (
84  std::string const &rfShortName) const;
85  unsigned long selectOrInsertLicenseIdForName (std::string rfShortname,
86  const int groupId,
87  const int userId);
91  std::unordered_map<std::string, long> licenseRefCache;
92 };
93 
94 #endif // OJOS_AGENT_DATABASE_HANDLER_HPP
unsigned long getCachedLicenseIdForName(std::string const &rfShortName) const
OjosDatabaseHandler spawn() const
std::vector< unsigned long > queryFileIdsForUpload(int uploadId, int agentId, bool ignoreFilesWithMimeType)
bool insertNoResultInDatabase(OjoDatabaseEntry &entry) const
Save no result to the database.
bool saveHighlightToDatabase(const ojomatch &match, const unsigned long fl_fk) const
unsigned long saveLicenseToDatabase(OjoDatabaseEntry &entry) const
Save findings to the database if agent was called by scheduler.
std::unordered_map< std::string, long > licenseRefCache
OjosDatabaseHandler(fo::DbManager dbManager)
unsigned long selectOrInsertLicenseIdForName(std::string rfShortname, const int groupId, const int userId)
unsigned long getLicenseIdForName(std::string const &rfShortName, const int groupId, const int userId)
Get the license id for a given short name.
Database handler for agents.
DbManager dbManager
DbManager to use.
DB wrapper for agents.
DB utility functions for agents.
General utility functions for CPP.
DB wrapper for agents.
The main FOSSology C library.
OjoDatabaseEntry(const unsigned long int l, const unsigned long int a, const unsigned long int p)
const unsigned long int license_fk
const unsigned long int agent_fk
const unsigned long int pfile_fk
Store the results of a regex match.
Definition: scanners.hpp:28
Store the results of a regex match.
Definition: ojomatch.hpp:17