46 public function __construct()
49 $this->licenseDao = $container->get(
'dao.license');
50 $this->clearingDao = $container->get(
'dao.clearing');
51 $this->uploadDao = $container->get(
'dao.upload');
63 function getObligations($licenseStatements, $mainLicenseStatements, $uploadId, $groupId)
65 $licenseIds = $this->
contentOnly($licenseStatements) ?: array();
66 $mainLicenseIds = $this->
contentOnly($mainLicenseStatements);
68 if (! empty($mainLicenseIds)) {
69 $allLicenseIds = array_unique(array_merge($licenseIds, $mainLicenseIds));
71 $allLicenseIds = array_unique($licenseIds);
75 $obligationRef = $this->licenseDao->getLicenseObligations($allLicenseIds,
'obligation_map') ?: array();
76 $obligationCandidate = $this->licenseDao->getLicenseObligations($allLicenseIds,
'obligation_candidate_map') ?: array();
77 $obligations = array_merge($obligationRef, $obligationCandidate);
78 $onlyLicenseIdsWithObligation = array_column($obligations,
'rf_fk');
79 if (!empty($bulkAddIds)) {
80 $onlyLicenseIdsWithObligation = array_unique(array_merge($onlyLicenseIdsWithObligation, $bulkAddIds));
82 $licenseWithoutObligations = array_diff($allLicenseIds, $onlyLicenseIdsWithObligation) ?: array();
83 foreach ($licenseWithoutObligations as $licenseWithoutObligation) {
84 $license = $this->licenseDao->getLicenseById($licenseWithoutObligation);
85 if (!empty($license)) {
86 $whiteLists[] = $license->getShortName();
90 return array($newobligations, $whiteLists);
101 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
102 $parentTreeBounds = $this->uploadDao->getParentItemBounds($uploadId, $uploadTreeTableName);
103 $bulkHistory = $this->clearingDao->getBulkHistory($parentTreeBounds, $groupId,
false);
104 if (!empty($bulkHistory)) {
105 $licenseLists = array_column($bulkHistory,
'addedLicenses');
106 $allLicenses = array();
107 foreach ($licenseLists as $licenseList) {
108 $allLicenses = array_unique(array_merge($allLicenses, $licenseList));
110 foreach ($allLicenses as $allLicense) {
111 $license = $this->licenseDao->getLicenseByShortName($allLicense);
112 if (!empty($license)) {
113 $licenseId[] = $license->getId();
127 $groupedOb = array();
128 $row = $this->uploadDao->getReportInfo($uploadId);
129 $excludedObligations = (array) json_decode($row[
'ri_excluded_obligations'],
true);
130 foreach ($obligations as $obligation ) {
131 $obTopic = $obligation[
'ob_topic'];
132 $obText = $obligation[
'ob_text'];
133 $licenseName = $obligation[
'rf_shortname'];
135 if (!in_array($licenseName,(array) $excludedObligations[$obTopic])) {
136 if (array_key_exists($groupBy, $groupedOb)) {
137 $currentLics = &$groupedOb[$groupBy][
'license'];
138 if (!in_array($licenseName, $currentLics)) {
139 $currentLics[] = $licenseName;
145 "license" => array($licenseName)
147 $groupedOb[$groupBy] = $singleOb;
161 foreach ($licenseStatements as $licenseStatement) {
162 $licenseId[] = $licenseStatement[
"licenseId"];
getObligations($licenseStatements, $mainLicenseStatements, $uploadId, $groupId)
For given list of license statements, return obligations and white lists.
contentOnly($licenseStatements)
From a list of license statements, return only license id.
getBulkAddLicenseList($uploadId, $groupId)
Get list of licenses added by Monk bulk.
groupObligations($obligations, $uploadId)
Group obligations based on $groupBy.