35 $clearingDecisionsMapped = array();
37 foreach ($clearingDecisions as $clearingDecision) {
38 if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
41 $itemId = $clearingDecision->getUploadTreeId();
42 $fileId = $clearingDecision->getPfileId();
43 $scope = $clearingDecision->getScope();
46 case DecisionScopes::ITEM:
47 $clearingDecisionsMapped[$fileId][$itemId] = $clearingDecision;
50 case DecisionScopes::REPO:
51 $clearingDecisionsMapped[$fileId][
self::KEYREPO] = $clearingDecision;
55 throw new \InvalidArgumentException(
"unhandled clearing decision scope '" . $scope .
"'");
59 return $clearingDecisionsMapped;
72 $clearingDecisionsForLicList = array();
74 foreach ($clearingDecisions as $clearingDecision) {
76 if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
80 foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
81 if ($clearingLicense->isRemoved()) {
84 $itemId = $clearingDecision->getUploadTreeId();
85 $clearingDecisionsForLicList[$itemId][] = $clearingLicense->getShortName();
88 return $clearingDecisionsForLicList;
97 public function filterCurrentReusableClearingDecisions($clearingDecisions)
100 $clearingDecisionsByItemId = array();
101 foreach ($clearingDecisions as $clearingDecision) {
102 $itemId = $clearingDecision->getUploadTreeId();
103 $clearingDecisionsByItemId[$itemId] = $clearingDecision;
105 return $clearingDecisionsByItemId;
115 if (array_key_exists($pfileId, $decisionMap)) {
116 $pfileMap = $decisionMap[$pfileId];
117 if (array_key_exists($itemId, $pfileMap)) {
118 return $pfileMap[$itemId];
120 if (array_key_exists(self::KEYREPO, $pfileMap)) {
139 $clearingDecisionsForCopyList = array();
141 foreach ($clearingDecisions as $clearingDecision) {
142 $itemId = $clearingDecision->getUploadTreeId();
143 $clearingDecisionsForCopyList[$itemId] = array();
144 if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
145 $clearingDecisionsForCopyList[$itemId][] =
"Void";
149 foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
150 if ($clearingLicense->isRemoved()) {
153 $clearingDecisionsForCopyList[$itemId][] = $clearingLicense->getShortName();
155 if (empty($clearingDecisionsForCopyList[$itemId])) {
156 $clearingDecisionsForCopyList[$itemId][] =
"Void";
159 return $clearingDecisionsForCopyList;
Various utility functions to filter ClearingDecision.
filterCurrentClearingDecisions($clearingDecisions)
Get the clearing decisions as a map of [<pfile-id>] => [<uploadtree-id>] => decision
getDecisionOf($decisionMap, $itemId, $pfileId)
For a given decision map, get the decision of the given item or pfile id.
filterCurrentClearingDecisionsForCopyrightList($clearingDecisions)
Get clearing decision as map of <item-id> => <license-shortnames> for copyright list.
filterCurrentClearingDecisionsForLicenseList($clearingDecisions)
Get clearing decision as map of <item-id> => <license-shortnames>
Contains business rules for FOSSology.