예제 #1
0
 public function testGetClearedLicenseMultiplicities()
 {
     $user = 1;
     $groupId = 601;
     $rf = 401;
     $isRm = false;
     $t = -10815;
     $this->buildProposals(array(array(303, $user, $groupId, $rf, $isRm, $t), array(305, $user, $groupId, $rf, $isRm, $t + 1)), $eventId = 0);
     $type = DecisionTypes::IDENTIFIED;
     $scope = DecisionScopes::ITEM;
     $this->buildDecisions(array(array(303, $user, $groupId, $type, $t, $scope, array($eventId)), array(305, $user, $groupId, $type, $t, $scope, array($eventId + 1))));
     $treeBounds = M::mock(ItemTreeBounds::classname());
     $treeBounds->shouldReceive('getLeft')->andReturn(1);
     $treeBounds->shouldReceive('getRight')->andReturn(8);
     $treeBounds->shouldReceive('getUploadTreeTableName')->andReturn("uploadtree");
     $treeBounds->shouldReceive('getUploadId')->andReturn(102);
     $map = $this->clearingDao->getClearedLicenseIdAndMultiplicities($treeBounds, $groupId);
     assertThat($map, is(array('FOO' => array('count' => 2, 'shortname' => 'FOO', 'rf_pk' => 401))));
 }
예제 #2
0
 /**
  * @param $uploadTreeId
  * @param $tagId
  * @param ItemTreeBounds $itemTreeBounds
  * @param int|int[] $agentIds
  * @param ClearingDecision []
  * @return array
  */
 private function createLicenseHistogram($uploadTreeId, $tagId, ItemTreeBounds $itemTreeBounds, $agentIds, $groupId)
 {
     $fileCount = $this->uploadDao->countPlainFiles($itemTreeBounds);
     $licenseHistogram = $this->licenseDao->getLicenseHistogram($itemTreeBounds, $agentIds);
     $editedLicensesHist = $this->clearingDao->getClearedLicenseIdAndMultiplicities($itemTreeBounds, $groupId);
     $agentId = GetParm('agentId', PARM_INTEGER);
     $licListUri = Traceback_uri() . "?mod=license_list_files&item={$uploadTreeId}";
     if ($tagId) {
         $licListUri .= "&tag={$tagId}";
     }
     if ($agentId) {
         $licListUri .= "&agentId={$agentId}";
     }
     /* Write license histogram to $VLic  */
     list($tableData, $totalScannerLicenseCount, $editedTotalLicenseCount) = $this->createLicenseHistogramJSarray($licenseHistogram, $editedLicensesHist, $licListUri);
     $uniqueLicenseCount = count($tableData);
     $scannerUniqueLicenseCount = count($licenseHistogram);
     $editedUniqueLicenseCount = count($editedLicensesHist);
     $noScannerLicenseFoundCount = array_key_exists(LicenseDao::NO_LICENSE_FOUND, $licenseHistogram) ? $licenseHistogram[LicenseDao::NO_LICENSE_FOUND]['count'] : 0;
     $editedNoLicenseFoundCount = array_key_exists(LicenseDao::NO_LICENSE_FOUND, $editedLicensesHist) ? $editedLicensesHist[LicenseDao::NO_LICENSE_FOUND]['count'] : 0;
     $vars = array('tableDataJson' => json_encode($tableData), 'uniqueLicenseCount' => $uniqueLicenseCount, 'fileCount' => $fileCount, 'scannerUniqueLicenseCount' => $scannerUniqueLicenseCount, 'editedUniqueLicenseCount' => $editedUniqueLicenseCount, 'scannerLicenseCount' => $totalScannerLicenseCount, 'editedLicenseCount' => $editedTotalLicenseCount - $editedNoLicenseFoundCount, 'noScannerLicenseFoundCount' => $noScannerLicenseFoundCount, 'editedNoLicenseFoundCount' => $editedNoLicenseFoundCount, 'scannerLicenses' => $licenseHistogram, 'editedLicenses' => $editedLicensesHist);
     return $vars;
 }