diff --git a/README.md b/README.md index 88170e8f..c96fc365 100644 --- a/README.md +++ b/README.md @@ -14,17 +14,20 @@ export FINERACT_PENTAHO_REPORTS_PATH="$PWD/pentahoReports/" ``` -3. Download the Mifos® Security Plugin and extract the files (all the libraries required for running it are included). **It is very important to use the specific version according to the Apache Fineract** +3. Download the Mifos® Reporting Plugin and extract the files (all the libraries required for running it are included). **It is very important to use the specific version according to the Apache Fineract** | Apache Fineract | Mifos Reporting Plugin | Download Link | | :---: | :---: | :---: | -| 1.12.0 | 1.12.1 | [Mifos® Security Plugin v1.12.1](https://sourceforge.net/projects/mifos/files/mifos-plugins/MifosReportingPlugin/MifosSecurityPlugin-1.12.1.zip/download) | -| 1.11.0 | 1.11.0 | [Mifos® Security Plugin v1.11.0](https://sourceforge.net/projects/mifos/files/mifos-plugins/MifosReportingPlugin/FineractPentahoPlugin-1.11.zip/download) | +| develop (1.15.x) | 1.15.0-SNAPSHOT | Build from source (see For Developers) | +| 1.12.0 | 1.12.1 | [Mifos® Reporting Plugin v1.12.1](https://sourceforge.net/projects/mifos/files/mifos-plugins/MifosReportingPlugin/MifosSecurityPlugin-1.12.1.zip/download) | +| 1.11.0 | 1.11.0 | [Mifos® Reporting Plugin v1.11.0](https://sourceforge.net/projects/mifos/files/mifos-plugins/MifosReportingPlugin/FineractPentahoPlugin-1.11.zip/download) | -4a. Execute only for Docker® - Create a directory, copy the Mifos® Reporting Plugin and the Pentaho® libraries in it +4a. Execute only for Docker® - Create a directory, copy the Mifos® Reporting Plugin JAR and the Pentaho® libraries into it, then mount it into your container at the path configured by `FINERACT_PENTAHO_REPORTS_PATH` ```bash - mkdir fineract-pentaho && cd fineract-pentaho + mkdir fineract-pentaho && cd fineract-pentaho + # copy the built plugin JAR and pentaho libs here + # e.g. cp ../target/pentaho-plugin-*.jar . ``` 4b. Execute only for Apache Tomcat® - Copy the Mifos® Reporting Plugin and Pentaho® libraries in $TOMCAT_HOME/webapps/fineract-provider/WEB-INF/lib/ @@ -38,20 +41,31 @@ This project is currently only tested against the very latest and greatest bleeding edge Apache Fineract® `develop` branch on Linux Ubuntu® 24.04LTS. Building and using it against other Apache Fineract® versions may be possible, but is not tested or documented here. +> **Windows users:** replace `./mvnw` with `mvnw.cmd` in all commands below. + 1. Download and compile ```bash git clone https://github.com/openMF/mifos-reporting-plugin.git cd mifos-reporting-plugin && ./mvnw -Dmaven.test.skip=true clean package && cd .. ``` -2. Export the Location of Mifos® reports (PRPT files) in the following variable + +2. Export the required environment variables + + - `FINERACT_PENTAHO_REPORTS_PATH` — path to the directory containing the `.prpt` report files + - `FINERACT_PENTAHO_REPORTS_LOCALE` — default locale for reports (e.g. `en`, `es`); **required at startup** ```bash - export FINERACT_PENTAHO_REPORTS_PATH="$PWD/fineract-pentaho/pentahoReports/" + export FINERACT_PENTAHO_REPORTS_PATH="$PWD/pentahoReports/" + export FINERACT_PENTAHO_REPORTS_LOCALE="en" ``` 3. Execute Apache Fineract® with the location of the Mifos® Reporting Plugin library + Replace the variables below with the actual paths on your system: + - `MIFOS_PENTAHO_PLUGIN_HOME` — directory containing this plugin's built JAR and its Pentaho® dependency JARs (e.g. `$PWD/mifos-reporting-plugin/target/libs`) + - `APACHE_FINERACT_HOME` — directory containing the Apache Fineract® runnable JAR (e.g. `$PWD/fineract/fineract-provider/build/libs`) + ```bash java -Dloader.path=$MIFOS_PENTAHO_PLUGIN_HOME/libs/ -jar $APACHE_FINERACT_HOME/fineract-provider.jar ``` @@ -66,8 +80,6 @@ java -Dloader.path=$MIFOS_PENTAHO_PLUGIN_HOME/libs/ -jar $APACHE_FINERACT_HOME/f 5. The output must be a PDF with the Expected Payment By Date Formated information in it (maybe it could have blank or zeroes if it is a fresh Apache Fineract® setup) -![alt text](https://github.com/openMF/fineract-pentaho/blob/1.8/img/screenshot_pentaho_report.png?raw=true) - The API call (above) should not fail if you follow the steps as shown, and all conditions met for the version of Apache Fineract® If the API call (above) [fails with](https://issues.apache.org/jira/browse/FINERACT-1173) @@ -76,7 +88,7 @@ then this Pentaho® Plugin has not been correctly registered & loaded by Apache Please note that the library will work using the latest Apache Fineract® development branch (30th December 2024), also make sure you got installed the type fonts required by the reports. This Mifos® Reporting Plugin will work only on Apache Tomcat® version 10+. -See also [`PentahoReportsTest`](src/test/java/org/mifos/fineract/pentaho/PentahoReportsTest.java) and the [`test`](test) script. +See also [`PentahoReportsTest`](src/test/java/org/apache/fineract/infrastructure/report/service/PentahoReportsTest.java). ## License @@ -111,4 +123,3 @@ See [TODO](TODO.md) for possible future follow-up enhancement work. The Mifos® Reporting Plugin has been updated to the Pentaho® version 9.5, please use the [`Pentaho® Report Designer version 9.5`](https://mifos.jfrog.io/artifactory/libs-snapshot-local/org/pentaho/reporting/prd-ce/9.5.0.0-SNAPSHOT/prd-ce-9.5.0.0-20230108.081758-1.zip) - diff --git a/src/main/java/org/apache/fineract/infrastructure/report/service/PentahoReportingProcessServiceImpl.java b/src/main/java/org/apache/fineract/infrastructure/report/service/PentahoReportingProcessServiceImpl.java index e77e54c7..7bc04fdc 100644 --- a/src/main/java/org/apache/fineract/infrastructure/report/service/PentahoReportingProcessServiceImpl.java +++ b/src/main/java/org/apache/fineract/infrastructure/report/service/PentahoReportingProcessServiceImpl.java @@ -90,8 +90,6 @@ public class PentahoReportingProcessServiceImpl implements ReportingProcessServi @Autowired FineractProperties fineractProperties; - @Autowired ApplicationContext applicationContext; - @Autowired ApplicationContext contextVar; @Autowired @@ -159,15 +157,14 @@ public Response processRequest( // reportName + // ".prpt"; String reportPath; - logger.debug("locale " + locale); - logger.debug("language " + language); - if (!"en".equals(locale.toString().toLowerCase()) && locale != null) { + logger.debug("locale {}", locale); + logger.debug("language {}", language); + if (locale != null && !"en".equals(locale.toString().toLowerCase())) { reportPath = getReportPath() + reportName + "_" + locale.toString().toLowerCase() + ".prpt"; } else { reportPath = getReportPath() + reportName + ".prpt"; } - var outPutInfo = "Report path: " + reportPath; - logger.debug("Report path: {}", outPutInfo); + logger.debug("Report path: {}", reportPath); // load report definition final var manager = new ResourceManager(); @@ -272,8 +269,7 @@ private void addParametersToReport( && !paramName.equals("username") && (!paramName.equals("password") && !paramName.equals("userid"))))) { - var outPutInfo2 = "paramName:" + paramName; - logger.debug("paramName: {}", outPutInfo2); + logger.debug("paramName: {}", paramName); final var pValue = queryParams.get(paramName); if (StringUtils.isBlank(pValue)) { @@ -282,15 +278,7 @@ private void addParametersToReport( } final Class clazz = paramDefEntry.getValueType(); - var outPutInfo3 = - "addParametersToReport(" - + paramName - + " : " - + pValue - + " : " - + clazz.getCanonicalName() - + ")"; - logger.debug("outputInfo: {}", outPutInfo3); + logger.debug("addParametersToReport({} : {} : {})", paramName, pValue, clazz.getCanonicalName()); if (clazz.getCanonicalName().equalsIgnoreCase("java.lang.Integer")) { rptParamValues.put(paramName, Integer.parseInt(pValue)); @@ -298,8 +286,8 @@ private void addParametersToReport( rptParamValues.put(paramName, Long.parseLong(pValue)); } else if (clazz.getCanonicalName().equalsIgnoreCase("java.sql.Date")) { logger.debug("ParamName: {}", paramName); - logger.debug("ParamValue: {}", pValue.toString()); - String myDate = pValue.toString(); + logger.debug("ParamValue: {}", pValue); + String myDate = pValue; SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy", Locale.ENGLISH); Date date = sdf.parse(myDate); long millis = date.getTime(); @@ -307,7 +295,7 @@ private void addParametersToReport( rptParamValues.put(paramName, mySQLDate); } else { logger.debug("ParamName Unknown: {}", paramName); - logger.debug("ParamValue Unknown: {}", pValue.toString()); + logger.debug("ParamValue Unknown: {}", pValue); rptParamValues.put(paramName, pValue); } } @@ -329,15 +317,13 @@ private void addParametersToReport( tenantConnection.getSchemaConnectionParameters()); final var userhierarchy = currentUser.getOffice().getHierarchy(); - logger.debug("userhierarchy " + userhierarchy); - var outPutInfo4 = "db URL:" + tenantUrl + " userhierarchy:" + userhierarchy; - logger.debug(outPutInfo4); + logger.debug("userhierarchy {}", userhierarchy); + logger.debug("db URL:{} userhierarchy:{}", tenantUrl, userhierarchy); rptParamValues.put("userhierarchy", userhierarchy); final var userid = currentUser.getId(); - var outPutInfo5 = "db URL:" + tenantUrl + " userid:" + userid; - logger.debug(outPutInfo5); + logger.debug("db URL:{} userid:{}", tenantUrl, userid); rptParamValues.put("userid", userid); @@ -399,7 +385,7 @@ private void setConnectionDetail(DataFactory dataFactory) throws SQLException { Driver e = DriverManager.getDriver(getTenantUrl()); // Printing the driver - logger.debug("Driver: " + e.getClass().getName().toString()); + logger.debug("Driver: {}", e.getClass().getName()); connectionProvider.setDriver(e.getClass().getName().toString()); connectionProvider.setUrl(getTenantUrl()); connectionProvider.setProperty("user", tenantConnection.getSchemaUsername());