protected function getStatements($uploadId, $uploadTreeTableName, $groupId = null) { $agentName = $this->tableName; $scanJobProxy = new ScanJobProxy($GLOBALS['container']->get('dao.agent'), $uploadId); $scanJobProxy->createAgentStatus(array($agentName)); $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds(); if (!array_key_exists($agentName, $selectedScanners)) { return array(); } $latestXpAgentId = $selectedScanners[$agentName]; if (!empty($this->extrawhere)) { $this->extrawhere .= ' AND'; } $this->extrawhere .= ' agent_fk=' . $latestXpAgentId; return $this->copyrightDao->getAllEntries($this->tableName, $uploadId, $uploadTreeTableName, $this->type, $this->getOnlyCleared, DecisionTypes::IDENTIFIED, $this->extrawhere); }
public function testRun() { $this->setUpTables(); $this->setUpRepo(); $output = $this->runCopyright($uploadId = 1); $this->rmRepo(); $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId); $matches = $this->copyrightDao->getAllEntries("copyright", $uploadId, $uploadTreeTableName); $this->assertGreaterThan($expected = 5, count($matches), $output); }
/** * @param $itemId - uploadtree id * @param $uploadId - upload id */ public function getCopyrightList($itemId, $uploadId) { if (empty($itemId)) { $itemId = $this->uploadDao->getUploadParent($uploadId); } if (!$this->selectAgentId($uploadId)) { echo 'no valid copyright agent found'; return; } $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($uploadId); $toprow = $this->uploadDao->getItemTreeBounds($itemId, $uploadtree_tablename); $extraWhere = 'agent_fk=' . $this->agentId . ' AND lft>' . $toprow->getLeft() . ' AND rgt<' . $toprow->getRight(); $allCopyrightEntries = $this->copyrightDao->getAllEntries('copyright', $uploadId, $uploadtree_tablename, empty($this->type) || $this->type == 'all' ? null : $this->type, false, null, $extraWhere); $modeMask = empty($this->includeContainer) ? 3 << 28 : 1 << 28; $sql = "SELECT uploadtree_pk, ufile_name, lft, rgt FROM {$uploadtree_tablename} \n WHERE upload_fk=\$1 AND lft>\$2 AND rgt<\$3 AND (ufile_mode & \$4) = 0\n ORDER BY uploadtree_pk"; $this->dbManager->prepare($outerStmt = __METHOD__ . '.loopThroughAllRecordsInTree', $sql); $outerresult = $this->dbManager->execute($outerStmt, array($toprow->getUploadId(), $toprow->getLeft(), $toprow->getRight(), $modeMask)); while ($row = $this->dbManager->fetchArray($outerresult)) { $this->printRow($row, $uploadtree_tablename, $allCopyrightEntries); //$this->uploadDao->getParentItemBounds($uploadId)->getItemId()); } $this->dbManager->freeResult($outerresult); }
public function testDeleteCopyright() { $this->setUpClearingTables(); $uploadDao = M::mock('Fossology\\Lib\\Dao\\UploadDao'); $copyrightDao = new CopyrightDao($this->dbManager, $uploadDao); $initialEntries = $copyrightDao->getAllEntries("copyright", 1, "uploadtree_a"); $initialCount = count($initialEntries); $item = new ItemTreeBounds(6, 'uploadtree_a', 1, 17, 18); $hash2 = '0x3a910990f114f12f'; $copyrightDao->updateTable($item, $hash2, $content = '', 55); $remainingEntries = $copyrightDao->getAllEntries("copyright", 1, "uploadtree_a"); $remainingCount = count($remainingEntries); assertThat($remainingCount, is(equalTo($initialCount - 1))); }