9 define(
"DECISIONEXPORTER_AGENT_NAME",
"decisionexporter");
16 include_once(__DIR__ .
"/version.php");
40 function __construct()
42 parent::__construct(DECISIONEXPORTER_AGENT_NAME, AGENT_VERSION, AGENT_REV);
44 $this->uploadDao = $this->container->get(
'dao.upload');
45 $this->allDecisionsDao = $this->container->get(
'dao.alldecisions');
46 $this->clearingDao = $this->container->get(
'dao.clearing');
58 $tableName =
"decision_exporter_pfile_" . $uploadId;
60 $pfileData = $this->allDecisionsDao->getAllAgentPfileIdsForUpload($uploadId,
$groupId,
$userId);
66 $uploadTreeData = $this->allDecisionsDao->getAllAgentUploadTreeDataForUpload($uploadId, $tableName);
68 $clearingDecisonData = $this->allDecisionsDao->getAllClearingDecisionDataForUpload($uploadId, $tableName);
70 $clearingEventData = $this->allDecisionsDao->getAllClearingEventDataForUpload($uploadId, $tableName);
72 $clearingDecisonEventData = $this->allDecisionsDao->getAllClearingDecisionEventDataForUpload($uploadId, $tableName);
74 $licenseRefBulkData = $this->allDecisionsDao->getAllLicenseRefBulkDataForUpload($uploadId);
76 $licenseSetBulkData = $this->allDecisionsDao->getAllLicenseSetBulkDataForUpload($uploadId);
78 $bulkHighlightData = $this->allDecisionsDao->getAllBulkHighlightDataForUpload($uploadId);
80 $copyrightData = $this->allDecisionsDao->getAllDataForGivenTableUpload($tableName,
'copyright');
82 $copyrightDecisionData = $this->allDecisionsDao->getAllDataForGivenDecisionTableUpload($tableName,
'copyright_decision');
84 $copyrightEventData = $this->allDecisionsDao->getAllDataForGivenEventTableUpload($uploadId,
'copyright_event',
'copyright');
86 $eccData = $this->allDecisionsDao->getAllDataForGivenTableUpload($tableName,
'ecc');
88 $eccDecisionData = $this->allDecisionsDao->getAllDataForGivenDecisionTableUpload($tableName,
'ecc_decision');
90 $eccEventData = $this->allDecisionsDao->getAllDataForGivenEventTableUpload($uploadId,
'ecc_event',
'ecc');
92 $ipraData = $this->allDecisionsDao->getAllDataForGivenTableUpload($tableName,
'ipra');
94 $ipraDecisionData = $this->allDecisionsDao->getAllDataForGivenDecisionTableUpload($tableName,
'ipra_decision');
96 $ipraEventData = $this->allDecisionsDao->getAllDataForGivenEventTableUpload($uploadId,
'ipra_event',
'ipra');
98 $reportInfoData = $this->uploadDao->getReportInfo($uploadId);
100 $licenseData = $this->allDecisionsDao->getAllLicenseDataForUpload($uploadId);
102 $mainLicenseData = $this->clearingDao->getMainLicenseIds($uploadId,
$groupId);
106 'uploadtree'=>$uploadTreeData,
107 'clearing_decision'=>$clearingDecisonData,
108 'clearing_event'=>$clearingEventData,
109 'clearing_decision_event'=>$clearingDecisonEventData,
110 'license_ref_bulk'=>$licenseRefBulkData,
111 'license_set_bulk'=>$licenseSetBulkData,
112 'highlight_bulk'=>$bulkHighlightData,
113 'copyright'=>$copyrightData,
114 'copyright_decision'=>$copyrightDecisionData,
115 'copyright_event'=>$copyrightEventData,
117 'ecc_decision'=>$eccDecisionData,
118 'ecc_event'=>$eccEventData,
120 'ipra_decision'=>$ipraDecisionData,
121 'ipra_event'=>$ipraEventData,
122 'report_info'=>$reportInfoData,
123 'licenses'=>$licenseData,
124 'upload_clearing_license'=>array_values($mainLicenseData)
145 $packageName = $this->uploadDao->getUpload($uploadId)->getFilename();
147 $fileBase = $SysConf[
'FOSSOLOGY'][
'path'] .
"/report/";
148 $fileName = $fileBase .
"FOSSology_Decisions_" . $packageName .
'_' . date(
"d_m_Y_H_i_s") .
".json";
150 if (!is_dir($fileBase)) {
151 mkdir($fileBase, 0777,
true);
155 file_put_contents($fileName, json_encode($contents, JSON_UNESCAPED_SLASHES));
167 $allPfileFk = array_keys($pfileData);
168 foreach ($allPfileFk as $pfileFk) {
169 $this->
dbManager->insertInto($tableName,
'pfile_fk', array($pfileFk));
179 $this->
dbManager->getSingleRow(
"CREATE TABLE IF NOT EXISTS ".$tableName.
" (pfile_fk BIGINT NOT NULL);",
180 array(), __METHOD__);
189 $this->
dbManager->getSingleRow(
"DROP TABLE IF EXISTS ".$tableName.
";",
190 array(), __METHOD__);
201 $this->
dbManager->getSingleRow(
"INSERT INTO reportgen(upload_fk, job_fk, filepath) VALUES($1,$2,$3)",
202 array($uploadId,
$jobId, $filename), __METHOD__);
207 $agent->scheduler_connect();
208 $agent->run_scheduler_event_loop();
209 $agent->scheduler_disconnect(0);
Generates Decision Exporter JSON.
processUploadId($uploadId)
Given an upload ID, process the items in it.
dropPfileTable($uploadId, $tableName)
Create database table.
createPfileTable($uploadId, $tableName)
Create database table.
insertPfileData($uploadId, $pfileData, $tableName)
Create database table.
writeReport($contents, $uploadId)
Writes the data to a json file.
updateReportTable($uploadId, $jobId, $filename)
Update database with generated report path.
Structure of an Agent with all required parameters.
heartbeat($newProcessed)
Send hear beat to the scheduler.
int jobId
The id of the job.
fo_dbManager * dbManager
fo_dbManager object