9 namespace Fossology\Lib\Dao;
24 require_once(dirname(dirname(__FILE__)) .
"/common-dir.php");
30 const REUSE_ENHANCED = 2;
32 const REUSE_CONF = 16;
33 const REUSE_COPYRIGHT = 128;
34 const UNIFIED_REPORT_HEADINGS = array(
35 "assessment" => array(
"Assessment Summary" =>
true),
36 "compliancetasks" => array(
"Required license compliance tasks" =>
true),
37 "acknowledgements" => array(
"Acknowledgements" =>
true),
38 "exportrestrictions" => array(
"Export Restrictions" =>
true),
39 "intellectualProperty" => array(
"Patent Relevant Statements" =>
true),
40 "notes" => array(
"Notes" =>
true),
41 "scanresults" => array(
"Results of License Scan" =>
true),
42 "mainlicenses" => array(
"Main Licenses" =>
true),
43 "redlicense" => array(
"Other OSS Licenses (red) - Do not Use Licenses" =>
true),
44 "yellowlicense" => array(
"Other OSS Licenses (yellow) - additional obligations to common rules (e.g. copyleft)" =>
true),
45 "whitelicense" => array(
"Other OSS Licenses (white) - only common rules" =>
true),
46 "overviewwithwithoutobligations" => array(
"Overview of All Licenses with or without Obligations" =>
true),
47 "copyrights" => array(
"Copyrights" =>
true),
48 "copyrightsuf" => array(
"Copyrights (User Findings)" =>
true),
49 "bulkfindings" => array(
"Bulk Findings" =>
true),
50 "licensenf" => array(
"Non-Functional Licenses" =>
true),
51 "irrelevantfiles" => array(
"Irrelevant Files" =>
true),
52 "dnufiles" => array(
"Do not use Files" =>
true),
53 "changelog" => array(
"Clearing Protocol Change Log" =>
true)
55 const CLIXML_REPORT_HEADINGS = array(
56 "mainlicensesclixml" => array(
"Main Licenses" =>
true),
57 "licensepath" => array(
"License File Path" =>
true),
58 "licensehash" => array(
"License File Hash" =>
true),
59 "copyrightsclixml" => array(
"Copyrights" =>
true),
60 "copyrightpath" => array(
"Copyright File Path" =>
true),
61 "copyrighthash" => array(
"Copyright File Hash" =>
true),
62 "exportrestrictionsclixml" => array(
"Export Restrictions(ECC)" =>
true),
63 "eccpath" => array(
"ECC File Path" =>
true),
64 "ecchash" => array(
"ECC File Hash" =>
true),
65 "intellectualPropertyclixml" => array(
"Identified Patent Relevant Analysis(IPRA)" =>
true),
66 "iprapath" => array(
"IPRA File Path" =>
true),
67 "iprahash" => array(
"IPRA File Hash" =>
true),
68 "allobligations" => array(
"All Obligations" =>
true),
69 "acknowledgementsclixml" => array(
"Acknowledgements" =>
true),
70 "irrelevantfilesclixml" => array(
"Irrelevant Files" =>
true),
71 "dnufilesclixml" => array(
"Do not use Files" =>
true),
72 "notesclixml" => array(
"Additional Notes" =>
true)
79 private $permissionDao;
84 $this->logger = $logger;
85 $this->permissionDao = $uploadPermissionDao;
94 public function getUploadEntry($uploadTreeId, $uploadTreeTableName =
"uploadtree")
96 $stmt = __METHOD__ .
".$uploadTreeTableName";
97 $uploadEntry = $this->
dbManager->getSingleRow(
"SELECT * FROM $uploadTreeTableName WHERE uploadtree_pk = $1",
98 array($uploadTreeId), $stmt);
100 $uploadEntry[
'tablename'] = $uploadTreeTableName;
114 $stmt = __METHOD__ .
".$uploadTreeTableName";
115 $uploadEntry = $this->
dbManager->getSingleRow(
"SELECT uploadtree_pk " .
116 "FROM $uploadTreeTableName " .
117 "WHERE upload_fk = $1 AND pfile_fk = $2",
118 array($uploadFk, $pfileFk), $stmt);
119 return intval($uploadEntry[
'uploadtree_pk']);
129 $row = $this->
dbManager->getSingleRow(
"SELECT * FROM upload WHERE upload_pk = $1",
130 array($uploadId), $stmt);
135 public function getActiveUploadsArray()
138 $queryResult = $this->
dbManager->getRows(
"SELECT * FROM upload where pfile_fk IS NOT NULL",
142 foreach ($queryResult as $row) {
158 $sql =
"SELECT u.* FROM upload u
159 LEFT JOIN perm_upload p ON p.upload_fk = u.upload_pk AND p.group_fk = $1
160 WHERE u.pfile_fk IS NOT NULL
161 AND (p.perm > $permNone OR u.public_perm > $permNone)";
163 $queryResult = $this->
dbManager->getRows($sql, array($groupId), $stmt);
166 foreach ($queryResult as $row) {
180 $uploadEntryData = $this->
getUploadEntry($itemId, $uploadTreeTableName);
203 if ($uploadTreeTableName ===
null) {
207 $stmt = __METHOD__ .
".$uploadTreeTableName";
208 $parameters = array();
209 $uploadCondition = $this->handleUploadIdForTable($uploadTreeTableName, $uploadId, $parameters);
211 $uploadEntryData = $this->
dbManager->getSingleRow(
"SELECT * FROM $uploadTreeTableName
217 return $uploadEntryData ? $this->
createItemTreeBounds($uploadEntryData, $uploadTreeTableName) :
false;
228 $stmt = __METHOD__ .
".$uploadTreeTableName";
229 $parameters = array($itemTreeBounds->
getLeft(), $itemTreeBounds->
getRight());
230 $uploadCondition = $this->handleUploadIdForTable($uploadTreeTableName, $itemTreeBounds->
getUploadId(), $parameters);
232 $row = $this->
dbManager->getSingleRow(
"SELECT count(*) as count FROM $uploadTreeTableName
233 WHERE lft BETWEEN $1 AND $2
235 AND ((ufile_mode & (3<<28))=0)
238 return intval($row[
"count"]);
241 private function handleUploadIdForTable($uploadTreeTableName, $uploadId, &$parameters)
243 if ($uploadTreeTableName ===
"uploadtree" || $uploadTreeTableName ===
"uploadtree_a") {
244 $parameters[] = $uploadId;
245 return " AND upload_fk = $" . count($parameters) .
" ";
254 public function getStatusTypeMap()
258 $uploadStatus = $container->get(
'upload_status.types');
259 return $uploadStatus->getMap();
271 if ($this->isAccessible($uploadId, $groupId)) {
272 $row = $this->
dbManager->getSingleRow(
"SELECT status_fk " .
273 "FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2;",
274 array($uploadId, $groupId));
275 if (
false === $row) {
278 return $row[
'status_fk'];
280 throw new \Exception(
"permission denied");
294 if ($this->isAccessible($uploadId, $groupId)) {
295 $row = $this->
dbManager->getSingleRow(
"SELECT assignee FROM upload_clearing WHERE upload_fk=$1 AND group_fk=$2;",
296 array($uploadId, $groupId));
297 if (
false === $row) {
300 return $row[
'assignee'];
302 throw new \Exception(
"permission denied");
315 $sql =
"SELECT event_ts FROM upload_events WHERE upload_fk = $1 " .
317 $row = $this->
dbManager->getSingleRow($sql, [$uploadId], __METHOD__);
318 if (empty($row) || empty($row[
"event_ts"])) {
321 return $row[
"event_ts"];
332 $sql =
"SELECT event_ts FROM upload_events WHERE upload_fk = $1 " .
334 $row = $this->
dbManager->getSingleRow($sql, [$uploadId], __METHOD__);
335 if (empty($row) || empty($row[
"event_ts"])) {
338 return $row[
"event_ts"];
353 if ($assignDate !=
null && $closingDate !=
null) {
355 $closingDate =
new DateTime($closingDate);
356 $assignDate =
new DateTime($assignDate);
357 if ($assignDate < $closingDate) {
359 $durationSort = $closingDate->getTimestamp() - $assignDate->getTimestamp();
364 return array($duration, $durationSort);
376 if (!empty($uploadId)) {
377 $statementName = __METHOD__;
379 "SELECT uploadtree_tablename FROM upload WHERE upload_pk=$1",
383 if (!empty($row[
'uploadtree_tablename'])) {
384 return $row[
'uploadtree_tablename'];
413 const NOT_FOUND =
null;
426 $originItem = $this->
getUploadEntry($itemId, $uploadTreeTableName);
427 $originLft = $originItem[
'lft'];
429 $options[UploadTreeProxy::OPT_ITEM_FILTER] =
" AND ut.ufile_mode & (3<<28) = 0";
430 $uploadTreeViewName =
'items2care';
432 if ($direction == self::DIR_FWD) {
433 $uploadTreeViewName .=
'fwd';
434 $options[UploadTreeProxy::OPT_ITEM_FILTER] .=
" AND lft>$1";
437 $uploadTreeViewName .=
'bwd';
438 $options[UploadTreeProxy::OPT_ITEM_FILTER] .=
" AND lft<$1";
442 $uploadTreeView =
new UploadTreeProxy($uploadId, $options, $uploadTreeTableName, $uploadTreeViewName);
443 $statementName = __METHOD__ .
".$uploadTreeViewName.";
444 $query = $uploadTreeView->getDbViewQuery().
" ORDER BY lft $order";
446 $newItemRow = $this->
dbManager->getSingleRow(
"$query LIMIT 1", array($originLft), $statementName);
448 return $this->
createItem($newItemRow, $uploadTreeTableName);
450 return self::NOT_FOUND;
462 $statementname = __METHOD__ . $uploadTreeTableName;
464 $parent = $this->
dbManager->getSingleRow(
465 "SELECT uploadtree_pk
466 FROM $uploadTreeTableName
467 WHERE upload_fk=$1 AND parent IS NULL", array($uploadId), $statementname);
468 if (
false === $parent) {
469 throw new \Exception(
"Missing upload tree parent for upload");
471 return $parent[
'uploadtree_pk'];
474 public function getLeftAndRight($uploadtreeID, $uploadTreeTableName =
"uploadtree")
476 $statementName = __METHOD__ . $uploadTreeTableName;
477 $leftRight = $this->
dbManager->getSingleRow(
478 "SELECT lft,rgt FROM $uploadTreeTableName WHERE uploadtree_pk = $1",
479 array($uploadtreeID), $statementName
482 return array($leftRight[
'lft'], $leftRight[
'rgt']);
492 $sql =
"SELECT count(*) FROM " . $uploadTreeView->
getDbViewName() .
" WHERE lft BETWEEN $1 AND $2";
493 $result = $this->
dbManager->getSingleRow($sql
494 , array($itemTreeBounds->
getLeft(), $itemTreeBounds->
getRight()), __METHOD__ . $uploadTreeView->
asCTE());
495 return $result[
'count'];
504 public function getContainedItems(
ItemTreeBounds $itemTreeBounds, $addCondition =
"", $addParameters = array())
508 $statementName = __METHOD__ .
".$uploadTreeTableName";
510 $view =
new UploadTreeViewProxy($itemTreeBounds, array(UploadTreeViewProxy::CONDITION_PLAIN_FILES));
512 $this->
dbManager->prepare($statementName,
513 $view->asCTE() .
" SELECT * FROM " . $view->getDbViewName() .
" ut ".
514 ($addCondition ?
" WHERE " . $addCondition :
''));
515 $res = $this->
dbManager->execute($statementName, $addParameters);
518 while ($row = $this->
dbManager->fetchArray($res)) {
519 $items[] = $this->
createItem($row, $uploadTreeTableName);
532 public function addReusedUpload($uploadId, $reusedUploadId, $groupId, $reusedGroupId, $reuseMode=0)
534 $this->
dbManager->insertTableRow(
'upload_reuse',
535 array(
'upload_fk'=>$uploadId,
'group_fk'=> $groupId,
'reused_upload_fk'=>$reusedUploadId,
'reused_group_fk'=>$reusedGroupId,
'reuse_mode'=>$reuseMode));
546 $statementName = __METHOD__;
548 $this->
dbManager->prepare($statementName,
549 "SELECT reused_upload_fk, reused_group_fk, reuse_mode FROM upload_reuse WHERE upload_fk = $1 AND group_fk=$2 ORDER BY date_added DESC");
550 $res = $this->
dbManager->execute($statementName, array($uploadId, $groupId));
551 $reusedPairs = $this->
dbManager->fetchAll($res);
561 protected function createItem($uploadEntry, $uploadTreeTableName)
564 intval($uploadEntry[
'uploadtree_pk']),
565 $uploadTreeTableName,
566 intval($uploadEntry[
'upload_fk']),
567 intval($uploadEntry[
'lft']), intval($uploadEntry[
'rgt']));
569 $parent = $uploadEntry[
'parent'];
571 $itemTreeBounds, $parent !==
null ? intval($parent) :
null, intval($uploadEntry[
'pfile_fk']), intval($uploadEntry[
'ufile_mode']), $uploadEntry[
'ufile_name']
583 if ($uploadEntryData ===
false) {
584 throw new Exception(
"did not find uploadTreeId in $uploadTreeTableName");
586 return new ItemTreeBounds(intval($uploadEntryData[
'uploadtree_pk']), $uploadTreeTableName, intval($uploadEntryData[
'upload_fk']), intval($uploadEntryData[
'lft']), intval($uploadEntryData[
'rgt']));
597 $sql =
"SELECT count(*) FROM ".$itemTreeBounds->getUploadTreeTableName().
" ut "
598 .
"WHERE ut.upload_fk=$1";
601 $stmt = __METHOD__.
'.parent';
602 $params[] = $itemTreeBounds->
getItemId();
603 $sql .=
" AND ut.ufile_mode & (1<<28) = 0 AND ut.realparent = $2";
605 $params[] = $itemTreeBounds->
getLeft();
606 $params[] = $itemTreeBounds->
getRight();
607 $sql .=
" AND ut.ufile_mode & (3<<28) = 0 AND (ut.lft BETWEEN $2 AND $3)";
610 $descendants = $this->
dbManager->getSingleRow($sql,$params);
611 return $descendants[
'count'];
615 public function isAccessible($uploadId, $groupId)
617 return $this->permissionDao->isAccessible($uploadId, $groupId);
620 public function isEditable($uploadId, $groupId)
622 return $this->permissionDao->isEditable($uploadId, $groupId);
625 public function makeAccessibleToGroup($uploadId, $groupId, $perm=
null)
627 $this->permissionDao->makeAccessibleToGroup($uploadId, $groupId, $perm);
630 public function makeAccessibleToAllGroupsOf($uploadId, $userId, $perm=
null)
632 $this->permissionDao->makeAccessibleToAllGroupsOf($uploadId, $userId, $perm);
635 public function filterAccessibleUploads(array $uploadIds, $groupId)
637 return $this->permissionDao->filterAccessibleUploads($uploadIds, $groupId);
646 $pfile = $this->
dbManager->getSingleRow(
'SELECT pfile.* FROM upload, pfile WHERE upload_pk=$1 AND pfile_fk=pfile_pk',
647 array($uploadId), __METHOD__);
648 return array(
'sha1'=>$pfile[
'pfile_sha1'],
'md5'=>$pfile[
'pfile_md5'],
'sha256'=>$pfile[
'pfile_sha256']);
659 $sqlChildrenOf =
"SELECT COUNT(*) FROM $uploadtreeTablename s
660 WHERE ufile_mode&(1<<28)=0 and s.upload_fk=$2 AND s.realparent=";
661 $sql=
"WITH RECURSIVE item_path (item_id,num_children,depth,ufile_mode,ufile_name) AS (
662 SELECT uploadtree_pk item_id, ($sqlChildrenOf $1) num_children, 0 depth, ufile_mode, ufile_name
663 FROM $uploadtreeTablename WHERE upload_fk=$2 AND uploadtree_pk=$1
665 SELECT uploadtree_pk item_id, ($sqlChildrenOf ut.uploadtree_pk) num_children,
666 item_path.depth+1 depth, ut.ufile_mode, item_path.ufile_name||'/'||ut.ufile_name ufile_name
667 FROM $uploadtreeTablename ut INNER JOIN item_path ON item_id=ut.realparent
668 WHERE upload_fk=$2 AND ut.ufile_mode&(1<<28)=0 AND num_children<2
670 SELECT * FROM item_path WHERE num_children!=1 OR ufile_mode&(1<<29)=0 ORDER BY depth DESC LIMIT 1";
671 return $this->
dbManager->getSingleRow($sql,array($itemId, $uploadId),__METHOD__.$uploadtreeTablename);
682 $itemRow = $this->
getFatItemArray($itemId,$uploadId,$uploadtreeTablename);
683 return $itemRow[
'item_id'];
693 $statementName = __METHOD__ .
'.' . $uploadTreeTableName;
696 $param[] = $itemTreeBounds->
getLeft();
697 $param[] = $itemTreeBounds->
getRight();
698 $condition =
" lft BETWEEN $1 AND $2";
699 $condition .=
" AND (ufile_mode & (1<<28)) = 0";
701 if (
'uploadtree_a' == $uploadTreeTableName) {
703 $condition .=
" AND upload_fk=$".count($param);
707 SELECT ufile_name, uploadtree_pk, lft, rgt, ufile_mode,
708 pfile_pk, pfile_md5, pfile_sha1, pfile_sha256
709 FROM $uploadTreeTableName
711 ON pfile_fk = pfile_pk
716 $this->
dbManager->prepare($statementName, $sql);
717 $result = $this->
dbManager->execute($statementName, $param);
718 $pfilePerFileName = array();
720 $row = $this->
dbManager->fetchArray($result);
721 $pathStack = array($row[
'ufile_name']);
722 $rgtStack = array($row[
'rgt']);
723 $lastLft = $row[
'lft'];
724 $this->addToPFilePerFileName($pfilePerFileName, $pathStack, $row);
725 while ($row = $this->
dbManager->fetchArray($result)) {
726 if ($row[
'lft'] < $lastLft) {
730 $this->updateStackState($pathStack, $rgtStack, $lastLft, $row);
731 $this->addToPFilePerFileName($pfilePerFileName, $pathStack, $row);
734 return $pfilePerFileName;
737 private function updateStackState(&$pathStack, &$rgtStack, &$lastLft, $row)
739 if ($row[
'lft'] >= $lastLft) {
740 while (count($rgtStack) > 0 && $row[
'lft'] > $rgtStack[count($rgtStack)-1]) {
741 array_pop($pathStack);
742 array_pop($rgtStack);
744 if ($row[
'lft'] > $lastLft) {
745 $pathStack[] = $row[
'ufile_name'];
746 $rgtStack[] = $row[
'rgt'];
747 $lastLft = $row[
'lft'];
752 private function addToPFilePerFileName(&$pfilePerFileName, $pathStack, $row)
754 if (($row[
'ufile_mode'] & (1 << 29)) == 0) {
755 $path = implode(
'/', $pathStack);
756 $pfilePerFileName[$path][
'pfile_pk'] = $row[
'pfile_pk'];
757 $pfilePerFileName[$path][
'uploadtree_pk'] = $row[
'uploadtree_pk'];
758 $pfilePerFileName[$path][
'md5'] = $row[
'pfile_md5'];
759 $pfilePerFileName[$path][
'sha1'] = $row[
'pfile_sha1'];
760 $pfilePerFileName[$path][
'sha256'] = $row[
'pfile_sha256'];
772 $statementName = __METHOD__ .
'.' . $uploadTreeTableName;
775 $param[] = $itemTreeBounds->
getLeft();
776 $param[] = $itemTreeBounds->
getRight();
777 $condition =
" lft BETWEEN $1 AND $2";
778 $condition .=
" AND (ufile_mode & (1<<28)) = 0";
780 if (
'uploadtree_a' == $uploadTreeTableName) {
782 $condition .=
" AND upload_fk=$".count($param);
784 $condition .=
" AND pfile_$hashAlgo IS NOT NULL";
787 SELECT pfile_fk, uploadtree_pk, ufile_mode, pfile_$hashAlgo as hash
788 FROM $uploadTreeTableName
790 ON pfile_fk = pfile_pk
795 $this->
dbManager->prepare($statementName, $sql);
796 $result = $this->
dbManager->execute($statementName, $param);
798 $pfilePerHashAlgo = array();
799 while ($row = $this->
dbManager->fetchArray($result)) {
800 if (($row[
'ufile_mode']&(1<<29)) == 0) {
801 $pfilePerHashAlgo[strtolower($row[
'hash'])][] = array(
'pfile_pk' => $row[
'pfile_fk'],
802 'uploadtree_pk' => $row[
'uploadtree_pk']);
806 return $pfilePerHashAlgo;
813 public function getReportInfo($uploadId)
816 $sql =
"SELECT * FROM report_info WHERE upload_fk = $1";
817 $row = $this->
dbManager->getSingleRow($sql, array($uploadId), $stmt);
821 $stmt = __METHOD__.
'ifempty';
822 $sql =
"INSERT INTO report_info (upload_fk) VALUES ($1) RETURNING *";
823 $row = $this->
dbManager->getSingleRow($sql, array($uploadId), $stmt);
836 $stmt = __METHOD__ .
'.getOwner';
837 $sql =
"SELECT user_fk FROM upload WHERE upload_pk = $1";
838 $uploadOwner = $this->
dbManager->getSingleRow($sql, array($uploadId), $stmt);
840 if (empty($uploadOwner)) {
841 return "unchecked,unchecked,unchecked";
844 $userId = $uploadOwner[
'user_fk'];
846 $stmt = __METHOD__ .
'.getUserDefaults';
847 $sql =
"SELECT spdx_settings FROM users WHERE user_pk = $1";
848 $userDefaults = $this->
dbManager->getSingleRow($sql, array($userId), $stmt);
850 if (empty($userDefaults) || empty($userDefaults[
'spdx_settings'])) {
851 return "unchecked,unchecked,unchecked";
854 $settings = explode(
',', $userDefaults[
'spdx_settings']);
855 if (count($settings) < 3) {
856 $settings = array_pad($settings, 3,
'unchecked');
859 $osselotExport = $settings[0];
860 $spdxLicenseComment = $settings[1];
861 $ignoreFilesWOInfo = $settings[2];
863 $result =
"$spdxLicenseComment,$ignoreFilesWOInfo,$osselotExport";
877 if ($column ===
"ri_unifiedcolumns") {
878 $value = json_decode($value,
true);
879 $oldValues = $this->getReportInfo($uploadId)[
"ri_unifiedcolumns"];
880 if (!empty($oldValues)) {
881 $oldValues = json_decode($oldValues,
true);
883 $oldValues = self::UNIFIED_REPORT_HEADINGS;
885 foreach ($value as $key => $val) {
886 $newValText = array_keys($val)[0];
887 $newValValue = array_values($val)[0];
888 $newValValue = ($newValValue ===
true || $newValValue ==
"true") ?
"on" :
null;
889 $oldValues[$key] = [$newValText => $newValValue];
891 $value = json_encode($oldValues);
892 } elseif ($column ===
"ri_excluded_obligations") {
893 $value = json_decode($value,
true);
894 $oldValues = $this->getReportInfo($uploadId)[
"ri_excluded_obligations"];
895 if (!empty($oldValues)) {
896 $oldValues = json_decode($oldValues,
true);
900 foreach ($value as $key => $newValue) {
901 $oldValues[$key] = $newValue;
903 $value = json_encode($oldValues);
904 } elseif ($column ===
"ri_globaldecision") {
905 $value = filter_var($value, FILTER_VALIDATE_BOOL);
908 $sql =
"UPDATE report_info SET $column = $2 WHERE upload_fk = $1;";
909 $stmt = __METHOD__ .
"updateReportInfo" . $column;
910 $this->
dbManager->getSingleRow($sql, [$uploadId, $value], $stmt);
917 public function getGlobalDecisionSettingsFromInfo($uploadId, $setGlobal=
null)
919 $stmt = __METHOD__ .
'get';
920 $sql =
"SELECT ri_globaldecision, ri_spdx_selection FROM report_info WHERE upload_fk = $1";
921 $row = $this->
dbManager->getSingleRow($sql, array($uploadId), $stmt);
923 if ($setGlobal ===
null) {
927 $stmt = __METHOD__ .
'ifempty';
929 $sql =
"INSERT INTO report_info (upload_fk, ri_globaldecision, ri_spdx_selection) VALUES ($1, $2, $3) RETURNING ri_globaldecision";
930 $row = $this->
dbManager->getSingleRow($sql, array($uploadId, $setGlobal, $userSPDXDefaults), $stmt);
934 if (!empty($setGlobal)) {
935 $stmt = __METHOD__ .
'update';
936 $sql =
"UPDATE report_info SET ri_globaldecision = $2 WHERE upload_fk = $1 RETURNING ri_globaldecision";
937 $row = $this->
dbManager->getSingleRow($sql, array($uploadId, $setGlobal), $stmt);
940 return $row[
'ri_globaldecision'];
950 $stmt = __METHOD__.
"getUploadHashesFromPfileId";
951 $sql =
"SELECT * FROM pfile WHERE pfile_pk = $1";
952 $row = $this->
dbManager->getSingleRow($sql, array($pfilePk), $stmt);
954 return [
"sha1" => $row[
"pfile_sha1"],
"md5" => $row[
"pfile_md5"],
"sha256" => $row[
"pfile_sha256"]];
964 $stmt = __METHOD__ .
".checkReused";
965 $sql =
"SELECT 1 AS exists FROM report_info WHERE upload_fk = $1 LIMIT 1;";
966 $row = $this->
dbManager->getSingleRow($sql, array($reusedUploadId), $stmt);
968 if (empty($row[
'exists'])) {
974 $stmt = __METHOD__ .
".removeExists";
975 $sql =
"DELETE FROM report_info WHERE upload_fk = $1;";
976 $this->
dbManager->getSingleRow($sql, [$uploadId], $stmt);
978 $stmt = __METHOD__ .
".getAllColumns";
979 $sql =
"SELECT string_agg(column_name, ',') AS columns
980 FROM information_schema.columns
981 WHERE table_name = 'report_info'
982 AND column_name != 'ri_pk'
983 AND column_name != 'upload_fk';";
984 $row = $this->
dbManager->getSingleRow($sql, [], $stmt);
985 $columns = $row[
'columns'];
987 $stmt = __METHOD__.
"CopyinsertReportConfReuse";
989 "INSERT INTO report_info(upload_fk, $columns)
991 FROM report_info WHERE upload_fk = $2"
994 $stmt, array($uploadId, $reusedUploadId)
Contains the constants and helpers for authentication of user.
getUploadtreeIdFromPfile($uploadFk, $pfileFk)
getParentItemBounds($uploadId, $uploadTreeTableName=null)
getReusedUpload($uploadId, $groupId)
createItem($uploadEntry, $uploadTreeTableName)
addReusedUpload($uploadId, $reusedUploadId, $groupId, $reusedGroupId, $reuseMode=0)
getUploadHashes($uploadId)
countNonArtifactDescendants(ItemTreeBounds $itemTreeBounds, $isFlat=true)
getClearingDuration(int $uploadId)
createItemTreeBounds($uploadEntryData, $uploadTreeTableName)
getUploadHashesFromPfileId($pfilePk)
Get Pfile hashes from the pfile id.
getPFileDataPerFileName(ItemTreeBounds $itemTreeBounds)
getContainingFileCount(ItemTreeBounds $itemTreeBounds, UploadTreeProxy $uploadTreeView)
getFatItemId($itemId, $uploadId, $uploadtreeTablename)
getItemTreeBoundsFromUploadId($uploadTreeId, $uploadId)
getAssigneeDate(int $uploadId)
getPFilesDataPerHashAlgo(ItemTreeBounds $itemTreeBounds, $hashAlgo="sha1")
getUploadParent($uploadId)
getItemByDirection($uploadId, $itemId, $direction, $options)
getFatItemArray($itemId, $uploadId, $uploadtreeTablename)
countPlainFiles(ItemTreeBounds $itemTreeBounds)
getNextItem($uploadId, $itemId, $options=null)
getClosedDate(int $uploadId)
updateReportInfo($uploadId, $column, $value)
Update report info for upload.
getPreviousItem($uploadId, $itemId, $options=null)
getItemTreeBounds($itemId, $uploadTreeTableName="uploadtree")
getUploadtreeTableName($uploadId)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree".
getAssignee($uploadId, $groupId)
Get the upload assignee id.
getUploadEntry($uploadTreeId, $uploadTreeTableName="uploadtree")
insertReportConfReuse($uploadId, $reusedUploadId)
getAccessibleUploads($groupId)
getUserSPDXDefaultsForUpload($uploadId)
getStatus($uploadId, $groupId)
Get the upload status.
This class contains the events for the upload_events table.
const UPLOAD_CLOSED_EVENT
static createFromTable($row)
asCTE()
Common Table Expressions.
HumanDuration(DateInterval $duration)
Convert DateInterval to Human readable format.
fo_dbManager * dbManager
fo_dbManager object