8 namespace Fossology\Lib\Proxy;
14 const CONDITION_UPLOAD = 1;
15 const CONDITION_RANGE = 2;
16 const CONDITION_PLAIN_FILES = 3;
26 parent::__construct($dbViewQuery,
'UploadTreeView' . ($viewSuffix ?
'.' . $viewSuffix :
''));
37 $isDefaultTable = $uploadTreeTableName ==
'uploadtree_a' || $uploadTreeTableName ==
'uploadtree';
38 if ($isDefaultTable) {
39 $constraints[] = self::CONDITION_UPLOAD;
41 $baseQuery =
"SELECT * FROM $uploadTreeTableName";
42 $condition = self::getConstraintsCondition($itemTreeBounds, $constraints);
43 return $baseQuery . $condition;
46 private static function getConstraintsCondition(
ItemTreeBounds $itemTreeBounds, $constraints)
48 $conditions = array();
49 foreach (array_unique($constraints) as $constraint) {
50 $conditions[] = self::getConstraintCondition($itemTreeBounds, $constraint);
52 $condition = implode(
' AND ', $conditions);
53 return $condition ?
' WHERE ' . $condition :
'';
56 private static function getConstraintCondition(ItemTreeBounds $itemTreeBounds, $constraint)
58 switch ($constraint) {
59 case self::CONDITION_UPLOAD:
60 $uploadId = $itemTreeBounds->getUploadId();
61 return "upload_fk = $uploadId";
62 case self::CONDITION_RANGE:
63 $left = $itemTreeBounds->getLeft();
64 $right = $itemTreeBounds->getRight();
65 return "lft BETWEEN $left AND $right";
66 case self::CONDITION_PLAIN_FILES:
67 return '((ufile_mode & (3<<28))=0) AND pfile_fk != 0';
69 throw new \InvalidArgumentException(
"constraint $constraint is not defined");
__construct(ItemTreeBounds $itemTreeBounds, $constraints=array(), $viewSuffix=null)
static getUploadTreeView(ItemTreeBounds $itemTreeBounds, $constraints)