FOSSology  4.4.0
Open Source License Compliance by Open Source Software
CompatibilityDatabaseHandler.hpp
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2024 Siemens AG
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
11 #ifndef COMPATIBILITY_AGENT_DATABASE_HANDLER_HPP
12 #define COMPATIBILITY_AGENT_DATABASE_HANDLER_HPP
13 
14 #include "CompatibilityStatus.hpp"
17 #include "libfossUtils.hpp"
18 
19 #include <algorithm>
20 #include <iostream>
21 #include <string>
22 #include <tuple>
23 #include <unordered_map>
24 #include <vector>
25 
26 extern "C"
27 {
28 #include "libfossology.h"
29 }
30 using namespace std;
36 {
45  const unsigned long int license_fk, agent_fk, pfile_fk;
52  CompatibilityDatabaseEntry(const unsigned long int l,
53  const unsigned long int a,
54  const unsigned long int p) :
55  license_fk(l), agent_fk(a), pfile_fk(p)
56  {
57  }
58 };
59 
65 {
66 public:
69  fo::AgentDatabaseHandler(std::move(other)) {};
70  CompatibilityDatabaseHandler spawn() const;
71 
72  std::vector<unsigned long> queryFileIdsForUpload(int uploadId);
73  std::vector<unsigned long> queryFileIdsForScan(int uploadId, int agentId);
74  std::vector<unsigned long> queryScannerIdsForUpload(int uploadId);
75 
76  std::vector<unsigned long> queryLicIdsFromPfile(
77  unsigned long pFileId, vector<unsigned long> agentIds);
78  std::vector<unsigned long> queryMainLicenseForUpload(int uploadId,
79  int groupId);
80  std::vector<std::tuple<unsigned long, std::string>> queryLicDetails(
81  const std::vector<unsigned long>& licId);
82  CompatibilityStatus queryRule1(tuple<unsigned long, string> lic1,
83  tuple<unsigned long, string> lic2) const;
84  CompatibilityStatus queryRule2(
85  std::tuple<unsigned long, std::string> lic1,
86  std::tuple<unsigned long, std::string> lic2) const;
87  CompatibilityStatus queryRule3(
88  std::tuple<unsigned long, std::string> lic1,
89  std::tuple<unsigned long, std::string> lic2) const;
90  bool queryInsertResult(unsigned long pFileId, int a_id, unsigned long id1,
91  unsigned long id2, const string& comp);
92  bool check(unsigned long id1, unsigned long id2, unsigned long pFileId);
93  CompatibilityStatus getDefaultRule() const;
94 };
95 
96 #endif // COMPATIBILITY_AGENT_DATABASE_HANDLER_HPP
Database handler for agents.
DB wrapper for agents.
DB utility functions for agents.
General utility functions for CPP.
PGresult * queryFileIdsForUpload(fo_dbManager *dbManager, int uploadId, bool ignoreFilesWithMimeType)
Get all file IDs (pfile_fk) for a given upload.
Definition: libfossagent.c:61
DB wrapper for agents.
The main FOSSology C library.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16
CompatibilityDatabaseEntry(const unsigned long int l, const unsigned long int a, const unsigned long int p)