84 $agentDetectedLicenses = array();
86 $licenseFileMatches = $this->licenseDao->getAgentFileLicenseMatches($itemTreeBounds, $usageId);
88 foreach ($licenseFileMatches as $licenseMatch) {
89 $licenseRef = $licenseMatch->getLicenseRef();
90 $licenseId = $licenseRef->getId();
91 if ($licenseRef->getShortName() ===
"No_license_found") {
94 $agentRef = $licenseMatch->getAgentRef();
95 $agentName = $agentRef->getAgentName();
96 $agentId = $agentRef->getAgentId();
98 $agentDetectedLicenses[$agentName][$agentId][$licenseId][] = array(
100 'licenseRef' => $licenseRef,
101 'agentRef' => $agentRef,
102 'matchId' => $licenseMatch->getLicenseFileId(),
103 'percentage' => $licenseMatch->getPercentage()
117 $agentDetectedLicenses = array();
119 $licenseFileMatches = $this->licenseDao->getAgentFileLicenseMatches($itemTreeBounds);
121 foreach ($licenseFileMatches as $licenseMatch) {
122 $licenseRef = $licenseMatch->getLicenseRef();
123 $licenseId = $licenseRef->getId();
124 if ($licenseRef->getShortName() ===
"No_license_found") {
127 $agentRef = $licenseMatch->getAgentRef();
128 $agentName = $agentRef->getAgentName();
129 $agentId = $agentRef->getAgentId();
131 $agentDetectedLicenses[$agentName][$agentId][$licenseId][] = $licenseMatch;
145 $agentNames = array_keys($agentDetectedLicenses);
146 if (empty($agentNames)) {
151 $latestAgentDetectedLicenses = $this->
filterDetectedLicenses($agentDetectedLicenses, $latestAgentIdPerAgent);
152 return $latestAgentDetectedLicenses;
165 if (!array_key_exists($uploadId,$this->latestAgentMapCache)
166 || count(array_diff_key($agentNames, $this->latestAgentMapCache[$uploadId]))>0) {
167 $latestScannerProxy =
new LatestScannerProxy($uploadId, $agentNames,
"latest_scanner$uploadId");
168 $latestAgentIdPerAgent = $latestScannerProxy->getNameToIdMap();
169 foreach ($latestAgentIdPerAgent as $agentName=>$agentMap) {
170 $this->latestAgentMapCache[$uploadId][$agentName] = $agentMap;
173 if (array_key_exists($uploadId, $this->latestAgentMapCache)) {
174 return $this->latestAgentMapCache[$uploadId];
188 $latestAgentDetectedLicenses = array();
190 foreach ($agentDetectedLicenses as $agentName => $licensesFoundPerAgentId) {
191 if (!array_key_exists($agentName, $agentLatestMap)) {
194 $latestAgentId = $agentLatestMap[$agentName];
195 if (!array_key_exists($latestAgentId, $licensesFoundPerAgentId)) {
198 foreach ($licensesFoundPerAgentId[$latestAgentId] as $licenseId => $properties) {
199 $latestAgentDetectedLicenses[$licenseId][$agentName] = $properties;
203 return $latestAgentDetectedLicenses;
215 foreach ($details as $licenseId => $agentEntries) {
216 foreach ($agentEntries as $matchProperties) {
217 $licenses[$licenseId] = $matchProperties[0][
'licenseRef'];
236 foreach ($agentDetails as $licenseId => $properties) {
237 $agentClearingEvents = array();
238 foreach ($properties as $licenseProperties) {
239 foreach ($licenseProperties as $licenseProperty) {
244 $result[$licenseId] = $agentClearingEvents;
258 $licenseProperty[
'licenseRef'],
259 $licenseProperty[
'agentRef'],
260 $licenseProperty[
'matchId'],
261 array_key_exists(
'percentage', $licenseProperty) ? $licenseProperty[
'percentage'] :
null
Handle events related to license findings.
getLatestAgentIdPerAgent($uploadId, $agentNames)
Get map for agent name => agent id.
getScannedLicenses($details)
Get scanned license as a map of license-id => license-ref.
createAgentClearingEvent($licenseProperty)
Create a new AgentClearingEvent.
getScannerDetectedLicenseDetails(ItemTreeBounds $itemTreeBounds, $usageId=LicenseMap::TRIVIAL)
Get licenses match from agents for given upload tree items.
getScannerEvents(ItemTreeBounds $itemTreeBounds, $usageId=LicenseMap::TRIVIAL)
Get all scanner events that occurred on a given upload tree bound.
getScannerDetectedLicenses(ItemTreeBounds $itemTreeBounds, $usageId=LicenseMap::TRIVIAL)
Get licenses detected by agents for a given upload tree item.
filterLatestScannerDetectedMatches($agentDetectedLicenses, $uploadId)
(A->B->C->X) => C->A->X if B=latestScannerId(A)
__construct(LicenseDao $licenseDao, AgentDao $agentDao)
filterDetectedLicenses($agentDetectedLicenses, $agentLatestMap)
(A->B->C->X, A->B) => C->A->X
getLatestScannerDetectedMatches(ItemTreeBounds $itemTreeBounds)
Get all license id matches by agent for a given upload tree item.
Contains business rules for FOSSology.