remove usage lookup data objects, formating of report java code, update api docs for center, groups.

This commit is contained in:
Keith Woodlock
2013-04-19 13:27:27 +01:00
parent 604f07f13e
commit dff53b9318
29 changed files with 986 additions and 1178 deletions
+91 -3
View File
@@ -299,6 +299,14 @@
<td><a href="#centers_delete">Delete a Center</a></td>
</tr>
<tr class="alt">
<td></td>
<td>centers/{centerId}?command=activate</td>
<td><a href="#centers_activate">Activate a Center</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><a href="#groups">Group</a></td>
<td>groups</td>
<td><a href="#groups_create">Create a Group</a></td>
@@ -306,7 +314,7 @@
<td></td>
<td></td>
</tr>
<tr>
<tr class="alt">
<td></td>
<td>groups/{group}</td>
<td></td>
@@ -314,6 +322,14 @@
<td><a href="#groups_update">Update a Group</a></td>
<td><a href="#groups_delete">Delete a Group</a></td>
</tr>
<tr>
<td></td>
<td>groups/{groupId}?command=activate</td>
<td><a href="#groups_activate">Activate a Group</a></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
</div>
@@ -1901,7 +1917,7 @@ Request Body:
<div class="method-section">
<div class="method-description">
<h2>Activate a Client</h2>
<p>Clients can be created in a <i>Pending</i> state if configuration is enabled. This API exists to enable client activation (for when a client becomes approved member of microfinance institue.</p>
<p>Clients can be created in a <i>Pending</i> state. This API exists to enable client activation (for when a client becomes approved member of microfinance institue).</p>
<p>If the client happens to be alrady active this API will result in an error.</p>
</div>
<div class="method-example">
@@ -2926,6 +2942,34 @@ Content-Type: application/json Request Body:
</div>
</div>
<a id="centers_activate" name="centers_activate" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h2>Activate a Center</h2>
<p>Centers can be created in a <i>Pending</i> state. This API exists to enable center activation.</p>
<p>If the center happens to be already active this API will result in an error.</p>
</div>
<div class="method-example">
<code class="method-declaration">POST https://Domain Name/api/v1/centers/{centerId}?command=activate</code>
<code class="method-request">POST centers/1?command=activate
Content-Type: application/json
Request Body:
{
"locale": "en",
"dateFormat": "dd MMMM yyyy",
"activationDate": "01 March 2011"
}
</code>
<code class="method-response">
{
"officeId": 1,
"groupId": 1,
"resourceId": 1
}
</code>
</div>
</div>
<a id="centers_update" name="centers_update" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
@@ -3322,6 +3366,34 @@ Content-Type: application/json Request Body:
</div>
</div>
<a id="groups_activate" name="groups_activate" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h2>Activate a Group</h2>
<p>Groups can be created in a <i>Pending</i> state. This API exists to enable group activation.</p>
<p>If the group happens to be already active this API will result in an error.</p>
</div>
<div class="method-example">
<code class="method-declaration">POST https://Domain Name/api/v1/groups/{groupId}?command=activate</code>
<code class="method-request">POST groups/1?command=activate
Content-Type: application/json
Request Body:
{
"locale": "en",
"dateFormat": "dd MMMM yyyy",
"activationDate": "01 March 2011"
}
</code>
<code class="method-response">
{
"officeId": 1,
"groupId": 1,
"resourceId": 1
}
</code>
</div>
</div>
<a id="groups_retrieve" name="groups_retrieve" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
@@ -13163,6 +13235,14 @@ GET https://DomainName/api/v1/search?query=000000111
<td><a href="#centers_delete">Delete a Center</a></td>
</tr>
<tr class="alt">
<td></td>
<td>centers/{centerId}?command=activate</td>
<td><a href="#centers_activate">Activate a Center</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><a href="#groups">Group</a></td>
<td>groups</td>
<td><a href="#groups_create">Create a Group</a></td>
@@ -13170,7 +13250,7 @@ GET https://DomainName/api/v1/search?query=000000111
<td></td>
<td></td>
</tr>
<tr>
<tr class="alt">
<td></td>
<td>groups/{group}</td>
<td></td>
@@ -13178,6 +13258,14 @@ GET https://DomainName/api/v1/search?query=000000111
<td><a href="#groups_update">Update a Group</a></td>
<td><a href="#groups_delete">Delete a Group</a></td>
</tr>
<tr>
<td></td>
<td>groups/{groupId}?command=activate</td>
<td><a href="#groups_activate">Activate a Group</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<!-- end of centers, groups api -->
<!-- loans api full matrix-->
<tr class="alt">
@@ -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<OfficeLookup>(this.officeReadPlatformService.retrieveAllOfficesForLookup()));
glClosureData.setAllowedOffices(this.officeReadPlatformService.retrieveAllOfficesForDropdown());
}
return this.apiJsonSerializerService.serialize(settings, glClosureData, RESPONSE_DATA_PARAMETERS);
@@ -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<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>();
private Collection<OfficeData> allowedOffices = new ArrayList<OfficeData>();
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<OfficeLookup> getAllowedOffices() {
public final Collection<OfficeData> getAllowedOffices() {
return this.allowedOffices;
}
public void setAllowedOffices(final List<OfficeLookup> allowedOffices) {
public void setAllowedOffices(final Collection<OfficeData> allowedOffices) {
this.allowedOffices = allowedOffices;
}
@@ -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;
}
}
@@ -7,7 +7,6 @@ package org.mifosplatform.infrastructure.dataqueries.data;
import java.util.List;
/**
* Immutable data object for generic resultset data.
*/
@@ -37,12 +37,9 @@ final public class ReportData {
@SuppressWarnings("unused")
private List<String> 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<ReportParameterData> reportParameters) {
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<ReportParameterData> reportParameters) {
this.id = id;
this.reportName = reportName;
this.reportType = reportType;
@@ -14,11 +14,9 @@ final public class ReportParameterData {
@SuppressWarnings("unused")
private final String parameterName;
public ReportParameterData(final Long id,
final String reportParameterName, final String parameterName) {
public ReportParameterData(final Long id, final String reportParameterName, final String parameterName) {
this.id = id;
this.reportParameterName = reportParameterName;
this.parameterName = parameterName;
}
}
@@ -21,12 +21,9 @@ final public class ReportParameterJoinData {
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) {
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;
@@ -88,5 +85,4 @@ final public class ReportParameterJoinData {
public String getDescription() {
return description;
}
}
@@ -63,33 +63,23 @@ public class Report extends AbstractPersistable<Long> {
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() {
//
}
public Report(final String reportName, final String reportType,
final String reportSubType, final String reportCategory,
final String description, final boolean useReport,
final String reportSql) {
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;
@@ -103,57 +93,47 @@ public class Report extends AbstractPersistable<Long> {
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(
8);
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(8);
String paramName = "reportName";
if (command.isChangeInStringParameterNamed(paramName, this.reportName)) {
final String newValue = command
.stringValueOfParameterNamed(paramName);
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);
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);
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);
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);
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);
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);
final String newValue = command.stringValueOfParameterNamed(paramName);
actualChanges.put(paramName, newValue);
this.reportSql = StringUtils.defaultIfEmpty(newValue, null);
}
@@ -163,12 +143,9 @@ public class Report extends AbstractPersistable<Long> {
if (!actualChanges.isEmpty()) {
if (isCoreReport()) {
for (final String key : actualChanges.keySet()) {
if (!(key.equals("useReport"))) {
throw new PlatformDataIntegrityException(
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);
}
"Only the Use Report field can be updated for Core Reports", key); }
}
}
}
@@ -183,73 +160,43 @@ public class Report extends AbstractPersistable<Long> {
private void validate() {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(
dataValidationErrors).resource("report");
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)
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("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);
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);
baseDataValidator.reset().parameter("reportSql").value(this.reportSql)
.mustBeBlankWhenParameterProvidedIs("reportType", this.reportType);
}
}
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
private void throwExceptionIfValidationWarningsExist(
final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) {
throw new PlatformApiDataValidationException(
"validation.msg.validation.errors.exist",
"Validation errors exist.", dataValidationErrors);
}
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
"Validation errors exist.", dataValidationErrors); }
}
public String getReportName() {
@@ -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 {
@@ -12,5 +12,4 @@ public class DatatableSystemErrorException extends AbstractPlatformDomainRuleExc
public DatatableSystemErrorException(final String msg) {
super("error.msg.datatable.system.error", msg, msg);
}
}
@@ -28,7 +28,8 @@ 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()) //
@@ -19,8 +19,7 @@ public class CreateReportCommandHandler implements NewCommandSourceHandler {
private final ReportWritePlatformService writePlatformService;
@Autowired
public CreateReportCommandHandler(
final ReportWritePlatformService writePlatformService) {
public CreateReportCommandHandler(final ReportWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@@ -28,7 +28,8 @@ 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()) //
@@ -28,7 +28,8 @@ 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()) //
@@ -20,8 +20,7 @@ public class DeleteReportCommandHandler implements NewCommandSourceHandler {
private final ReportWritePlatformService writePlatformService;
@Autowired
public DeleteReportCommandHandler(
final ReportWritePlatformService writePlatformService) {
public DeleteReportCommandHandler(final ReportWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@@ -28,8 +28,8 @@ 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()) //
@@ -28,8 +28,8 @@ 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()) //
@@ -19,8 +19,7 @@ public class UpdateReportCommandHandler implements NewCommandSourceHandler {
private final ReportWritePlatformService writePlatformService;
@Autowired
public UpdateReportCommandHandler(
final ReportWritePlatformService writePlatformService) {
public UpdateReportCommandHandler(final ReportWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@@ -28,7 +27,6 @@ public class UpdateReportCommandHandler implements NewCommandSourceHandler {
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.updateReport(command.entityId(),
command);
return this.writePlatformService.updateReport(command.entityId(), command);
}
}
@@ -25,27 +25,21 @@ public final class ReportCommandFromApiJsonDeserializer {
/**
* The parameters supported for this command.
*/
private final Set<String> supportedParameters = new HashSet<String>(
Arrays.asList("reportName", "reportType", "reportSubType",
private final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("reportName", "reportType", "reportSubType",
"reportCategory", "description", "reportSql", "useReport"));
private final FromJsonHelper fromApiJsonHelper;
@Autowired
public ReportCommandFromApiJsonDeserializer(
final FromJsonHelper fromApiJsonHelper) {
public ReportCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper) {
this.fromApiJsonHelper = fromApiJsonHelper;
}
public void validate(final String json) {
if (StringUtils.isBlank(json)) {
throw new InvalidJsonException();
}
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {
}.getType();
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json,
supportedParameters);
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
}
}
@@ -16,17 +16,13 @@ import org.mifosplatform.infrastructure.dataqueries.data.ReportData;
public interface ReadReportingService {
StreamingOutput retrieveReportCSV(String name, String type,
Map<String, String> extractedQueryParams);
StreamingOutput retrieveReportCSV(String name, String type, Map<String, String> extractedQueryParams);
GenericResultsetData retrieveGenericResultset(String name, String type,
Map<String, String> extractedQueryParams);
GenericResultsetData retrieveGenericResultset(String name, String type, Map<String, String> extractedQueryParams);
Response processPentahoRequest(String reportName, String outputType,
Map<String, String> queryParams);
Response processPentahoRequest(String reportName, String outputType, Map<String, String> queryParams);
String retrieveReportPDF(String name, String type,
Map<String, String> extractedQueryParams);
String retrieveReportPDF(String name, String type, Map<String, String> extractedQueryParams);
String getReportType(String reportName);
@@ -68,8 +68,7 @@ import com.lowagie.text.pdf.PdfWriter;
@Service
public class ReadReportingServiceImpl implements ReadReportingService {
private final static Logger logger = LoggerFactory
.getLogger(ReadReportingServiceImpl.class);
private final static Logger logger = LoggerFactory.getLogger(ReadReportingServiceImpl.class);
private final JdbcTemplate jdbcTemplate;
private final DataSource dataSource;
@@ -78,8 +77,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
private boolean noPentaho = false;
@Autowired
public ReadReportingServiceImpl(final PlatformSecurityContext context,
final TenantAwareRoutingDataSource dataSource,
public ReadReportingServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
final GenericDataService genericDataService) {
// kick off pentaho reports server
ClassicEngineBoot.getInstance().start();
@@ -92,8 +90,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
}
@Override
public StreamingOutput retrieveReportCSV(final String name,
final String type, final Map<String, String> queryParams) {
public StreamingOutput retrieveReportCSV(final String name, final String type, final Map<String, String> queryParams) {
return new StreamingOutput() {
@@ -101,12 +98,10 @@ public class ReadReportingServiceImpl implements ReadReportingService {
public void write(final OutputStream out) {
try {
GenericResultsetData result = retrieveGenericResultset(
name, type, queryParams);
GenericResultsetData result = retrieveGenericResultset(name, type, queryParams);
StringBuffer sb = generateCsvFileBuffer(result);
InputStream in = new ByteArrayInputStream(sb.toString()
.getBytes("UTF-8"));
InputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
byte[] outputByte = new byte[4096];
Integer readLen = in.read(outputByte, 0, 4096);
@@ -119,8 +114,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
// out.flush();
// out.close();
} catch (Exception e) {
throw new PlatformDataIntegrityException(
"error.msg.exception.error", e.getMessage());
throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage());
}
}
};
@@ -130,14 +124,12 @@ public class ReadReportingServiceImpl implements ReadReportingService {
private StringBuffer generateCsvFileBuffer(final GenericResultsetData result) {
StringBuffer writer = new StringBuffer();
List<ResultsetColumnHeaderData> columnHeaders = result
.getColumnHeaders();
List<ResultsetColumnHeaderData> 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(",");
if (i < (chSize - 1)) writer.append(",");
}
writer.append('\n');
@@ -158,19 +150,14 @@ public class ReadReportingServiceImpl implements ReadReportingService {
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"))
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) + '"');
writer.append('"' + genericDataService.replace(currVal, doubleQuote, twoDoubleQuotes) + '"');
}
if (j < (rSize - 1))
writer.append(",");
if (j < (rSize - 1)) writer.append(",");
}
writer.append('\n');
}
@@ -179,25 +166,21 @@ public class ReadReportingServiceImpl implements ReadReportingService {
}
@Override
public GenericResultsetData retrieveGenericResultset(final String name,
final String type, final Map<String, String> queryParams) {
public GenericResultsetData retrieveGenericResultset(final String name, final String type, final Map<String, String> queryParams) {
long startTime = System.currentTimeMillis();
logger.info("STARTING REPORT: " + name + " Type: " + type);
String sql = getSQLtoRun(name, type, queryParams);
GenericResultsetData result = genericDataService
.fillGenericResultSet(sql);
GenericResultsetData result = genericDataService.fillGenericResultSet(sql);
long elapsed = System.currentTimeMillis() - startTime;
logger.info("FINISHING Report/Request Name: " + name + " - " + type
+ " Elapsed Time: " + elapsed);
logger.info("FINISHING Report/Request Name: " + name + " - " + type + " Elapsed Time: " + elapsed);
return result;
}
private String getSQLtoRun(final String name, final String type,
final Map<String, String> queryParams) {
private String getSQLtoRun(final String name, final String type, final Map<String, String> queryParams) {
String sql = getSql(name, type);
@@ -210,13 +193,11 @@ public class ReadReportingServiceImpl implements ReadReportingService {
AppUser currentUser = context.authenticatedUser();
// Allows sql query to restrict data by office hierarchy if required
sql = genericDataService.replace(sql, "${currentUserHierarchy}",
currentUser.getOffice().getHierarchy());
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.replace(sql, "${currentUserId}", currentUser.getId().toString());
sql = genericDataService.wrapSQL(sql);
@@ -226,58 +207,42 @@ public class ReadReportingServiceImpl implements ReadReportingService {
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 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");
}
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 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");
}
if (rs.next()) { return rs.getString("report_type"); }
throw new ReportNotFoundException(sql);
}
@Override
public Response processPentahoRequest(final String reportName,
final String outputTypeParam, final Map<String, String> queryParams) {
public Response processPentahoRequest(final String reportName, final String outputTypeParam, final Map<String, String> queryParams) {
String outputType = "HTML";
if (StringUtils.isNotBlank(outputTypeParam))
outputType = outputTypeParam;
if (StringUtils.isNotBlank(outputTypeParam)) outputType = outputTypeParam;
if (!(outputType.equalsIgnoreCase("HTML")
|| outputType.equalsIgnoreCase("PDF")
|| outputType.equalsIgnoreCase("XLS") || outputType
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);
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");
}
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";
final String reportPath = FileUtils.MIFOSX_BASE_DIR + File.separator + "pentahoReports" + File.separator + reportName + ".prpt";
logger.info("Report path: " + reportPath);
// load report definition
@@ -295,65 +260,44 @@ public class ReadReportingServiceImpl implements ReadReportingService {
if ("PDF".equalsIgnoreCase(outputType)) {
PdfReportUtil.createPDF(masterReport, baos);
return Response.ok().entity(baos.toByteArray())
.type("application/pdf").build();
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();
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();
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();
return Response.ok().entity(baos.toByteArray()).type("text/html").build();
}
} catch (ResourceException e) {
throw new PlatformDataIntegrityException(
"error.msg.reporting.error", e.getMessage());
throw new PlatformDataIntegrityException("error.msg.reporting.error", e.getMessage());
} catch (ReportProcessingException e) {
throw new PlatformDataIntegrityException(
"error.msg.reporting.error", e.getMessage());
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.reporting.error", e.getMessage());
}
throw new PlatformDataIntegrityException(
"error.msg.invalid.outputType", "No matching Output Type: "
+ outputType);
throw new PlatformDataIntegrityException("error.msg.invalid.outputType", "No matching Output Type: " + outputType);
}
private void addParametersToReport(final MasterReport report,
final Map<String, String> queryParams) {
private void addParametersToReport(final MasterReport report, final Map<String, String> queryParams) {
AppUser currentUser = context.authenticatedUser();
try {
ReportParameterValues rptParamValues = report.getParameterValues();
ReportParameterDefinition paramsDefinition = report
.getParameterDefinition();
ReportParameterDefinition paramsDefinition = report.getParameterDefinition();
/*
* only allow integer, long, date and string parameter types and
@@ -362,30 +306,22 @@ public class ReadReportingServiceImpl implements ReadReportingService {
* better... currently assuming they come in ok... and if not an
* error
*/
for (ParameterDefinitionEntry paramDefEntry : paramsDefinition
.getParameterDefinitions()) {
for (ParameterDefinitionEntry paramDefEntry : paramsDefinition.getParameterDefinitions()) {
String paramName = paramDefEntry.getName();
if (!((paramName.equals("tenantdb")) || (paramName
.equals("userhierarchy")))) {
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
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"))
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"))
else if (clazz.getCanonicalName().equalsIgnoreCase("java.lang.Long"))
rptParamValues.put(paramName, Long.parseLong(pValue));
else if (clazz.getCanonicalName().equalsIgnoreCase(
"java.sql.Date"))
else if (clazz.getCanonicalName().equalsIgnoreCase("java.sql.Date"))
rptParamValues.put(paramName, Date.valueOf(pValue));
else
rptParamValues.put(paramName, pValue);
@@ -399,35 +335,29 @@ public class ReadReportingServiceImpl implements ReadReportingService {
// data scoping
String tenantdb = dataSource.getConnection().getCatalog();
String userhierarchy = currentUser.getOffice().getHierarchy();
logger.info("db name:" + tenantdb + " userhierarchy:"
+ userhierarchy);
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());
throw new PlatformDataIntegrityException("error.msg.reporting.error", e.getMessage());
}
}
@Override
public String retrieveReportPDF(final String reportName, final String type,
final Map<String, String> queryParams) {
public String retrieveReportPDF(final String reportName, final String type, final Map<String, String> 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";
String genaratePdf = fileLocation + File.separator + reportName + ".pdf";
try {
GenericResultsetData result = retrieveGenericResultset(reportName,
type, queryParams);
GenericResultsetData result = retrieveGenericResultset(reportName, type, queryParams);
List<ResultsetColumnHeaderData> columnHeaders = result
.getColumnHeaders();
List<ResultsetColumnHeaderData> columnHeaders = result.getColumnHeaders();
List<ResultsetRowData> data = result.getData();
List<String> row;
@@ -436,8 +366,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
Document document = new Document(PageSize.B0.rotate());
PdfWriter.getInstance(document, new FileOutputStream(new File(
fileLocation + reportName + ".pdf")));
PdfWriter.getInstance(document, new FileOutputStream(new File(fileLocation + reportName + ".pdf")));
document.open();
PdfPTable table = new PdfPTable(chSize);
@@ -461,11 +390,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
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")) {
if (currColType.equals("DECIMAL") || currColType.equals("DOUBLE") || currColType.equals("BIGINT")
|| currColType.equals("SMALLINT") || currColType.equals("INT")) {
table.addCell(currVal.toString());
} else {
@@ -480,13 +406,12 @@ public class ReadReportingServiceImpl implements ReadReportingService {
return genaratePdf;
} catch (Exception e) {
logger.error("error.msg.reporting.error:" + e.getMessage());
throw new PlatformDataIntegrityException(
"error.msg.exception.error", e.getMessage());
throw new PlatformDataIntegrityException("error.msg.exception.error", e.getMessage());
}
}
@Override
public ReportData retrieveReport(Long id) {
public ReportData retrieveReport(final Long id) {
Collection<ReportData> reports = retrieveReports(id);
for (ReportData report : reports) {
@@ -506,12 +431,10 @@ public class ReadReportingServiceImpl implements ReadReportingService {
String sql = rm.schema(id);
Collection<ReportParameterJoinData> rpJoins = this.jdbcTemplate.query(
sql, rm, new Object[] {});
Collection<ReportParameterJoinData> rpJoins = this.jdbcTemplate.query(sql, rm, new Object[] {});
Collection<ReportData> reportList = new ArrayList<ReportData>();
if (rpJoins == null || rpJoins.size() == 0)
return reportList;
if (rpJoins == null || rpJoins.size() == 0) return reportList;
Collection<ReportParameterData> reportParameters = null;
@@ -531,19 +454,19 @@ public class ReadReportingServiceImpl implements ReadReportingService {
if (rpJoin.getReportId().equals(prevReportId)) {
// more than one parameter for report
reportParameters.add(new ReportParameterData(rpJoin
.getReportParameterId(), rpJoin
.getReportParameterName(), rpJoin.getParameterName()));
if (reportParameters == null) {
reportParameters = new ArrayList<ReportParameterData>();
}
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));
reportList.add(new ReportData(reportId, reportName, reportType, reportSubType, reportCategory, description, reportSql,
coreReport, useReport, reportParameters));
}
prevReportId = rpJoin.getReportId();
@@ -561,9 +484,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
if (rpJoin.getReportParameterId() != null) {
// report has at least one parameter
reportParameters = new ArrayList<ReportParameterData>();
reportParameters.add(new ReportParameterData(rpJoin
.getReportParameterId(), rpJoin
.getReportParameterName(), rpJoin
reportParameters.add(new ReportParameterData(rpJoin.getReportParameterId(), rpJoin.getReportParameterName(), rpJoin
.getParameterName()));
} else {
reportParameters = null;
@@ -572,27 +493,23 @@ public class ReadReportingServiceImpl implements ReadReportingService {
}
// write last report
reportList.add(new ReportData(reportId, reportName, reportType,
reportSubType, reportCategory, description, reportSql,
coreReport, useReport, reportParameters));
reportList.add(new ReportData(reportId, reportName, reportType, reportSubType, reportCategory, description, reportSql, coreReport,
useReport, reportParameters));
return reportList;
}
private static final class ReportParameterJoinMapper implements
RowMapper<ReportParameterJoinData> {
private static final class ReportParameterJoinMapper implements RowMapper<ReportParameterJoinData> {
public String schema(Long reportId) {
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 ";
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"
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;
@@ -601,24 +518,22 @@ public class ReadReportingServiceImpl implements ReadReportingService {
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))) ";
/*
* 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 {
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");
@@ -637,18 +552,12 @@ public class ReadReportingServiceImpl implements ReadReportingService {
reportSql = null;
}
final Long reportParameterId = JdbcSupport.getLong(rs,
"reportParameterId");
final String reportParameterName = rs
.getString("reportParameterName");
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);
return new ReportParameterJoinData(reportId, reportName, reportType, reportSubType, reportCategory, description, reportSql,
coreReport, useReport, reportParameterId, reportParameterName, parameterName);
}
}
}
@@ -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);
}
}
@@ -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<OfficeData> retrieveAllOfficesForDropdown();
/*
* Deprecated so cane eventually remove need for OfficeLookup type - so use
* retrieveAllOfficesForDropdown instead.
*/
@Deprecated
Collection<OfficeLookup> retrieveAllOfficesForLookup();
OfficeData retrieveOffice(Long officeId);
OfficeData retrieveNewOfficeTemplate();
@@ -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<OfficeLookup> {
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<OfficeTransactionData> {
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<OfficeLookup> 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) {
@@ -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<OfficeLookup> officeOptions;
private final Collection<OfficeData> officeOptions;
@SuppressWarnings("unused")
private final Collection<StaffData> loanOfficerOptions;
@SuppressWarnings("unused")
private final StaffAccountSummaryCollectionData accountSummaryCollection;
public static BulkTransferLoanOfficerData templateForBulk(final Long officeId, final Long fromLoanOfficerId,
final LocalDate assignmentDate, final Collection<OfficeLookup> officeOptions, final Collection<StaffData> loanOfficerOptions,
final LocalDate assignmentDate, final Collection<OfficeData> officeOptions, final Collection<StaffData> 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<OfficeLookup> officeOptions, final Collection<StaffData> loanOfficerOptions,
final Collection<OfficeData> officeOptions, final Collection<StaffData> loanOfficerOptions,
final StaffAccountSummaryCollectionData accountSummaryCollection) {
this.officeId = officeId;
this.fromLoanOfficerId = fromLoanOfficerId;
@@ -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<OfficeLookup> offices = this.officeReadPlatformService.retrieveAllOfficesForLookup();
final Collection<OfficeData> offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown();
Collection<StaffData> loanOfficers = null;
StaffAccountSummaryCollectionData staffAccountSummaryCollectionData = null;