From dff53b931847507f11adf33f4c8dbf3670db2e7e Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Fri, 19 Apr 2013 13:27:27 +0100 Subject: [PATCH] remove usage lookup data objects, formating of report java code, update api docs for center, groups. --- api-docs/apiLive.htm | 94 +- .../closure/api/GLClosuresApiResource.java | 4 +- .../closure/data/GLClosureData.java | 10 +- .../commands/data/CommandSourceData.java | 44 - .../data/GenericResultsetData.java | 1 - .../dataqueries/data/ReportData.java | 133 +- .../dataqueries/data/ReportParameterData.java | 24 +- .../data/ReportParameterJoinData.java | 132 +- .../dataqueries/domain/Report.java | 343 +++--- .../dataqueries/domain/ReportRepository.java | 2 +- .../exception/DatatableNotFoundException.java | 2 +- .../DatatableSystemErrorException.java | 3 +- .../exception/ReportNotFoundException.java | 2 +- .../CreateDatatableEntryCommandHandler.java | 13 +- .../handler/CreateReportCommandHandler.java | 21 +- ...OneToManyDatatableEntryCommandHandler.java | 13 +- ...eOneToOneDatatableEntryCommandHandler.java | 13 +- .../handler/DeleteReportCommandHandler.java | 29 +- ...OneToManyDatatableEntryCommandHandler.java | 22 +- ...eOneToOneDatatableEntryCommandHandler.java | 22 +- .../handler/UpdateReportCommandHandler.java | 22 +- .../ReportCommandFromApiJsonDeserializer.java | 36 +- .../service/ReadReportingService.java | 18 +- .../service/ReadReportingServiceImpl.java | 1073 ++++++++--------- .../office/data/OfficeLookup.java | 29 - .../service/OfficeReadPlatformService.java | 8 - .../OfficeReadPlatformServiceImpl.java | 35 +- .../data/BulkTransferLoanOfficerData.java | 12 +- .../loanaccount/api/BulkLoansApiResource.java | 4 +- 29 files changed, 986 insertions(+), 1178 deletions(-) delete mode 100644 mifosng-provider/src/main/java/org/mifosplatform/commands/data/CommandSourceData.java delete mode 100644 mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeLookup.java diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 486da1890..829bc7968 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -299,6 +299,14 @@ Delete a Center + + centers/{centerId}?command=activate + Activate a Center + + + + + Group groups Create a Group @@ -306,7 +314,7 @@ - + groups/{group} @@ -314,6 +322,14 @@ Update a Group Delete a Group + + + groups/{groupId}?command=activate + Activate a Group + + + + @@ -1901,7 +1917,7 @@ Request Body:

Activate a Client

-

