FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
unifiedreport.php
Go to the documentation of this file.
1 <?php
2 /*
3  Author: Shaheem Azmal, anupam.ghosh@siemens.com
4  Copyright (C) 2017-2018, Siemens AG
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
99 define("REPORT_AGENT_NAME", "unifiedreport");
100 
116 
117 include_once(__DIR__ . "/version.php");
118 include_once(__DIR__ . "/reportStatic.php");
119 include_once(__DIR__ . "/reportSummary.php");
120 
125 class UnifiedReport extends Agent
126 {
131 
136 
141 
146 
151 
156 
161 
166 
171 
175  private $otherGetter;
176 
180  private $uploadDao;
181 
185  private $userDao;
186 
190  private $rowHeight = 500;
191 
195  private $tablestyle = array("borderSize" => 2,
196  "name" => "Arial",
197  "borderColor" => "000000",
198  "cellSpacing" => 5
199  );
200 
204  private $subHeadingStyle = array("size" => 9,
205  "align" => "center",
206  "bold" => true
207  );
208 
212  private $licenseColumn = array("size" => "9",
213  "bold" => true
214  );
215 
219  private $licenseTextColumn = array("name" => "Courier New",
220  "size" => 9,
221  "bold" => false
222  );
223 
227  private $filePathColumn = array("size" => "9",
228  "bold" => false
229  );
230 
234  private $groupBy;
235 
236  function __construct()
237  {
238  $this->cpClearedGetter = new XpClearedGetter("copyright", "statement");
239  $this->eccClearedGetter = new XpClearedGetter("ecc", "ecc");
240  $this->licenseClearedGetter = new LicenseClearedGetter();
241  $this->licenseMainGetter = new LicenseMainGetter();
242  $this->bulkMatchesGetter = new BulkMatchesGetter();
243  $this->licenseIrrelevantGetter = new LicenseIrrelevantGetter();
244  $this->licenseIrrelevantCommentGetter = new LicenseIrrelevantGetter(false);
245  $this->licenseDNUGetter = new LicenseDNUGetter();
246  $this->licenseDNUCommentGetter = new LicenseDNUGetter(false);
247  $this->otherGetter = new OtherGetter();
248  $this->obligationsGetter = new ObligationsGetter();
249 
250  parent::__construct(REPORT_AGENT_NAME, AGENT_VERSION, AGENT_REV);
251 
252  $this->uploadDao = $this->container->get("dao.upload");
253  $this->userDao = $this->container->get("dao.user");
254  }
255 
260  function processUploadId($uploadId)
261  {
264 
265  $this->heartbeat(0);
266 
267  $licenses = $this->licenseClearedGetter->getCleared($uploadId, $groupId, true, null, false, $this);
268  $this->heartbeat(empty($licenses) ? 0 : count($licenses["statements"]));
269 
270  $licensesMain = $this->licenseMainGetter->getCleared($uploadId, $groupId, true, null, false, $this);
271  $this->heartbeat(empty($licensesMain) ? 0 : count($licensesMain["statements"]));
272 
273  $licensesHist = $this->licenseClearedGetter->getLicenseHistogramForReport($uploadId, $groupId, true, null, false, $this);
274  $this->heartbeat(empty($licensesHist) ? 0 : count($licensesHist["statements"]));
275 
276  $bulkLicenses = $this->bulkMatchesGetter->getCleared($uploadId, $groupId, true, null, false, $this);
277  $this->heartbeat(empty($bulkLicenses) ? 0 : count($bulkLicenses["statements"]));
278 
279  $this->licenseClearedGetter->setOnlyAcknowledgements(true);
280  $licenseAcknowledgements = $this->licenseClearedGetter->getCleared($uploadId, $groupId, true, null, false, $this);
281  $this->heartbeat(empty($licenseAcknowledgements) ? 0 : count($licenseAcknowledgements["statements"]));
282 
283  $this->licenseClearedGetter->setOnlyComments(true);
284  $licenseComments = $this->licenseClearedGetter->getCleared($uploadId, $groupId, true, null, false, $this);
285  $this->heartbeat(empty($licenseComments) ? 0 : count($licenseComments["statements"]));
286 
287  $licensesIrre = $this->licenseIrrelevantGetter->getCleared($uploadId, $groupId, true, null, false, $this);
288  $this->heartbeat(empty($licensesIrre) ? 0 : count($licensesIrre["statements"]));
289 
290  $licensesIrreComment = $this->licenseIrrelevantCommentGetter->getCleared($uploadId, $groupId, true, null, false, $this);
291  $this->heartbeat(empty($licensesIrreComment) ? 0 : count($licensesIrreComment["statements"]));
292 
293  $licensesDNU = $this->licenseDNUGetter->getCleared($uploadId, $groupId, true, null, false, $this);
294  $this->heartbeat(empty($licensesDNU) ? 0 : count($licensesDNU["statements"]));
295 
296  $licensesDNUComment = $this->licenseDNUCommentGetter->getCleared($uploadId, $groupId, true, null, false, $this);
297  $this->heartbeat(empty($licensesDNUComment) ? 0 : count($licensesDNUComment["statements"]));
298 
299  $copyrights = $this->cpClearedGetter->getCleared($uploadId, $groupId, true, "copyright", true, $this);
300  $this->heartbeat(empty($copyrights["statements"]) ? 0 : count($copyrights["statements"]));
301 
302  $ecc = $this->eccClearedGetter->getCleared($uploadId, $groupId, true, "ecc", false, $this);
303  $this->heartbeat(empty($ecc) ? 0 : count($ecc["statements"]));
304 
305  $otherStatement = $this->otherGetter->getReportData($uploadId);
306  $this->heartbeat(empty($otherStatement) ? 0 : count($otherStatement));
307  $otherStatement['includeDNU'] = (count($licensesDNU["statements"]) > 0) ? true : false;
308 
309  $contents = array(
310  "licenses" => $licenses,
311  "bulkLicenses" => $bulkLicenses,
312  "licenseAcknowledgements" => $licenseAcknowledgements,
313  "licenseComments" => $licenseComments,
314  "copyrights" => $copyrights,
315  "ecc" => $ecc,
316  "licensesIrre" => $licensesIrre,
317  "licensesIrreComment" => $licensesIrreComment,
318  "licensesDNU" => $licensesDNU,
319  "licensesDNUComment" => $licensesDNUComment,
320  "licensesMain" => $licensesMain,
321  "licensesHist" => $licensesHist,
322  "otherStatement" => $otherStatement
323  );
324 
325  $this->writeReport($contents, $uploadId, $groupId, $userId);
326  return true;
327  }
328 
335  private function documentSettingsAndStyles(PhpWord &$phpWord, $timestamp, $userName)
336  {
337 
338  $topHeading = array("size" => 22,
339  "bold" => true,
340  "underline" => "single"
341  );
342 
343  $mainHeading = array("size" => 20,
344  "bold" => true,
345  "color" => "000000"
346  );
347 
348  $subHeading = array("size" => 16,
349  "italic" => true
350  );
351 
352  $subSubHeading = array("size" => 14,
353  "bold" => true
354  );
355 
356  $paragraphStyle = array("spaceAfter" => 0,
357  "spaceBefore" => 0,
358  "spacing" => 0
359  );
360 
361  $phpWord->addNumberingStyle('hNum',
362  array('type' => 'multilevel', 'levels' => array(
363  array('pStyle' => 'Heading01', 'format' => 'bullet', 'text' => ''),
364  array('pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%2.'),
365  array('pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%2.%3.'),
366  array('pStyle' => 'Heading4', 'format' => 'decimal', 'text' => '%2.%3.%4.'),
367  )
368  )
369  );
370 
371  /* Adding styles for the document*/
372  $phpWord->setDefaultFontName("Arial");
373  $phpWord->addTitleStyle(1, $topHeading, array('numStyle' => 'hNum', 'numLevel' => 0));
374  $phpWord->addTitleStyle(2, $mainHeading, array('numStyle' => 'hNum', 'numLevel' => 1));
375  $phpWord->addTitleStyle(3, $subHeading, array('numStyle' => 'hNum', 'numLevel' => 2));
376  $phpWord->addTitleStyle(4, $subSubHeading, array('numStyle' => 'hNum', 'numLevel' => 3));
377  $phpWord->addParagraphStyle("pStyle", $paragraphStyle);
378 
379  /* Setting document properties*/
380  $properties = $phpWord->getDocInfo();
381  $properties->setCreator($userName);
382  $properties->setCompany("Your Organisation");
383  $properties->setTitle("Clearing Report");
384  $properties->setDescription("OSS clearing report by Fossology tool");
385  $properties->setSubject("Copyright (C) ".date("Y", $timestamp).", Your Organisation");
386  }
387 
394  private function globalLicenseTable(Section $section, $mainLicenses, $titleSubHeading)
395  {
396  $firstColLen = 2000;
397  $secondColLen = 9500;
398  $thirdColLen = 4000;
399 
400  $section->addTitle(htmlspecialchars("Main Licenses"), 2);
401  $section->addText($titleSubHeading, $this->subHeadingStyle);
402 
403  $table = $section->addTable($this->tablestyle);
404  if (!empty($mainLicenses)) {
405  foreach ($mainLicenses as $licenseMain) {
406  if ($licenseMain["risk"] == "4" || $licenseMain["risk"] == "5") {
407  $styleColumn = array("bgColor" => "F9A7B0");
408  } elseif ($licenseMain["risk"] == "2" || $licenseMain["risk"] == "3") {
409  $styleColumn = array("bgColor" => "FEFF99");
410  } else {
411  $styleColumn = array("bgColor" => "FFFFFF");
412  }
413  $table->addRow($this->rowHeight);
414  $cell1 = $table->addCell($firstColLen, $styleColumn);
415  $cell1->addText(htmlspecialchars($licenseMain["content"], ENT_DISALLOWED), $this->licenseColumn, "pStyle");
416  $cell2 = $table->addCell($secondColLen);
417  // replace new line character
418  $licenseText = str_replace("\n", "<w:br/>\n", htmlspecialchars($licenseMain["text"], ENT_DISALLOWED));
419  $cell2->addText($licenseText, $this->licenseTextColumn, "pStyle");
420  if (!empty($licenseMain["files"])) {
421  $cell3 = $table->addCell($thirdColLen, $styleColumn);
422  asort($licenseMain["files"]);
423  foreach ($licenseMain["files"] as $fileName) {
424  $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn, "pStyle");
425  }
426  } else {
427  $cell3 = $table->addCell($thirdColLen, $styleColumn)->addText("");
428  }
429  }
430  } else {
431  $table->addRow($this->rowHeight);
432  $table->addCell($firstColLen)->addText("");
433  $table->addCell($secondColLen)->addText("");
434  $table->addCell($thirdColLen)->addText("");
435  }
436  $section->addTextBreak();
437  }
438 
447  private function bulkLicenseTable(Section $section, $title, $licenses, $titleSubHeading)
448  {
449  $firstColLen = 2000;
450  $secondColLen = 9500;
451  $thirdColLen = 4000;
452  if (!empty($title)) {
453  $section->addTitle(htmlspecialchars($title), 2);
454  }
455  $section->addText($titleSubHeading, $this->subHeadingStyle);
456 
457  $table = $section->addTable($this->tablestyle);
458  if (!empty($licenses)) {
459  foreach ($licenses as $licenseStatement) {
460  $table->addRow($this->rowHeight);
461  $cell1 = $table->addCell($firstColLen, null, "pStyle");
462  $cell1->addText(htmlspecialchars($licenseStatement["content"], ENT_DISALLOWED), $this->licenseColumn, "pStyle");
463  $cell2 = $table->addCell($secondColLen, "pStyle");
464  // replace new line character
465  $licenseText = str_replace("\n", "<w:br/>\n", htmlspecialchars($licenseStatement["text"], ENT_DISALLOWED));
466  $cell2->addText($licenseText, $this->licenseTextColumn, "pStyle");
467  $cell3 = $table->addCell($thirdColLen, null, "pStyle");
468  asort($licenseStatement["files"]);
469  foreach ($licenseStatement["files"] as $fileName) {
470  $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn, "pStyle");
471  }
472  }
473  } else {
474  $table->addRow($this->rowHeight);
475  $table->addCell($firstColLen)->addText("");
476  $table->addCell($secondColLen)->addText("");
477  $table->addCell($thirdColLen)->addText("");
478  }
479  $section->addTextBreak();
480  }
481 
490  private function licensesTable(Section $section, $title, $licenses, $riskarray, $titleSubHeading)
491  {
492  $firstColLen = 2000;
493  $secondColLen = 9500;
494  $thirdColLen = 4000;
495  $emptyFlag = false;
496 
497  $section->addTitle(htmlspecialchars($title), 2);
498  $section->addText($titleSubHeading, $this->subHeadingStyle);
499 
500  $table = $section->addTable($this->tablestyle);
501  if (!empty($licenses)) {
502  foreach ($licenses as $licenseStatement) {
503  if (in_array($licenseStatement['risk'], $riskarray['riskLevel'])) {
504  $emptyFlag = true;
505  $table->addRow($this->rowHeight);
506  $cell1 = $table->addCell($firstColLen, $riskarray['color']);
507  $cell1->addText(htmlspecialchars($licenseStatement["content"], ENT_DISALLOWED), $this->licenseColumn, "pStyle");
508  $cell2 = $table->addCell($secondColLen);
509  // replace new line character
510  $licenseText = str_replace("\n", "<w:br/>\n", htmlspecialchars($licenseStatement["text"], ENT_DISALLOWED));
511  $cell2->addText($licenseText, $this->licenseTextColumn, "pStyle");
512  $cell3 = $table->addCell($thirdColLen, $riskarray['color']);
513  asort($licenseStatement["files"]);
514  foreach ($licenseStatement["files"] as $fileName) {
515  $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn, "pStyle");
516  }
517  } else {
518  continue;
519  }
520  }
521  }
522 
523  if (empty($emptyFlag)) {
524  $table->addRow($this->rowHeight);
525  $table->addCell($firstColLen)->addText("");
526  $table->addCell($secondColLen)->addText("");
527  $table->addCell($thirdColLen)->addText("");
528  }
529  $section->addTextBreak();
530  }
531 
540  private function getRowsAndColumnsForCEI(Section $section, $title, $statementsCEI, $titleSubHeading, $text="")
541  {
542  $smallRowHeight = 50;
543  $firstColLen = 6500;
544  $secondColLen = 5000;
545  $thirdColLen = 4000;
546  $textStyle = array("size" => 10, "bold" => true);
547 
548  $section->addTitle(htmlspecialchars($title), 2);
549  if (!empty($text)) {
550  $section->addText($text, $textStyle);
551  }
552  $section->addText($titleSubHeading, $this->subHeadingStyle);
553 
554  $table = $section->addTable($this->tablestyle);
555  if (!empty($statementsCEI)) {
556  foreach ($statementsCEI as $statements) {
557  if (!empty($statements['content'])) {
558  $table->addRow($smallRowHeight);
559  $cell1 = $table->addCell($firstColLen);
560  $text = html_entity_decode($statements['content']);
561  $cell1->addText(htmlspecialchars($text, ENT_DISALLOWED), $this->licenseTextColumn, "pStyle");
562  $cell2 = $table->addCell($secondColLen);
563  $cell2->addText(htmlspecialchars($statements['comments'], ENT_DISALLOWED), $this->licenseTextColumn, "pStyle");
564  $cell3 = $table->addCell($thirdColLen);
565  asort($statements["files"]);
566  foreach ($statements['files'] as $fileName) {
567  $cell3->addText(htmlspecialchars($fileName), $this->filePathColumn, "pStyle");
568  }
569  }
570  }
571  } else {
572  $table->addRow($this->rowHeight);
573  $table->addCell($firstColLen)->addText("");
574  $table->addCell($secondColLen)->addText("");
575  $table->addCell($thirdColLen)->addText("");
576  }
577  $section->addTextBreak();
578  }
579 
587  private function getRowsAndColumnsForIrre(Section $section, $title, $licensesIrre, $titleSubHeading)
588  {
589  $firstColLen = 5000;
590  $secondColLen = 5000;
591  $thirdColLen = 5000;
592 
593  $section->addTitle(htmlspecialchars($title), 2);
594  $section->addText($titleSubHeading, $this->subHeadingStyle);
595 
596  $table = $section->addTable($this->tablestyle);
597  if (!empty($licensesIrre)) {
598  foreach ($licensesIrre as $statements) {
599  $table->addRow($rowWidth, "pStyle");
600  $cell1 = $table->addCell($firstColLen)->addText(htmlspecialchars($statements['content']),null, "pStyle");
601  $cell2 = $table->addCell($secondColLen)->addText(htmlspecialchars($statements['fileName']),null, "pStyle");
602  $cell3 = $table->addCell($thirdColLen);
603  asort($statements["licenses"]);
604  foreach ($statements['licenses'] as $licenseName) {
605  $cell3->addText(htmlspecialchars($licenseName), $this->filePathColumn, "pStyle");
606  }
607  }
608  } else {
609  $table->addRow($this->rowHeight);
610  $table->addCell($firstColLen, "pStyle")->addText("");
611  $table->addCell($secondColLen, "pStyle")->addText("");
612  $table->addCell($thirdColLen, "pStyle")->addText("");
613  }
614  $section->addTextBreak();
615  }
616 
623  private function licenseHistogram(Section $section, $dataHistogram, $titleSubHeading)
624  {
625  $firstColLen = 2000;
626  $secondColLen = 2000;
627  $thirdColLen = 5000;
628 
629  $section->addTitle(htmlspecialchars("Results of License Scan"), 2);
630  $section->addText($titleSubHeading, $this->subHeadingStyle);
631 
632  $table = $section->addTable($this->tablestyle);
633 
634  foreach ($dataHistogram as $licenseData) {
635  $table->addRow($this->rowHeight);
636  $table->addCell($firstColLen)->addText($licenseData['scannerCount'], "pStyle");
637  $table->addCell($secondColLen)->addText($licenseData['editedCount'], "pStyle");
638  $table->addCell($thirdColLen)->addText(htmlspecialchars($licenseData['licenseShortname']), "pStyle");
639  }
640  $section->addTextBreak();
641  }
642 
643 
655  private function writeReport($contents, $uploadId, $groupId, $userId)
656  {
657  global $SysConf;
658 
659  $userName = $this->userDao->getUserName($userId);
660  $groupName = $this->userDao->getGroupNameById($groupId);
661  $packageName = $this->uploadDao->getUpload($uploadId)->getFilename();
662  //replace '(',')',' ' with '_' to avoid conflict while creating report.
663  $packageName = str_replace('(','_',$packageName);
664  $packageName = str_replace(' ','_',$packageName);
665  $packageName = str_replace(')','_',$packageName);
666 
667  $parentItem = $this->uploadDao->getParentItemBounds($uploadId);
668  $docLayout = array("orientation" => "landscape",
669  "marginLeft" => "950",
670  "marginRight" => "950",
671  "marginTop" => "950",
672  "marginBottom" => "950"
673  );
674 
675  /* Creating the new DOCX */
676  $phpWord = new PhpWord();
677 
678  /* Get start time */
679  $jobInfo = $this->dbManager->getSingleRow("SELECT extract(epoch from jq_starttime) "
680  ." AS ts, jq_cmd_args FROM jobqueue WHERE jq_job_fk=$1", array($this->jobId));
681  $timestamp = $jobInfo['ts'];
682  $packageUri = "";
683  if (!empty($jobInfo['jq_cmd_args'])) {
684  $packageUri = trim($jobInfo['jq_cmd_args'])."?mod=showjobs&upload=".$uploadId;
685  }
686 
687  /* Applying document properties and styling */
688  $this->documentSettingsAndStyles($phpWord, $timestamp, $userName);
689 
690  /* Creating document layout */
691  $section = $phpWord->addSection($docLayout);
692 
693  $reportSummarySection = new ReportSummary();
694  $reportStaticSection = new ReportStatic($timestamp);
695 
696  list($obligations, $whiteLists) = $this->obligationsGetter->getObligations($contents['licenses']['statements'],
697  $contents['licensesMain']['statements'], $uploadId, $groupId);
698 
699  /* Header starts */
700  $reportStaticSection->reportHeader($section);
701 
702  list($contents['licensesMain']['statements'], $contents['licenses']['statements']) = $this->licenseClearedGetter->updateIdentifiedGlobalLicenses($contents['licensesMain']['statements'], $contents['licenses']['statements']);
703 
704  /* Summery table */
705  $reportSummarySection->summaryTable($section, $uploadId, $userName,
706  $contents['licensesMain']['statements'], $contents['licenses']['statements'],
707  $contents['licensesHist']['statements'], $contents['otherStatement'], $timestamp, $groupName, $packageUri);
708 
709  /* Assessment summery table */
710  $bookMarkCell = $reportStaticSection->assessmentSummaryTable($section, $contents['otherStatement']);
711 
712  /* Todoinfo table */
713  $reportStaticSection->todoTable($section);
714 
715  /* Todoobligation table */
716  $reportStaticSection->todoObliTable($section, $obligations);
717 
718  /* Display acknowledgement */
719  $heading = "Acknowledgements";
720  $titleSubHeadingAcknowledgement = "(Reference to the license, Text of acknowledgements, File path)";
721  $this->bulkLicenseTable($section, $heading, $contents['licenseAcknowledgements']['statements'], $titleSubHeadingAcknowledgement);
722 
723  /* Display Ecc statements and files */
724  $heading = "Export Restrictions";
725  $titleSubHeadingCEI = "(Statements, Comments, File path)";
726  $section->addBookmark("eccInternalLink");
727  $textEcc ="The content of this paragraph is not the result of the evaluation"
728  ." of the export control experts (the ECCN). It contains information"
729  ." found by the scanner which shall be taken in consideration by"
730  ." the export control experts during the evaluation process. If"
731  ." the scanner identifies an ECCN it will be listed here. (NOTE:"
732  ." The ECCN is seen as an attribute of the component release and"
733  ." thus it shall be present in the component catalogue.";
734  $this->getRowsAndColumnsForCEI($section, $heading, $contents['ecc']['statements'], $titleSubHeadingCEI, $textEcc);
735 
736  /* Display comments entered for report */
737  $heading = "Notes";
738  $subHeading = "Notes on individual files";
739  $reportStaticSection->notes($section, $heading, $subHeading);
740  $titleSubHeadingNotes = "(License name, Comment Entered, File path)";
741  $this->bulkLicenseTable($section, "", $contents['licenseComments']['statements'], $titleSubHeadingNotes);
742 
743  /* Display scan results and edited results */
744  $titleSubHeadingHistogram = "(Scanner count, Concluded license count, License name)";
745  $this->licenseHistogram($section, $contents['licensesHist']['statements'], $titleSubHeadingHistogram);
746 
747  /* Display global licenses */
748  $titleSubHeadingLicense = "(License name, License text, File path)";
749  $this->globalLicenseTable($section, $contents['licensesMain']['statements'], $titleSubHeadingLicense);
750 
751  /* Display licenses(red) name,text and files */
752  $heading = "Other OSS Licenses (red) - specific obligations";
753  $redLicense = array("color" => array("bgColor" => "F9A7B0"), "riskLevel" => array("5", "4"));
754  $this->licensesTable($section, $heading, $contents['licenses']['statements'], $redLicense, $titleSubHeadingLicense);
755 
756  /* Display licenses(yellow) name,text and files */
757  $heading = "Other OSS Licenses (yellow) - additional obligations to common rules (e.g. copyleft)";
758  $yellowLicense = array("color" => array("bgColor" => "FEFF99"), "riskLevel" => array("3", "2"));
759  $this->licensesTable($section, $heading, $contents['licenses']['statements'], $yellowLicense, $titleSubHeadingLicense);
760 
761  /* Display licenses(white) name,text and files */
762  $heading = "Other OSS Licenses (white) - only common rules";
763  $whiteLicense = array("color" => array("bgColor" => "FFFFFF"), "riskLevel" => array("", "0", "1"));
764  $this->licensesTable($section, $heading, $contents['licenses']['statements'], $whiteLicense, $titleSubHeadingLicense);
765 
766  $heading = "Overview of All Licenses with or without Obligations";
767  $titleSubHeadingObli = "(License ShortName, Obligation)";
768  $reportStaticSection->allLicensesWithAndWithoutObligations($section, $heading, $obligations, $whiteLists, $titleSubHeadingObli);
769 
770  /* Display copyright statements and files */
771  $heading = "Copyrights";
772  $this->getRowsAndColumnsForCEI($section, $heading, $contents['copyrights']['scannerFindings'], $titleSubHeadingCEI);
773 
774  /* Display user findings copyright statements and files */
775  $heading = "Copyrights (User Findings)";
776  $this->getRowsAndColumnsForCEI($section, $heading, $contents['copyrights']['userFindings'], $titleSubHeadingCEI);
777 
778  /* Display Bulk findings name,text and files */
779  $heading = "Bulk Findings";
780  $this->bulkLicenseTable($section, $heading, $contents['bulkLicenses']['statements'], $titleSubHeadingLicense);
781 
782  /* Display NON-Functional Licenses license files */
783  $heading = "Non-Functional Licenses";
784  $reportStaticSection->getNonFunctionalLicenses($section, $heading);
785 
786  /* Display irrelavant license files */
787  $heading = "Irrelevant Files";
788  $titleSubHeadingIrre = "(Path, Files, Licenses)";
789  $this->getRowsAndColumnsForIrre($section, $heading, $contents['licensesIrre']['statements'], $titleSubHeadingIrre);
790 
791  /* Display irrelavant file license comment */
792  $subHeading = "Comment for Irrelevant files";
793  $section->addTitle(htmlspecialchars("$subHeading"), 3);
794  $titleSubHeadingNotes = "(License name, Comment Entered, File path)";
795  $this->bulkLicenseTable($section, "", $contents['licensesIrreComment']['statements'], $titleSubHeadingNotes);
796 
797  /* Display Do not use license files */
798  $heading = "Do not use Files";
799  if ($contents['otherStatement']['includeDNU']) {
800  // adding an internal bookmark
801  $columnStyleWithUnderline = array("size" => 11, "color" => "0000A0", 'underline' => 'single');
802  $section->addBookmark('DNUBookmark');
803  $bookMarkCell->addLink('DNUBookmark', htmlspecialchars(' NOTE: DO NOT USE files found! Please check Do not use files section', ENT_COMPAT, 'UTF-8'), $columnStyleWithUnderline, "pStyle", true);
804  }
805  $titleSubHeadingIrre = "(Path, Files, Licenses)";
806  $this->getRowsAndColumnsForIrre($section, $heading, $contents['licensesDNU']['statements'], $titleSubHeadingIrre);
807 
808  /* Display Do not use file license comment */
809  $subHeading = "Comment for Do not use files";
810  $section->addTitle(htmlspecialchars("$subHeading"), 3);
811  $titleSubHeadingNotes = "(License name, Comment Entered, File path)";
812  $this->bulkLicenseTable($section, "", $contents['licensesDNUComment']['statements'], $titleSubHeadingNotes);
813 
814  /* clearing protocol change log table */
815  $reportStaticSection->clearingProtocolChangeLogTable($section);
816 
817  /* Footer starts */
818  $reportStaticSection->reportFooter($phpWord, $section, $contents['otherStatement']);
819 
820  $fileBase = $SysConf["FOSSOLOGY"]["path"]."/report/";
821  if (!is_dir($fileBase)) {
822  mkdir($fileBase, 0777, true);
823  }
824  umask(0022);
825  $fileName = $fileBase. "$packageName"."_clearing_report_".date("D_M_d_m_Y_h_i_s").".docx";
826  $objWriter = IOFactory::createWriter($phpWord, "Word2007");
827  $objWriter->save($fileName);
828 
829  $this->updateReportTable($uploadId, $this->jobId, $fileName);
830  }
831 
832 
839  private function updateReportTable($uploadId, $jobId, $filename)
840  {
841  $this->dbManager->getSingleRow("INSERT INTO reportgen(upload_fk, job_fk, filepath) VALUES($1,$2,$3)",
842  array($uploadId, $jobId, $filename), __METHOD__);
843  }
844 }
845 
846 $agent = new UnifiedReport();
847 $agent->scheduler_connect();
848 $agent->run_scheduler_event_loop();
849 $agent->scheduler_disconnect(0);
heartbeat($newProcessed)
Send hear beat to the scheduler.
Definition: Agent.php:214
writeReport($contents, $uploadId, $groupId, $userId)
Writes the report to a file.
processUploadId($uploadId)
Given an upload ID, process the items in it.
Structure of an Agent with all required parameters.
Definition: Agent.php:51
int jobId
The id of the job.
bulkLicenseTable(Section $section, $title, $licenses, $titleSubHeading)
This function lists out the bulk licenses, comments of identified licenses.
Handles static part of report.
getRowsAndColumnsForCEI(Section $section, $title, $statementsCEI, $titleSubHeading, $text="")
Copyright or ecc table.
Handles report summary.
documentSettingsAndStyles(PhpWord &$phpWord, $timestamp, $userName)
Setting default heading styles and paragraph styles.
getRowsAndColumnsForIrre(Section $section, $title, $licensesIrre, $titleSubHeading)
Irrelevant files in report.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:28
licenseHistogram(Section $section, $dataHistogram, $titleSubHeading)
License histogram into report.
globalLicenseTable(Section $section, $mainLicenses, $titleSubHeading)
Generate global license table.
const REPORT_AGENT_NAME
Generates unified report.
licensesTable(Section $section, $title, $licenses, $riskarray, $titleSubHeading)
This function lists out the red, white & yellow licenses.
updateReportTable($uploadId, $jobId, $filename)
Update database with generated report path.
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695