56 define(
"CLEARING_DECISION_IS_GLOBAL",
false);
58 include_once(__DIR__ .
"/version.php");
66 const FORCE_DECISION = 1;
111 parent::__construct(AGENT_DECIDER_JOB_NAME, AGENT_DECIDER_JOB_VERSION, AGENT_DECIDER_JOB_REV);
113 $this->uploadDao = $this->container->get(
'dao.upload');
114 $this->clearingDao = $this->container->get(
'dao.clearing');
115 $this->highlightDao = $this->container->get(
'dao.highlight');
116 $this->decisionTypes = $this->container->get(
'decision.types');
117 $this->clearingDecisionProcessor = $this->container->get(
'businessrules.clearing_decision_processor');
118 $this->agentLicenseEventProcessor = $this->container->get(
'businessrules.agent_license_event_processor');
120 $this->agentSpecifOptions =
"k:";
133 $eventsOfThisJob = $this->clearingDao->getEventIdsOfJob(
$jobId);
134 foreach ($eventsOfThisJob as $uploadTreeId => $additionalEventsFromThisJob) {
135 $containerBounds = $this->uploadDao->getItemTreeBounds($uploadTreeId);
149 if (!$itemTreeBounds->containsFiles()) {
150 return array($itemTreeBounds);
153 $condition =
"(ut.lft BETWEEN $1 AND $2) AND ((ut.ufile_mode & (3<<28)) = 0)";
154 $params = array($itemTreeBounds->getLeft(), $itemTreeBounds->getRight());
155 foreach ($this->uploadDao->getContainedItems($itemTreeBounds, $condition, $params) as $item) {
156 $result[] = $item->getItemTreeBounds();
168 $this->conflictStrategyId = array_key_exists(
'k',
$args) ?
$args[
'k'] : null;
170 $this->licenseMap =
new LicenseMap($this->
dbManager, $this->groupId, $this->licenseMapUsage);
172 if ($this->conflictStrategyId ==
'global') {
174 if (!empty($this->clearingDao->getCandidateLicenseCountForCurrentDecisions($uploadTreeId, $uploadId))) {
175 throw new \Exception( _(
"Cannot add candidate license as global decision\n") );
178 $this->
heartbeat($this->clearingDao->marklocalDecisionsAsGlobal($uploadId));
198 switch ($this->conflictStrategyId) {
199 case self::FORCE_DECISION:
200 $createDecision =
true;
204 $createDecision = !$this->clearingDecisionProcessor->hasUnhandledScannerDetectedLicenses($itemTreeBounds,
$groupId, $additionalEventsFromThisJob, $this->licenseMap);
207 if ($createDecision) {
208 $this->clearingDecisionProcessor->makeDecisionFromLastEvents($itemTreeBounds,
$userId,
$groupId, DecisionTypes::IDENTIFIED, $this->decisionIsGlobal, $additionalEventsFromThisJob);
210 foreach ($additionalEventsFromThisJob as $eventId) {
211 $this->clearingDao->copyEventIdTo($eventId, $itemId,
$userId,
$groupId);
heartbeat($newProcessed)
Send hear beat to the scheduler.
Namespace of DeciderJob agent.
processUploadId($uploadId)
Given an upload ID, process the items in it.
Structure of an Agent with all required parameters.
Wrapper class for license map.
$clearingDecisionProcessor
processClearingEventOfCurrentJob()
Process clearing events of current job handled by agent.
$agentLicenseEventProcessor
fo_dbManager * dbManager
fo_dbManager object
loopContainedItems($itemTreeBounds)
Get items contained inside an item tree.
Get the decision from Monk bulk and apply decisions.
processClearingEventsForItem(ItemTreeBounds $itemTreeBounds, $userId, $groupId, $additionalEventsFromThisJob)
Get an item, process events and create new decisions.