Clients can be created in a Pending state if configuration is enabled. This API exists to enable client activation (for when a client becomes approved member of microfinance institue.

+

Clients can be created in a Pending state. This API exists to enable client activation (for when a client becomes approved member of microfinance institue).

If the client happens to be alrady active this API will result in an error.

@@ -2926,6 +2942,34 @@ Content-Type: application/json Request Body:
+   +
+
+

Activate a Center

+

Centers can be created in a Pending state. This API exists to enable center activation.

+

If the center happens to be already active this API will result in an error.

+
+
+ POST https://Domain Name/api/v1/centers/{centerId}?command=activate + POST centers/1?command=activate +Content-Type: application/json +Request Body: +{ + "locale": "en", + "dateFormat": "dd MMMM yyyy", + "activationDate": "01 March 2011" +} + + +{ + "officeId": 1, + "groupId": 1, + "resourceId": 1 +} + +
+
+  
@@ -3322,6 +3366,34 @@ Content-Type: application/json Request Body:
+   +
+
+

Activate a Group

+

Groups can be created in a Pending state. This API exists to enable group activation.

+

If the group happens to be already active this API will result in an error.

+
+
+ POST https://Domain Name/api/v1/groups/{groupId}?command=activate + POST groups/1?command=activate +Content-Type: application/json +Request Body: +{ + "locale": "en", + "dateFormat": "dd MMMM yyyy", + "activationDate": "01 March 2011" +} + + +{ + "officeId": 1, + "groupId": 1, + "resourceId": 1 +} + +
+
+  
@@ -13163,6 +13235,14 @@ GET https://DomainName/api/v1/search?query=000000111 Delete a Center + + centers/{centerId}?command=activate + Activate a Center + + + + + Group groups Create a Group @@ -13170,7 +13250,7 @@ GET https://DomainName/api/v1/search?query=000000111 - + groups/{group} @@ -13178,6 +13258,14 @@ GET https://DomainName/api/v1/search?query=000000111 Update a Group Delete a Group + + + groups/{groupId}?command=activate + Activate a Group + + + + diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java index b71d79e4b..68d8b7d48 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java @@ -5,7 +5,6 @@ */ package org.mifosplatform.accounting.closure.api; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -34,7 +33,6 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; -import org.mifosplatform.organisation.office.data.OfficeLookup; import org.mifosplatform.organisation.office.service.OfficeReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @@ -95,7 +93,7 @@ public class GLClosuresApiResource { final GLClosureData glClosureData = this.glClosureReadPlatformService.retrieveGLClosureById(glClosureId); if (settings.isTemplate()) { - glClosureData.setAllowedOffices(new ArrayList(this.officeReadPlatformService.retrieveAllOfficesForLookup())); + glClosureData.setAllowedOffices(this.officeReadPlatformService.retrieveAllOfficesForDropdown()); } return this.apiJsonSerializerService.serialize(settings, glClosureData, RESPONSE_DATA_PARAMETERS); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/data/GLClosureData.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/data/GLClosureData.java index 400f56bdb..ee4bad1d7 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/data/GLClosureData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/data/GLClosureData.java @@ -6,10 +6,10 @@ package org.mifosplatform.accounting.closure.data; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import org.joda.time.LocalDate; -import org.mifosplatform.organisation.office.data.OfficeLookup; +import org.mifosplatform.organisation.office.data.OfficeData; /** * Immutable object representing a General Ledger Account @@ -44,7 +44,7 @@ public class GLClosureData { @SuppressWarnings("unused") private final String comments; - private List allowedOffices = new ArrayList(); + private Collection allowedOffices = new ArrayList(); public GLClosureData(final Long id, final Long officeId, final String officeName, final LocalDate closingDate, final boolean deleted, final LocalDate createdDate, final LocalDate lastUpdatedDate, final Long createdByUserId, final String createdByUsername, @@ -64,11 +64,11 @@ public class GLClosureData { this.allowedOffices = null; } - public List getAllowedOffices() { + public final Collection getAllowedOffices() { return this.allowedOffices; } - public void setAllowedOffices(final List allowedOffices) { + public void setAllowedOffices(final Collection allowedOffices) { this.allowedOffices = allowedOffices; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/data/CommandSourceData.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/data/CommandSourceData.java deleted file mode 100644 index 402a60cd2..000000000 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/data/CommandSourceData.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.mifosplatform.commands.data; - -import org.joda.time.LocalDate; - -/** - * Immutable data object representing maker-checker entry - */ -@Deprecated -final public class CommandSourceData { - - @SuppressWarnings("unused") - private final Long id; - @SuppressWarnings("unused") - private final String actionName; - @SuppressWarnings("unused") - private final String entityName; - @SuppressWarnings("unused") - private final Long entityId; - @SuppressWarnings("unused") - private final String entityHref; - private final String commandJson; - @SuppressWarnings("unused") - private final LocalDate madeOnDate; - - public CommandSourceData(final Long id, final String actionName, final String entityName, final Long entityId, final String entityHref, - final String commandJson, final LocalDate madeOnDate) { - this.id = id; - this.actionName = actionName; - this.entityName = entityName; - this.entityId = entityId; - this.entityHref = entityHref; - this.commandJson = commandJson; - this.madeOnDate = madeOnDate; - } - - public String json() { - return this.commandJson; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java index 034d60fe8..5b70bace9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/GenericResultsetData.java @@ -7,7 +7,6 @@ package org.mifosplatform.infrastructure.dataqueries.data; import java.util.List; - /** * Immutable data object for generic resultset data. */ diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportData.java index 0b8ac8927..47b8d13e2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportData.java @@ -11,79 +11,76 @@ import java.util.List; final public class ReportData { - @SuppressWarnings("unused") - private final Long id; - @SuppressWarnings("unused") - private final String reportName; - @SuppressWarnings("unused") - private final String reportType; - @SuppressWarnings("unused") - private final String reportSubType; - @SuppressWarnings("unused") - private final String reportCategory; - @SuppressWarnings("unused") - private final String description; - @SuppressWarnings("unused") - private final String reportSql; - @SuppressWarnings("unused") - private final Boolean coreReport; - @SuppressWarnings("unused") - private final Boolean useReport; - @SuppressWarnings("unused") - private final Collection reportParameters; + @SuppressWarnings("unused") + private final Long id; + @SuppressWarnings("unused") + private final String reportName; + @SuppressWarnings("unused") + private final String reportType; + @SuppressWarnings("unused") + private final String reportSubType; + @SuppressWarnings("unused") + private final String reportCategory; + @SuppressWarnings("unused") + private final String description; + @SuppressWarnings("unused") + private final String reportSql; + @SuppressWarnings("unused") + private final Boolean coreReport; + @SuppressWarnings("unused") + private final Boolean useReport; + @SuppressWarnings("unused") + private final Collection reportParameters; - @SuppressWarnings("unused") - private List allowedReportTypes; - @SuppressWarnings("unused") - private List allowedReportSubTypes; + @SuppressWarnings("unused") + private List allowedReportTypes; + @SuppressWarnings("unused") + private List allowedReportSubTypes; - public ReportData(final Long id, final String reportName, - final String reportType, final String reportSubType, - final String reportCategory, final String description, - final String reportSql, final Boolean coreReport, - final Boolean useReport, - final Collection reportParameters) { - this.id = id; - this.reportName = reportName; - this.reportType = reportType; - this.reportSubType = reportSubType; - this.reportCategory = reportCategory; - this.description = description; - this.reportParameters = reportParameters; - this.reportSql = reportSql; - this.coreReport = coreReport; - this.useReport = useReport; - this.allowedReportTypes = null; - this.allowedReportSubTypes = null; - } + public ReportData(final Long id, final String reportName, final String reportType, final String reportSubType, + final String reportCategory, final String description, final String reportSql, final Boolean coreReport, + final Boolean useReport, final Collection reportParameters) { + this.id = id; + this.reportName = reportName; + this.reportType = reportType; + this.reportSubType = reportSubType; + this.reportCategory = reportCategory; + this.description = description; + this.reportParameters = reportParameters; + this.reportSql = reportSql; + this.coreReport = coreReport; + this.useReport = useReport; + this.allowedReportTypes = null; + this.allowedReportSubTypes = null; + } - public ReportData() { - this.id = null; - this.reportName = null; - this.reportType = null; - this.reportSubType = null; - this.reportCategory = null; - this.description = null; - this.reportParameters = null; - this.reportSql = null; - this.coreReport = null; - this.useReport = null; - this.allowedReportTypes = null; - this.allowedReportSubTypes = null; - } + public ReportData() { + this.id = null; + this.reportName = null; + this.reportType = null; + this.reportSubType = null; + this.reportCategory = null; + this.description = null; + this.reportParameters = null; + this.reportSql = null; + this.coreReport = null; + this.useReport = null; + this.allowedReportTypes = null; + this.allowedReportSubTypes = null; + } - public void appendedTemplate() { + public void appendedTemplate() { - List reportTypes = new ArrayList(); - reportTypes.add("Table"); - reportTypes.add("Pentaho"); - reportTypes.add("Chart"); - this.allowedReportTypes = reportTypes; + List reportTypes = new ArrayList(); + reportTypes.add("Table"); + reportTypes.add("Pentaho"); + reportTypes.add("Chart"); + this.allowedReportTypes = reportTypes; - List reportSubTypes = new ArrayList(); - reportSubTypes.add("Bar"); - reportSubTypes.add("Pie"); - this.allowedReportSubTypes = reportSubTypes; - } + List reportSubTypes = new ArrayList(); + reportSubTypes.add("Bar"); + reportSubTypes.add("Pie"); + this.allowedReportSubTypes = reportSubTypes; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterData.java index 449ff5f3a..55676dcd5 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterData.java @@ -7,18 +7,16 @@ package org.mifosplatform.infrastructure.dataqueries.data; final public class ReportParameterData { - @SuppressWarnings("unused") - private final Long id; - @SuppressWarnings("unused") - private final String reportParameterName; - @SuppressWarnings("unused") - private final String parameterName; - - public ReportParameterData(final Long id, - final String reportParameterName, final String parameterName) { - this.id = id; - this.reportParameterName = reportParameterName; - this.parameterName = parameterName; - } + @SuppressWarnings("unused") + private final Long id; + @SuppressWarnings("unused") + private final String reportParameterName; + @SuppressWarnings("unused") + private final String parameterName; + public ReportParameterData(final Long id, final String reportParameterName, final String parameterName) { + this.id = id; + this.reportParameterName = reportParameterName; + this.parameterName = parameterName; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterJoinData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterJoinData.java index 3b3fb3937..7bc93e2f3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterJoinData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ReportParameterJoinData.java @@ -7,86 +7,82 @@ package org.mifosplatform.infrastructure.dataqueries.data; final public class ReportParameterJoinData { - private final Long reportId; - private final String reportName; - private final String reportType; - private final String reportSubType; - private final String reportCategory; - private final String description; - private final String reportSql; - private final Boolean coreReport; - private final Boolean useReport; + private final Long reportId; + private final String reportName; + private final String reportType; + private final String reportSubType; + private final String reportCategory; + private final String description; + private final String reportSql; + private final Boolean coreReport; + private final Boolean useReport; - private final Long reportParameterId; - private final String reportParameterName; - private final String parameterName; + private final Long reportParameterId; + private final String reportParameterName; + private final String parameterName; - public ReportParameterJoinData(final Long reportId, - final String reportName, final String reportType, - final String reportSubType, final String reportCategory, final String description, - final String reportSql, final Boolean coreReport, - final Boolean useReport, final Long reportParameterId, - final String reportParameterName, final String parameterName) { - this.reportId = reportId; - this.reportName = reportName; - this.reportType = reportType; - this.reportSubType = reportSubType; - this.reportCategory = reportCategory; - this.description = description; - this.reportSql = reportSql; - this.coreReport = coreReport; - this.useReport = useReport; - this.reportParameterId = reportParameterId; - this.reportParameterName = reportParameterName; - this.parameterName = parameterName; - } + public ReportParameterJoinData(final Long reportId, final String reportName, final String reportType, final String reportSubType, + final String reportCategory, final String description, final String reportSql, final Boolean coreReport, + final Boolean useReport, final Long reportParameterId, final String reportParameterName, final String parameterName) { + this.reportId = reportId; + this.reportName = reportName; + this.reportType = reportType; + this.reportSubType = reportSubType; + this.reportCategory = reportCategory; + this.description = description; + this.reportSql = reportSql; + this.coreReport = coreReport; + this.useReport = useReport; + this.reportParameterId = reportParameterId; + this.reportParameterName = reportParameterName; + this.parameterName = parameterName; + } - public Long getReportId() { - return reportId; - } + public Long getReportId() { + return reportId; + } - public String getReportName() { - return reportName; - } + public String getReportName() { + return reportName; + } - public String getReportType() { - return reportType; - } + public String getReportType() { + return reportType; + } - public String getReportSubType() { - return reportSubType; - } + public String getReportSubType() { + return reportSubType; + } - public String getReportCategory() { - return reportCategory; - } + public String getReportCategory() { + return reportCategory; + } - public String getReportSql() { - return reportSql; - } + public String getReportSql() { + return reportSql; + } - public Boolean getCoreReport() { - return coreReport; - } + public Boolean getCoreReport() { + return coreReport; + } - public Boolean getUseReport() { - return useReport; - } + public Boolean getUseReport() { + return useReport; + } - public Long getReportParameterId() { - return reportParameterId; - } + public Long getReportParameterId() { + return reportParameterId; + } - public String getReportParameterName() { - return reportParameterName; - } + public String getReportParameterName() { + return reportParameterName; + } - public String getParameterName() { - return parameterName; - } - - public String getDescription() { - return description; - } + public String getParameterName() { + return parameterName; + } + public String getDescription() { + return description; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/Report.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/Report.java index 8804fed8c..e86c77d65 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/Report.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/Report.java @@ -27,233 +27,180 @@ import org.springframework.data.jpa.domain.AbstractPersistable; @Table(name = "stretchy_report", uniqueConstraints = { @UniqueConstraint(columnNames = { "report_name" }, name = "unq_report_name") }) public class Report extends AbstractPersistable { - @Column(name = "report_name", nullable = false, unique = true) - private String reportName; + @Column(name = "report_name", nullable = false, unique = true) + private String reportName; - @Column(name = "report_type", nullable = false) - private String reportType; + @Column(name = "report_type", nullable = false) + private String reportType; - @Column(name = "report_subtype") - private String reportSubType; + @Column(name = "report_subtype") + private String reportSubType; - @Column(name = "report_category") - private String reportCategory; + @Column(name = "report_category") + private String reportCategory; - @Column(name = "description") - private String description; + @Column(name = "description") + private String description; - @Column(name = "core_report", nullable = false) - private boolean coreReport; + @Column(name = "core_report", nullable = false) + private boolean coreReport; - // only defines if report should appear in reference app UI List - @Column(name = "use_report", nullable = false) - private boolean useReport; + // only defines if report should appear in reference app UI List + @Column(name = "use_report", nullable = false) + private boolean useReport; - @Column(name = "report_sql") - private String reportSql; + @Column(name = "report_sql") + private String reportSql; - /* - * @ManyToMany - * - * @JoinTable(name = "stretchy_report_parameter", joinColumns = - * - * @JoinColumn(name = "reportn_id"), inverseJoinColumns = @JoinColumn(name = - * "parameter_id")) private List charges; - */ + /* + * @ManyToMany + * + * @JoinTable(name = "stretchy_report_parameter", joinColumns = + * + * @JoinColumn(name = "reportn_id"), inverseJoinColumns = @JoinColumn(name = + * "parameter_id")) private List charges; + */ - public static Report fromJson(final JsonCommand command) { + public static Report fromJson(final JsonCommand command) { - final String reportName = command - .stringValueOfParameterNamed("reportName"); - final String reportType = command - .stringValueOfParameterNamed("reportType"); - final String reportSubType = command - .stringValueOfParameterNamed("reportSubType"); - final String reportCategory = command - .stringValueOfParameterNamed("reportCategory"); - final String description = command - .stringValueOfParameterNamed("description"); - final boolean useReport = command - .booleanPrimitiveValueOfParameterNamed("useReport"); - final String reportSql = command - .stringValueOfParameterNamed("reportSql"); + final String reportName = command.stringValueOfParameterNamed("reportName"); + final String reportType = command.stringValueOfParameterNamed("reportType"); + final String reportSubType = command.stringValueOfParameterNamed("reportSubType"); + final String reportCategory = command.stringValueOfParameterNamed("reportCategory"); + final String description = command.stringValueOfParameterNamed("description"); + final boolean useReport = command.booleanPrimitiveValueOfParameterNamed("useReport"); + final String reportSql = command.stringValueOfParameterNamed("reportSql"); - return new Report(reportName, reportType, reportSubType, - reportCategory, description, useReport, reportSql); - } + return new Report(reportName, reportType, reportSubType, reportCategory, description, useReport, reportSql); + } - protected Report() { - // - } + protected Report() { + // + } - public Report(final String reportName, final String reportType, - final String reportSubType, final String reportCategory, - final String description, final boolean useReport, - final String reportSql) { - this.reportName = reportName; - this.reportType = reportType; - this.reportSubType = reportSubType; - this.reportCategory = reportCategory; - this.description = description; - this.coreReport = false; - this.useReport = useReport; - this.reportSql = reportSql; - validate(); - } + public Report(final String reportName, final String reportType, final String reportSubType, final String reportCategory, + final String description, final boolean useReport, final String reportSql) { + this.reportName = reportName; + this.reportType = reportType; + this.reportSubType = reportSubType; + this.reportCategory = reportCategory; + this.description = description; + this.coreReport = false; + this.useReport = useReport; + this.reportSql = reportSql; + validate(); + } - public Map update(final JsonCommand command) { + public Map update(final JsonCommand command) { - final Map actualChanges = new LinkedHashMap( - 8); + final Map actualChanges = new LinkedHashMap(8); - String paramName = "reportName"; - if (command.isChangeInStringParameterNamed(paramName, this.reportName)) { - final String newValue = command - .stringValueOfParameterNamed(paramName); - actualChanges.put(paramName, newValue); - this.reportName = StringUtils.defaultIfEmpty(newValue, null); - } - paramName = "reportType"; - if (command.isChangeInStringParameterNamed(paramName, this.reportType)) { - final String newValue = command - .stringValueOfParameterNamed(paramName); - actualChanges.put(paramName, newValue); - this.reportType = StringUtils.defaultIfEmpty(newValue, null); - } - paramName = "reportSubType"; - if (command.isChangeInStringParameterNamed(paramName, - this.reportSubType)) { - final String newValue = command - .stringValueOfParameterNamed(paramName); - actualChanges.put(paramName, newValue); - this.reportSubType = StringUtils.defaultIfEmpty(newValue, null); - } - paramName = "reportCategory"; - if (command.isChangeInStringParameterNamed(paramName, - this.reportCategory)) { - final String newValue = command - .stringValueOfParameterNamed(paramName); - actualChanges.put(paramName, newValue); - this.reportCategory = StringUtils.defaultIfEmpty(newValue, null); - } - paramName = "description"; - if (command.isChangeInStringParameterNamed(paramName, this.description)) { - final String newValue = command - .stringValueOfParameterNamed(paramName); - actualChanges.put(paramName, newValue); - this.description = StringUtils.defaultIfEmpty(newValue, null); - } - paramName = "useReport"; - if (command.isChangeInBooleanParameterNamed(paramName, this.useReport)) { - final boolean newValue = command - .booleanPrimitiveValueOfParameterNamed(paramName); - actualChanges.put(paramName, newValue); - this.useReport = newValue; - } - paramName = "reportSql"; - if (command.isChangeInStringParameterNamed(paramName, this.reportSql)) { - final String newValue = command - .stringValueOfParameterNamed(paramName); - actualChanges.put(paramName, newValue); - this.reportSql = StringUtils.defaultIfEmpty(newValue, null); - } + String paramName = "reportName"; + if (command.isChangeInStringParameterNamed(paramName, this.reportName)) { + final String newValue = command.stringValueOfParameterNamed(paramName); + actualChanges.put(paramName, newValue); + this.reportName = StringUtils.defaultIfEmpty(newValue, null); + } + paramName = "reportType"; + if (command.isChangeInStringParameterNamed(paramName, this.reportType)) { + final String newValue = command.stringValueOfParameterNamed(paramName); + actualChanges.put(paramName, newValue); + this.reportType = StringUtils.defaultIfEmpty(newValue, null); + } + paramName = "reportSubType"; + if (command.isChangeInStringParameterNamed(paramName, this.reportSubType)) { + final String newValue = command.stringValueOfParameterNamed(paramName); + actualChanges.put(paramName, newValue); + this.reportSubType = StringUtils.defaultIfEmpty(newValue, null); + } + paramName = "reportCategory"; + if (command.isChangeInStringParameterNamed(paramName, this.reportCategory)) { + final String newValue = command.stringValueOfParameterNamed(paramName); + actualChanges.put(paramName, newValue); + this.reportCategory = StringUtils.defaultIfEmpty(newValue, null); + } + paramName = "description"; + if (command.isChangeInStringParameterNamed(paramName, this.description)) { + final String newValue = command.stringValueOfParameterNamed(paramName); + actualChanges.put(paramName, newValue); + this.description = StringUtils.defaultIfEmpty(newValue, null); + } + paramName = "useReport"; + if (command.isChangeInBooleanParameterNamed(paramName, this.useReport)) { + final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(paramName); + actualChanges.put(paramName, newValue); + this.useReport = newValue; + } + paramName = "reportSql"; + if (command.isChangeInStringParameterNamed(paramName, this.reportSql)) { + final String newValue = command.stringValueOfParameterNamed(paramName); + actualChanges.put(paramName, newValue); + this.reportSql = StringUtils.defaultIfEmpty(newValue, null); + } - validate(); + validate(); - if (!actualChanges.isEmpty()) { - if (isCoreReport()) { - for (final String key : actualChanges.keySet()) { - if (!(key.equals("useReport"))) { - throw new PlatformDataIntegrityException( - "error.msg.only.use.report.can.be.updated.for.core.report", - "Only the Use Report field can be updated for Core Reports", - key); - } - } - } - } + if (!actualChanges.isEmpty()) { + if (isCoreReport()) { + for (final String key : actualChanges.keySet()) { + if (!(key.equals("useReport"))) { throw new PlatformDataIntegrityException( + "error.msg.only.use.report.can.be.updated.for.core.report", + "Only the Use Report field can be updated for Core Reports", key); } + } + } + } - return actualChanges; - } + return actualChanges; + } - public boolean isCoreReport() { - return coreReport; - } + public boolean isCoreReport() { + return coreReport; + } - private void validate() { + private void validate() { - final List dataValidationErrors = new ArrayList(); - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder( - dataValidationErrors).resource("report"); + final List dataValidationErrors = new ArrayList(); + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("report"); - baseDataValidator.reset().parameter("reportName") - .value(this.reportName).notBlank().notExceedingLengthOf(100); + baseDataValidator.reset().parameter("reportName").value(this.reportName).notBlank().notExceedingLengthOf(100); - baseDataValidator - .reset() - .parameter("reportType") - .value(this.reportType) - .notBlank() - .isOneOfTheseValues( - new Object[] { "Table", "Pentaho", "Chart" }); + baseDataValidator.reset().parameter("reportType").value(this.reportType).notBlank() + .isOneOfTheseValues(new Object[] { "Table", "Pentaho", "Chart" }); - baseDataValidator.reset().parameter("reportSubType") - .value(this.reportSubType).notExceedingLengthOf(20); + baseDataValidator.reset().parameter("reportSubType").value(this.reportSubType).notExceedingLengthOf(20); - if (StringUtils.isNotBlank(this.reportType)) { - if (this.reportType.equals("Chart")) { - baseDataValidator - .reset() - .parameter("reportSubType") - .value(this.reportSubType) - .cantBeBlankWhenParameterProvidedIs("reportType", - this.reportType) - .isOneOfTheseValues(new Object[] { "Bar", "Pie" }); - } else { - baseDataValidator - .reset() - .parameter("reportSubType") - .value(this.reportSubType) - .mustBeBlankWhenParameterProvidedIs("reportType", - this.reportType); - } - } + if (StringUtils.isNotBlank(this.reportType)) { + if (this.reportType.equals("Chart")) { + baseDataValidator.reset().parameter("reportSubType").value(this.reportSubType) + .cantBeBlankWhenParameterProvidedIs("reportType", this.reportType) + .isOneOfTheseValues(new Object[] { "Bar", "Pie" }); + } else { + baseDataValidator.reset().parameter("reportSubType").value(this.reportSubType) + .mustBeBlankWhenParameterProvidedIs("reportType", this.reportType); + } + } - baseDataValidator.reset().parameter("reportCategory") - .value(this.reportCategory).notExceedingLengthOf(45); + baseDataValidator.reset().parameter("reportCategory").value(this.reportCategory).notExceedingLengthOf(45); - if (StringUtils.isNotBlank(this.reportType)) { - if ((this.reportType.equals("Table")) - || (this.reportType.equals("Chart"))) { - baseDataValidator - .reset() - .parameter("reportSql") - .value(this.reportSql) - .cantBeBlankWhenParameterProvidedIs("reportType", - this.reportType); - } else { - baseDataValidator - .reset() - .parameter("reportSql") - .value(this.reportSql) - .mustBeBlankWhenParameterProvidedIs("reportType", - this.reportType); - } - } - throwExceptionIfValidationWarningsExist(dataValidationErrors); - } + if (StringUtils.isNotBlank(this.reportType)) { + if ((this.reportType.equals("Table")) || (this.reportType.equals("Chart"))) { + baseDataValidator.reset().parameter("reportSql").value(this.reportSql) + .cantBeBlankWhenParameterProvidedIs("reportType", this.reportType); + } else { + baseDataValidator.reset().parameter("reportSql").value(this.reportSql) + .mustBeBlankWhenParameterProvidedIs("reportType", this.reportType); + } + } + throwExceptionIfValidationWarningsExist(dataValidationErrors); + } - private void throwExceptionIfValidationWarningsExist( - final List dataValidationErrors) { - if (!dataValidationErrors.isEmpty()) { - throw new PlatformApiDataValidationException( - "validation.msg.validation.errors.exist", - "Validation errors exist.", dataValidationErrors); - } - } + private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { + if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); } + } - public String getReportName() { - return reportName; - } + public String getReportName() { + return reportName; + } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/ReportRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/ReportRepository.java index 27607d13f..0a21d3f42 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/ReportRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/domain/ReportRepository.java @@ -9,5 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; public interface ReportRepository extends JpaRepository, JpaSpecificationExecutor { - // no added behaviour + // no added behaviour } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableNotFoundException.java index a82da4fb6..d33635e15 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableNotFoundException.java @@ -8,7 +8,7 @@ package org.mifosplatform.infrastructure.dataqueries.exception; import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** - * A {@link RuntimeException} thrown when client resources are not found. + * A {@link RuntimeException} thrown when datatable resources are not found. */ public class DatatableNotFoundException extends AbstractPlatformResourceNotFoundException { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableSystemErrorException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableSystemErrorException.java index 58e8964c5..503d2023e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableSystemErrorException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DatatableSystemErrorException.java @@ -12,5 +12,4 @@ public class DatatableSystemErrorException extends AbstractPlatformDomainRuleExc public DatatableSystemErrorException(final String msg) { super("error.msg.datatable.system.error", msg, msg); } - -} +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/ReportNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/ReportNotFoundException.java index f248e56ce..0a4780769 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/ReportNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/ReportNotFoundException.java @@ -15,7 +15,7 @@ public class ReportNotFoundException extends AbstractPlatformResourceNotFoundExc public ReportNotFoundException(final String reportSql) { super("error.msg.report.name.not.found", "Reporting meta-data entry not found.", "Input sql: " + reportSql); } - + public ReportNotFoundException(final Long id) { super("error.msg.report.id.invalid", "Report with identifier " + id + " does not exist", id); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateDatatableEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateDatatableEntryCommandHandler.java index 68cb68a30..deee0fec3 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateDatatableEntryCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateDatatableEntryCommandHandler.java @@ -28,16 +28,17 @@ public class CreateDatatableEntryCommandHandler implements NewCommandSourceHandl @Override public CommandProcessingResult processCommand(final JsonCommand command) { - CommandProcessingResult commandProcessingResult = this.writePlatformService.createNewDatatableEntry(command.entityName(), command.entityId(), command); + CommandProcessingResult commandProcessingResult = this.writePlatformService.createNewDatatableEntry(command.entityName(), + command.entityId(), command); return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(command.entityId()) // - .withOfficeId(commandProcessingResult.getOfficeId()) // - .withGroupId(commandProcessingResult.getGroupId()) // - .withClientId(commandProcessingResult.getClientId()) // - .withSavingsId(commandProcessingResult.getSavingsId()) // - .withLoanId(commandProcessingResult.getLoanId()) // + .withOfficeId(commandProcessingResult.getOfficeId()) // + .withGroupId(commandProcessingResult.getGroupId()) // + .withClientId(commandProcessingResult.getClientId()) // + .withSavingsId(commandProcessingResult.getSavingsId()) // + .withLoanId(commandProcessingResult.getLoanId()) // .build(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateReportCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateReportCommandHandler.java index 497ad616a..345062e56 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateReportCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/CreateReportCommandHandler.java @@ -16,18 +16,17 @@ import org.springframework.transaction.annotation.Transactional; @Service public class CreateReportCommandHandler implements NewCommandSourceHandler { - private final ReportWritePlatformService writePlatformService; + private final ReportWritePlatformService writePlatformService; - @Autowired - public CreateReportCommandHandler( - final ReportWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } + @Autowired + public CreateReportCommandHandler(final ReportWritePlatformService writePlatformService) { + this.writePlatformService = writePlatformService; + } - @Transactional - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { - return this.writePlatformService.createReport(command); - } + return this.writePlatformService.createReport(command); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToManyDatatableEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToManyDatatableEntryCommandHandler.java index 0356c642a..0a791f123 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToManyDatatableEntryCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToManyDatatableEntryCommandHandler.java @@ -28,16 +28,17 @@ public class DeleteOneToManyDatatableEntryCommandHandler implements NewCommandSo @Override public CommandProcessingResult processCommand(final JsonCommand command) { - CommandProcessingResult commandProcessingResult = this.writePlatformService.deleteDatatableEntry(command.entityName(), command.entityId(), command.subentityId()); + CommandProcessingResult commandProcessingResult = this.writePlatformService.deleteDatatableEntry(command.entityName(), + command.entityId(), command.subentityId()); return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(command.entityId()) // - .withOfficeId(commandProcessingResult.getOfficeId()) // - .withGroupId(commandProcessingResult.getGroupId()) // - .withClientId(commandProcessingResult.getClientId()) // - .withSavingsId(commandProcessingResult.getSavingsId()) // - .withLoanId(commandProcessingResult.getLoanId()) // + .withOfficeId(commandProcessingResult.getOfficeId()) // + .withGroupId(commandProcessingResult.getGroupId()) // + .withClientId(commandProcessingResult.getClientId()) // + .withSavingsId(commandProcessingResult.getSavingsId()) // + .withLoanId(commandProcessingResult.getLoanId()) // .build(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java index 8f031c1b3..301e29bbb 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteOneToOneDatatableEntryCommandHandler.java @@ -28,16 +28,17 @@ public class DeleteOneToOneDatatableEntryCommandHandler implements NewCommandSou @Override public CommandProcessingResult processCommand(final JsonCommand command) { - CommandProcessingResult commandProcessingResult = this.writePlatformService.deleteDatatableEntries(command.entityName(), command.entityId()); + CommandProcessingResult commandProcessingResult = this.writePlatformService.deleteDatatableEntries(command.entityName(), + command.entityId()); return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(command.entityId()) // - .withOfficeId(commandProcessingResult.getOfficeId()) // - .withGroupId(commandProcessingResult.getGroupId()) // - .withClientId(commandProcessingResult.getClientId()) // - .withSavingsId(commandProcessingResult.getSavingsId()) // - .withLoanId(commandProcessingResult.getLoanId()) // + .withOfficeId(commandProcessingResult.getOfficeId()) // + .withGroupId(commandProcessingResult.getGroupId()) // + .withClientId(commandProcessingResult.getClientId()) // + .withSavingsId(commandProcessingResult.getSavingsId()) // + .withLoanId(commandProcessingResult.getLoanId()) // .build(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteReportCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteReportCommandHandler.java index 497e42f07..c7b78b788 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteReportCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/DeleteReportCommandHandler.java @@ -17,23 +17,22 @@ import org.springframework.transaction.annotation.Transactional; @Service public class DeleteReportCommandHandler implements NewCommandSourceHandler { - private final ReportWritePlatformService writePlatformService; + private final ReportWritePlatformService writePlatformService; - @Autowired - public DeleteReportCommandHandler( - final ReportWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } + @Autowired + public DeleteReportCommandHandler(final ReportWritePlatformService writePlatformService) { + this.writePlatformService = writePlatformService; + } - @Transactional - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { - this.writePlatformService.deleteReport(command.entityId()); + this.writePlatformService.deleteReport(command.entityId()); - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(command.entityId()) // - .build(); - } + return new CommandProcessingResultBuilder() // + .withCommandId(command.commandId()) // + .withEntityId(command.entityId()) // + .build(); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToManyDatatableEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToManyDatatableEntryCommandHandler.java index eb867109f..71bfef446 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToManyDatatableEntryCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToManyDatatableEntryCommandHandler.java @@ -28,18 +28,18 @@ public class UpdateOneToManyDatatableEntryCommandHandler implements NewCommandSo @Override public CommandProcessingResult processCommand(final JsonCommand command) { - final CommandProcessingResult commandProcessingResult = this.writePlatformService.updateDatatableEntryOneToMany(command.entityName(), - command.entityId(), command.subentityId(), command); + final CommandProcessingResult commandProcessingResult = this.writePlatformService.updateDatatableEntryOneToMany( + command.entityName(), command.entityId(), command.subentityId(), command); return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(command.entityId()) // - .withOfficeId(commandProcessingResult.getOfficeId()) // - .withGroupId(commandProcessingResult.getGroupId()) // - .withClientId(commandProcessingResult.getClientId()) // - .withSavingsId(commandProcessingResult.getSavingsId()) // - .withLoanId(commandProcessingResult.getLoanId()) // - .with(commandProcessingResult.getChanges()) // - .build(); + .withCommandId(command.commandId()) // + .withEntityId(command.entityId()) // + .withOfficeId(commandProcessingResult.getOfficeId()) // + .withGroupId(commandProcessingResult.getGroupId()) // + .withClientId(commandProcessingResult.getClientId()) // + .withSavingsId(commandProcessingResult.getSavingsId()) // + .withLoanId(commandProcessingResult.getLoanId()) // + .with(commandProcessingResult.getChanges()) // + .build(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToOneDatatableEntryCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToOneDatatableEntryCommandHandler.java index 5805864be..b8dc7f82f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToOneDatatableEntryCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateOneToOneDatatableEntryCommandHandler.java @@ -28,18 +28,18 @@ public class UpdateOneToOneDatatableEntryCommandHandler implements NewCommandSou @Override public CommandProcessingResult processCommand(final JsonCommand command) { - final CommandProcessingResult commandProcessingResult = this.writePlatformService.updateDatatableEntryOneToOne(command.entityName(), command.entityId(), - command); + final CommandProcessingResult commandProcessingResult = this.writePlatformService.updateDatatableEntryOneToOne( + command.entityName(), command.entityId(), command); return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(command.entityId()) // - .withOfficeId(commandProcessingResult.getOfficeId()) // - .withGroupId(commandProcessingResult.getGroupId()) // - .withClientId(commandProcessingResult.getClientId()) // - .withSavingsId(commandProcessingResult.getSavingsId()) // - .withLoanId(commandProcessingResult.getLoanId()) // - .with(commandProcessingResult.getChanges()) // - .build(); + .withCommandId(command.commandId()) // + .withEntityId(command.entityId()) // + .withOfficeId(commandProcessingResult.getOfficeId()) // + .withGroupId(commandProcessingResult.getGroupId()) // + .withClientId(commandProcessingResult.getClientId()) // + .withSavingsId(commandProcessingResult.getSavingsId()) // + .withLoanId(commandProcessingResult.getLoanId()) // + .with(commandProcessingResult.getChanges()) // + .build(); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateReportCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateReportCommandHandler.java index 66fc1d6fb..a42685f86 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateReportCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/handler/UpdateReportCommandHandler.java @@ -16,19 +16,17 @@ import org.springframework.transaction.annotation.Transactional; @Service public class UpdateReportCommandHandler implements NewCommandSourceHandler { - private final ReportWritePlatformService writePlatformService; + private final ReportWritePlatformService writePlatformService; - @Autowired - public UpdateReportCommandHandler( - final ReportWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } + @Autowired + public UpdateReportCommandHandler(final ReportWritePlatformService writePlatformService) { + this.writePlatformService = writePlatformService; + } - @Transactional - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { - return this.writePlatformService.updateReport(command.entityId(), - command); - } + return this.writePlatformService.updateReport(command.entityId(), command); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/serialization/ReportCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/serialization/ReportCommandFromApiJsonDeserializer.java index 689df151c..f91efd770 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/serialization/ReportCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/serialization/ReportCommandFromApiJsonDeserializer.java @@ -22,30 +22,24 @@ import com.google.gson.reflect.TypeToken; @Component public final class ReportCommandFromApiJsonDeserializer { - /** - * The parameters supported for this command. - */ - private final Set supportedParameters = new HashSet( - Arrays.asList("reportName", "reportType", "reportSubType", - "reportCategory", "description", "reportSql", "useReport")); + /** + * The parameters supported for this command. + */ + private final Set supportedParameters = new HashSet(Arrays.asList("reportName", "reportType", "reportSubType", + "reportCategory", "description", "reportSql", "useReport")); - private final FromJsonHelper fromApiJsonHelper; + private final FromJsonHelper fromApiJsonHelper; - @Autowired - public ReportCommandFromApiJsonDeserializer( - final FromJsonHelper fromApiJsonHelper) { - this.fromApiJsonHelper = fromApiJsonHelper; - } + @Autowired + public ReportCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper) { + this.fromApiJsonHelper = fromApiJsonHelper; + } - public void validate(final String json) { - if (StringUtils.isBlank(json)) { - throw new InvalidJsonException(); - } + public void validate(final String json) { + if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } - final Type typeOfMap = new TypeToken>() { - }.getType(); + final Type typeOfMap = new TypeToken>() {}.getType(); - fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, - supportedParameters); - } + fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingService.java index c01fd5b56..ad76bee12 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingService.java @@ -16,21 +16,17 @@ import org.mifosplatform.infrastructure.dataqueries.data.ReportData; public interface ReadReportingService { - StreamingOutput retrieveReportCSV(String name, String type, - Map extractedQueryParams); + StreamingOutput retrieveReportCSV(String name, String type, Map extractedQueryParams); - GenericResultsetData retrieveGenericResultset(String name, String type, - Map extractedQueryParams); + GenericResultsetData retrieveGenericResultset(String name, String type, Map extractedQueryParams); - Response processPentahoRequest(String reportName, String outputType, - Map queryParams); + Response processPentahoRequest(String reportName, String outputType, Map queryParams); - String retrieveReportPDF(String name, String type, - Map extractedQueryParams); + String retrieveReportPDF(String name, String type, Map extractedQueryParams); - String getReportType(String reportName); + String getReportType(String reportName); - Collection retrieveReportList(); + Collection retrieveReportList(); - ReportData retrieveReport(final Long id); + ReportData retrieveReport(final Long id); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java index cda0f433b..9ba167280 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java @@ -68,587 +68,496 @@ import com.lowagie.text.pdf.PdfWriter; @Service public class ReadReportingServiceImpl implements ReadReportingService { - private final static Logger logger = LoggerFactory - .getLogger(ReadReportingServiceImpl.class); - - private final JdbcTemplate jdbcTemplate; - private final DataSource dataSource; - private final PlatformSecurityContext context; - private final GenericDataService genericDataService; - private boolean noPentaho = false; - - @Autowired - public ReadReportingServiceImpl(final PlatformSecurityContext context, - final TenantAwareRoutingDataSource dataSource, - final GenericDataService genericDataService) { - // kick off pentaho reports server - ClassicEngineBoot.getInstance().start(); - noPentaho = false; - - this.context = context; - this.dataSource = dataSource; - this.jdbcTemplate = new JdbcTemplate(this.dataSource); - this.genericDataService = genericDataService; - } - - @Override - public StreamingOutput retrieveReportCSV(final String name, - final String type, final Map queryParams) { - - return new StreamingOutput() { - - @Override - public void write(final OutputStream out) { - try { - - GenericResultsetData result = retrieveGenericResultset( - name, type, queryParams); - StringBuffer sb = generateCsvFileBuffer(result); - - InputStream in = new ByteArrayInputStream(sb.toString() - .getBytes("UTF-8")); - - byte[] outputByte = new byte[4096]; - Integer readLen = in.read(outputByte, 0, 4096); - - while (readLen != -1) { - out.write(outputByte, 0, readLen); - readLen = in.read(outputByte, 0, 4096); - } - // in.close(); - // out.flush(); - // out.close(); - } catch (Exception e) { - throw new PlatformDataIntegrityException( - "error.msg.exception.error", e.getMessage()); - } - } - }; - - } - - private StringBuffer generateCsvFileBuffer(final GenericResultsetData result) { - StringBuffer writer = new StringBuffer(); - - List columnHeaders = result - .getColumnHeaders(); - logger.info("NO. of Columns: " + columnHeaders.size()); - Integer chSize = columnHeaders.size(); - for (int i = 0; i < chSize; i++) { - writer.append('"' + columnHeaders.get(i).getColumnName() + '"'); - if (i < (chSize - 1)) - writer.append(","); - } - writer.append('\n'); - - List data = result.getData(); - List row; - Integer rSize; - // String currCol; - String currColType; - String currVal; - String doubleQuote = "\""; - String twoDoubleQuotes = doubleQuote + doubleQuote; - logger.info("NO. of Rows: " + data.size()); - for (int i = 0; i < data.size(); i++) { - row = data.get(i).getRow(); - rSize = row.size(); - for (int j = 0; j < rSize; j++) { - // currCol = columnHeaders.get(j).getColumnName(); - currColType = columnHeaders.get(j).getColumnType(); - currVal = row.get(j); - if (currVal != null) { - if (currColType.equals("DECIMAL") - || currColType.equals("DOUBLE") - || currColType.equals("BIGINT") - || currColType.equals("SMALLINT") - || currColType.equals("INT")) - writer.append(currVal); - else - writer.append('"' + genericDataService.replace(currVal, - doubleQuote, twoDoubleQuotes) + '"'); - - } - if (j < (rSize - 1)) - writer.append(","); - } - writer.append('\n'); - } - - return writer; - } - - @Override - public GenericResultsetData retrieveGenericResultset(final String name, - final String type, final Map queryParams) { - - long startTime = System.currentTimeMillis(); - logger.info("STARTING REPORT: " + name + " Type: " + type); - - String sql = getSQLtoRun(name, type, queryParams); - - GenericResultsetData result = genericDataService - .fillGenericResultSet(sql); - - long elapsed = System.currentTimeMillis() - startTime; - logger.info("FINISHING Report/Request Name: " + name + " - " + type - + " Elapsed Time: " + elapsed); - return result; - } - - private String getSQLtoRun(final String name, final String type, - final Map queryParams) { - - String sql = getSql(name, type); - - Set keys = queryParams.keySet(); - for (String key : keys) { - String pValue = queryParams.get(key); - // logger.info("(" + key + " : " + pValue + ")"); - sql = genericDataService.replace(sql, key, pValue); - } - - AppUser currentUser = context.authenticatedUser(); - // Allows sql query to restrict data by office hierarchy if required - sql = genericDataService.replace(sql, "${currentUserHierarchy}", - currentUser.getOffice().getHierarchy()); - // Allows sql query to restrict data by current user Id if required - // (typically used to return report lists containing only reports - // permitted to be run by the user - sql = genericDataService.replace(sql, "${currentUserId}", currentUser - .getId().toString()); - - sql = genericDataService.wrapSQL(sql); - - return sql; - - } - - private String getSql(final String name, final String type) { - - final String inputSql = "select " + type - + "_sql as the_sql from stretchy_" + type + " where " + type - + "_name = '" + name + "'"; - final String inputSqlWrapped = genericDataService.wrapSQL(inputSql); - - final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(inputSqlWrapped); - - if (rs.next()) { - return rs.getString("the_sql"); - } - throw new ReportNotFoundException(inputSql); - } - - @Override - public String getReportType(final String reportName) { - - final String sql = "SELECT ifnull(report_type,'') as report_type FROM `stretchy_report` where report_name = '" - + reportName + "'"; - - final String sqlWrapped = genericDataService.wrapSQL(sql); - - final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(sqlWrapped); - - if (rs.next()) { - return rs.getString("report_type"); - } - throw new ReportNotFoundException(sql); - } - - @Override - public Response processPentahoRequest(final String reportName, - final String outputTypeParam, final Map queryParams) { - - String outputType = "HTML"; - if (StringUtils.isNotBlank(outputTypeParam)) - outputType = outputTypeParam; - - if (!(outputType.equalsIgnoreCase("HTML") - || outputType.equalsIgnoreCase("PDF") - || outputType.equalsIgnoreCase("XLS") || outputType - .equalsIgnoreCase("CSV"))) - throw new PlatformDataIntegrityException( - "error.msg.invalid.outputType", "No matching Output Type: " - + outputType); - - if (noPentaho) { - throw new PlatformDataIntegrityException("error.msg.no.pentaho", - "Pentaho is not enabled", "Pentaho is not enabled"); - } - - final String reportPath = FileUtils.MIFOSX_BASE_DIR + File.separator - + "pentahoReports" + File.separator + reportName + ".prpt"; - logger.info("Report path: " + reportPath); - - // load report definition - ResourceManager manager = new ResourceManager(); - manager.registerDefaults(); - Resource res; - - try { - res = manager.createDirectly(reportPath, MasterReport.class); - MasterReport masterReport = (MasterReport) res.getResource(); - - addParametersToReport(masterReport, queryParams); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - if ("PDF".equalsIgnoreCase(outputType)) { - PdfReportUtil.createPDF(masterReport, baos); - return Response.ok().entity(baos.toByteArray()) - .type("application/pdf").build(); - } - - if ("XLS".equalsIgnoreCase(outputType)) { - ExcelReportUtil.createXLS(masterReport, baos); - return Response - .ok() - .entity(baos.toByteArray()) - .type("application/vnd.ms-excel") - .header("Content-Disposition", - "attachment;filename=" - + reportName.replaceAll(" ", "") - + ".xls").build(); - } - - if ("CSV".equalsIgnoreCase(outputType)) { - CSVReportUtil.createCSV(masterReport, baos, "UTF-8"); - return Response - .ok() - .entity(baos.toByteArray()) - .type("application/x-msdownload") - .header("Content-Disposition", - "attachment;filename=" - + reportName.replaceAll(" ", "") - + ".csv").build(); - } - - if ("HTML".equalsIgnoreCase(outputType)) { - HtmlReportUtil.createStreamHTML(masterReport, baos); - return Response.ok().entity(baos.toByteArray()) - .type("text/html").build(); - } - } catch (ResourceException e) { - throw new PlatformDataIntegrityException( - "error.msg.reporting.error", e.getMessage()); - } catch (ReportProcessingException e) { - throw new PlatformDataIntegrityException( - "error.msg.reporting.error", e.getMessage()); - } catch (IOException e) { - throw new PlatformDataIntegrityException( - "error.msg.reporting.error", e.getMessage()); - } - - throw new PlatformDataIntegrityException( - "error.msg.invalid.outputType", "No matching Output Type: " - + outputType); - } - - private void addParametersToReport(final MasterReport report, - final Map queryParams) { - - AppUser currentUser = context.authenticatedUser(); - - try { - - ReportParameterValues rptParamValues = report.getParameterValues(); - ReportParameterDefinition paramsDefinition = report - .getParameterDefinition(); - - /* - * only allow integer, long, date and string parameter types and - * assume all mandatory - could go more detailed like Pawel did in - * Mifos later and could match incoming and pentaho parameters - * better... currently assuming they come in ok... and if not an - * error - */ - for (ParameterDefinitionEntry paramDefEntry : paramsDefinition - .getParameterDefinitions()) { - String paramName = paramDefEntry.getName(); - if (!((paramName.equals("tenantdb")) || (paramName - .equals("userhierarchy")))) { - logger.info("paramName:" + paramName); - String pValue = queryParams.get(paramName); - if (StringUtils.isBlank(pValue)) - throw new PlatformDataIntegrityException( - "error.msg.reporting.error", - "Pentaho Parameter: " + paramName - + " - not Provided"); - - Class clazz = paramDefEntry.getValueType(); - logger.info("addParametersToReport(" + paramName + " : " - + pValue + " : " + clazz.getCanonicalName() + ")"); - if (clazz.getCanonicalName().equalsIgnoreCase( - "java.lang.Integer")) - rptParamValues.put(paramName, Integer.parseInt(pValue)); - else if (clazz.getCanonicalName().equalsIgnoreCase( - "java.lang.Long")) - rptParamValues.put(paramName, Long.parseLong(pValue)); - else if (clazz.getCanonicalName().equalsIgnoreCase( - "java.sql.Date")) - rptParamValues.put(paramName, Date.valueOf(pValue)); - else - rptParamValues.put(paramName, pValue); - } - - } - - // tenant database name and current user's office hierarchy - // passed as parameters to allow multitenant penaho reporting - // and - // data scoping - String tenantdb = dataSource.getConnection().getCatalog(); - String userhierarchy = currentUser.getOffice().getHierarchy(); - logger.info("db name:" + tenantdb + " userhierarchy:" - + userhierarchy); - rptParamValues.put("tenantdb", tenantdb); - rptParamValues.put("userhierarchy", userhierarchy); - } catch (Exception e) { - logger.error("error.msg.reporting.error:" + e.getMessage()); - throw new PlatformDataIntegrityException( - "error.msg.reporting.error", e.getMessage()); - } - } - - @Override - public String retrieveReportPDF(final String reportName, final String type, - final Map queryParams) { - - String fileLocation = FileUtils.MIFOSX_BASE_DIR + File.separator + ""; - if (!new File(fileLocation).isDirectory()) { - new File(fileLocation).mkdirs(); - } - - String genaratePdf = fileLocation + File.separator + reportName - + ".pdf"; - - try { - GenericResultsetData result = retrieveGenericResultset(reportName, - type, queryParams); - - List columnHeaders = result - .getColumnHeaders(); - List data = result.getData(); - List row; - - logger.info("NO. of Columns: " + columnHeaders.size()); - Integer chSize = columnHeaders.size(); - - Document document = new Document(PageSize.B0.rotate()); - - PdfWriter.getInstance(document, new FileOutputStream(new File( - fileLocation + reportName + ".pdf"))); - document.open(); - - PdfPTable table = new PdfPTable(chSize); - table.setWidthPercentage(100); - - for (int i = 0; i < chSize; i++) { - - table.addCell(columnHeaders.get(i).getColumnName()); - - } - table.completeRow(); - - Integer rSize; - String currColType; - String currVal; - logger.info("NO. of Rows: " + data.size()); - for (int i = 0; i < data.size(); i++) { - row = data.get(i).getRow(); - rSize = row.size(); - for (int j = 0; j < rSize; j++) { - currColType = columnHeaders.get(j).getColumnType(); - currVal = row.get(j); - if (currVal != null) { - if (currColType.equals("DECIMAL") - || currColType.equals("DOUBLE") - || currColType.equals("BIGINT") - || currColType.equals("SMALLINT") - || currColType.equals("INT")) { - - table.addCell(currVal.toString()); - } else { - table.addCell(currVal.toString()); - } - } - } - } - table.completeRow(); - document.add(table); - document.close(); - return genaratePdf; - } catch (Exception e) { - logger.error("error.msg.reporting.error:" + e.getMessage()); - throw new PlatformDataIntegrityException( - "error.msg.exception.error", e.getMessage()); - } - } - - @Override - public ReportData retrieveReport(Long id) { - Collection reports = retrieveReports(id); - - for (ReportData report : reports) { - return report; - } - return null; - } - - @Override - public Collection retrieveReportList() { - return retrieveReports(null); - } - - private Collection retrieveReports(final Long id) { - - ReportParameterJoinMapper rm = new ReportParameterJoinMapper(); - - String sql = rm.schema(id); - - Collection rpJoins = this.jdbcTemplate.query( - sql, rm, new Object[] {}); - - Collection reportList = new ArrayList(); - if (rpJoins == null || rpJoins.size() == 0) - return reportList; - - Collection reportParameters = null; - - Long reportId = null; - String reportName = null; - String reportType = null; - String reportSubType = null; - String reportCategory = null; - String description = null; - Boolean coreReport = null; - Boolean useReport = null; - String reportSql = null; - - Long prevReportId = (long) -1234; - Boolean firstReport = true; - for (ReportParameterJoinData rpJoin : rpJoins) { - - if (rpJoin.getReportId().equals(prevReportId)) { - // more than one parameter for report - reportParameters.add(new ReportParameterData(rpJoin - .getReportParameterId(), rpJoin - .getReportParameterName(), rpJoin.getParameterName())); - - } else { - if (firstReport) { - firstReport = false; - } else { - // write report entry - reportList.add(new ReportData(reportId, reportName, - reportType, reportSubType, reportCategory, - description, reportSql, coreReport, useReport, - reportParameters)); - } - - prevReportId = rpJoin.getReportId(); - - reportId = rpJoin.getReportId(); - reportName = rpJoin.getReportName(); - reportType = rpJoin.getReportType(); - reportSubType = rpJoin.getReportSubType(); - reportCategory = rpJoin.getReportCategory(); - description = rpJoin.getDescription(); - reportSql = rpJoin.getReportSql(); - coreReport = rpJoin.getCoreReport(); - useReport = rpJoin.getUseReport(); - - if (rpJoin.getReportParameterId() != null) { - // report has at least one parameter - reportParameters = new ArrayList(); - reportParameters.add(new ReportParameterData(rpJoin - .getReportParameterId(), rpJoin - .getReportParameterName(), rpJoin - .getParameterName())); - } else { - reportParameters = null; - } - } - - } - // write last report - reportList.add(new ReportData(reportId, reportName, reportType, - reportSubType, reportCategory, description, reportSql, - coreReport, useReport, reportParameters)); - - return reportList; - } - - private static final class ReportParameterJoinMapper implements - RowMapper { - - public String schema(Long reportId) { - - String sql = "select r.id as reportId, r.report_name as reportName, r.report_type as reportType, " - + " r.report_subtype as reportSubType, r.report_category as reportCategory, r.description, r.core_report as coreReport, r.use_report as useReport, " - + " rp.parameter_id as reportParameterId, rp.report_parameter_name as reportParameterName, p.parameter_name as parameterName"; - - if (reportId != null) - sql += ", r.report_sql as reportSql "; - - sql += " from stretchy_report r" - + " left join stretchy_report_parameter rp on rp.report_id = r.id" - + " left join stretchy_parameter p on p.id = rp.parameter_id"; - if (reportId != null) - sql += " where r.id = " + reportId; - else - sql += " order by r.id, rp.parameter_id"; - - return sql; - -/* used to only return reports that the use can run as done in report UI but not necessary as there is a read_report permission - * which should give user access to look all reports - + " where exists" - + " (select 'f'" - + " from m_appuser_role ur " - + " join m_role r on r.id = ur.role_id" - + " left join m_role_permission rp on rp.role_id = r.id" - + " left join m_permission p on p.id = rp.permission_id" - + " where ur.appuser_id = " - + userId - + " and (p.code in ('ALL_FUNCTIONS', 'ALL_FUNCTIONS_READ') or p.code = concat('READ_', r.report_name))) "; - */ - } - - @Override - public ReportParameterJoinData mapRow(final ResultSet rs, - @SuppressWarnings("unused") final int rowNum) - throws SQLException { - - final Long reportId = rs.getLong("reportId"); - final String reportName = rs.getString("reportName"); - final String reportType = rs.getString("reportType"); - final String reportSubType = rs.getString("reportSubType"); - final String reportCategory = rs.getString("reportCategory"); - final String description = rs.getString("description"); - final Boolean coreReport = rs.getBoolean("coreReport"); - final Boolean useReport = rs.getBoolean("useReport"); - - String reportSql; - // reportSql might not be on the select list of columns - try { - reportSql = rs.getString("reportSql"); - } catch (SQLException e) { - reportSql = null; - } - - final Long reportParameterId = JdbcSupport.getLong(rs, - "reportParameterId"); - final String reportParameterName = rs - .getString("reportParameterName"); - final String parameterName = rs.getString("parameterName"); - - return new ReportParameterJoinData(reportId, reportName, - reportType, reportSubType, reportCategory, description, - reportSql, coreReport, useReport, reportParameterId, - reportParameterName, parameterName); - } - - } + private final static Logger logger = LoggerFactory.getLogger(ReadReportingServiceImpl.class); + + private final JdbcTemplate jdbcTemplate; + private final DataSource dataSource; + private final PlatformSecurityContext context; + private final GenericDataService genericDataService; + private boolean noPentaho = false; + + @Autowired + public ReadReportingServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource, + final GenericDataService genericDataService) { + // kick off pentaho reports server + ClassicEngineBoot.getInstance().start(); + noPentaho = false; + + this.context = context; + this.dataSource = dataSource; + this.jdbcTemplate = new JdbcTemplate(this.dataSource); + this.genericDataService = genericDataService; + } + + @Override + public StreamingOutput retrieveReportCSV(final String name, final String type, final Map queryParams) { + + return new StreamingOutput() { + + @Override + public void write(final OutputStream out) { + try { + + GenericResultsetData result = retrieveGenericResultset(name, type, queryParams); + StringBuffer sb = generateCsvFileBuffer(result); + + InputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8")); + + byte[] outputByte = new byte[4096]; + Integer readLen = in.read(outputByte, 0, 4096); + + while (readLen != -1) { + out.write(outputByte, 0, readLen); + readLen = in.read(outputByte, 0, 4096); + } + // in.close(); + // out.flush(); + // out.close(); + } catch (Exception e) { + throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage()); + } + } + }; + + } + + private StringBuffer generateCsvFileBuffer(final GenericResultsetData result) { + StringBuffer writer = new StringBuffer(); + + List columnHeaders = result.getColumnHeaders(); + logger.info("NO. of Columns: " + columnHeaders.size()); + Integer chSize = columnHeaders.size(); + for (int i = 0; i < chSize; i++) { + writer.append('"' + columnHeaders.get(i).getColumnName() + '"'); + if (i < (chSize - 1)) writer.append(","); + } + writer.append('\n'); + + List data = result.getData(); + List row; + Integer rSize; + // String currCol; + String currColType; + String currVal; + String doubleQuote = "\""; + String twoDoubleQuotes = doubleQuote + doubleQuote; + logger.info("NO. of Rows: " + data.size()); + for (int i = 0; i < data.size(); i++) { + row = data.get(i).getRow(); + rSize = row.size(); + for (int j = 0; j < rSize; j++) { + // currCol = columnHeaders.get(j).getColumnName(); + currColType = columnHeaders.get(j).getColumnType(); + currVal = row.get(j); + if (currVal != null) { + if (currColType.equals("DECIMAL") || currColType.equals("DOUBLE") || currColType.equals("BIGINT") + || currColType.equals("SMALLINT") || currColType.equals("INT")) + writer.append(currVal); + else + writer.append('"' + genericDataService.replace(currVal, doubleQuote, twoDoubleQuotes) + '"'); + + } + if (j < (rSize - 1)) writer.append(","); + } + writer.append('\n'); + } + + return writer; + } + + @Override + public GenericResultsetData retrieveGenericResultset(final String name, final String type, final Map queryParams) { + + long startTime = System.currentTimeMillis(); + logger.info("STARTING REPORT: " + name + " Type: " + type); + + String sql = getSQLtoRun(name, type, queryParams); + + GenericResultsetData result = genericDataService.fillGenericResultSet(sql); + + long elapsed = System.currentTimeMillis() - startTime; + logger.info("FINISHING Report/Request Name: " + name + " - " + type + " Elapsed Time: " + elapsed); + return result; + } + + private String getSQLtoRun(final String name, final String type, final Map queryParams) { + + String sql = getSql(name, type); + + Set keys = queryParams.keySet(); + for (String key : keys) { + String pValue = queryParams.get(key); + // logger.info("(" + key + " : " + pValue + ")"); + sql = genericDataService.replace(sql, key, pValue); + } + + AppUser currentUser = context.authenticatedUser(); + // Allows sql query to restrict data by office hierarchy if required + sql = genericDataService.replace(sql, "${currentUserHierarchy}", currentUser.getOffice().getHierarchy()); + // Allows sql query to restrict data by current user Id if required + // (typically used to return report lists containing only reports + // permitted to be run by the user + sql = genericDataService.replace(sql, "${currentUserId}", currentUser.getId().toString()); + + sql = genericDataService.wrapSQL(sql); + + return sql; + + } + + private String getSql(final String name, final String type) { + + final String inputSql = "select " + type + "_sql as the_sql from stretchy_" + type + " where " + type + "_name = '" + name + "'"; + final String inputSqlWrapped = genericDataService.wrapSQL(inputSql); + + final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(inputSqlWrapped); + + if (rs.next()) { return rs.getString("the_sql"); } + throw new ReportNotFoundException(inputSql); + } + + @Override + public String getReportType(final String reportName) { + + final String sql = "SELECT ifnull(report_type,'') as report_type FROM `stretchy_report` where report_name = '" + reportName + "'"; + + final String sqlWrapped = genericDataService.wrapSQL(sql); + + final SqlRowSet rs = this.jdbcTemplate.queryForRowSet(sqlWrapped); + + if (rs.next()) { return rs.getString("report_type"); } + throw new ReportNotFoundException(sql); + } + + @Override + public Response processPentahoRequest(final String reportName, final String outputTypeParam, final Map queryParams) { + + String outputType = "HTML"; + if (StringUtils.isNotBlank(outputTypeParam)) outputType = outputTypeParam; + + if (!(outputType.equalsIgnoreCase("HTML") || outputType.equalsIgnoreCase("PDF") || outputType.equalsIgnoreCase("XLS") || outputType + .equalsIgnoreCase("CSV"))) + throw new PlatformDataIntegrityException("error.msg.invalid.outputType", "No matching Output Type: " + outputType); + + if (noPentaho) { throw new PlatformDataIntegrityException("error.msg.no.pentaho", "Pentaho is not enabled", + "Pentaho is not enabled"); } + + final String reportPath = FileUtils.MIFOSX_BASE_DIR + File.separator + "pentahoReports" + File.separator + reportName + ".prpt"; + logger.info("Report path: " + reportPath); + + // load report definition + ResourceManager manager = new ResourceManager(); + manager.registerDefaults(); + Resource res; + + try { + res = manager.createDirectly(reportPath, MasterReport.class); + MasterReport masterReport = (MasterReport) res.getResource(); + + addParametersToReport(masterReport, queryParams); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + if ("PDF".equalsIgnoreCase(outputType)) { + PdfReportUtil.createPDF(masterReport, baos); + return Response.ok().entity(baos.toByteArray()).type("application/pdf").build(); + } + + if ("XLS".equalsIgnoreCase(outputType)) { + ExcelReportUtil.createXLS(masterReport, baos); + return Response.ok().entity(baos.toByteArray()).type("application/vnd.ms-excel") + .header("Content-Disposition", "attachment;filename=" + reportName.replaceAll(" ", "") + ".xls").build(); + } + if ("CSV".equalsIgnoreCase(outputType)) { + CSVReportUtil.createCSV(masterReport, baos, "UTF-8"); + return Response.ok().entity(baos.toByteArray()).type("application/x-msdownload") + .header("Content-Disposition", "attachment;filename=" + reportName.replaceAll(" ", "") + ".csv").build(); + } + + if ("HTML".equalsIgnoreCase(outputType)) { + HtmlReportUtil.createStreamHTML(masterReport, baos); + return Response.ok().entity(baos.toByteArray()).type("text/html").build(); + } + } catch (ResourceException e) { + throw new PlatformDataIntegrityException("error.msg.reporting.error", e.getMessage()); + } catch (ReportProcessingException e) { + throw new PlatformDataIntegrityException("error.msg.reporting.error", e.getMessage()); + } catch (IOException e) { + throw new PlatformDataIntegrityException("error.msg.reporting.error", e.getMessage()); + } + + throw new PlatformDataIntegrityException("error.msg.invalid.outputType", "No matching Output Type: " + outputType); + } + + private void addParametersToReport(final MasterReport report, final Map queryParams) { + + AppUser currentUser = context.authenticatedUser(); + + try { + + ReportParameterValues rptParamValues = report.getParameterValues(); + ReportParameterDefinition paramsDefinition = report.getParameterDefinition(); + + /* + * only allow integer, long, date and string parameter types and + * assume all mandatory - could go more detailed like Pawel did in + * Mifos later and could match incoming and pentaho parameters + * better... currently assuming they come in ok... and if not an + * error + */ + for (ParameterDefinitionEntry paramDefEntry : paramsDefinition.getParameterDefinitions()) { + String paramName = paramDefEntry.getName(); + if (!((paramName.equals("tenantdb")) || (paramName.equals("userhierarchy")))) { + logger.info("paramName:" + paramName); + String pValue = queryParams.get(paramName); + if (StringUtils.isBlank(pValue)) + throw new PlatformDataIntegrityException("error.msg.reporting.error", "Pentaho Parameter: " + paramName + + " - not Provided"); + + Class clazz = paramDefEntry.getValueType(); + logger.info("addParametersToReport(" + paramName + " : " + pValue + " : " + clazz.getCanonicalName() + ")"); + if (clazz.getCanonicalName().equalsIgnoreCase("java.lang.Integer")) + rptParamValues.put(paramName, Integer.parseInt(pValue)); + else if (clazz.getCanonicalName().equalsIgnoreCase("java.lang.Long")) + rptParamValues.put(paramName, Long.parseLong(pValue)); + else if (clazz.getCanonicalName().equalsIgnoreCase("java.sql.Date")) + rptParamValues.put(paramName, Date.valueOf(pValue)); + else + rptParamValues.put(paramName, pValue); + } + + } + + // tenant database name and current user's office hierarchy + // passed as parameters to allow multitenant penaho reporting + // and + // data scoping + String tenantdb = dataSource.getConnection().getCatalog(); + String userhierarchy = currentUser.getOffice().getHierarchy(); + logger.info("db name:" + tenantdb + " userhierarchy:" + userhierarchy); + rptParamValues.put("tenantdb", tenantdb); + rptParamValues.put("userhierarchy", userhierarchy); + } catch (Exception e) { + logger.error("error.msg.reporting.error:" + e.getMessage()); + throw new PlatformDataIntegrityException("error.msg.reporting.error", e.getMessage()); + } + } + + @Override + public String retrieveReportPDF(final String reportName, final String type, final Map queryParams) { + + String fileLocation = FileUtils.MIFOSX_BASE_DIR + File.separator + ""; + if (!new File(fileLocation).isDirectory()) { + new File(fileLocation).mkdirs(); + } + + String genaratePdf = fileLocation + File.separator + reportName + ".pdf"; + + try { + GenericResultsetData result = retrieveGenericResultset(reportName, type, queryParams); + + List columnHeaders = result.getColumnHeaders(); + List data = result.getData(); + List row; + + logger.info("NO. of Columns: " + columnHeaders.size()); + Integer chSize = columnHeaders.size(); + + Document document = new Document(PageSize.B0.rotate()); + + PdfWriter.getInstance(document, new FileOutputStream(new File(fileLocation + reportName + ".pdf"))); + document.open(); + + PdfPTable table = new PdfPTable(chSize); + table.setWidthPercentage(100); + + for (int i = 0; i < chSize; i++) { + + table.addCell(columnHeaders.get(i).getColumnName()); + + } + table.completeRow(); + + Integer rSize; + String currColType; + String currVal; + logger.info("NO. of Rows: " + data.size()); + for (int i = 0; i < data.size(); i++) { + row = data.get(i).getRow(); + rSize = row.size(); + for (int j = 0; j < rSize; j++) { + currColType = columnHeaders.get(j).getColumnType(); + currVal = row.get(j); + if (currVal != null) { + if (currColType.equals("DECIMAL") || currColType.equals("DOUBLE") || currColType.equals("BIGINT") + || currColType.equals("SMALLINT") || currColType.equals("INT")) { + + table.addCell(currVal.toString()); + } else { + table.addCell(currVal.toString()); + } + } + } + } + table.completeRow(); + document.add(table); + document.close(); + return genaratePdf; + } catch (Exception e) { + logger.error("error.msg.reporting.error:" + e.getMessage()); + throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage()); + } + } + + @Override + public ReportData retrieveReport(final Long id) { + Collection reports = retrieveReports(id); + + for (ReportData report : reports) { + return report; + } + return null; + } + + @Override + public Collection retrieveReportList() { + return retrieveReports(null); + } + + private Collection retrieveReports(final Long id) { + + ReportParameterJoinMapper rm = new ReportParameterJoinMapper(); + + String sql = rm.schema(id); + + Collection rpJoins = this.jdbcTemplate.query(sql, rm, new Object[] {}); + + Collection reportList = new ArrayList(); + if (rpJoins == null || rpJoins.size() == 0) return reportList; + + Collection reportParameters = null; + + Long reportId = null; + String reportName = null; + String reportType = null; + String reportSubType = null; + String reportCategory = null; + String description = null; + Boolean coreReport = null; + Boolean useReport = null; + String reportSql = null; + + Long prevReportId = (long) -1234; + Boolean firstReport = true; + for (ReportParameterJoinData rpJoin : rpJoins) { + + if (rpJoin.getReportId().equals(prevReportId)) { + // more than one parameter for report + if (reportParameters == null) { + reportParameters = new ArrayList(); + } + reportParameters.add(new ReportParameterData(rpJoin.getReportParameterId(), rpJoin.getReportParameterName(), rpJoin + .getParameterName())); + + } else { + if (firstReport) { + firstReport = false; + } else { + // write report entry + reportList.add(new ReportData(reportId, reportName, reportType, reportSubType, reportCategory, description, reportSql, + coreReport, useReport, reportParameters)); + } + + prevReportId = rpJoin.getReportId(); + + reportId = rpJoin.getReportId(); + reportName = rpJoin.getReportName(); + reportType = rpJoin.getReportType(); + reportSubType = rpJoin.getReportSubType(); + reportCategory = rpJoin.getReportCategory(); + description = rpJoin.getDescription(); + reportSql = rpJoin.getReportSql(); + coreReport = rpJoin.getCoreReport(); + useReport = rpJoin.getUseReport(); + + if (rpJoin.getReportParameterId() != null) { + // report has at least one parameter + reportParameters = new ArrayList(); + reportParameters.add(new ReportParameterData(rpJoin.getReportParameterId(), rpJoin.getReportParameterName(), rpJoin + .getParameterName())); + } else { + reportParameters = null; + } + } + + } + // write last report + reportList.add(new ReportData(reportId, reportName, reportType, reportSubType, reportCategory, description, reportSql, coreReport, + useReport, reportParameters)); + + return reportList; + } + + private static final class ReportParameterJoinMapper implements RowMapper { + + public String schema(final Long reportId) { + + String sql = "select r.id as reportId, r.report_name as reportName, r.report_type as reportType, " + + " r.report_subtype as reportSubType, r.report_category as reportCategory, r.description, r.core_report as coreReport, r.use_report as useReport, " + + " rp.parameter_id as reportParameterId, rp.report_parameter_name as reportParameterName, p.parameter_name as parameterName"; + + if (reportId != null) sql += ", r.report_sql as reportSql "; + + sql += " from stretchy_report r" + " left join stretchy_report_parameter rp on rp.report_id = r.id" + + " left join stretchy_parameter p on p.id = rp.parameter_id"; + if (reportId != null) + sql += " where r.id = " + reportId; + else + sql += " order by r.id, rp.parameter_id"; + + return sql; + + /* + * used to only return reports that the use can run as done in + * report UI but not necessary as there is a read_report permission + * which should give user access to look all reports + + * " where exists" + " (select 'f'" + " from m_appuser_role ur " + + * " join m_role r on r.id = ur.role_id" + + * " left join m_role_permission rp on rp.role_id = r.id" + + * " left join m_permission p on p.id = rp.permission_id" + + * " where ur.appuser_id = " + userId + + * " and (p.code in ('ALL_FUNCTIONS', 'ALL_FUNCTIONS_READ') or p.code = concat('READ_', r.report_name))) " + * ; + */ + } + + @Override + public ReportParameterJoinData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { + + final Long reportId = rs.getLong("reportId"); + final String reportName = rs.getString("reportName"); + final String reportType = rs.getString("reportType"); + final String reportSubType = rs.getString("reportSubType"); + final String reportCategory = rs.getString("reportCategory"); + final String description = rs.getString("description"); + final Boolean coreReport = rs.getBoolean("coreReport"); + final Boolean useReport = rs.getBoolean("useReport"); + + String reportSql; + // reportSql might not be on the select list of columns + try { + reportSql = rs.getString("reportSql"); + } catch (SQLException e) { + reportSql = null; + } + + final Long reportParameterId = JdbcSupport.getLong(rs, "reportParameterId"); + final String reportParameterName = rs.getString("reportParameterName"); + final String parameterName = rs.getString("parameterName"); + + return new ReportParameterJoinData(reportId, reportName, reportType, reportSubType, reportCategory, description, reportSql, + coreReport, useReport, reportParameterId, reportParameterName, parameterName); + } + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeLookup.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeLookup.java deleted file mode 100644 index 8ff0cf2e3..000000000 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/data/OfficeLookup.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.mifosplatform.organisation.office.data; - -/** - * Immutable data object used for office lookups (will remove eventually and just use {@link OfficeData}. - */ -@Deprecated -public class OfficeLookup { - - private final Long id; - @SuppressWarnings("unused") - private final String name; - @SuppressWarnings("unused") - private final String nameDecorated; - - public OfficeLookup(final Long id, final String name, final String nameDecorated) { - this.id = id; - this.name = name; - this.nameDecorated = nameDecorated; - } - - public boolean hasIdentifyOf(final Long officeId) { - return this.id.equals(officeId); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java index e6b83dd8c..faa891020 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformService.java @@ -8,7 +8,6 @@ package org.mifosplatform.organisation.office.service; import java.util.Collection; import org.mifosplatform.organisation.office.data.OfficeData; -import org.mifosplatform.organisation.office.data.OfficeLookup; import org.mifosplatform.organisation.office.data.OfficeTransactionData; public interface OfficeReadPlatformService { @@ -17,13 +16,6 @@ public interface OfficeReadPlatformService { Collection retrieveAllOfficesForDropdown(); - /* - * Deprecated so cane eventually remove need for OfficeLookup type - so use - * retrieveAllOfficesForDropdown instead. - */ - @Deprecated - Collection retrieveAllOfficesForLookup(); - OfficeData retrieveOffice(Long officeId); OfficeData retrieveNewOfficeTemplate(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java index ac7473801..5a0162570 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/service/OfficeReadPlatformServiceImpl.java @@ -18,7 +18,6 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService; import org.mifosplatform.organisation.office.data.OfficeData; -import org.mifosplatform.organisation.office.data.OfficeLookup; import org.mifosplatform.organisation.office.data.OfficeTransactionData; import org.mifosplatform.organisation.office.exception.OfficeNotFoundException; import org.mifosplatform.useradministration.domain.AppUser; @@ -86,23 +85,6 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } } - private static final class OfficeLookupMapper implements RowMapper { - - public String officeLookupSchema() { - return " o.id as id, " + nameDecoratedBaseOnHierarchy + " as nameDecorated, o.name as name from m_office o "; - } - - @Override - public OfficeLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { - - Long id = rs.getLong("id"); - String name = rs.getString("name"); - String nameDecorated = rs.getString("nameDecorated"); - - return new OfficeLookup(id, name, nameDecorated); - } - } - private static final class OfficeTransactionMapper implements RowMapper { public String schema() { @@ -137,8 +119,8 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService BigDecimal transactionAmount = rs.getBigDecimal("transactionAmount"); String description = rs.getString("description"); - return OfficeTransactionData.instance(id, transactionDate, fromOfficeId, fromOfficeName, toOfficeId, toOfficeName, currencyData, - transactionAmount, description); + return OfficeTransactionData.instance(id, transactionDate, fromOfficeId, fromOfficeName, toOfficeId, toOfficeName, + currencyData, transactionAmount, description); } } @@ -169,19 +151,6 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService return this.jdbcTemplate.query(sql, rm, new Object[] { hierarchySearchString }); } - @Override - public Collection retrieveAllOfficesForLookup() { - AppUser currentUser = context.authenticatedUser(); - - String hierarchy = currentUser.getOffice().getHierarchy(); - String hierarchySearchString = hierarchy + "%"; - - OfficeLookupMapper rm = new OfficeLookupMapper(); - String sql = "select " + rm.officeLookupSchema() + "where o.hierarchy like ? order by o.hierarchy"; - - return this.jdbcTemplate.query(sql, rm, new Object[] { hierarchySearchString }); - } - @Override public OfficeData retrieveOffice(final Long officeId) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/BulkTransferLoanOfficerData.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/BulkTransferLoanOfficerData.java index 22c971a25..c3d1cffed 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/BulkTransferLoanOfficerData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/BulkTransferLoanOfficerData.java @@ -5,11 +5,11 @@ */ package org.mifosplatform.organisation.staff.data; -import org.joda.time.LocalDate; -import org.mifosplatform.organisation.office.data.OfficeLookup; - import java.util.Collection; +import org.joda.time.LocalDate; +import org.mifosplatform.organisation.office.data.OfficeData; + /** * Immutable data object returned for loan-officer bulk transfer screens. */ @@ -24,14 +24,14 @@ public class BulkTransferLoanOfficerData { // template @SuppressWarnings("unused") - private final Collection officeOptions; + private final Collection officeOptions; @SuppressWarnings("unused") private final Collection loanOfficerOptions; @SuppressWarnings("unused") private final StaffAccountSummaryCollectionData accountSummaryCollection; public static BulkTransferLoanOfficerData templateForBulk(final Long officeId, final Long fromLoanOfficerId, - final LocalDate assignmentDate, final Collection officeOptions, final Collection loanOfficerOptions, + final LocalDate assignmentDate, final Collection officeOptions, final Collection loanOfficerOptions, final StaffAccountSummaryCollectionData accountSummaryCollection) { return new BulkTransferLoanOfficerData(officeId, fromLoanOfficerId, assignmentDate, officeOptions, loanOfficerOptions, accountSummaryCollection); @@ -43,7 +43,7 @@ public class BulkTransferLoanOfficerData { } private BulkTransferLoanOfficerData(final Long officeId, final Long fromLoanOfficerId, final LocalDate assignmentDate, - final Collection officeOptions, final Collection loanOfficerOptions, + final Collection officeOptions, final Collection loanOfficerOptions, final StaffAccountSummaryCollectionData accountSummaryCollection) { this.officeId = officeId; this.fromLoanOfficerId = fromLoanOfficerId; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/BulkLoansApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/BulkLoansApiResource.java index 5d5c5a216..7e9b2db4b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/BulkLoansApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/BulkLoansApiResource.java @@ -29,7 +29,7 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; -import org.mifosplatform.organisation.office.data.OfficeLookup; +import org.mifosplatform.organisation.office.data.OfficeData; import org.mifosplatform.organisation.office.service.OfficeReadPlatformService; import org.mifosplatform.organisation.staff.data.BulkTransferLoanOfficerData; import org.mifosplatform.organisation.staff.data.StaffAccountSummaryCollectionData; @@ -82,7 +82,7 @@ public class BulkLoansApiResource { context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions); - final Collection offices = this.officeReadPlatformService.retrieveAllOfficesForLookup(); + final Collection offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown(); Collection loanOfficers = null; StaffAccountSummaryCollectionData staffAccountSummaryCollectionData = null;