diff --git a/NOTICE b/NOTICE index 67df7198d3..f50518fc86 100644 --- a/NOTICE +++ b/NOTICE @@ -21,11 +21,6 @@ License: Creative Commons Attribution-NonCommercial 3.0 Author: Torstein Hønsi Link: http://www.highcharts.com/ -Name: Jasper Reports -License: LGPL 3.0 -Author: Jaspersoft Corporation -Link: http://community.jaspersoft.com/project/jasperreports-library - Name: Commons BeanUtils License: Apache License Version 2.0 Author: The Apache Software Foundation @@ -86,6 +81,10 @@ License: New BSD License Author: André Rothe, Justin Swanhart Link: http://code.google.com/p/php-sql-parser/ +Name: PHP Word +License: LGPL 3 +Link: https://github.com/PHPOffice/PHPWord + Name: JSON Schema for PHP License: MIT License Author: Justin Rainbow diff --git a/README.md b/README.md index dbef90ea42..a8fab9fc28 100644 --- a/README.md +++ b/README.md @@ -305,7 +305,6 @@ XDMoD files being missing. These warnings can be safely ignored if they are for the following files: - `/usr/share/xdmod/configuration/linker.php` -- `/usr/share/xdmod/reporting/jasper_builder/ReportBuilder.sh` - `/usr/share/xdmod/configuration/constants.php` - `/etc/xdmod/portal_settings.ini` - `/usr/local/xdmod/etc/logrotate.d/xdmod` diff --git a/classes/Reports/ClassicReport.php b/classes/Reports/ClassicReport.php new file mode 100644 index 0000000000..2e6498ec1c --- /dev/null +++ b/classes/Reports/ClassicReport.php @@ -0,0 +1,153 @@ +settings = $settings; + + $single = $this->settings['charts_per_page'] === 1; + + $baseStyle = array( + 'paperSize' => 'Letter', + 'headerHeight' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(20), + 'footerHeight' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(20) + ); + + $this->styles['titlepage'] = array_merge($baseStyle, array( + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(43), + 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(43), + )); + + $this->styles['page'] = array_merge($baseStyle, array( + 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip($single ? 78 : 48), + 'marginBottom' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(43), + )); + + $this->fonts['hdrfoot'] = array( + 'size' => 12, + 'italic' => true + ); + + $this->styles['hdrfoot'] = array( + 'align'=>'center' + ); + + $this->fonts['reportTitle'] = array( + 'size' => $single ? 25 : 20 + ); + + $this->styles['reportTitle'] = array( + 'align'=>'center', + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip($single ? 35 : 7) + ); + + $this->fonts['chartTitle'] = array( + 'size' => $single ? 16 : 14, + 'bold' => true + ); + + $this->styles['chartTitle'] = array( + 'align'=>'center', + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip($single ? 10 : 5) + ); + + // used for the second chart on a two-charts-per-page report + $this->styles['chartTitle2'] = array( + 'align'=>'center', + 'spaceBefore' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(45), + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip($single ? 10 : 5) + ); + + $this->fonts['chartDrill'] = array( + 'size' => $single ? 10 : 8 + ); + + $this->styles['chartDrill'] = array( + 'align'=>'center', + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip($single ? 21 : 0) + ); + + $this->fonts['chartComments'] = array( + 'size' => $single ? 12 : 8 + ); + + $this->styles['chartComments'] = array( + 'align'=>'center', + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip($single ? 68 : 7) + ); + + $this->styles['chartImage'] = array( + 'width' => $single ? 432 : 340, + 'align' => 'center', + 'wrappingStyle' => 'inline' + ); + + $this->phpWord = new \PhpOffice\PhpWord\PhpWord(); + $this->phpWord->setDefaultFontName('Arial'); + } + + private function createSection($sectionStyle) { + $section = $this->phpWord->addSection($this->styles[$sectionStyle]); + + if (strlen($this->settings['header']) > 0) { + $header = $section->addHeader(); + $header->addText($this->settings['header'], $this->fonts['hdrfoot'], $this->styles['hdrfoot']); + } + + if (strlen($this->settings['footer']) > 0) { + $header = $section->addFooter(); + $header->addText($this->settings['footer'], $this->fonts['hdrfoot'], $this->styles['hdrfoot']); + } + + return $section; + } + + /** + * Create the report + */ + public function writeReport($path) + { + if (strlen($this->settings['title']) > 0) { + $section = $this->createSection('titlepage'); + $section->addText($this->settings['title'], $this->fonts['reportTitle'], $this->styles['reportTitle']); + } else { + $section = $this->createSection('page'); + } + + $chartNo = 0; + foreach ($this->settings['charts'] as $chart) { + $pageNo = (int) ($chartNo / $this->settings['charts_per_page']); + $chartSlot = $chartNo % $this->settings['charts_per_page']; + + if ($pageNo > 0 && $chartSlot === 0) { + if(strlen($this->settings['title']) > 0 && $pageNo === 1) { + $section = $this->createSection('page'); + } else { + $section->addPageBreak(); + } + } + + $chartStyle = 'chartTitle'; + if ($chartSlot === 1) { + $chartStyle = 'chartTitle2'; + } + + $section->addText($chart['title'], $this->fonts['chartTitle'], $this->styles[$chartStyle]); + $section->addText($chart['drill_details'], $this->fonts['chartDrill'], $this->styles['chartDrill']); + $section->addText($chart['comments'], $this->fonts['chartComments'], $this->styles['chartComments']); + $section->addImage($chart['imagedata'], $this->styles['chartImage']); + + $chartNo++; + } + + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($this->phpWord, 'Word2007'); + $objWriter->save($path); + } +} diff --git a/classes/XDReportManager.php b/classes/XDReportManager.php index 94f2a22e49..ceecf11f3b 100644 --- a/classes/XDReportManager.php +++ b/classes/XDReportManager.php @@ -1568,196 +1568,6 @@ public function generateChartBlob( return $raw_png_data; } - /* - * writeXMLConfiguration() - * - * This function generates the XML configuration file and image files for - * processing by jasper-builder. The files are placed in the supplied - * directory (which must exist) - * - * \param outputdir the name of an existing, writable directory in which to put the files. - * \param report_id the identifier for the report - * \param export_format the specified export format - * \returns The name of the report file that was written - */ - private function writeXMLConfiguration( - $outputdir, - $report_id, - $export_format = null - ) { - $dom = new \DOMDocument("1.0"); - - $nodeRoot = $dom->createElement("Report"); - $dom->appendChild($nodeRoot); - - $nodeUser = $dom->createElement("User"); - $nodeRoot->appendChild($nodeUser); - - $this->createElement( - $dom, - $nodeUser, - "LastName", - $this->getReportUserLastName($report_id) - ); - - $this->createElement( - $dom, - $nodeUser, - "FirstName", - $this->getReportUserFirstName($report_id) - ); - - $this->createElement( - $dom, - $nodeUser, - "Email", - $this->getReportUserEmailAddress($report_id) - ); - - $this->createElement( - $dom, - $nodeRoot, - "Format", - ($export_format != null) - ? $export_format - : $this->getReportFormat($report_id) - ); - - $this->createElement( - $dom, - $nodeRoot, - "Title", - $this->getReportTitle($report_id) - ); - - $this->createElement( - $dom, - $nodeRoot, - "PageHeader", - $this->getReportHeader($report_id) - ); - - $results = $this->fetchReportData($report_id); - - $charts_per_page = $this->getReportChartsPerPage($report_id); - - $chartCount = 0; - - foreach ($results as $entry) { - $chartSlot = $chartCount++ % $charts_per_page; - - if ($chartSlot == 0) { - $nodeSection = $dom->createElement("Section"); - $nodeRoot->appendChild($nodeSection); - } - - $this->createElement( - $dom, - $nodeSection, - 'SectionTitle_' . $chartSlot, - $entry['title'] - ); - - if (strtolower($entry['timeframe_type']) == 'user defined') { - list($start_date, $end_date) - = explode(' to ', $entry['comments']); - } - else { - $e = \xd_date\getEndpoints($entry['timeframe_type']); - - $start_date = $e['start_date']; - $end_date = $e['end_date']; - } - - // Update comments and hyperlink so reporting engine can - // work with the correct chart (image) - $entry['comments'] = $start_date . ' to ' . $end_date; - - $imagedata = $this->fetchChartBlob("report", array("report_id" => $report_id, "ordering" => $entry['order'] ) ); - $imagefilename = $outputdir . "/" . $entry['order'] . ".png"; - file_put_contents($imagefilename, $imagedata); - - $entry['image_url'] = $imagefilename; - - if (empty($entry['drill_details'])) { - $entry['drill_details'] = ORGANIZATION_NAME_ABBREV; - } - - $this->createElement( - $dom, - $nodeSection, - 'SectionDrillParameters_' . $chartSlot, - $entry['drill_details'] - ); - - $this->createElement( - $dom, - $nodeSection, - 'SectionDescription_' . $chartSlot, - $entry['comments'] - ); - - $this->createElement( - $dom, - $nodeSection, - 'SectionImage_' . $chartSlot, - $entry['image_url'] - ); - } - - $remainingSlots = $chartCount % $charts_per_page; - - if ($remainingSlots > 0) { - - // Handle remainder of charts - - for ($r = $remainingSlots; $r < $charts_per_page; $r++) { - $this->createElement( - $dom, - $nodeSection, - 'SectionTitle_' . $r, - '' - ); - - $this->createElement( - $dom, - $nodeSection, - 'SectionDrillParameters_' . $r, - '' - ); - - $this->createElement( - $dom, - $nodeSection, - 'SectionDescription_' . $r, - '' - ); - - $this->createElement( - $dom, - $nodeSection, - 'SectionImage_' . $r, - 'dummy_image' - ); - } - } - - $this->createElement( - $dom, - $nodeRoot, - "PageFooter", - $this->getReportFooter($report_id) - ); - - $report_filename = $outputdir . "/" . $report_id . ".xml"; - $bytes = file_put_contents($report_filename, $dom->saveXML() . "\n"); - - if ($bytes === false) { - throw new \Exception("Failed to write report XML definition file"); - } - - return $report_filename; - } public function buildReport($report_id, $export_format) { @@ -1781,8 +1591,6 @@ public function buildReport($report_id, $export_format) return $response; } - $base_path = \xd_utilities\getConfiguration('reporting', 'base_path'); - $report_format = ($export_format != null) ? $export_format : $this->getReportFormat($report_id); // Initialize a temporary working directory for the report generation @@ -1800,43 +1608,15 @@ public function buildReport($report_id, $export_format) throw new \Exception("Failed to create directory '$template_path'"); } - // Copy all report templates into this working directory - - $paths = glob("$base_path/*.jrxml"); - - foreach ($paths as $path) { - $dest = $template_path . '/' . pathinfo($path, PATHINFO_BASENAME); - - if (!copy($path, $dest)) { - throw new \Exception("Failed to copy '$path' to '$dest'"); - } - } - - $report_file_name = $report_id; - $report_output_file = $template_path . '/' . $report_file_name . '.' . strtolower($report_format); + $report_output_file = $template_path . '/' . $report_id . '.' . strtolower($report_format); - // Generate a report definition (XML) to be used as the input to - // the Jasper Report Builder application - $this->writeXMLConfiguration($template_path, $report_id, $export_format); + $settings = $this->gatherReportSettings($report_id); - $charts_per_page = $this->getReportChartsPerPage($report_id); + $rp = new \Reports\ClassicReport($settings); + $rp->writeReport($template_path . '/' . $report_id . '.doc'); - $report_template = 'template_' . $charts_per_page . 'up'; - - $log_file = 'build.log'; - - $buildSuccess = $this->executeReportBuilder( - $template_path, - $report_file_name, - $report_template, - $log_file - ); - - if (!file_exists($report_output_file) || !$buildSuccess) { - $msg = "There was a problem building the report. " - . "See $template_path/$log_file for details or contact " - . "support with that file name."; - throw new \Exception($msg); + if ($report_format == 'pdf') { + exec('HOME=' . $template_path . ' libreoffice --headless --convert-to pdf ' . $template_path . '/' . $report_id . '.doc --outdir ' . $template_path); } return array( @@ -1845,139 +1625,6 @@ public function buildReport($report_id, $export_format) ); } - /** - * Execute the report builder java code. - * - * Runs Jasper Report Builder application (XML --> PDF). - * - * @param string $templatePath Directory containing template files. - * @param string $reportFileName Name used for report files. - * @param string $reportTemplate Template name. - * @param string $logFile Log file name. - */ - protected function executeReportBuilder( - $templatePath, - $reportFileName, - $reportTemplate = 'template', - $logFile = 'build.log' - ) { - $builderPath = $templatePath; - $inputDir = $templatePath; - $outputDir = $templatePath; - $templateDir = $templatePath; - - $inputFile = $reportFileName; - $outputFile = $reportFileName; - - $logPath = "$templatePath/$logFile"; - - $logger = Log::factory('report-builder', array( - 'file' => $logPath, - 'fileLogLevel' => Log::INFO, - 'console' => false, - 'db' => true, - 'mail' => false, - )); - - $logger->info("Using template $reportTemplate"); - - $currentDir = getcwd(); - chdir($builderPath); - - $javaPath = \xd_utilities\getConfiguration('reporting', 'java_path'); - $javacPath = \xd_utilities\getConfiguration('reporting', 'javac_path'); - $basePath = \xd_utilities\getConfiguration('reporting', 'base_path'); - - $classPaths = array( - $basePath, - "$basePath/lib/commons-beanutils/commons-beanutils-1.8.0.jar", - "$basePath/lib/commons-logging/commons-logging.jar", - "$basePath/lib/jasperreports/jasperreports-3.7.6.jar", - "$basePath/lib/commons-collections/commons-collections-2.1.1.jar", - "$basePath/lib/poi/poi-3.6-20091214.jar", - "$basePath/lib/commons-digester/commons-digester-1.7.jar", - "$basePath/lib/itextpdf/itext-2.1.7.jar", - "$basePath/lib/xalan/xalan.jar", - ); - - // Add the current CLASSPATH if it's set in the environment. - $classPath = getenv('CLASSPATH'); - if (!empty($classPath)) { - array_unshift($classPaths, $classPath); - } - - $classPath = implode(':', $classPaths); - - $args = array( - $javaPath, - '-cp', $classPath, - 'Builder', - $inputDir, - $inputFile, - $outputDir, - $outputFile, - $templateDir, - $reportTemplate - ); - - $cmd = implode(' ', array_map('escapeshellarg', $args)); - - // If a javac path has been configured, prepend its dirname to - // the PATH environment variable to ensure that specific javac - // is used by Jasper Reports. - if ($javacPath !== '') { - $javacDir = pathinfo($javacPath, PATHINFO_DIRNAME); - - // If the javac path isn't actually a path, but just a file - // name, pathinfo returns ".". Don't change the PATH since - // the executable is presumably already in the PATH. - if ($javacDir !== '.') { - $path = escapeshellarg($javacDir) . ':' . escapeshellarg(getenv('PATH')); - $cmd = 'PATH=' . $path . ' ' . $cmd; - } - } - - $logger->info("Executing command: $cmd"); - - // Assume everything will work just fine. - $success = true; - - $logger->info(array( - 'message' => 'Build start', - 'ts' => time(), - )); - - $output = array(); - $returnVar = 0; - - exec($cmd . ' 2>&1', $output, $returnVar); - - if (count($output) > 0) { - $logger->warning('Command output start'); - - foreach ($output as $line) { - $logger->warning($line); - } - - $logger->warning('Command output end'); - } - - if ($returnVar != 0) { - $success = false; - $logger->err("Command returned non-zero value '$returnVar'"); - } - - $logger->info(array( - 'message' => 'Build end', - 'ts' => time(), - )); - - chmod($logPath, 0444); - chdir($currentDir); - - return $success; - } - public function mailReport( $report_id, $report_file, @@ -2058,6 +1705,50 @@ public function mailReport( return true; } + /** + * generate a php array containing the report configuration settings + * and the chart images. + * @param $report_id The report to generate + * @return array $settings the report settings + */ + private function gatherReportSettings($report_id) + { + $settings = array(); + + $settings['header'] = $this->getReportHeader($report_id); + $settings['footer'] = $this->getReportFooter($report_id); + $settings['title'] = $this->getReportTitle($report_id); + $settings['charts_per_page'] = (int) $this->getReportChartsPerPage($report_id); + + $settings['charts'] = array(); + + foreach ($this->fetchReportData($report_id) as $entry) { + + $chart = $entry; + + if (empty($entry['drill_details'])) { + $chart['drill_details'] = ORGANIZATION_NAME_ABBREV; + } + + if (strtolower($entry['timeframe_type']) == 'user defined') { + list($start_date, $end_date) + = explode(' to ', $entry['comments']); + } + else { + $e = \xd_date\getEndpoints($entry['timeframe_type']); + + $start_date = $e['start_date']; + $end_date = $e['end_date']; + } + + $chart['comments'] = $start_date . ' to ' . $end_date; + $chart['imagedata'] = $this->fetchChartBlob("report", array("report_id" => $report_id, "ordering" => $entry['order'] ) ); + $settings['charts'][] = $chart; + } + + return $settings; + } + /** retrieve information about the available report templates * for a given set of ACLs. * @param acls array() of acl names diff --git a/composer.json b/composer.json index 911f434c6a..d5879887a4 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ "highsoft/highcharts": "^4.2.5", "ircmaxell/password-compat": "~1", "itextpdf/itextpdf": "^2.1.7", - "jaspersoft/jasperreports-library-jar": "^3.7.6", "jquery/jquery-min-file": "^1.12.4", "justinrainbow/json-schema": "~5.2", "moment/moment-min-file": "^2.13.0", @@ -30,7 +29,8 @@ "tildeio/rsvpjs-min-file": "^3.0.18", "ubccr/log": "1.13.2", "ubccr/simplesamlphp-module-authglobus": "^1.3", - "ubccr/simplesamlphp-module-authoidcoauth2": "^1.1" + "ubccr/simplesamlphp-module-authoidcoauth2": "^1.1", + "phpoffice/phpword": "^0.17.0" }, "require-dev": { "phpunit/phpunit": "~4.8", diff --git a/composer.lock b/composer.lock index 444a94b215..901c3e83e8 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ea6637e0bf229226261351609c44f43a", + "content-hash": "cd159b11be6ece8f357301f4cde41149", "packages": [ { "name": "apache/commons-beanutils", @@ -12,7 +12,6 @@ "dist": { "type": "tar", "url": "https://archive.apache.org/dist/commons/beanutils/binaries/commons-beanutils-1.8.0-bin.tar.gz", - "reference": null, "shasum": "f21decfd6f01a42cae665db8e1a4401b154a2fe9" }, "require": { @@ -33,7 +32,6 @@ "dist": { "type": "tar", "url": "https://archive.apache.org/dist/commons/collections/binaries/commons-collections-2.1.1.tar.gz", - "reference": null, "shasum": "26baa7ff12af5b2484b64c0011f32e48a10b0df9" }, "require": { @@ -54,7 +52,6 @@ "dist": { "type": "tar", "url": "https://archive.apache.org/dist/commons/digester/binaries/commons-digester-1.7.tar.gz", - "reference": null, "shasum": "43842197ddfe6930bd9a20b526e4e8c96bee1137" }, "require": { @@ -75,7 +72,6 @@ "dist": { "type": "tar", "url": "https://archive.apache.org/dist/commons/logging/binaries/commons-logging-1.0.4.tar.gz", - "reference": null, "shasum": "633cad7b22536388da2c0b3ddb0661f25a07e849" }, "require": { @@ -96,7 +92,6 @@ "dist": { "type": "tar", "url": "https://archive.apache.org/dist/poi/release/bin/poi-bin-3.6-20091214.tar.gz", - "reference": null, "shasum": "e65a6fc5acd1c4e09c654cf72e9f70707235d309" }, "require": { @@ -117,7 +112,6 @@ "dist": { "type": "zip", "url": "https://archive.apache.org/dist/xalan/xalan-j/binaries/xalan-j_2_7_1-bin-2jars.zip", - "reference": null, "shasum": "e14810b4c586fb40e80c049b9096215ab22d816d" }, "require": { @@ -138,7 +132,6 @@ "dist": { "type": "file", "url": "https://github.com/carlo/jquery-base64/raw/master/jquery.base64.js", - "reference": null, "shasum": "7f0ba311c1676b1b730b29b06e1a9e9e55760acc" }, "require": { @@ -155,28 +148,31 @@ }, { "name": "composer/installers", - "version": "v1.8.0", + "version": "v1.9.0", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "7d610d50aae61ae7ed6675e58efeabdf279bb5e3" + "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/7d610d50aae61ae7ed6675e58efeabdf279bb5e3", - "reference": "7d610d50aae61ae7ed6675e58efeabdf279bb5e3", + "url": "https://api.github.com/repos/composer/installers/zipball/b93bcf0fa1fccb0b7d176b0967d969691cd74cca", + "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0" + "composer-plugin-api": "^1.0 || ^2.0" }, "replace": { "roundcube/plugin-installer": "*", "shama/baton": "*" }, "require-dev": { - "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "^4.8.36" + "composer/composer": "1.6.* || 2.0.*@dev", + "composer/semver": "1.0.* || 2.0.*@dev", + "phpunit/phpunit": "^4.8.36", + "sebastian/comparator": "^1.2.4", + "symfony/process": "^2.3" }, "type": "composer-plugin", "extra": { @@ -275,7 +271,17 @@ "zend", "zikula" ], - "time": "2020-02-07T10:39:20+00:00" + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-04-07T06:57:05+00:00" }, { "name": "doctrine/lexer", @@ -613,7 +619,6 @@ "dist": { "type": "zip", "url": "https://code.highcharts.com/zips/Highcharts-4.2.5.zip", - "reference": null, "shasum": "e4ad04f3a6c1b5042d25a8f960f62ce5aeb32777" }, "require": { @@ -677,7 +682,6 @@ "dist": { "type": "file", "url": "https://repo1.maven.org/maven2/com/lowagie/itext/2.1.7/itext-2.1.7.jar", - "reference": null, "shasum": "892bfb3e97074a61123b3b2d7caa2db112750864" }, "type": "vanilla-plugin", @@ -731,34 +735,12 @@ "abandoned": "simplesamlphp/twig-configurable-i18n", "time": "2016-10-03T12:34:15+00:00" }, - { - "name": "jaspersoft/jasperreports-library-jar", - "version": "3.7.6", - "dist": { - "type": "file", - "url": "https://downloads.sourceforge.net/project/jasperreports/archive/jasperreports/JasperReports%203.7.6/jasperreports-3.7.6.jar", - "reference": null, - "shasum": "6d32314023c5e33a649b6f40fab51eb0922a6da9" - }, - "require": { - "composer/installers": "~1.0" - }, - "type": "vanilla-plugin", - "extra": { - "installer-name": "jasperreports" - }, - "license": [ - "LGPL-3.0" - ], - "homepage": "http://community.jaspersoft.com/project/jasperreports-library" - }, { "name": "jquery/jquery-min-file", "version": "1.12.4", "dist": { "type": "file", "url": "https://code.jquery.com/jquery-1.12.4.min.js", - "reference": null, "shasum": "5a9dcfbef655a2668e78baebeaa8dc6f41d8dabb" }, "require": { @@ -845,7 +827,6 @@ "dist": { "type": "file", "url": "https://raw.githubusercontent.com/moment/moment/2.13.0/min/moment.min.js", - "reference": null, "shasum": "a8ca7eea2616fa92e2e85ba6291af6ea012fd190" }, "require": { @@ -866,7 +847,6 @@ "dist": { "type": "file", "url": "https://raw.githubusercontent.com/moment/moment-timezone/0.5.4/builds/moment-timezone-with-data.min.js", - "reference": null, "shasum": "39b9fccc20863c23f19524a756d75cfef2ff9cbe" }, "require": { @@ -930,6 +910,43 @@ ], "time": "2019-01-03T20:59:08+00:00" }, + { + "name": "pclzip/pclzip", + "version": "2.8.2", + "source": { + "type": "git", + "url": "https://github.com/ivanlanin/pclzip.git", + "reference": "19dd1de9d3f5fc4d7d70175b4c344dee329f45fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ivanlanin/pclzip/zipball/19dd1de9d3f5fc4d7d70175b4c344dee329f45fd", + "reference": "19dd1de9d3f5fc4d7d70175b4c344dee329f45fd", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "pclzip.lib.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Vincent Blavet" + } + ], + "description": "A PHP library that offers compression and extraction functions for Zip formatted archives", + "homepage": "http://www.phpconcept.net/pclzip", + "keywords": [ + "php", + "zip" + ], + "time": "2014-06-05T11:42:24+00:00" + }, { "name": "pear/pear_exception", "version": "v1.0.0", @@ -1062,6 +1079,170 @@ "description": "PHPMailer is a full-featured email creation and transfer class for PHP", "time": "2018-11-15T22:32:31+00:00" }, + { + "name": "phpoffice/common", + "version": "0.2.9", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/Common.git", + "reference": "edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/Common/zipball/edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d", + "reference": "edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d", + "shasum": "" + }, + "require": { + "pclzip/pclzip": "^2.8", + "php": ">=5.3.0" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "2.*", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^4.8.36 || ^7.0", + "sebastian/phpcpd": "2.*", + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\Common\\": "src/Common/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Mark Baker" + }, + { + "name": "Franck Lefevre", + "homepage": "http://rootslabs.net" + } + ], + "description": "PHPOffice Common", + "homepage": "http://phpoffice.github.io", + "keywords": [ + "common", + "component", + "office", + "php" + ], + "time": "2018-07-13T14:12:34+00:00" + }, + { + "name": "phpoffice/phpword", + "version": "0.17.0", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PHPWord.git", + "reference": "b8346af548d399acd9e30fc76ab0c55c2fec03a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PHPWord/zipball/b8346af548d399acd9e30fc76ab0c55c2fec03a5", + "reference": "b8346af548d399acd9e30fc76ab0c55c2fec03a5", + "shasum": "" + }, + "require": { + "ext-xml": "*", + "php": "^5.3.3 || ^7.0", + "phpoffice/common": "^0.2.9", + "zendframework/zend-escaper": "^2.2" + }, + "require-dev": { + "dompdf/dompdf": "0.8.*", + "ext-gd": "*", + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^2.2", + "mpdf/mpdf": "5.7.4 || 6.* || 7.*", + "php-coveralls/php-coveralls": "1.1.0 || ^2.0", + "phploc/phploc": "2.* || 3.* || 4.*", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^4.8.36 || ^7.0", + "squizlabs/php_codesniffer": "^2.9", + "tecnickcom/tcpdf": "6.*" + }, + "suggest": { + "dompdf/dompdf": "Allows writing PDF", + "ext-gd2": "Allows adding images", + "ext-xmlwriter": "Allows writing OOXML and ODF", + "ext-xsl": "Allows applying XSL style sheet to headers, to main document part, and to footers of an OOXML template", + "ext-zip": "Allows writing OOXML and ODF" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "0.18-dev" + } + }, + "autoload": { + "psr-4": { + "PhpOffice\\PhpWord\\": "src/PhpWord" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0" + ], + "authors": [ + { + "name": "Mark Baker" + }, + { + "name": "Gabriel Bull", + "email": "me@gabrielbull.com", + "homepage": "http://gabrielbull.com/" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net/blog/" + }, + { + "name": "Ivan Lanin", + "homepage": "http://ivan.lanin.org" + }, + { + "name": "Roman Syroeshko", + "homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/" + }, + { + "name": "Antoine de Troostembergh" + } + ], + "description": "PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)", + "homepage": "http://phpoffice.github.io", + "keywords": [ + "ISO IEC 29500", + "OOXML", + "Office Open XML", + "OpenDocument", + "OpenXML", + "PhpOffice", + "PhpWord", + "Rich Text Format", + "WordprocessingML", + "doc", + "docx", + "html", + "odf", + "odt", + "office", + "pdf", + "php", + "reader", + "rtf", + "template", + "template processor", + "word", + "writer" + ], + "time": "2019-10-01T20:43:33+00:00" + }, { "name": "pimple/pimple", "version": "v1.1.1", @@ -1199,7 +1380,6 @@ "dist": { "type": "zip", "url": "https://cdn.sencha.com/ext/gpl/ext-3.4.1.1-gpl.zip", - "reference": null, "shasum": "26734b47eae909ff7f8cd7de4cadfb3531bd3cdc" }, "require": { @@ -1431,14 +1611,14 @@ "LGPL-2.1-or-later" ], "authors": [ - { - "name": "Olav Morken", - "email": "olav.morken@uninett.no" - }, { "name": "Andreas Åkre Solberg", "email": "andreas.solberg@uninett.no" }, + { + "name": "Olav Morken", + "email": "olav.morken@uninett.no" + }, { "name": "Jaime Perez", "email": "jaime.perez@uninett.no" @@ -2226,7 +2406,6 @@ "dist": { "type": "file", "url": "https://rsvpjs-builds.s3.amazonaws.com/rsvp-1979d5ad89293dadbe7656dd53d152f7426fa35e.min.js", - "reference": null, "shasum": "24522232c6252718638ad3475e236da7692fa4ae" }, "require": { @@ -2294,6 +2473,7 @@ "i18n", "text" ], + "abandoned": true, "time": "2018-12-05T18:34:18+00:00" }, { @@ -2546,6 +2726,51 @@ "apr1" ], "time": "2015-02-11T11:06:42+00:00" + }, + { + "name": "zendframework/zend-escaper", + "version": "2.5.1", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-escaper.git", + "reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73", + "reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73", + "shasum": "" + }, + "require": { + "php": ">=5.3.23" + }, + "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" + } + }, + "autoload": { + "psr-4": { + "Zend\\Escaper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "homepage": "https://github.com/zendframework/zend-escaper", + "keywords": [ + "escaper", + "zf2" + ], + "abandoned": "laminas/laminas-escaper", + "time": "2015-06-03T14:05:37+00:00" } ], "packages-dev": [ @@ -3568,5 +3793,6 @@ "platform-dev": [], "platform-overrides": { "php": "5.4" - } + }, + "plugin-api-version": "1.1.0" } diff --git a/configuration/portal_settings.ini b/configuration/portal_settings.ini index 680ce95977..92b88d2778 100644 --- a/configuration/portal_settings.ini +++ b/configuration/portal_settings.ini @@ -98,9 +98,6 @@ captcha_public_key = "" captcha_private_key = "" [reporting] -base_path = "/usr/share/xdmod/reporting/jasper_builder" -java_path = "" -javac_path = "" chromium_path = "" [logger] diff --git a/docs/notices.md b/docs/notices.md index 7bc08497a2..2e640eb8e2 100644 --- a/docs/notices.md +++ b/docs/notices.md @@ -31,8 +31,6 @@ where denoted. These software products are free for commercial use. under the [New BSD License][new-bsd]. - [jQuery](http://jquery.com/), which is available under the [MIT License][mit]. -- [Jasper Reports](http://community.jaspersoft.com/project/jasperreports-library), - which is available under the [LGPL 3.0][lgpl3]. - [Commons BeanUtils](http://commons.apache.org/proper/commons-beanutils/), which is available under the [Apache License Version 2.0][apache2]. - [Commons Collections](http://commons.apache.org/proper/commons-collections/), @@ -57,6 +55,8 @@ where denoted. These software products are free for commercial use. the [Apache License Version 2.0][apache2]. - [PHP SQL Parser](http://code.google.com/p/php-sql-parser/), which is available under the [New BSD License][new-bsd]. +- [PHP Word](https://github.com/PHPOffice/PHPWord), which is available under the + [LGPL 3.0][lgpl3], - [JSON Schema for PHP](https://github.com/justinrainbow/json-schema), which is available under the [MIT License][mit]. - [Symfony Process Component](https://symfony.com/components/Process), which is diff --git a/docs/software-requirements.md b/docs/software-requirements.md index 5b1c7df176..bf93b71e91 100644 --- a/docs/software-requirements.md +++ b/docs/software-requirements.md @@ -21,7 +21,8 @@ Open XDMoD requires the following software: - [PEAR MDB2 MySQL Driver][pear-mdb2-mysql] - [mbstring][php-mbstring] - [APCu][php-pecl-apcu] -- [Java][] 1.8 including the [JDK][] +- [libreoffice][] + - Only the libreoffice-writer component of libreoffice is used. - [Chromium][] - `chromium-headless` is assumed, but chromium has been known to work - [libRsvg][] @@ -50,8 +51,7 @@ Open XDMoD requires the following software: [pear-mdb2-mysql]: https://pear.php.net/package/MDB2_Driver_mysql [php-mbstring]: https://secure.php.net/manual/en/book.mbstring.php [php-pecl-apcu]: https://www.php.net/manual/en/book.apcu.php -[java]: https://java.com/ -[jdk]: http://www.oracle.com/technetwork/java/javase/downloads/index.html +[libreoffice]: https://www.libreoffice.org [chromium]: https://www.chromium.org/Home [librsvg]: https://wiki.gnome.org/Projects/LibRsvg [exiftool]: http://www.sno.phy.queensu.ca/%7Ephil/exiftool/ @@ -83,7 +83,7 @@ added with this command for CentOS 7: # yum install httpd php php-cli php-mysql php-gd \ gmp-devel php-gmp php-pdo php-xml \ php-pear-MDB2 php-pear-MDB2-Driver-mysql \ - java-1.8.0-openjdk java-1.8.0-openjdk-devel \ + libreoffice \ mariadb-server mariadb cronie logrotate \ perl-Image-ExifTool php-mbstring php-pecl-apcu jq \ chromium-headless librsvg2-tools diff --git a/html/controllers/report_builder/save_report.php b/html/controllers/report_builder/save_report.php index 4cefeb8211..1c39fb24bf 100644 --- a/html/controllers/report_builder/save_report.php +++ b/html/controllers/report_builder/save_report.php @@ -32,7 +32,6 @@ try { $user = \xd_security\getLoggedInUser(); $rm = new XDReportManager($user); - $base_path = \xd_utilities\getConfiguration('reporting', 'base_path'); $post = filter_input_array(INPUT_POST, $filters); $map = array(); diff --git a/open_xdmod/build_scripts/templates/install.template b/open_xdmod/build_scripts/templates/install.template index 3a4c356cf0..022dfa5286 100755 --- a/open_xdmod/build_scripts/templates/install.template +++ b/open_xdmod/build_scripts/templates/install.template @@ -513,11 +513,6 @@ function substitutePaths($dirs) '#^\$baseDir\s*=.+$#m' => '$baseDir = \'' . $dirs['data'] . "';", )); - substituteInFile($destDir . $dirs['data'] . '/reporting/jasper_builder/ReportBuilder.sh', array( - '#^\s*DIR\s*=.+$#m' => '', - '#^(\s*)SETTINGS\s*=.+$#m' => '$1SETTINGS="' . $dirs['conf'] . '/portal_settings.ini";', - )); - substituteInFile($destDir . $dirs['data'] . '/configuration/constants.php', array( '/__XDMOD_BIN_PATH__/' => $dirs['bin'], "#^define\('CONFIG_DIR',.+$#m" diff --git a/open_xdmod/modules/xdmod/assets/setup.sh b/open_xdmod/modules/xdmod/assets/setup.sh index 567ce54e2b..988b2abd2d 100755 --- a/open_xdmod/modules/xdmod/assets/setup.sh +++ b/open_xdmod/modules/xdmod/assets/setup.sh @@ -13,7 +13,3 @@ composer install --no-dev echo Installing npm managed dependencies npm install --production --prefix etl/js - -echo Compiling report builder code -cd "$xdmod_dir/reporting/jasper_builder" -bash ReportBuilder.sh -C diff --git a/open_xdmod/modules/xdmod/build.json b/open_xdmod/modules/xdmod/build.json index ad693c8f4e..181ff992bb 100644 --- a/open_xdmod/modules/xdmod/build.json +++ b/open_xdmod/modules/xdmod/build.json @@ -47,7 +47,6 @@ "etl", "html", "libraries", - "reporting", "templates", "tools", "vendor", diff --git a/open_xdmod/modules/xdmod/xdmod.spec.in b/open_xdmod/modules/xdmod/xdmod.spec.in index 4b87498d26..91c5d2edbd 100644 --- a/open_xdmod/modules/xdmod/xdmod.spec.in +++ b/open_xdmod/modules/xdmod/xdmod.spec.in @@ -15,7 +15,7 @@ Requires: httpd mod_ssl Requires: mariadb >= 5.5.3 Requires: php >= 5.4 php-cli php-mysql php-pdo php-gd php-xml php-mbstring Requires: php-pear-MDB2 php-pear-MDB2-Driver-mysql php-pecl-apcu -Requires: java-1.8.0-openjdk java-1.8.0-openjdk-devel +Requires: libreoffice-writer Requires: chromium-headless Requires: librsvg2-tools Requires: crontabs diff --git a/reporting/jasper_builder/Builder.java b/reporting/jasper_builder/Builder.java deleted file mode 100644 index 6612c146c8..0000000000 --- a/reporting/jasper_builder/Builder.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - -Author: Lizhe Wang -Date: Dec 1 2010 - -Last Updated: May 4, 2012 - -*/ - -public class Builder { - - public static void main(String args[]) { - - String inputfile = ""; - String outputfile = ""; - String inputdir = ""; - String outputdir = ""; - String templatedir = ""; - String template = ""; - - boolean isOk = true; - boolean flag = false; - - if (args != null) { - - if (args[0] != null) - inputdir = args[0]; - else - isOk = false; - - if (args[1] != null) - inputfile = args[1]+".xml"; - else - isOk = false; - - if (args[2] != null) - outputdir = args[2]; - else - isOk = false; - if (args[3] != null) - outputfile = args[3]; - else - isOk = false; - if (args[4] != null) - templatedir = args[4]; - else - isOk = false; - if (args[5] != null) - template = args[5]; - else - isOk = false; - - }//if (args != null) - - if (isOk) { - - try { - - Translate tran = new Translate(inputdir, inputfile,outputdir, outputfile, templatedir, template); - if(tran.report.getFormat().toLowerCase().equals("pdf")){ - flag = tran.translateToPDF(); - } - else if(tran.report.getFormat().toLowerCase().equals("xls")){ - flag = tran.translateToXLS(); - } - else if(tran.report.getFormat().toLowerCase().equals("html")){ - flag = tran.translateToHTML(); - } - else if(tran.report.getFormat().toLowerCase().equals("doc")){ - flag = tran.translateToDoc(); - } - else if(tran.report.getFormat().toLowerCase().equals("pptx")){ - flag = tran.translateToPptx(); - } - else{ - //System.out.println("PDF"); - flag = tran.translateToPDF(); - - } - - } - catch (Exception e) { - e.printStackTrace(); - } - - } - else { - System.out.println("error"); - } - - }//main - -}//Builder diff --git a/reporting/jasper_builder/MyDataSource.java b/reporting/jasper_builder/MyDataSource.java deleted file mode 100644 index 74d1c191d0..0000000000 --- a/reporting/jasper_builder/MyDataSource.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - -Author: Lizhe Wang -Date: Dec 1 2010 - -Last Updated: May 4, 2012 - -MyDataSource is executed against a Jasper Report Template XML file (.jrxml) - -*/ - -import net.sf.jasperreports.engine.JRDataSource; -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JRField; - -public class MyDataSource implements JRDataSource -{ - - private Report report; - private int index = -1; - - // --------------------------------------------- - - public MyDataSource(Report report) - { - this.report = report; - } - - // --------------------------------------------- - - public boolean next() throws JRException - { - index++; - return (index < report.getSections().size()); - } - - // --------------------------------------------- - - public Object getFieldValue(JRField field) throws JRException - { - - Object value = null; - String fieldName = field.getName(); - - for (int entryIndex = 0; entryIndex <= ReportSettings.MAX_CHARTS_PER_PAGE; entryIndex++) { - - if (("Section_Description_" + entryIndex).equals(fieldName)) - { - value = (String)report.getSections().get(index).getSectionDescription(entryIndex).trim(); - } - else if (("Section_Drill_Parameters_" + entryIndex).equals(fieldName)) - { - value = (String)report.getSections().get(index).getSectionDrillParameters(entryIndex).trim(); - } - else if (("Section_Image_" + entryIndex).equals(fieldName)) - { - value = (String)report.getSections().get(index).getSectionImage(entryIndex).trim(); - } - else if (("Section_Title_" + entryIndex).equals(fieldName)) - { - value = (String)report.getSections().get(index).getSectionTitle(entryIndex).trim(); - } - - }//for - - return value; - - }//getFieldValue - -}//MyDataSource diff --git a/reporting/jasper_builder/MySection.java b/reporting/jasper_builder/MySection.java deleted file mode 100644 index 6869e383e8..0000000000 --- a/reporting/jasper_builder/MySection.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - -Author: Lizhe Wang -Date: Dec 1 2010 - -Last Updated: May 4, 2012 - -*/ - -public class MySection { - - private String[] sectionTitle; - private String[] sectionDrillParameters; - private String[] sectionDescription; - private String[] sectionImage; - - // --------------------------------------------- - - public MySection () { - - sectionTitle = new String[ReportSettings.MAX_CHARTS_PER_PAGE]; - sectionDrillParameters = new String[ReportSettings.MAX_CHARTS_PER_PAGE]; - sectionDescription = new String[ReportSettings.MAX_CHARTS_PER_PAGE]; - sectionImage = new String[ReportSettings.MAX_CHARTS_PER_PAGE]; - - }//MySection - - // --------------------------------------------- - - public String getSectionTitle(int slot) { - return sectionTitle[slot]; - } - - // --------------------------------------------- - - public void setSectionTitle(String sectionTitle, int slot) { - this.sectionTitle[slot] = sectionTitle; - } - - // --------------------------------------------- - - public String getSectionDescription(int slot) { - return sectionDescription[slot]; - } - - // --------------------------------------------- - - public void setSectionDescription(String sectionDescription, int slot) { - this.sectionDescription[slot] = sectionDescription; - } - - // --------------------------------------------- - - public String getSectionDrillParameters(int slot) { - return sectionDrillParameters[slot]; - } - - // --------------------------------------------- - - public void setSectionDrillParameters(String sectionDrillParameters, int slot) { - this.sectionDrillParameters[slot] = sectionDrillParameters; - } - - // --------------------------------------------- - - public String getSectionImage(int slot) { - return sectionImage[slot]; - } - - // --------------------------------------------- - - public void setSectionImage(String sectionImage, int slot) { - this.sectionImage[slot] = sectionImage; - } - -}//MySection diff --git a/reporting/jasper_builder/README.txt b/reporting/jasper_builder/README.txt deleted file mode 100644 index 4387d414df..0000000000 --- a/reporting/jasper_builder/README.txt +++ /dev/null @@ -1,4 +0,0 @@ -Jasper Report Builder for XDMoD ---------------------------------- - -- Run 'sh ReportBuilder.sh -C' to retrieve the syntax needed to compile the Java Source Code \ No newline at end of file diff --git a/reporting/jasper_builder/Report.java b/reporting/jasper_builder/Report.java deleted file mode 100644 index 730ba8473e..0000000000 --- a/reporting/jasper_builder/Report.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - -Author: Lizhe Wang -Date: Dec 1 2010 - -Last Updated: May 4, 2012 - -*/ - -import java.util.ArrayList; - -//!ELEMENT Report ( User, Title, pageHeader, Section*, pageFooter ) > -public class Report { - - private String UserLastName; - private String UserFirstName; - private String Email; - private String Title; - private String pageHeader; - private String Format; - private ArrayList sections; - private String pageFooter; - - // --------------------------------------------- - - public String getUserLastName() { - return UserLastName; - } - - // --------------------------------------------- - - public String getUserFirstName() { - return UserFirstName; - } - - // --------------------------------------------- - - public void setUserLastName(String userLastName) { - UserLastName = userLastName; - } - - // --------------------------------------------- - - public void setUserFirstName(String userFirstName) { - UserFirstName = userFirstName; - } - - // --------------------------------------------- - - public String getEmail() { - return Email; - } - - // --------------------------------------------- - - public void setEmail(String email) { - Email = email; - } - - // --------------------------------------------- - - public String getTitle() { - return Title; - } - - // --------------------------------------------- - - public void setTitle(String title) { - Title = title; - } - - // --------------------------------------------- - - public String getPageHeader() { - return pageHeader; - } - - // --------------------------------------------- - - public void setPageHeader(String pageHeader) { - this.pageHeader = pageHeader; - } - - // --------------------------------------------- - - public ArrayList getSections() { - return sections; - } - - // --------------------------------------------- - - public void setSections(ArrayList sections) { - this.sections = sections; - } - - // --------------------------------------------- - - public String getPageFooter() { - return pageFooter; - } - - // --------------------------------------------- - - public void setPageFooter(String pageFooter) { - this.pageFooter = pageFooter; - } - - // --------------------------------------------- - - public String getFormat() { - return Format; - } - - // --------------------------------------------- - - public void setFormat(String format) { - Format = format; - } - -}//Report diff --git a/reporting/jasper_builder/ReportBuilder.sh b/reporting/jasper_builder/ReportBuilder.sh deleted file mode 100755 index e4b6333ef0..0000000000 --- a/reporting/jasper_builder/ReportBuilder.sh +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/bash -#--------------------------------------------------------------------------------- -# Author: Ryan Gentner -# Tasks: Set Class Path, Compile Java code, Execute Report Builder -# Updated: 6/10/2013 -#--------------------------------------------------------------------------------- - -PATH=$PATH:/opt/java/bin/ - -function getSetting { - # This settings file path is replaced during the (open source) - # installation process, so make sure that works if this is ever - # changed. - DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - SETTINGS="$DIR/../../configuration/portal_settings.ini" - - if ! [ -e "$SETTINGS" ]; then - return - fi - - SECTION=$1 - PARAM=$2 - - sed -n -e "/\[$SECTION\]/,/\[/ p" $SETTINGS | grep $PARAM | sed "s/$PARAM = \(['\"]\)\(.*\)\1/\2/" -} - -# ================================================================== - -JAVA=$(getSetting "reporting" "java_path") -JAVAC=$(getSetting "reporting" "javac_path") - -# Use defaults on PATH if there is no configuration file or no values were set. -JAVA="${JAVA:-java}" -JAVAC="${JAVAC:-javac}" - -BASEPATH="$(cd "$(dirname "$0")" && pwd -P)" - -# ================================================================== - -displayUsage() { - echo "Invalid arguments" - echo "Usage: ReportBuilder.sh [options]" - echo "-C : compile java source code" - echo "-W : working directory (the temporary space used for the build)" - echo "-E : execute report builder, it requires the following arguments:" - echo " -W + working directory (source and destination, including template files)" - echo " -B + base filename (without file type extension, .xml, .pdf, .docx, …) " - echo " -T + JasperReport template file name (without file type extension, .jrxml)" - - exit -} - -# Set up java classpath string ===================================== - -path="$BASEPATH/" -path="$path:$BASEPATH/lib/commons-beanutils/commons-beanutils-1.8.0.jar" -path="$path:$BASEPATH/lib/commons-logging/commons-logging.jar" -path="$path:$BASEPATH/lib/jasperreports/jasperreports-3.7.6.jar" -path="$path:$BASEPATH/lib/commons-collections/commons-collections-2.1.1.jar" -path="$path:$BASEPATH/lib/poi/poi-3.6-20091214.jar" -path="$path:$BASEPATH/lib/commons-digester/commons-digester-1.7.jar" -path="$path:$BASEPATH/lib/itextpdf/itext-2.1.7.jar" -path="$path:$BASEPATH/lib/xalan/xalan.jar" - -CLASSPATH=${CLASSPATH}:${path} - -# Must take parameters ============================================= - -if [ $# = 0 ]; then - displayUsage - exit -fi - -# Default values =================================================== - -template="template" -inputfile="NULL" -outputfile="NULL" -execute=0 -compile=0 -builder_path="." - -# ================================================================== - -while getopts "W:B:T:F:CE" OPTION -do - case $OPTION in - E) - execute=1 - ;; - W) - builder_path=$OPTARG - inputdir=$OPTARG - outputdir=$OPTARG - templatedir=$OPTARG - ;; - B) - inputfile=$OPTARG - outputfile=$OPTARG - ;; - T) - template=$OPTARG - ;; - C) - compile=1 - ;; - ?) - displayUsage - exit - ;; - esac -done - -# Compile (if -C passed in) ======================================== - -if [ $compile = 1 ]; then - cd $builder_path - echo "Attempting to compile JasperReport code..." - echo "$JAVAC -classpath ${CLASSPATH} *.java" - echo - $JAVAC -classpath ${CLASSPATH} *.java - exit -fi - -# Execute report builder =========================================== - -if [ $execute = 1 ]; then - if [ $inputfile = "NULL" ] || [ $outputfile = "NULL" ]; then - displayUsage - exit - fi - - cd $builder_path - - echo "Start: `date` `date +%s`" > $outputdir/build_info - $JAVA -cp ${CLASSPATH} Builder $inputdir $inputfile $outputdir $outputfile $templatedir $template - echo "End: `date` `date +%s`" >> $outputdir/build_info - chmod 444 $outputdir/build_info -fi diff --git a/reporting/jasper_builder/ReportSettings.java b/reporting/jasper_builder/ReportSettings.java deleted file mode 100644 index e6279f3853..0000000000 --- a/reporting/jasper_builder/ReportSettings.java +++ /dev/null @@ -1,6 +0,0 @@ - -public class ReportSettings { - - public static final int MAX_CHARTS_PER_PAGE = 2; - -}//ReportSettings diff --git a/reporting/jasper_builder/Translate.java b/reporting/jasper_builder/Translate.java deleted file mode 100644 index d67431270f..0000000000 --- a/reporting/jasper_builder/Translate.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - -Author: Lizhe Wang -Date: Dec 1 2010 - -Last Updated: May 4, 2012 - -*/ - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.HashMap; -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JRExporterParameter; -import net.sf.jasperreports.engine.JasperCompileManager; -import net.sf.jasperreports.engine.JasperFillManager; -import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JasperReport; -import net.sf.jasperreports.engine.JasperRunManager; -import net.sf.jasperreports.engine.export.JExcelApiExporter; -import net.sf.jasperreports.engine.export.JRCsvExporter; -import net.sf.jasperreports.engine.export.JRXhtmlExporter; -import net.sf.jasperreports.engine.export.JRXlsExporter; -import net.sf.jasperreports.engine.export.JRXlsExporterParameter; -import net.sf.jasperreports.engine.export.JRHtmlExporter; -import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; -import net.sf.jasperreports.engine.export.JRPdfExporter; -import net.sf.jasperreports.engine.export.JRRtfExporter; -import net.sf.jasperreports.engine.export.JRXmlExporter; -import net.sf.jasperreports.engine.export.oasis.JROdtExporter; -import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter; -import net.sf.jasperreports.engine.export.ooxml.JRPptxExporter; -import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter; -import net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory; -import net.sf.jasperreports.engine.util.JRLoader; -import net.sf.jasperreports.engine.util.JRXmlUtils; -import net.sf.jasperreports.engine.util.JRLoader; -import net.sf.jasperreports.engine.util.AbstractSampleApp; -import net.sf.jasperreports.engine.JasperExportManager; -import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JasperPrintManager; - -public class Translate { - - private String inputfile = null; - private String inputdir =null ; - private String outputdir =null ; - private String outputfile =null ; - private String templatedir = null; - private String template = null; - - public Report report = null; - - private JasperReport jasperReport; - private JasperPrint jasperPrint = null; - private File reportFile = null; - private MyDataSource cds = null; - private String position; - HashMap arg = null; - - // --------------------------------------------- - - public Translate(String inputdir, String inputfile, String outputdir, String outputfile, String templatedir, String template) { - - this.inputdir=inputdir; - this.outputdir = outputdir; - this.inputfile = inputfile; - this.outputfile = outputfile; - this.templatedir = templatedir; - this.template = template; - - report = XmlParser.parse(inputdir+"/"+inputfile); - - try { - JasperCompileManager.compileReportToFile(templatedir+"/"+template+".jrxml", templatedir+"/"+template+".jasper"); - } - catch (JRException e1) { - e1.printStackTrace(); - } - - reportFile = new File(templatedir+"/"+template+".jasper"); - cds = new MyDataSource(report); - arg = new HashMap(); - arg.put("title", report.getTitle()); - arg.put("user", report.getUserFirstName()+ " " + report.getUserLastName()); - arg.put("email", report.getEmail()); - arg.put("pageHeader", report.getPageHeader()); - arg.put("pageFooter", report.getPageFooter()); - - try { - - jasperReport = (JasperReport) JRLoader.loadObject(reportFile.getPath()); - jasperPrint = JasperFillManager.fillReport(jasperReport, arg, cds); - JasperFillManager.fillReportToFile(jasperReport, templatedir+"/"+template+".jrprint", arg, cds); - - } - catch (Exception e) { - e.printStackTrace(); - } - - }//Translate - - // --------------------------------------------- - - public boolean translateToPDF() throws JRException { - - boolean flag = false; - position = outputdir + "/"+outputfile + ".pdf"; - JRPdfExporter pdfExporter = new JRPdfExporter(); - pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); - pdfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, position); - - try { - - pdfExporter.exportReport(); - flag = true; - - } - catch (JRException e) { - e.printStackTrace(); - } - - return flag; - - }//translateToPDF - - // --------------------------------------------- - - public boolean translateToDoc() throws JRException { - - boolean flag = false; - position = outputdir + "/"+outputfile + ".doc"; - JRDocxExporter docxExporter = new JRDocxExporter(); - docxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); - docxExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, position); - - try { - - docxExporter.exportReport(); - flag = true; - - } - catch (JRException e) { - e.printStackTrace(); - } - - return flag; - - }//translateToDoc - - // --------------------------------------------- - - public boolean translateToPptx() throws JRException { - - boolean flag = false; - position = outputdir + "/"+outputfile + ".pptx"; - JRPptxExporter pptxExporter = new JRPptxExporter(); - pptxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); - pptxExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, position); - - try { - - pptxExporter.exportReport(); - flag = true; - - } - catch (JRException e) { - e.printStackTrace(); - } - - return flag; - - }//translateToPptx - - // --------------------------------------------- - - public boolean translateToXLS() { - - boolean flag = false; - position = outputdir + "/"+outputfile + ".xls"; - - try { - - File in = new File(inputfile); - File out = new File(position); - XMLToExcel excel = new XMLToExcel(); - excel.generateExcel(in, out); - - } - catch (Exception e) { - e.printStackTrace(); - } - - return flag; - - }//translateToXLS - - // --------------------------------------------- - - public boolean translateToHTML() { - - boolean flag = false; - position = inputfile.substring(0, inputfile.indexOf("."))+ ".html"; - - try { - - JRHtmlExporter htmlExporter = new JRHtmlExporter(); - htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); - htmlExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, position); - htmlExporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.TRUE); - htmlExporter.setParameter( JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE); - htmlExporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT, JRHtmlExporterParameter.SIZE_UNIT_POINT); - - try { - - htmlExporter.exportReport(); - flag = true; - - } catch (JRException e) { - e.printStackTrace(); - } - - } - catch (Exception e) { - e.printStackTrace(); - } - - return flag; - - }//translateToHTML - -}//Translate diff --git a/reporting/jasper_builder/XMLToExcel.java b/reporting/jasper_builder/XMLToExcel.java deleted file mode 100644 index 74402d9dfd..0000000000 --- a/reporting/jasper_builder/XMLToExcel.java +++ /dev/null @@ -1,181 +0,0 @@ -/* -Author: Lizhe Wang -Date: 12/18/2010 -*/ - -import org.apache.poi.hssf.usermodel.*; -import org.apache.xpath.NodeSet; -import org.w3c.dom.*; -import org.xml.sax.InputSource; -import java.io.*; -import javax.xml.xpath.*; -import org.w3c.dom.Document; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.NodeList; - -public class XMLToExcel{ -private int section_num; -private int column_num; -public void generateExcel(File in, File out) -{/* start of generateExcel */ - DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); - - try{ - HSSFWorkbook wb = new HSSFWorkbook(); - - DocumentBuilder builder = f.newDocumentBuilder(); - Document d = builder.parse(in); - NodeList nl = d.getElementsByTagName("Section"); - - HSSFCellStyle cellStyle = wb.createCellStyle(); - cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM); - cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM); - - HSSFSheet firstSheet = wb.createSheet("Overview"); - firstSheet.setColumnWidth((short) 0, (short) (250 * 50)); - firstSheet.setColumnWidth((short) 1, (short) (250 * 50)); - HSSFRow R = firstSheet.createRow(( short) 0); - HSSFCell C = R.createCell((short) 0); - C.setCellValue("Report Title"); - C.setCellStyle(cellStyle); - C = R.createCell((short) 1); - C.setCellValue( d.getElementsByTagName("Title").item(0).getFirstChild().getNodeValue()); - C.setCellStyle(cellStyle); - - R = firstSheet.createRow(( short) 1); - C = R.createCell((short) 0); - C.setCellValue( d.getElementsByTagName("FirstName").item(0).getFirstChild().getNodeValue()); - C.setCellStyle(cellStyle); - C = R.createCell((short) 1); - C.setCellValue( d.getElementsByTagName("LastName").item(0).getFirstChild().getNodeValue()); - C.setCellStyle(cellStyle); - C = R.createCell((short) 2); - C.setCellValue( d.getElementsByTagName("Email").item(0).getFirstChild().getNodeValue()); - C.setCellStyle(cellStyle); - - - - - int j=2; - - for (int i = 0; i < nl.getLength(); i++) - { - - HSSFSheet spreadSheet = wb.createSheet(d.getElementsByTagName("SectionTitle").item(i).getFirstChild().getNodeValue()); - //System.out.println(d.getElementsByTagName("SectionTitle").item(i).getFirstChild().getNodeValue()); - - - - NodeList child_nl = nl.item(i).getChildNodes(); - - HSSFRow firstrow = spreadSheet.createRow(( short) 0); - for(int ii = 0 ; ii al = new ArrayList(); - Report userprofile = new Report(); - DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); - - try { - - int count = 0; - DocumentBuilder builder = f.newDocumentBuilder(); - Document d = builder.parse(fileName); - - String firstname = d.getElementsByTagName("FirstName").item(0).getFirstChild().getNodeValue(); - String lastname = d.getElementsByTagName("LastName").item(0).getFirstChild().getNodeValue(); - String email = d.getElementsByTagName("Email").item(0).getFirstChild().getNodeValue(); - String title = d.getElementsByTagName("Title").item(0).getFirstChild().getNodeValue(); - String pageHeader = d.getElementsByTagName("PageHeader").item(0).getFirstChild().getNodeValue(); - String pageFooter = d.getElementsByTagName("PageFooter").item(0).getFirstChild().getNodeValue(); - - if (title==null || title=="") title=" "; - if (pageHeader==null || pageHeader=="") pageHeader=" "; - if (pageFooter==null || pageFooter=="") pageFooter=" "; - - userprofile.setEmail(email); - userprofile.setUserLastName(lastname); - userprofile.setUserFirstName(firstname); - userprofile.setTitle(title); - userprofile.setPageHeader(pageHeader); - userprofile.setPageFooter(pageFooter); - - try{ - - String format = null; - format = d.getElementsByTagName("Format").item(0).getFirstChild().getNodeValue(); - - if(format!=null){ - if(format.equals("")){ - format = "pdf"; - } - } - else{ - format = "pdf"; - } - userprofile.setFormat(format); - - } - catch(Exception e){ - e.printStackTrace(); - userprofile.setFormat("pdf"); - } - - NodeList nl = d.getElementsByTagName("Section"); - - for (int i = 0; i < nl.getLength(); i++) { - - MySection section = new MySection(); - - for (int e = 0; e < ReportSettings.MAX_CHARTS_PER_PAGE; e++) { - - if (d.getElementsByTagName("SectionTitle_" + e).item(i + count) != null) - { - String sectionTitle = d.getElementsByTagName("SectionTitle_" + e).item(i + count).getFirstChild().getNodeValue(); - section.setSectionTitle(sectionTitle, e); - } - else - { - section.setSectionTitle(" ", e); - } - - if (d.getElementsByTagName("SectionImage_" + e).item(i) != null) - { - String image = d.getElementsByTagName("SectionImage_" + e).item(i).getFirstChild().getNodeValue(); - section.setSectionImage(image, e); - } else - { - section.setSectionImage(" ", e); - } - - if (d.getElementsByTagName("SectionDrillParameters_" + e).item(i) != null) - { - String drillparams = d.getElementsByTagName("SectionDrillParameters_" + e).item(i).getFirstChild().getNodeValue(); - section.setSectionDrillParameters(drillparams, e); - } else - { - section.setSectionDrillParameters(" ", e); - } - if (d.getElementsByTagName("SectionDescription_" + e).item(i) != null) - { - String description = d.getElementsByTagName("SectionDescription_" + e).item(i).getFirstChild().getNodeValue(); - section.setSectionDescription(description, e); - } else - { - section.setSectionDescription(" ", e); - } - - }//for (int e = 0; e < ReportSettings.MAX_CHARTS_PER_PAGE; e++) - - al.add(section); - - }//for (int i = 0; i < nl.getLength(); i++) - - userprofile.setSections(al); - - } - catch (Exception e) { - e.printStackTrace(); - } - - return userprofile; - - }//parse - -}//XmlParser diff --git a/reporting/jasper_builder/template_1up.jrxml b/reporting/jasper_builder/template_1up.jrxml deleted file mode 100644 index 14cec74d42..0000000000 --- a/reporting/jasper_builder/template_1up.jrxml +++ /dev/null @@ -1,330 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <band></band> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/reporting/jasper_builder/template_2up.jrxml b/reporting/jasper_builder/template_2up.jrxml deleted file mode 100644 index 45513dec62..0000000000 --- a/reporting/jasper_builder/template_2up.jrxml +++ /dev/null @@ -1,447 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <band></band> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/templates/portal_settings.template b/templates/portal_settings.template index 55ab3182be..459287fe36 100644 --- a/templates/portal_settings.template +++ b/templates/portal_settings.template @@ -98,9 +98,6 @@ captcha_public_key = "[:mailer_captcha_public_key:]" captcha_private_key = "[:mailer_captcha_private_key:]" [reporting] -base_path = "/usr/share/xdmod/reporting/jasper_builder" -java_path = "[:reporting_java_path:]" -javac_path = "[:reporting_javac_path:]" chromium_path = "[:reporting_chromium_path:]" [logger]