95 $agentDetectedLicenses = array();
97 $licenseFileMatches = $this->licenseDao->getAgentFileLicenseMatches($itemTreeBounds, $usageId);
99 foreach ($licenseFileMatches as $licenseMatch) {
100 $licenseRef = $licenseMatch->getLicenseRef();
101 $licenseId = $licenseRef->getId();
102 if ($licenseRef->getShortName() ===
"No_license_found") {
105 $agentRef = $licenseMatch->getAgentRef();
106 $agentName = $agentRef->getAgentName();
107 $agentId = $agentRef->getAgentId();
109 $agentDetectedLicenses[$agentName][$agentId][$licenseId][] = array(
111 'licenseRef' => $licenseRef,
112 'agentRef' => $agentRef,
113 'matchId' => $licenseMatch->getLicenseFileId(),
114 'percentage' => $licenseMatch->getPercentage()
128 $agentDetectedLicenses = array();
130 $licenseFileMatches = $this->licenseDao->getAgentFileLicenseMatches($itemTreeBounds);
132 foreach ($licenseFileMatches as $licenseMatch) {
133 $licenseRef = $licenseMatch->getLicenseRef();
134 $licenseId = $licenseRef->getId();
135 if ($licenseRef->getShortName() ===
"No_license_found") {
138 $agentRef = $licenseMatch->getAgentRef();
139 $agentName = $agentRef->getAgentName();
140 $agentId = $agentRef->getAgentId();
142 $agentDetectedLicenses[$agentName][$agentId][$licenseId][] = $licenseMatch;
156 $agentNames = array_keys($agentDetectedLicenses);
157 if (empty($agentNames)) {
162 $latestAgentDetectedLicenses = $this->
filterDetectedLicenses($agentDetectedLicenses, $latestAgentIdPerAgent);
163 return $latestAgentDetectedLicenses;
176 if (!array_key_exists($uploadId,$this->latestAgentMapCache)
177 || count(array_diff_key($agentNames, $this->latestAgentMapCache[$uploadId]))>0) {
178 $latestScannerProxy =
new LatestScannerProxy($uploadId, $agentNames,
"latest_scanner$uploadId");
179 $latestAgentIdPerAgent = $latestScannerProxy->getNameToIdMap();
180 foreach ($latestAgentIdPerAgent as $agentName=>$agentMap) {
181 $this->latestAgentMapCache[$uploadId][$agentName] = $agentMap;
184 if (array_key_exists($uploadId, $this->latestAgentMapCache)) {
185 return $this->latestAgentMapCache[$uploadId];
199 $latestAgentDetectedLicenses = array();
201 foreach ($agentDetectedLicenses as $agentName => $licensesFoundPerAgentId) {
202 if (!array_key_exists($agentName, $agentLatestMap)) {
205 $latestAgentId = $agentLatestMap[$agentName];
206 if (!array_key_exists($latestAgentId, $licensesFoundPerAgentId)) {
209 foreach ($licensesFoundPerAgentId[$latestAgentId] as $licenseId => $properties) {
210 $latestAgentDetectedLicenses[$licenseId][$agentName] = $properties;
214 return $latestAgentDetectedLicenses;
226 foreach ($details as $licenseId => $agentEntries) {
227 foreach ($agentEntries as $matchProperties) {
228 $licenses[$licenseId] = $matchProperties[0][
'licenseRef'];
247 foreach ($agentDetails as $licenseId => $properties) {
248 $agentClearingEvents = array();
249 foreach ($properties as $licenseProperties) {
250 foreach ($licenseProperties as $licenseProperty) {
255 $result[$licenseId] = $agentClearingEvents;
269 $licenseProperty[
'licenseRef'],
270 $licenseProperty[
'agentRef'],
271 $licenseProperty[
'matchId'],
272 array_key_exists(
'percentage', $licenseProperty) ? $licenseProperty[
'percentage'] : null
getLatestScannerDetectedMatches(ItemTreeBounds $itemTreeBounds)
Get all license id matches by agent for a given upload tree item.
__construct(LicenseDao $licenseDao, AgentDao $agentDao)
getScannerDetectedLicenses(ItemTreeBounds $itemTreeBounds, $usageId=LicenseMap::TRIVIAL)
Get licenses detected by agents for a given upload tree item.
filterDetectedLicenses($agentDetectedLicenses, $agentLatestMap)
(A->B->C->X, A->B) => C->A->X
filterLatestScannerDetectedMatches($agentDetectedLicenses, $uploadId)
(A->B->C->X) => C->A->X if B=latestScannerId(A)
getLatestAgentIdPerAgent($uploadId, $agentNames)
Get map for agent name => agent id.
Handle events related to license findings.
getScannerEvents(ItemTreeBounds $itemTreeBounds, $usageId=LicenseMap::TRIVIAL)
Get all scanner events that occurred on a given upload tree bound.
Contains business rules for FOSSology.
getScannedLicenses($details)
Get scanned license as a map of license-id => license-ref.
getScannerDetectedLicenseDetails(ItemTreeBounds $itemTreeBounds, $usageId=LicenseMap::TRIVIAL)
Get licenses match from agents for given upload tree items.
createAgentClearingEvent($licenseProperty)
Create a new AgentClearingEvent.