Ejemplo n.º 1
0
 public function testGetAgentClearingEvents()
 {
     $this->licenseDecisionResult = new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1, $this->agentClearingEvent2));
     assertThat($this->licenseDecisionResult->getAgentDecisionEvents(), is(array($this->agentClearingEvent1, $this->agentClearingEvent2)));
 }
 /**
  * @param ItemTreeBounds $itemTreeBounds
  * @param int $groupId
  * @return array
  * @throws Exception
  */
 public function getCurrentClearings(ItemTreeBounds $itemTreeBounds, $groupId, $usageId = LicenseMap::TRIVIAL)
 {
     $agentEvents = $this->agentLicenseEventProcessor->getScannerEvents($itemTreeBounds, $usageId);
     $events = $this->clearingDao->getRelevantClearingEvents($itemTreeBounds, $groupId);
     $addedResults = array();
     $removedResults = array();
     foreach (array_unique(array_merge(array_keys($events), array_keys($agentEvents))) as $licenseId) {
         $licenseDecisionEvent = array_key_exists($licenseId, $events) ? $events[$licenseId] : null;
         $agentClearingEvents = array_key_exists($licenseId, $agentEvents) ? $agentEvents[$licenseId] : array();
         if ($licenseDecisionEvent === null && count($agentClearingEvents) == 0) {
             throw new Exception('not in merge');
         }
         $licenseDecisionResult = new ClearingResult($licenseDecisionEvent, $agentClearingEvents);
         if ($licenseDecisionResult->isRemoved()) {
             $removedResults[$licenseId] = $licenseDecisionResult;
         } else {
             $addedResults[$licenseId] = $licenseDecisionResult;
         }
     }
     return array($addedResults, $removedResults);
 }
Ejemplo n.º 3
0
 /**
  * @param ClearingResult $licenseDecisionResult
  * @param string $uberUri
  * @param int $uploadTreeId
  * @return array
  */
 protected function getAgentInfo($licenseDecisionResult, $uberUri, $uploadTreeId)
 {
     $agentResults = array();
     foreach ($licenseDecisionResult->getAgentDecisionEvents() as $agentDecisionEvent) {
         $agentId = $agentDecisionEvent->getAgentId();
         $matchId = $agentDecisionEvent->getMatchId();
         $percentage = $agentDecisionEvent->getPercentage();
         $agentResults[$agentDecisionEvent->getAgentName()][] = array("uri" => $uberUri . "&item={$uploadTreeId}&agentId={$agentId}&highlightId={$matchId}#highlight", "text" => $percentage ? " (" . $percentage . " %)" : "");
     }
     $results = array();
     foreach ($agentResults as $agentName => $agentResult) {
         $matchTexts = array();
         foreach ($agentResult as $index => $agentData) {
             $uri = $agentData['uri'];
             $matchTexts[] = "<a href=\"{$uri}\">#" . ($index + 1) . "</a>" . $agentData['text'];
         }
         $results[] = $agentName . ": " . implode(', ', $matchTexts);
     }
     return $results;
 }