9 #include "CompatibilityStatus.hpp"
25 bool insertResultInDb(CompatibilityStatus status,
bool verbosityDebug,
27 unsigned long& pFileId,
int agentId,
unsigned long lid1,
28 unsigned long lid2,
const string& ruleName)
30 string compatibility = (status == COMPATIBLE) ?
"t" :
"f";
33 cout << ruleName << ((status == COMPATIBLE) ?
"" :
" not")
34 <<
" compatible, " << pFileId <<
'\n';
44 agentId(agentId), verbosityDebug(verbosityDebug)
56 vector<unsigned long>& licId,
unsigned long& pFileId,
59 vector<tuple<unsigned long, string>> licenseTypes;
60 CompatibilityStatus defaultStatus = databaseHandler.
getDefaultRule();
61 string defaultRule = defaultStatus == COMPATIBLE ?
"t" :
"f";
62 bool res, resultExists;
64 size_t length = licenseTypes.size();
65 for (
size_t first = 0; first < (length - 1); ++first)
67 for (
size_t second = (first + 1); second < length; ++second)
69 CompatibilityStatus status;
70 unsigned long licenseId1, licenseId2;
71 licenseId1 = get<0>(licenseTypes[first]);
72 licenseId2 = get<0>(licenseTypes[second]);
73 resultExists = databaseHandler.
check(licenseId1, licenseId2, pFileId);
79 status = databaseHandler.
queryRule1(licenseTypes[first],
80 licenseTypes[second]);
81 if (status != UNKNOWN)
83 res = insertResultInDb(status, verbosityDebug, databaseHandler, pFileId,
84 agentId, licenseId1, licenseId2,
"rule1");
92 status = databaseHandler.
queryRule2(licenseTypes[first],
93 licenseTypes[second]);
94 if (status != UNKNOWN)
96 res = insertResultInDb(status, verbosityDebug, databaseHandler, pFileId,
97 agentId, licenseId1, licenseId2,
"rule2");
105 status = databaseHandler.
queryRule3(licenseTypes[first],
106 licenseTypes[second]);
107 if (status != UNKNOWN)
109 res = insertResultInDb(status, verbosityDebug, databaseHandler, pFileId,
110 agentId, licenseId1, licenseId2,
"rule3");
119 licenseId2, defaultRule);
122 cout <<
"default rule " << pFileId <<
'\n';
135 this->agentId = agentId;
CompatibilityAgent(int agentId, bool verbosityDebug)
bool checkCompatibilityForPfile(vector< unsigned long > &licId, unsigned long &pFileId, CompatibilityDatabaseHandler &databaseHandler) const
find the compatibility between the licenses using scheduler mode
void setAgentId(const int agentId)
Set the agent ID for the agent object.
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
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.
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.
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
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.
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.
CompatibilityStatus getDefaultRule() const
Get the default rule from DB as CompatibilityStatus.