45 define(
"CLEARING_DECISION_IS_GLOBAL",
false);
47 include_once(__DIR__ .
"/version.php");
55 const FORCE_DECISION = 1;
100 parent::__construct(AGENT_DECIDER_JOB_NAME, AGENT_DECIDER_JOB_VERSION, AGENT_DECIDER_JOB_REV);
102 $this->uploadDao = $this->container->get(
'dao.upload');
103 $this->clearingDao = $this->container->get(
'dao.clearing');
104 $this->highlightDao = $this->container->get(
'dao.highlight');
105 $this->decisionTypes = $this->container->get(
'decision.types');
106 $this->clearingDecisionProcessor = $this->container->get(
'businessrules.clearing_decision_processor');
107 $this->agentLicenseEventProcessor = $this->container->get(
'businessrules.agent_license_event_processor');
109 $this->agentSpecifOptions =
"k:";
122 $eventsOfThisJob = $this->clearingDao->getEventIdsOfJob(
$jobId);
123 foreach ($eventsOfThisJob as $uploadTreeId => $additionalEventsFromThisJob) {
124 $containerBounds = $this->uploadDao->getItemTreeBounds($uploadTreeId);
138 if (!$itemTreeBounds->containsFiles()) {
139 return array($itemTreeBounds);
142 $condition =
"(ut.lft BETWEEN $1 AND $2) AND ((ut.ufile_mode & (3<<28)) = 0)";
143 $params = array($itemTreeBounds->getLeft(), $itemTreeBounds->getRight());
144 foreach ($this->uploadDao->getContainedItems($itemTreeBounds, $condition, $params) as $item) {
145 $result[] = $item->getItemTreeBounds();
157 $this->conflictStrategyId = array_key_exists(
'k',
$args) ?
$args[
'k'] :
null;
159 $this->licenseMap =
new LicenseMap($this->
dbManager, $this->groupId, $this->licenseMapUsage);
161 if ($this->conflictStrategyId ==
'global') {
163 if (!empty($this->clearingDao->getCandidateLicenseCountForCurrentDecisions($uploadTreeId, $uploadId))) {
164 throw new \Exception( _(
"Cannot add candidate license as global decision\n") );
167 $this->
heartbeat($this->clearingDao->marklocalDecisionsAsGlobal($uploadId));
187 switch ($this->conflictStrategyId) {
188 case self::FORCE_DECISION:
189 $createDecision =
true;
193 $createDecision = !$this->clearingDecisionProcessor->hasUnhandledScannerDetectedLicenses($itemTreeBounds,
$groupId, $additionalEventsFromThisJob, $this->licenseMap);
196 if ($createDecision) {
197 $this->clearingDecisionProcessor->makeDecisionFromLastEvents($itemTreeBounds,
$userId,
$groupId, DecisionTypes::IDENTIFIED, $this->decisionIsGlobal, $additionalEventsFromThisJob);
199 foreach ($additionalEventsFromThisJob as $eventId) {
200 $this->clearingDao->copyEventIdTo($eventId, $itemId,
$userId,
$groupId);
Get the decision from Monk bulk and apply decisions.
processUploadId($uploadId)
Given an upload ID, process the items in it.
processClearingEventOfCurrentJob()
Process clearing events of current job handled by agent.
$agentLicenseEventProcessor
loopContainedItems($itemTreeBounds)
Get items contained inside an item tree.
$clearingDecisionProcessor
processClearingEventsForItem(ItemTreeBounds $itemTreeBounds, $userId, $groupId, $additionalEventsFromThisJob)
Get an item, process events and create new decisions.
Structure of an Agent with all required parameters.
heartbeat($newProcessed)
Send hear beat to the scheduler.
Handle events related to license findings.
Utility functions to process ClearingDecision.
Wrapper class for license map.
fo_dbManager * dbManager
fo_dbManager object
Namespace of DeciderJob agent.