34 private $onlyComments =
false;
36 private $onlyAcknowledgements =
false;
44 private $licenseCache = array();
46 protected $agentNames = AgentRef::AGENT_LIST;
48 public function __construct()
52 $this->clearingDao = $container->get(
'dao.clearing');
53 $this->licenseDao = $container->get(
'dao.license');
54 $this->agentDao = $container->get(
'dao.agent');
56 parent::__construct($groupBy =
'text');
59 protected function getStatements($uploadId, $uploadTreeTableName, $groupId = null)
61 $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId,$uploadTreeTableName);
62 $clearingDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId);
63 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
64 $licenseMap =
new LicenseMap($dbManager, $groupId, LicenseMap::REPORT);
65 $ungroupedStatements = array();
66 foreach ($clearingDecisions as $clearingDecision) {
67 if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
71 foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
72 if ($clearingLicense->isRemoved()) {
76 if ($this->onlyComments && !($comment = $clearingLicense->getComment())) {
80 if ($this->onlyAcknowledgements && !($acknowledgement = $clearingLicense->getAcknowledgement())) {
84 $originLicenseId = $clearingLicense->getLicenseId();
85 $licenseId = $licenseMap->getProjectedId($originLicenseId);
87 if ($this->onlyAcknowledgements) {
88 $text = $acknowledgement;
90 }
else if ($this->onlyComments) {
94 $reportInfo = $clearingLicense->getReportInfo();
99 $ungroupedStatements[] = array(
100 'licenseId' => $licenseId,
102 'content' => $licenseMap->getProjectedShortname($originLicenseId, $clearingLicense->getShortName()),
103 'uploadtree_pk' => $clearingDecision->getUploadTreeId(),
109 return $ungroupedStatements;
117 $this->onlyAcknowledgements =
false;
118 $this->onlyComments = $displayOnlyCommentedLicenseClearings;
126 $this->onlyComments =
false;
127 $this->onlyAcknowledgements = $displayOnlyAcknowledgements;
136 if (!array_key_exists($licenseId, $this->licenseCache)) {
137 $this->licenseCache[$licenseId] = $this->licenseDao->getLicenseById($licenseId, $groupId);
139 return $this->licenseCache[$licenseId]->getText();
148 if (!array_key_exists($licenseId, $this->licenseCache)) {
149 $this->licenseCache[$licenseId] = $this->licenseDao->getLicenseById($licenseId, $groupId);
151 return $this->licenseCache[$licenseId]->getRisk();
160 $LicenseHistArray = array();
161 $scannerAgents = array_keys($this->agentNames);
162 $scanJobProxy =
new ScanJobProxy($this->agentDao, $uploadId);
163 $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents);
164 $allAgentIds = $scanJobProxy->getLatestSuccessfulAgentIds();
165 $itemTreeBounds = $this->uploadDao->getParentItemBounds($uploadId);
166 $scannerLicenseHistogram = $this->licenseDao->getLicenseHistogram($itemTreeBounds, $allAgentIds);
167 $editedLicensesHist = $this->clearingDao->getClearedLicenseIdAndMultiplicities($itemTreeBounds, $groupId);
168 $noScannerLicenseFoundCount = array_key_exists(LicenseDao::NO_LICENSE_FOUND, $scannerLicenseHistogram)
169 ? $scannerLicenseHistogram[LicenseDao::NO_LICENSE_FOUND][
'count'] : 0;
170 $editedNoLicenseFoundCount = array_key_exists(LicenseDao::NO_LICENSE_FOUND, $editedLicensesHist)
171 ? $editedLicensesHist[LicenseDao::NO_LICENSE_FOUND][
'count'] : 0;
173 $totalLicenses = array_unique(array_merge(array_keys($scannerLicenseHistogram), array_keys($editedLicensesHist)));
174 foreach ($totalLicenses as $licenseShortName) {
176 if (array_key_exists($licenseShortName, $scannerLicenseHistogram)) {
177 $count = $scannerLicenseHistogram[$licenseShortName][
'unique'];
179 $editedCount = array_key_exists($licenseShortName, $editedLicensesHist) ? $editedLicensesHist[$licenseShortName][
'count'] : 0;
180 if (strcmp($licenseShortName, LicenseDao::NO_LICENSE_FOUND) !== 0) {
181 $LicenseHistArray[] = array(
"scannerCount" => $count,
"editedCount" => $editedCount,
"licenseShortname" => $licenseShortName);
183 $LicenseHistArray[] = array(
"scannerCount" => $noScannerLicenseFoundCount,
"editedCount" => $editedNoLicenseFoundCount,
"licenseShortname" => $licenseShortName);
186 return $LicenseHistArray;
197 return strcmp($licenses1[
'licenseId'], $licenses2[
'licenseId']);
208 $onlyMainLic = array_udiff($licensesMain, $licenses, array($this,
"checkLicenseId"));
209 $mainLicensesInIdetifiedFiles = array_uintersect($licenses, $licensesMain, array($this,
"checkLicenseId"));
210 $onlyLicense = array_udiff($licenses, $licensesMain, array($this,
"checkLicenseId"));
212 array_values(array_merge($onlyMainLic, $mainLicensesInIdetifiedFiles)),
213 array_values($onlyLicense)
checkLicenseId($licenses1, $licenses2)
callback to compare licenses
getHistogram($uploadId, $groupId)
updateIdentifiedGlobalLicenses($licensesMain, $licenses)
Copy identified global licenses.
Wrapper class for license map.
setOnlyAcknowledgements($displayOnlyAcknowledgements)
getCachedLicenseRisk($licenseId, $groupId)
setOnlyComments($displayOnlyCommentedLicenseClearings)
getStatements($uploadId, $uploadTreeTableName, $groupId=null)
getCachedLicenseText($licenseId, $groupId)