14 namespace Fossology\DecisionImporter;
21 define(
"DECISIONIMPORTER_AGENT_NAME",
"decisionimporter");
26 include_once(__DIR__ .
"/version.php");
27 require_once
"DecisionImporterIdFetcher.php";
28 require_once
"FoDecisionData.php";
29 require_once
"DecisionImporterDataCreator.php";
81 parent::__construct(DECISIONIMPORTER_AGENT_NAME, AGENT_VERSION, AGENT_REV);
83 $this->agentSpecifLongOptions[] = self::REPORT_KEY .
':';
84 foreach (self::LONG_OPT_KEYS as $opt) {
85 $this->agentSpecifLongOptions[] = $opt .
":";
88 $dbManager = $this->container->get(
"db.manager");
89 $pfileDao = $this->container->get(
"dao.pfile");
90 $licenseDao = $this->container->get(
"dao.license");
91 $agentDao = $this->container->get(
"dao.agent");
92 $copyrightDao = $this->container->get(
"dao.copyright");
93 $uploadDao = $this->container->get(
"dao.upload");
94 $clearingDao = $this->container->get(
"dao.clearing");
98 $licenseDao, $uploadDao, $clearingDao);
111 $fileBase = $SysConf[
'FOSSOLOGY'][
'path'] .
"/DecisionImport/";
114 if (!file_exists($this->report) ||
115 !is_readable($this->report)) {
116 echo
"No report to process\n";
117 echo
"Maybe the permissions on " . htmlspecialchars($fileBase) .
" are not sufficient\n";
125 $this->decisionImporterUtils->setUploadId($uploadId);
126 $this->decisionImporterUtils->setGroupId(
$groupId);
127 $this->decisionImporterUtils->setUserId(
$userId);
129 $this->decisionImporterUtils->getOrCreateIds($this->reportData, $this);
131 $this->decisionImporterDataCreator->setUserId($this->setUserId);
132 $this->decisionImporterDataCreator->setGroupId(
$groupId);
133 $this->decisionImporterDataCreator->setUploadId($uploadId);
135 $this->decisionImporterDataCreator->createClearingDecisions($this->reportData, $this);
136 $this->decisionImporterDataCreator->createMonkBulkData($this->reportData, $this);
137 $this->decisionImporterDataCreator->createCopyrightData($this->reportData, $this,
"copyright", $this->
jobId);
138 $this->decisionImporterDataCreator->createCopyrightData($this->reportData, $this,
"ecc", $this->
jobId);
139 $this->decisionImporterDataCreator->createCopyrightData($this->reportData, $this,
"ipra", $this->
jobId);
140 $this->decisionImporterDataCreator->createReportData($this->reportData);
141 $this->decisionImporterDataCreator->createMainLicenses($this->reportData, $uploadId,
$groupId);
152 $args = explode(
" --", $this->args[self::REPORT_KEY]);
153 $this->report =
$args[0];
155 foreach (
$args as $arg) {
156 list($key, $value) = explode(
"=", $arg);
157 if ($key == self::LONG_OPT_KEYS[0]) {
158 $this->setUserId = intval($value);
Import decisions generated by Decision Exporter from JSON files.
const REPORT_KEY
Key used to pass report name.
const LONG_OPT_KEYS
Other CLI args required by agents.
processUploadId($uploadId)
Given an upload ID, process the items in it.
$decisionImporterDataCreator
static createFromFile(string $path)
Structure of an Agent with all required parameters.
heartbeat($newProcessed)
Send hear beat to the scheduler.
int jobId
The id of the job.
list_t type structure used to keep various lists. (e.g. there are multiple lists).