function testWip() { $groupId = 701; $this->buildProposals(array(array(301, 1, $groupId, 401, false, -99), array(301, 1, $groupId, 402, false, -98), array(301, 1, $groupId, 401, true, -89)), $firstEventId = 0); $this->buildDecisions(array(array(301, 1, $groupId, DecisionTypes::IDENTIFIED, -90, DecisionScopes::REPO, array($firstEventId, $firstEventId + 1)))); $watchThis = $this->clearingDao->isDecisionWip(301, $groupId); assertThat($watchThis, is(FALSE)); $watchOther = $this->clearingDao->isDecisionWip(303, $groupId); assertThat($watchOther, is(FALSE)); $this->buildProposals(array(array(301, 1, $groupId, 403, false, -89)), $firstEventId + 3); $this->clearingDao->markDecisionAsWip(301, 1, $groupId); $watchThisNow = $this->clearingDao->isDecisionWip(301, $groupId); assertThat($watchThisNow, is(TRUE)); $watchOtherNow = $this->clearingDao->isDecisionWip(303, $groupId); assertThat($watchOtherNow, is(FALSE)); }
/** * @param ItemTreeBounds $itemTreeBounds * @param int $userId */ protected function processClearingEventsForItem(ItemTreeBounds $itemTreeBounds, $userId, $groupId, $additionalEventsFromThisJob) { $this->dbManager->begin(); $itemId = $itemTreeBounds->getItemId(); switch ($this->conflictStrategyId) { case self::FORCE_DECISION: $createDecision = true; break; default: $createDecision = !$this->clearingDecisionProcessor->hasUnhandledScannerDetectedLicenses($itemTreeBounds, $groupId, $additionalEventsFromThisJob, $this->licenseMap); } if ($createDecision) { $this->clearingDecisionProcessor->makeDecisionFromLastEvents($itemTreeBounds, $userId, $groupId, DecisionTypes::IDENTIFIED, $this->decisionIsGlobal, $additionalEventsFromThisJob); } else { foreach ($additionalEventsFromThisJob as $eventId) { $this->clearingDao->copyEventIdTo($eventId, $itemId, $userId, $groupId); } $this->clearingDao->markDecisionAsWip($itemId, $userId, $groupId); } $this->heartbeat(1); $this->dbManager->commit(); }
private function processItem(Item $item) { $itemTreeBounds = $item->getItemTreeBounds(); $unMappedMatches = $this->agentLicenseEventProcessor->getLatestScannerDetectedMatches($itemTreeBounds); $projectedScannerMatches = $this->remapByProjectedId($unMappedMatches); $lastDecision = $this->clearingDao->getRelevantClearingDecision($itemTreeBounds, $this->groupId); if (null !== $lastDecision && $lastDecision->getType() == DecisionTypes::IRRELEVANT) { return 0; } $currentEvents = $this->clearingDao->getRelevantClearingEvents($itemTreeBounds, $this->groupId); $markAsWip = false; if (null !== $lastDecision && $projectedScannerMatches && ($this->activeRules & self::RULES_WIP_SCANNER_UPDATES) == self::RULES_WIP_SCANNER_UPDATES) { $licensesFromDecision = array(); foreach ($lastDecision->getClearingLicenses() as $clearingLicense) { $licenseIdFromEvent = $this->licenseMap->getProjectedId($clearingLicense->getLicenseId()); $licensesFromDecision[$licenseIdFromEvent] = $licenseIdFromEvent; } $markAsWip = $this->existsUnhandledMatch($projectedScannerMatches, $licensesFromDecision); } if (null !== $lastDecision && $markAsWip) { $this->clearingDao->markDecisionAsWip($item->getId(), $this->userId, $this->groupId); return 1; } if (null !== $lastDecision || 0 < count($currentEvents)) { return 0; } $haveDecided = false; if (($this->activeRules & self::RULES_NOMOS_IN_MONK) == self::RULES_NOMOS_IN_MONK) { $haveDecided = $this->autodecideNomosMatchesInsideMonk($itemTreeBounds, $projectedScannerMatches); } if (!$haveDecided && ($this->activeRules & self::RULES_NOMOS_MONK_NINKA) == self::RULES_NOMOS_MONK_NINKA) { $haveDecided = $this->autodecideNomosMonkNinka($itemTreeBounds, $projectedScannerMatches); } if (!$haveDecided && $markAsWip) { $this->clearingDao->markDecisionAsWip($item->getId(), $this->userId, $this->groupId); } return $haveDecided || $markAsWip ? 1 : 0; }