9 namespace Fossology\Lib\Dao;
35 $this->logger = $logger;
37 $this->agentDao = $container->get(
'dao.agent');
38 $this->uploadDao = $container->get(
'dao.upload');
47 $extendedQuery =
" AND jq_type LIKE 'nomos' OR jq_type LIKE 'monk'".
48 " OR jq_type LIKE 'ojo' OR jq_type LIKE 'copyright'".
49 " OR jq_type LIKE 'ecc' OR jq_type LIKE 'ipra'";
50 $sql =
"SELECT DISTINCT(jq_type) FROM jobqueue INNER JOIN job ON jq_job_fk=job_pk " .
51 "WHERE jq_end_bits ='1'".$extendedQuery.
" AND job_upload_fk=$1;";
52 $statementName = __METHOD__ .
".getAllFinishedJobsForUploadId";
53 $rows = $this->
dbManager->getRows($sql, array($uploadId), $statementName);
55 return array_column($rows,
'jq_type');
67 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
69 array(UploadTreeProxy::OPT_SKIP_THESE => $skip,
70 UploadTreeProxy::OPT_GROUP_ID => $groupId),
72 'no_license_uploadtree' . $uploadId);
85 $sql =
"WITH latestResultsPfile AS (".$allLicEntries->getDbViewQuery().
")".
86 "SELECT pfile_fk, pfile_sha1 || '.' || pfile_md5 || '.' || pfile_size AS pfilehash FROM latestResultsPfile LSP".
87 " INNER JOIN pfile p ON LSP.pfile_fk = p.pfile_pk " ;
88 $statementName = __METHOD__ .
".allLicEntrieslatestResultsPfile." . $skip;
89 $rows = $this->
dbManager->getRows($sql, array(), $statementName);
90 return array_column($rows,
'pfilehash',
'pfile_fk');
100 $sql =
"SELECT DISTINCT ON(uploadtree_pk) " .
101 "uploadtree_pk, ut.pfile_fk, ut.lft, ut.rgt FROM uploadtree ut " .
102 "INNER JOIN ".$tableName.
" ON ".$tableName.
".pfile_fk=ut.pfile_fk WHERE upload_fk=$1";
103 $statementName = __METHOD__ .
".allLicEntriesuploadtreeForUpload";
104 $rows = $this->
dbManager->getRows($sql, array($uploadId), $statementName);
105 foreach ($rows as $index => $row) {
106 $rows[$index][
"path"] = implode(
"/",
107 array_column(
Dir2Path($row[
"uploadtree_pk"]),
"ufile_name"));
119 $columns =
"clearing_decision_pk, cd.uploadtree_fk, cd.pfile_fk, decision_type, scope, date_added";
120 $sql =
"SELECT ".$columns.
" FROM clearing_decision cd ".
121 " INNER JOIN ".$tableName.
" ON ".$tableName.
".pfile_fk=cd.pfile_fk ".
122 " INNER JOIN uploadtree ut ON cd.uploadtree_fk=ut.uploadtree_pk WHERE ut.upload_fk=$1";
123 $statementName = __METHOD__ .
".allLicEntriesClearingDecisionForUpload";
124 return $this->
dbManager->getRows($sql, array($uploadId), $statementName);
134 $columns =
"DISTINCT(clearing_event_pk), ce.uploadtree_fk, rf_fk, removed, ".
135 " lrb_pk, type_fk, comment, reportinfo, acknowledgement, date_added";
136 $sql =
"SELECT ".$columns.
" FROM clearing_event ce ".
137 " INNER JOIN uploadtree ut ON ce.uploadtree_fk=ut.uploadtree_pk ".
138 " INNER JOIN ".$tableName.
" ON ".$tableName.
".pfile_fk=ut.pfile_fk " .
139 " LEFT JOIN jobqueue jq ON jq.jq_job_fk=ce.job_fk AND jq.jq_type='monkbulk'" .
140 " LEFT JOIN license_ref_bulk lrb ON jq.jq_args::int=lrb_pk " .
141 "WHERE ut.upload_fk=$1";
142 $statementName = __METHOD__ .
".allLicEntriesClearingEventForUpload";
143 return $this->
dbManager->getRows($sql, array($uploadId), $statementName);
153 $columns =
"clearing_decision_fk, clearing_event_fk";
154 $sql =
"SELECT ".$columns.
" FROM clearing_decision_event cde ".
155 " INNER JOIN clearing_decision cd ON cde.clearing_decision_fk=cd.clearing_decision_pk ".
156 " INNER JOIN ".$tableName.
" ON ".$tableName.
".pfile_fk=cd.pfile_fk".
157 " INNER JOIN uploadtree ut ON cd.uploadtree_fk=ut.uploadtree_pk WHERE ut.upload_fk=$1";
158 $statementName = __METHOD__ .
".allLicEntriesClearingDecisionEventForUpload";
159 return $this->
dbManager->getRows($sql, array($uploadId), $statementName);
168 $columns =
"lrb_pk, rf_text, uploadtree_fk, ignore_irrelevant, bulk_delimiters, scan_findings";
169 $sql =
"SELECT ".$columns.
" FROM license_ref_bulk lrb ".
170 " INNER JOIN uploadtree ut ON lrb.uploadtree_fk=ut.uploadtree_pk WHERE ut.upload_fk=$1";
171 $statementName = __METHOD__ .
".allLicEntriesLicenseRefBulkForUpload";
172 return $this->
dbManager->getRows($sql, array($uploadId), $statementName);
181 $columns =
"rf_fk, removing, lrb_fk, comment, reportinfo, acknowledgement";
182 $sql =
"SELECT ".$columns.
" FROM license_set_bulk lsb ".
183 " INNER JOIN license_ref_bulk lrb ON lsb.lrb_fk=lrb.lrb_pk ".
184 " INNER JOIN uploadtree ut ON lrb.uploadtree_fk=ut.uploadtree_pk WHERE ut.upload_fk=$1";
185 $statementName = __METHOD__ .
".allLicEntriesLicenseSetBulkForUpload";
186 return $this->
dbManager->getRows($sql, array($uploadId), $statementName);
195 $columns =
"clearing_event_fk, lrb_fk, start, len";
196 $sql =
"SELECT $columns FROM highlight_bulk hb INNER JOIN license_ref_bulk lrb ON hb.lrb_fk=lrb.lrb_pk " .
197 "INNER JOIN uploadtree ut ON lrb.uploadtree_fk=ut.uploadtree_pk WHERE ut.upload_fk=$1";
198 $statementName = __METHOD__ .
".allBulkHighlightDataForUpload";
199 return $this->
dbManager->getRows($sql, [$uploadId], $statementName);
209 $columns =
"DISTINCT(".$givenTableName.
"_pk), ".$givenTableName.
".pfile_fk, content, hash, copy_startbyte, copy_endbyte";
210 $sql =
"SELECT ".$columns.
" FROM ".$givenTableName.
" ".
211 " INNER JOIN ".$pfileTableName.
" ON ".$pfileTableName.
".pfile_fk=".$givenTableName.
".pfile_fk";
212 $statementName = __METHOD__ .
".allLicEntries".$givenTableName.
"ForUpload";
213 return $this->
dbManager->getRows($sql, array(), $statementName);
223 $columns =
"DISTINCT(".$givenTableName.
"_pk), ".$givenTableName.
".pfile_fk, ".
224 " clearing_decision_type_fk, description, textfinding, hash, comment";
225 $sql =
"SELECT ".$columns.
" FROM ".$givenTableName.
" ".
226 " INNER JOIN ".$pfileTableName.
" ON ".$pfileTableName.
".pfile_fk=".$givenTableName.
".pfile_fk";
227 $statementName = __METHOD__ .
".allLicEntries".$givenTableName.
"ForUpload";
228 return $this->
dbManager->getRows($sql, array(), $statementName);
239 $columns =
"DISTINCT(".$givenTableName.
"_pk), ".$tableType.
"_fk, ".
240 "uploadtree_fk, content, hash, is_enabled, scope";
241 $sql =
"SELECT ".$columns.
" FROM ".$givenTableName.
" ".
242 " INNER JOIN uploadtree ut ON ".$givenTableName.
".uploadtree_fk=ut.uploadtree_pk".
243 " WHERE ".$givenTableName.
".upload_fk=$1";
244 $statementName = __METHOD__ .
".allLicEntries".$givenTableName.
"ForUpload";
245 return $this->
dbManager->getRows($sql, array($uploadId), $statementName);
254 $columns =
"rf_pk, rf_shortname, rf_fullname, rf_text, rf_url, rf_notes, rf_md5, rf_risk";
255 $sql =
"WITH alllicense AS (" .
256 "SELECT $columns, false AS is_candidate FROM ONLY license_ref UNION " .
257 "SELECT $columns, true AS is_candidate FROM ONLY license_candidate) " .
258 "SELECT lf.* FROM alllicense AS lf " .
259 " INNER JOIN clearing_event ce ON ce.rf_fk=lf.rf_pk " .
260 " INNER JOIN uploadtree ut ON ce.uploadtree_fk=ut.uploadtree_pk WHERE ut.upload_fk=$1" .
262 "SELECT lf.* FROM alllicense AS lf " .
263 " INNER JOIN upload_clearing_license ucl ON ucl.rf_fk = lf.rf_pk AND ucl.upload_fk=$1;";
264 $statementName = __METHOD__ .
".allLicEntriesLicenseForUpload";
265 return $this->
dbManager->getRows($sql, array($uploadId), $statementName);
276 $licensePfile = array();
277 $copyrightPfile = array();
280 $licenseAgentNames = array(
'nomos',
'monk',
'ojo');
282 foreach ($executedAgents as $agent) {
283 if (in_array($agent,$licenseAgentNames)) {
284 $executedAgents = array_diff($executedAgents,$licenseAgentNames);
286 }
else if ($agent ==
'copyright') {
287 $executedAgents = array_diff($executedAgents,array(
'copyright'));
289 }
else if ($agent ==
'ecc') {
290 $executedAgents = array_diff($executedAgents,array(
'ecc'));
292 }
else if ($agent ==
'ipra') {
293 $executedAgents = array_diff($executedAgents,array(
'ipra'));
297 return $licensePfile + $copyrightPfile + $eccPfile + $ipPfile;
getAllAgentPfileIdsForUpload($uploadId, $groupId, $userId)
getAllAgentEntriesForPfile($uploadId, $groupId, $userId, $skip)
getAllLicenseSetBulkDataForUpload($uploadId)
getAllClearingDecisionEventDataForUpload($uploadId, $tableName)
getAllClearingDecisionDataForUpload($uploadId, $tableName)
getSqlQueryDataPfile($uploadId, $groupId, $userId, $skip='noLicense')
getAllJobTypeForUpload($uploadId)
getAllLicenseDataForUpload($uploadId)
getAllDataForGivenTableUpload($pfileTableName, $givenTableName)
getAllDataForGivenDecisionTableUpload($pfileTableName, $givenTableName)
getAllAgentUploadTreeDataForUpload($uploadId, $tableName)
getAllBulkHighlightDataForUpload($uploadId)
getAllLicenseRefBulkDataForUpload($uploadId)
getAllDataForGivenEventTableUpload($uploadId, $givenTableName, $tableType)
__construct(DbManager $dbManager, Logger $logger)
getAllClearingEventDataForUpload($uploadId, $tableName)
Dir2Path($uploadtree_pk, $uploadtree_tablename='uploadtree')
Return the path (without artifacts) of an uploadtree_pk.
fo_dbManager * dbManager
fo_dbManager object