/** @group Functional */ public function testRunMonkBulkScanWithAnEmptySearchText() { $this->setUpTables(); $this->setUpRepo(); $userId = 2; $groupId = 2; $uploadTreeId = 1; $licenseId = 225; $removing = false; $refText = ""; $bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, array($licenseId => $removing), $refText); $this->assertGreaterThan($expected = 0, $bulkId); $jobId = 64; list($output, $retCode) = $this->runBulkMonk($userId, $groupId, $jobId, $bulkId); $this->rmRepo(); $this->assertEquals($retCode, 0, 'monk bulk failed: ' . $output); $bounds6 = new ItemTreeBounds(6, 'uploadtree_a', 1, 17, 18); $bounds7 = new ItemTreeBounds(7, 'uploadtree_a', 1, 15, 16); $relevantDecisionsItem6 = $this->clearingDao->getRelevantClearingEvents($bounds6, $groupId); $relevantDecisionsItem7 = $this->clearingDao->getRelevantClearingEvents($bounds7, $groupId); assertThat(count($relevantDecisionsItem6), is(equalTo(0))); assertThat(count($relevantDecisionsItem7), is(equalTo(0))); $bulkHighlights = $this->highlightDao->getHighlightBulk(6); assertThat(count($bulkHighlights), is(equalTo(0))); }
/** * * @param int $uploadTreeId * @param Request $request * @return int $jobQueueId */ private function getJobQueueId($uploadTreeId, Request $request) { $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId); $uploadId = intval($uploadEntry['upload_fk']); $userId = Auth::getUserId(); $groupId = Auth::getGroupId(); if ($uploadId <= 0 || !$this->uploadDao->isAccessible($uploadId, $groupId)) { throw new Exception('permission denied'); } $bulkScope = $request->get('bulkScope'); switch ($bulkScope) { case 'u': $uploadTreeTable = $this->uploadDao->getUploadtreeTableName($uploadId); $topBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTable); $uploadTreeId = $topBounds->getItemId(); break; case 'f': if (!Isdir($uploadEntry['ufile_mode']) && !Iscontainer($uploadEntry['ufile_mode']) && !Isartifact($uploadEntry['ufile_mode'])) { $uploadTreeId = $uploadEntry['parent'] ?: $uploadTreeId; } break; default: throw new InvalidArgumentException('bad scope request'); } $refText = $request->get('refText'); $actions = $request->get('bulkAction'); $licenseRemovals = array(); foreach ($actions as $licenseAction) { $licenseRemovals[$licenseAction['licenseId']] = $licenseAction['action'] == 'remove'; } $bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseRemovals, $refText); if ($bulkId <= 0) { throw new Exception('cannot insert bulk reference'); } $upload = $this->uploadDao->getUpload($uploadId); $uploadName = $upload->getFilename(); $job_pk = JobAddJob($userId, $groupId, $uploadName, $uploadId); /** @var DeciderJobAgentPlugin $deciderPlugin */ $deciderPlugin = plugin_find("agent_deciderjob"); $dependecies = array(array('name' => 'agent_monk_bulk', 'args' => $bulkId)); $conflictStrategyId = intval($request->get('forceDecision')); $errorMsg = ''; $jqId = $deciderPlugin->AgentAdd($job_pk, $uploadId, $errorMsg, $dependecies, $conflictStrategyId); if (!empty($errorMsg)) { throw new Exception(str_replace('<br>', "\n", $errorMsg)); } return $jqId; }
private function getJobQueueId($uploadTreeId) { $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId); $uploadId = intval($uploadEntry['upload_fk']); if ($uploadId <= 0) { throw new Exception('permission denied'); } $bulkScope = filter_input(INPUT_POST, 'bulkScope'); switch ($bulkScope) { case 'u': $uploadTreeTable = $this->uploadDao->getUploadtreeTableName($uploadId); $row = $this->dbManager->getSingleRow("SELECT uploadtree_pk FROM {$uploadTreeTable} WHERE upload_fk = \$1 ORDER BY uploadtree_pk LIMIT 1", array($uploadId), __METHOD__ . "adam" . $uploadTreeTable); $uploadTreeId = $row['uploadtree_pk']; break; case 'f': if (!Isdir($uploadEntry['ufile_mode']) && !Iscontainer($uploadEntry['ufile_mode']) && !Isartifact($uploadEntry['ufile_mode'])) { $uploadTreeId = $uploadEntry['parent'] ?: $uploadTreeId; } break; default: throw new InvalidArgumentException('bad scope request'); } $userId = Auth::getUserId(); $groupId = Auth::getGroupId(); $refText = filter_input(INPUT_POST, 'refText'); $action = filter_input(INPUT_POST, 'bulkAction'); $licenseId = GetParm('licenseId', PARM_INTEGER); $removing = $action === 'remove'; $bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseId, $removing, $refText); if ($bulkId <= 0) { throw new Exception('cannot insert bulk reference'); } $upload = $this->uploadDao->getUpload($uploadId); $uploadName = $upload->getFilename(); $job_pk = JobAddJob($userId, $groupId, $uploadName, $uploadId); /** @var DeciderJobAgentPlugin $deciderPlugin */ $deciderPlugin = plugin_find("agent_deciderjob"); $dependecies = array(array('name' => 'agent_monk_bulk', 'args' => $bulkId)); $conflictStrategyId = intval(filter_input(INPUT_POST, 'forceDecision')); $errorMsg = ''; $jqId = $deciderPlugin->AgentAdd($job_pk, $uploadId, $errorMsg, $dependecies, $conflictStrategyId); if (!empty($errorMsg)) { throw new Exception(str_replace('<br>', "\n", $errorMsg)); } return $jqId; }