8 namespace Fossology\Lib\Report;
30 public function __construct()
33 $this->licenseDao = $container->get(
'dao.license');
34 $this->uploadDao = $container->get(
'dao.upload');
46 function getObligations($licenseStatements, $mainLicenseStatements, $uploadId, $groupId)
48 $whiteLists = array();
49 $licenseIds = $this->
contentOnly($licenseStatements) ?: array();
50 $mainLicenseIds = $this->
contentOnly($mainLicenseStatements);
52 if (!empty($mainLicenseIds)) {
53 $allLicenseIds = array_unique(array_merge($licenseIds, $mainLicenseIds));
55 $allLicenseIds = array_unique($licenseIds);
58 $obligationRef = $this->licenseDao->getLicenseObligations($allLicenseIds) ?: array();
59 $obligationCandidate = $this->licenseDao->getLicenseObligations($allLicenseIds,
true) ?: array();
60 $obligations = array_merge($obligationRef, $obligationCandidate);
61 $onlyLicenseIdsWithObligation = array_column($obligations,
'rf_fk');
62 $licenseWithObligations = array_unique(array_intersect($onlyLicenseIdsWithObligation, $allLicenseIds));
63 $licenseWithoutObligations = array_diff($allLicenseIds, $licenseWithObligations) ?: array();
64 foreach ($licenseWithoutObligations as $licenseWithoutObligation) {
65 $license = $this->licenseDao->getLicenseById($licenseWithoutObligation);
66 if (!empty($license)) {
67 $whiteLists[] = $license->getSpdxId();
71 return array($newobligations, array_unique(array_merge($whiteLists, $newWhiteList)));
83 $row = $this->uploadDao->getReportInfo($uploadId);
84 $excludedObligations = (array) json_decode($row[
'ri_excluded_obligations'],
true);
85 foreach ($obligations as $obligation ) {
86 $obTopic = $obligation[
'ob_topic'];
87 $obText = $obligation[
'ob_text'];
89 $obligation[
'rf_spdx_id']);
91 if (!empty($excludedObligations) && array_key_exists($obTopic, $excludedObligations)) {
92 $obligationLicenseNames = $excludedObligations[$obTopic];
94 $obligationLicenseNames = array();
96 if (!in_array($licenseName, $obligationLicenseNames)) {
97 if (array_key_exists($groupBy, $groupedOb)) {
98 $currentLics = &$groupedOb[$groupBy][
'license'];
99 if (!in_array($licenseName, $currentLics)) {
100 $currentLics[] = $licenseName;
106 "license" => array($licenseName)
108 $groupedOb[$groupBy] = $singleOb;
111 if (!in_array($licenseName, $whiteList)) {
112 $whiteList[] = $licenseName;
119 foreach ($groupedOb as $obli) {
120 $whiteList = array_diff($whiteList, $obli[
'license']);
122 return [$groupedOb, $whiteList];
133 foreach ($licenseStatements as $licenseStatement) {
134 $licenseId[] = $licenseStatement[
"licenseId"];
static convertToSpdxId($shortname, $spdxId)
Given a license's shortname and spdx id, give out spdx id to use in reports.
groupObligations($obligations, $uploadId)
Group obligations based on $groupBy.
contentOnly($licenseStatements)
From a list of license statements, return only license id.
getObligations($licenseStatements, $mainLicenseStatements, $uploadId, $groupId)
For given list of license statements, return obligations and white lists.
list_t type structure used to keep various lists. (e.g. there are multiple lists).