9 namespace Fossology\Lib\Dao;
44 public function getPfile($sha1 =
null, $md5 =
null, $sha256 =
null,
47 $statement = __METHOD__ .
".getPfileId";
48 $sql =
"SELECT * FROM pfile WHERE ";
52 $statement .=
".sha1";
54 $conds[] =
"pfile_sha1 = $" . count($params);
59 $conds[] =
"pfile_md5 = $" . count($params);
61 if (! empty($sha256)) {
62 $statement .=
".sha256";
64 $conds[] =
"pfile_sha256 = $" . count($params);
67 $statement .=
".size";
69 $conds[] =
"pfile_size = $" . count($params);
71 $sql .= join(
" AND ", $conds);
72 $row = $this->
dbManager->getSingleRow($sql, $params, $statement);
73 return (! empty($row)) ? $row :
null;
83 $statement = __METHOD__ .
".getScannerFindings";
84 $sql =
"SELECT DISTINCT ON(rf_pk) rf_shortname " .
85 "FROM license_file AS lf " .
86 "INNER JOIN ONLY license_ref AS lr ON lf.rf_fk = lr.rf_pk " .
87 "WHERE lf.pfile_fk = $1;";
89 $rows = $this->
dbManager->getRows($sql, $params, $statement);
90 if (! empty($rows) && array_key_exists(
'rf_shortname', $rows[0])) {
91 $licenses = array_column($rows,
'rf_shortname');
92 natcasesort($licenses);
93 return array_values($licenses);
111 return [
"NOASSERTION"];
113 $statement = __METHOD__ .
".getScannerFindings";
114 $sql =
"WITH allDecsPfile AS (
115 SELECT cd.pfile_fk, cd.clearing_decision_pk, cd.decision_type,
116 lr.rf_shortname, ce.removed
117 FROM clearing_decision AS cd
118 INNER JOIN clearing_decision_event AS cde
119 ON cde.clearing_decision_fk = cd.clearing_decision_pk
120 INNER JOIN clearing_event AS ce
121 ON cde.clearing_event_fk = ce.clearing_event_pk
122 INNER JOIN license_ref AS lr
123 ON ce.rf_fk = lr.rf_pk
124 WHERE cd.pfile_fk = $1 AND (cd.group_fk = $2 OR cd.scope = " .
125 DecisionScopes::REPO .
")
126 ORDER BY cd.clearing_decision_pk DESC
129 SELECT *, rank() OVER (
130 PARTITION BY pfile_fk, rf_shortname ORDER BY clearing_decision_pk DESC
131 ) rnk FROM allDecsPfile
133 SELECT * FROM rankedDecs
134 WHERE rnk = 1 AND removed = false AND decision_type = " .
135 DecisionTypes::IDENTIFIED .
";";
136 $params = [$pfileId, $groupId];
137 $rows = $this->
dbManager->getRows($sql, $params, $statement);
138 if (! empty($rows) && array_key_exists(
'rf_shortname', $rows[0])) {
139 $licenses = array_column($rows,
'rf_shortname');
140 natcasesort($licenses);
141 return array_values($licenses);
155 $statement = __METHOD__ .
".getUploadForPackage";
156 $sql =
"SELECT upload_pk FROM upload WHERE pfile_fk = $1;";
157 $params = [$pfileId];
158 $rows = $this->
dbManager->getRows($sql, $params, $statement);
159 if (! empty($rows) && array_key_exists(
'upload_pk', $rows[0])) {
160 $uploads = array_column($rows,
'upload_pk');
161 return array_map(
function ($upload) {
162 return intval($upload);
178 $statement = __METHOD__ .
".pfileHaveConclusions";
179 $sql =
"SELECT count(*) AS cnt FROM clearing_decision " .
180 "WHERE pfile_fk = $1 AND (group_fk = $2 OR scope = " .
181 DecisionScopes::REPO .
");";
182 $params = [$pfileId, $groupId];
183 $row = $this->
dbManager->getSingleRow($sql, $params, $statement);
184 if (! empty($row[
'cnt']) && $row[
'cnt'] > 0) {
197 $statement = __METHOD__ .
".getCopyright";
198 $sql =
"SELECT content " .
200 "WHERE (pfile_fk = $1) AND (is_enabled = TRUE) " .
202 "SELECT textfinding " .
203 "FROM copyright_decision " .
204 "WHERE (pfile_fk = $1) AND (is_enabled = TRUE);";
205 $params = [$pfileId];
206 $rows = $this->
dbManager->getRows($sql, $params, $statement);
207 if (!empty($rows) && array_key_exists(
'content', $rows[0])) {
208 $copyright = array_column($rows,
'content');
209 natcasesort($copyright);
210 return array_values($copyright);
getPfile($sha1=null, $md5=null, $sha256=null, $size=null)
getUploadForPackage($pfileId)
getScannerFindings($pfileId)
getConclusions($groupId, $pfileId)
haveConclusions($groupId, $pfileId)
fo_dbManager * dbManager
fo_dbManager object
FUNCTION char * strtoupper(char *s)
Helper function to upper case a string.