From 986a3c5f91f4e8ae9e40ef53a8a2a22d0e44d9eb Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Wed, 9 Jan 2013 00:09:45 +0000 Subject: [PATCH] MIFOSX-97: update urls for getting data when viewing changes against existing data for maker-checker. --- .../service/CommandWrapperBuilder.java | 214 +++++++++++++----- .../codes/api/CodesApiResource.java | 15 +- .../dataqueries/api/DataTableApiResource.java | 12 +- .../monetary/api/CurrenciesApiResource.java | 5 +- .../api/OfficeTransactionsApiResource.java | 4 +- .../office/api/OfficesApiResource.java | 5 +- .../staff/api/StaffApiResource.java | 10 +- .../charge/api/ChargesApiResource.java | 9 +- .../api/ClientIdentifiersApiResource.java | 11 +- .../client/api/ClientNotesApiResource.java | 7 +- .../portfolio/fund/api/FundsApiResource.java | 6 +- .../loanaccount/api/BulkLoansApiResource.java | 3 +- .../api/LoanChargesApiResource.java | 13 +- .../api/LoanTransactionsApiResource.java | 18 +- .../loanaccount/api/LoansApiResource.java | 35 ++- .../api/LoanProductsApiResource.java | 11 +- .../api/PermissionsApiResource.java | 6 +- .../api/UsersApiResource.java | 15 +- 18 files changed, 246 insertions(+), 153 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java index 1b2d6a629..45f9d76dd 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java @@ -17,14 +17,14 @@ public class CommandWrapperBuilder { private Long datatableId; public CommandWrapper build() { - return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.actionName, this.entityName, this.entityId, this.apptableId, this.datatableId, - this.href, this.json); + return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.actionName, this.entityName, this.entityId, + this.apptableId, this.datatableId, this.href, this.json); } - public CommandWrapperBuilder withEntityId(final Long withId) { - this.entityId = withId; - return this; - } + // public CommandWrapperBuilder withEntityId(final Long withId) { + // this.entityId = withId; + // return this; + // } public CommandWrapperBuilder withLoanId(final Long withLoanId) { this.loanId = withLoanId; @@ -40,15 +40,20 @@ public class CommandWrapperBuilder { this.json = withJson; return this; } - - public CommandWrapperBuilder withUrl(final String withUrl) { - this.href = withUrl; + + public CommandWrapperBuilder updateGlobalConfiguration() { + this.actionName = "UPDATE"; + this.entityName = "CONFIGURATION"; + this.entityId = null; + this.href = "/configurations"; return this; } public CommandWrapperBuilder updatePermissions() { this.actionName = "UPDATE"; this.entityName = "PERMISSION"; + this.entityId = null; + this.href = "/permissions"; return this; } @@ -78,144 +83,194 @@ public class CommandWrapperBuilder { public CommandWrapperBuilder createUser() { this.actionName = "CREATE"; this.entityName = "USER"; + this.entityId = null; + this.href = "/users/template"; return this; } - public CommandWrapperBuilder updateUser() { + public CommandWrapperBuilder updateUser(final Long userId) { this.actionName = "UPDATE"; this.entityName = "USER"; + this.entityId = userId; + this.href = "/users/" + userId; return this; } - public CommandWrapperBuilder deleteUser() { + public CommandWrapperBuilder deleteUser(final Long userId) { this.actionName = "DELETE"; this.entityName = "USER"; + this.entityId = userId; + this.href = "/users/" + userId; return this; } public CommandWrapperBuilder createOffice() { this.actionName = "CREATE"; this.entityName = "OFFICE"; + this.entityId = null; + this.href = "/offices/template"; return this; } - public CommandWrapperBuilder updateOffice() { + public CommandWrapperBuilder updateOffice(final Long officeId) { this.actionName = "UPDATE"; this.entityName = "OFFICE"; + this.entityId = officeId; + this.href = "/offices/" + officeId; return this; } public CommandWrapperBuilder createOfficeTransaction() { this.actionName = "CREATE"; this.entityName = "OFFICETRANSACTION"; + this.href = "/officetransactions/template"; return this; } public CommandWrapperBuilder createStaff() { this.actionName = "CREATE"; this.entityName = "STAFF"; + this.entityId = null; + this.href = "/staff/template"; return this; } - public CommandWrapperBuilder updateStaff() { + public CommandWrapperBuilder updateStaff(final Long staffId) { this.actionName = "UPDATE"; this.entityName = "STAFF"; + this.entityId = staffId; + this.href = "/staff/" + staffId; return this; } public CommandWrapperBuilder createFund() { this.actionName = "CREATE"; this.entityName = "FUND"; + this.entityId = null; + this.href = "/funds/template"; return this; } - public CommandWrapperBuilder updateFund() { + public CommandWrapperBuilder updateFund(final Long fundId) { this.actionName = "UPDATE"; this.entityName = "FUND"; + this.entityId = fundId; + this.href = "/funds/" + fundId; return this; } public CommandWrapperBuilder updateCurrencies() { this.actionName = "UPDATE"; this.entityName = "CURRENCY"; + this.href = "/currencies"; return this; } public CommandWrapperBuilder createCode() { this.actionName = "CREATE"; this.entityName = "CODE"; + this.entityId = null; + this.href = "/codes/template"; return this; } - public CommandWrapperBuilder updateCode() { + public CommandWrapperBuilder updateCode(final Long codeId) { this.actionName = "UPDATE"; this.entityName = "CODE"; + this.entityId = codeId; + this.href = "/codes/" + codeId; return this; } - public CommandWrapperBuilder deleteCode() { + public CommandWrapperBuilder deleteCode(final Long codeId) { this.actionName = "DELETE"; this.entityName = "CODE"; + this.entityId = codeId; + this.href = "/codes/" + codeId; return this; } public CommandWrapperBuilder createCharge() { this.actionName = "CREATE"; this.entityName = "CHARGE"; + this.entityId = null; + this.href = "/charges/template"; return this; } - public CommandWrapperBuilder updateCharge() { + public CommandWrapperBuilder updateCharge(final Long chargeId) { this.actionName = "UPDATE"; this.entityName = "CHARGE"; + this.entityId = chargeId; + this.href = "/charges/" + chargeId; return this; } - public CommandWrapperBuilder deleteCharge() { + public CommandWrapperBuilder deleteCharge(final Long chargeId) { this.actionName = "DELETE"; this.entityName = "CHARGE"; + this.entityId = chargeId; + this.href = "/charges/" + chargeId; return this; } public CommandWrapperBuilder createLoanProduct() { this.actionName = "CREATE"; this.entityName = "LOANPRODUCT"; + this.entityId = null; + this.href = "/loanproducts/template"; return this; } - public CommandWrapperBuilder updateLoanProduct() { + public CommandWrapperBuilder updateLoanProduct(final Long productId) { this.actionName = "UPDATE"; this.entityName = "LOANPRODUCT"; + this.entityId = productId; + this.href = "/loanproducts/" + productId; return this; } - public CommandWrapperBuilder createClientIdentifier() { + public CommandWrapperBuilder createClientIdentifier(final Long clientId) { this.actionName = "CREATE"; this.entityName = "CLIENTIDENTIFIER"; + this.entityId = null; + this.clientId = clientId; + this.href = "/clients/" + clientId + "/identifiers/template"; return this; } - public CommandWrapperBuilder updateClientIdentifier() { + public CommandWrapperBuilder updateClientIdentifier(final Long clientId, final Long clientIdentifierId) { this.actionName = "UPDATE"; this.entityName = "CLIENTIDENTIFIER"; + this.entityId = clientIdentifierId; + this.clientId = clientId; + this.href = "/clients/" + clientId + "/identifiers/" + clientIdentifierId; return this; } - public CommandWrapperBuilder deleteClientIdentifier() { + public CommandWrapperBuilder deleteClientIdentifier(final Long clientId, final Long clientIdentifierId) { this.actionName = "DELETE"; this.entityName = "CLIENTIDENTIFIER"; + this.entityId = clientIdentifierId; + this.clientId = clientId; + this.href = "/clients/" + clientId + "/identifiers/" + clientIdentifierId; return this; } - public CommandWrapperBuilder createClientNote() { + public CommandWrapperBuilder createClientNote(final Long clientId) { this.actionName = "CREATE"; this.entityName = "CLIENTNOTE"; + this.clientId = clientId; + this.href = "/clients/" + clientId + "/notes/template"; return this; } - public CommandWrapperBuilder updateClientNote() { + public CommandWrapperBuilder updateClientNote(final Long clientId, final Long noteId) { this.actionName = "UPDATE"; this.entityName = "CLIENTNOTE"; + this.entityId = noteId; + this.clientId = clientId; + this.href = "/clients/" + clientId + "/notes"; return this; } @@ -248,6 +303,11 @@ public class CommandWrapperBuilder { this.datatableId = datatableId; this.actionName = "CREATE"; this.entityName = datatable; + if (datatableId == null) { + this.href = "/datatables/" + datatable + "/" + apptableId; + } else { + this.href = "/datatables/" + datatable + "/" + apptableId + "/" + datatableId; + } return this; } @@ -267,138 +327,190 @@ public class CommandWrapperBuilder { return this; } - public CommandWrapperBuilder createLoanCharge() { + public CommandWrapperBuilder createLoanCharge(final Long loanId) { this.actionName = "CREATE"; this.entityName = "LOANCHARGE"; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/charges"; return this; } - public CommandWrapperBuilder updateLoanCharge() { + public CommandWrapperBuilder updateLoanCharge(final Long loanId, Long loanChargeId) { this.actionName = "UPDATE"; this.entityName = "LOANCHARGE"; + this.entityId = loanChargeId; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/charges/" + loanChargeId; return this; } - public CommandWrapperBuilder waiveLoanCharge() { + public CommandWrapperBuilder waiveLoanCharge(final Long loanId, final Long loanChargeId) { this.actionName = "WAIVE"; this.entityName = "LOANCHARGE"; + this.entityId = loanChargeId; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/charges/" + loanChargeId; return this; } - public CommandWrapperBuilder deleteLoanCharge() { + public CommandWrapperBuilder deleteLoanCharge(final Long loanId, final Long loanChargeId) { this.actionName = "DELETE"; this.entityName = "LOANCHARGE"; + this.entityId = loanChargeId; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/charges/" + loanChargeId; return this; } - public CommandWrapperBuilder loanRepaymentTransaction() { + public CommandWrapperBuilder loanRepaymentTransaction(final Long loanId) { this.actionName = "REPAYMENT"; this.entityName = "LOAN"; + this.entityId = null; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/transactions/template?command=repayment"; return this; } - public CommandWrapperBuilder waiveInterestPortionTransaction() { + public CommandWrapperBuilder waiveInterestPortionTransaction(final Long loanId) { this.actionName = "WAIVEINTERESTPORTION"; this.entityName = "LOAN"; + this.entityId = null; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/transactions/template?command=waiveinterest"; return this; } - public CommandWrapperBuilder writeOffLoanTransaction() { + public CommandWrapperBuilder writeOffLoanTransaction(final Long loanId) { this.actionName = "WRITEOFF"; this.entityName = "LOAN"; + this.entityId = null; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/transactions/template?command=writeoff"; return this; } - public CommandWrapperBuilder closeLoanAsRescheduledTransaction() { + public CommandWrapperBuilder closeLoanAsRescheduledTransaction(final Long loanId) { this.actionName = "CLOSEASRESCHEDULED"; this.entityName = "LOAN"; + this.entityId = null; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/transactions/template?command=close-rescheduled"; return this; } - public CommandWrapperBuilder closeLoanTransaction() { + public CommandWrapperBuilder closeLoanTransaction(final Long loanId) { this.actionName = "CLOSE"; this.entityName = "LOAN"; + this.entityId = null; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/transactions/template?command=close"; return this; } - public CommandWrapperBuilder adjustTransaction() { + public CommandWrapperBuilder adjustTransaction(final Long loanId, final Long transactionId) { this.actionName = "ADJUST"; this.entityName = "LOAN"; + this.entityId = transactionId; + this.loanId = loanId; + this.href = "/loans/" + loanId + "/transactions/" + transactionId; return this; } public CommandWrapperBuilder createLoanApplication() { this.actionName = "CREATE"; this.entityName = "LOAN"; + this.entityId = null; + this.loanId = null; + this.href = "/loans"; return this; } - public CommandWrapperBuilder updateLoanApplication() { + public CommandWrapperBuilder updateLoanApplication(final Long loanId) { this.actionName = "UPDATE"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder deleteLoanApplication() { + public CommandWrapperBuilder deleteLoanApplication(final Long loanId) { this.actionName = "DELETE"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder rejectLoanApplication() { + public CommandWrapperBuilder rejectLoanApplication(final Long loanId) { this.actionName = "REJECT"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder withdrawLoanApplication() { + public CommandWrapperBuilder withdrawLoanApplication(final Long loanId) { this.actionName = "WITHDRAW"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder approveLoanApplication() { + public CommandWrapperBuilder approveLoanApplication(final Long loanId) { this.actionName = "APPROVE"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder disburseLoanApplication() { + public CommandWrapperBuilder disburseLoanApplication(final Long loanId) { this.actionName = "DISBURSE"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder undoLoanApplicationApproval() { + public CommandWrapperBuilder undoLoanApplicationApproval(final Long loanId) { this.actionName = "APPROVALUNDO"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder undoLoanApplicationDisbursal() { + public CommandWrapperBuilder undoLoanApplicationDisbursal(final Long loanId) { this.actionName = "DISBURSALUNDO"; this.entityName = "LOAN"; + this.entityId = loanId; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } - public CommandWrapperBuilder assignLoanOfficer() { + public CommandWrapperBuilder assignLoanOfficer(final Long loanId) { this.actionName = "UPDATELOANOFFICER"; this.entityName = "LOAN"; + this.entityId = null; + this.loanId = loanId; + this.href = "/loans/" + loanId; return this; } public CommandWrapperBuilder assignLoanOfficersInBulk() { this.actionName = "BULKREASSIGN"; this.entityName = "LOAN"; - return this; - } - - public CommandWrapperBuilder updateGlobalConfiguration() { - this.actionName = "UPDATE"; - this.entityName = "CONFIGURATION"; - this.entityId = null; - this.href = "/configurations"; + this.href = "/loans/loanreassignment"; return this; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java index d667709d2..dcf3d0962 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java @@ -77,11 +77,10 @@ public class CodesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String createCode(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createCode().withUrl("/codes").withJson(apiRequestBodyAsJson) - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createCode().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - + return this.toApiJsonSerializer.serialize(result); } @@ -103,11 +102,10 @@ public class CodesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateCode(@PathParam("codeId") final Long codeId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCode().withUrl("/codes").withEntityId(codeId).withJson(apiRequestBodyAsJson) - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCode(codeId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - + return this.toApiJsonSerializer.serialize(result); } @@ -117,11 +115,10 @@ public class CodesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String deleteCode(@PathParam("codeId") final Long codeId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCode().withUrl("/codes").withEntityId(codeId).withJson("{}") - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCode(codeId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - + return this.toApiJsonSerializer.serialize(result); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java index 7db3999dd..aefff61cd 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java @@ -142,7 +142,7 @@ public class DataTableApiResource { final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createDatatable(datatable, apptableId, null) - .withUrl("/datatables/" + datatable).withJson(apiRequestBodyAsJson).build(); + .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -157,7 +157,7 @@ public class DataTableApiResource { @PathParam("apptableId") final Long apptableId, final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDatatable(datatable, apptableId, null) - .withUrl("/datatables/" + datatable).withJson(apiRequestBodyAsJson).build(); + .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -173,7 +173,7 @@ public class DataTableApiResource { final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDatatable(datatable, apptableId, datatableId) - .withUrl("/datatables/" + datatable + "/" + apptableId).withJson(apiRequestBodyAsJson).build(); + .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -186,8 +186,7 @@ public class DataTableApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String deleteDatatableEntries(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, null) - .withUrl("/datatables/" + datatable).withJson("{}").build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, null).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -201,8 +200,7 @@ public class DataTableApiResource { public String deleteDatatableEntries(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId, @PathParam("datatableId") final Long datatableId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, datatableId) - .withUrl("/datatables/" + datatable + "/" + apptableId).withJson("{}").build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, datatableId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/api/CurrenciesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/api/CurrenciesApiResource.java index 36e80f7fb..ed856f71a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/api/CurrenciesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/api/CurrenciesApiResource.java @@ -72,11 +72,10 @@ public class CurrenciesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateCurrencies(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCurrencies().withUrl("/currencies").withJson(apiRequestBodyAsJson) - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCurrencies().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - + return this.toApiJsonSerializer.serialize(result); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficeTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficeTransactionsApiResource.java index 644dc3339..a6e406619 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficeTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficeTransactionsApiResource.java @@ -88,8 +88,8 @@ public class OfficeTransactionsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String transferMoneyFrom(final String apiRequestBodyAsJson) { - - final CommandWrapper commandRequest = new CommandWrapperBuilder().createOfficeTransaction().withUrl("/officetransactions").withJson(apiRequestBodyAsJson).build(); + + final CommandWrapper commandRequest = new CommandWrapperBuilder().createOfficeTransaction().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java index c7a8811a7..30dc6d949 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/office/api/OfficesApiResource.java @@ -99,7 +99,7 @@ public class OfficesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String createOffice(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createOffice().withUrl("/offices").withJson(apiRequestBodyAsJson) + final CommandWrapper commandRequest = new CommandWrapperBuilder().createOffice().withJson(apiRequestBodyAsJson) .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -132,8 +132,7 @@ public class OfficesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateOffice(@PathParam("officeId") final Long officeId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateOffice().withUrl("/offices").withEntityId(officeId) - .withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateOffice(officeId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java index 083225194..1f1a22daf 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java @@ -87,9 +87,8 @@ public class StaffApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String createStaff(final String apiRequestBodyAsJson) { - - final CommandWrapper commandRequest = new CommandWrapperBuilder().createStaff().withUrl("/staff").withJson(apiRequestBodyAsJson) - .build(); + + final CommandWrapper commandRequest = new CommandWrapperBuilder().createStaff().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -121,11 +120,10 @@ public class StaffApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateStaff(@PathParam("staffId") final Long staffId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateStaff().withUrl("/staff").withEntityId(staffId).withJson(apiRequestBodyAsJson) - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateStaff(staffId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - + return this.toApiJsonSerializer.serialize(result); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java index 1f34bb721..f683fde42 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java @@ -110,8 +110,7 @@ public class ChargesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String createCharge(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createCharge().withUrl("/charges").withJson(apiRequestBodyAsJson) - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createCharge().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -124,8 +123,7 @@ public class ChargesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateCharge(@PathParam("chargeId") final Long chargeId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCharge().withUrl("/charges").withEntityId(chargeId) - .withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCharge(chargeId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -138,8 +136,7 @@ public class ChargesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String deleteCharge(@PathParam("chargeId") final Long chargeId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCharge().withUrl("/charges").withEntityId(chargeId) - .withJson("{}").build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCharge(chargeId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientIdentifiersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientIdentifiersApiResource.java index 96ceab855..e5b258f83 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientIdentifiersApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientIdentifiersApiResource.java @@ -100,8 +100,8 @@ public class ClientIdentifiersApiResource { public String createClientIdentifier(@PathParam("clientId") final Long clientId, final String apiRequestBodyAsJson) { try { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientIdentifier().withClientId(clientId) - .withUrl("/clients/" + clientId + "/identifiers").withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientIdentifier(clientId) + .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -147,8 +147,7 @@ public class ClientIdentifiersApiResource { @PathParam("identifierId") final Long clientIdentifierId, final String apiRequestBodyAsJson) { try { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientIdentifier() - .withUrl("/clients/" + clientId + "/identifiers").withClientId(clientId).withEntityId(clientIdentifierId) + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientIdentifier(clientId, clientIdentifierId) .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -173,9 +172,7 @@ public class ClientIdentifiersApiResource { public String deleteClientIdentifier(@PathParam("clientId") final Long clientId, @PathParam("identifierId") final Long clientIdentifierId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteClientIdentifier() - .withUrl("/clients/" + clientId + "/identifiers").withClientId(clientId).withEntityId(clientIdentifierId).withJson("{}") - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteClientIdentifier(clientId, clientIdentifierId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientNotesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientNotesApiResource.java index ed73f3109..cd7b7fa62 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientNotesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientNotesApiResource.java @@ -73,8 +73,7 @@ public class ClientNotesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String addNewClientNote(@PathParam("clientId") final Long clientId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientNote().withUrl("/clients/" + clientId + "/notes") - .withClientId(clientId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientNote(clientId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -103,8 +102,8 @@ public class ClientNotesApiResource { public String updateClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientNote().withUrl("/clients/" + clientId + "/notes") - .withClientId(clientId).withEntityId(noteId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientNote(clientId, noteId).withJson(apiRequestBodyAsJson) + .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java index f20c4e866..e96c38162 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java @@ -78,8 +78,7 @@ public class FundsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String createFund(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createFund().withUrl("/funds").withJson(apiRequestBodyAsJson) - .build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createFund().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -106,8 +105,7 @@ public class FundsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateFund(@PathParam("fundId") final Long fundId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFund().withUrl("/funds").withEntityId(fundId) - .withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFund(fundId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); 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 a3f28a0dc..3d30d999b 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 @@ -99,8 +99,7 @@ public class BulkLoansApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String loanReassignment(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().assignLoanOfficersInBulk().withUrl("/loans/loanreassignment") - .withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().assignLoanOfficersInBulk().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java index 4877d690d..b3fe38cbe 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanChargesApiResource.java @@ -104,8 +104,7 @@ public class LoanChargesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String addLoanCharge(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanCharge().withUrl("/loans/" + loanId + "/charges") - .withLoanId(loanId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanCharge(loanId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -119,8 +118,8 @@ public class LoanChargesApiResource { public String updateLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("loanChargeId") final Long loanChargeId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanCharge().withUrl("/loans/" + loanId + "/charges") - .withLoanId(loanId).withEntityId(loanChargeId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanCharge(loanId, loanChargeId) + .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -136,8 +135,7 @@ public class LoanChargesApiResource { String json = ""; if (is(commandParam, "waive")) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().waiveLoanCharge().withUrl("/loans/" + loanId + "/charges") - .withLoanId(loanId).withEntityId(loanChargeId).withJson("{}").build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().waiveLoanCharge(loanId, loanChargeId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -155,8 +153,7 @@ public class LoanChargesApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String deleteLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanCharge().withUrl("/loans/" + loanId + "/charges") - .withLoanId(loanId).withEntityId(loanChargeId).withJson("{}").build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanCharge(loanId, loanChargeId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java index 0818e9baf..83047377f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java @@ -117,24 +117,23 @@ public class LoanTransactionsApiResource { public String executeLoanTransaction(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam, final String apiRequestBodyAsJson) { - CommandWrapperBuilder builder = new CommandWrapperBuilder().withUrl("/loans/" + loanId + "/transactions").withLoanId(loanId) - .withJson(apiRequestBodyAsJson); + CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); CommandProcessingResult result = null; if (is(commandParam, "repayment")) { - final CommandWrapper commandRequest = builder.loanRepaymentTransaction().build(); + final CommandWrapper commandRequest = builder.loanRepaymentTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "waiveinterest")) { - final CommandWrapper commandRequest = builder.waiveInterestPortionTransaction().build(); + final CommandWrapper commandRequest = builder.waiveInterestPortionTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "writeoff")) { - final CommandWrapper commandRequest = builder.writeOffLoanTransaction().build(); + final CommandWrapper commandRequest = builder.writeOffLoanTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "close-rescheduled")) { - final CommandWrapper commandRequest = builder.closeLoanAsRescheduledTransaction().build(); + final CommandWrapper commandRequest = builder.closeLoanAsRescheduledTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "close")) { - final CommandWrapper commandRequest = builder.closeLoanTransaction().build(); + final CommandWrapper commandRequest = builder.closeLoanTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } @@ -150,9 +149,8 @@ public class LoanTransactionsApiResource { public String adjustLoanTransaction(@PathParam("loanId") final Long loanId, @PathParam("transactionId") final Long transactionId, final String apiRequestBodyAsJson) { - CommandWrapperBuilder builder = new CommandWrapperBuilder().withUrl("/loans/" + loanId + "/transactions").withLoanId(loanId).withEntityId(transactionId) - .withJson(apiRequestBodyAsJson); - final CommandWrapper commandRequest = builder.adjustTransaction().build(); + CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); + final CommandWrapper commandRequest = builder.adjustTransaction(loanId, transactionId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java index 79b8e25bc..2439d713b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoansApiResource.java @@ -232,6 +232,9 @@ public class LoansApiResource { } if (associationParameters.contains("permissions")) { + + if (repaymentSchedule == null) { throw new IllegalStateException(); } + // FIXME - KW - Waive feature was changed to waive interest at // anytime so this permission checking is probably not needed - // look into. @@ -245,8 +248,8 @@ public class LoansApiResource { && (tolerance.isGreaterThan(totalOutstandingMoney) || tolerance.isEqualTo(totalOutstandingMoney)); loanRepaymentsCount = retrieveNonDisbursementTransactions(loanRepayments); - permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, - loanRepaymentsCount, existsGuarantor); + permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, loanRepaymentsCount, + existsGuarantor); // clear parent data which wasn't requested if (!associationParameters.contains("repaymentSchedule")) { @@ -333,8 +336,7 @@ public class LoansApiResource { return this.loanScheduleToApiJsonSerializer.serialize(settings, loanSchedule, new HashSet()); } - final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanApplication().withUrl("/loans") - .withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanApplication().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -347,8 +349,8 @@ public class LoansApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String modifyLoanApplication(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanApplication().withUrl("/loans").withLoanId(loanId) - .withEntityId(loanId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanApplication(loanId).withJson(apiRequestBodyAsJson) + .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -361,8 +363,7 @@ public class LoansApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String deleteLoanApplication(@PathParam("loanId") final Long loanId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanApplication().withUrl("/loans").withLoanId(loanId) - .withEntityId(loanId).withJson("{}").build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanApplication(loanId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -376,30 +377,29 @@ public class LoansApiResource { public String stateTransitions(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam, final String apiRequestBodyAsJson) { - final CommandWrapperBuilder builder = new CommandWrapperBuilder().withUrl("/loans").withLoanId(loanId).withEntityId(loanId) - .withJson(apiRequestBodyAsJson); + final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); CommandProcessingResult result = null; if (is(commandParam, "reject")) { - final CommandWrapper commandRequest = builder.rejectLoanApplication().build(); + final CommandWrapper commandRequest = builder.rejectLoanApplication(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "withdrewbyclient")) { - final CommandWrapper commandRequest = builder.withdrawLoanApplication().build(); + final CommandWrapper commandRequest = builder.withdrawLoanApplication(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "approve")) { - final CommandWrapper commandRequest = builder.approveLoanApplication().build(); + final CommandWrapper commandRequest = builder.approveLoanApplication(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "disburse")) { - final CommandWrapper commandRequest = builder.disburseLoanApplication().build(); + final CommandWrapper commandRequest = builder.disburseLoanApplication(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } if (is(commandParam, "undoapproval")) { - final CommandWrapper commandRequest = builder.undoLoanApplicationApproval().build(); + final CommandWrapper commandRequest = builder.undoLoanApplicationApproval(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } else if (is(commandParam, "undodisbursal")) { - final CommandWrapper commandRequest = builder.undoLoanApplicationDisbursal().build(); + final CommandWrapper commandRequest = builder.undoLoanApplicationDisbursal(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); } @@ -440,8 +440,7 @@ public class LoansApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String assignLoanOfficer(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().assignLoanOfficer().withUrl("/loans").withLoanId(loanId) - .withEntityId(loanId).withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().assignLoanOfficer(loanId).withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java index 645efbcd0..668a65718 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -88,11 +88,10 @@ public class LoanProductsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String createLoanProduct(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanProduct().withUrl("/loanproducts") - .withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanProduct().withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - + return this.toApiJsonSerializer.serialize(result); } @@ -147,9 +146,9 @@ public class LoanProductsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String updateLoanProduct(@PathParam("productId") final Long productId, final String apiRequestBodyAsJson) { - - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanProduct().withUrl("/loanproducts").withEntityId(productId) - .withJson(apiRequestBodyAsJson).build(); + + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanProduct(productId).withJson(apiRequestBodyAsJson) + .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/PermissionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/PermissionsApiResource.java index 33ccaf902..88d77ec43 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/PermissionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/PermissionsApiResource.java @@ -79,8 +79,10 @@ public class PermissionsApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updatePermissionsDetails(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePermissions().withUrl("/permissions") - .withJson(apiRequestBodyAsJson).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder() // + .updatePermissions() // + .withJson(apiRequestBodyAsJson) // + .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/UsersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/UsersApiResource.java index c33ff554e..a9f9cd4f6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/UsersApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/api/UsersApiResource.java @@ -120,7 +120,9 @@ public class UsersApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String createUser(final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().createUser().withUrl("/users").withJson(apiRequestBodyAsJson) + final CommandWrapper commandRequest = new CommandWrapperBuilder() // + .createUser() // + .withJson(apiRequestBodyAsJson) // .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -134,8 +136,10 @@ public class UsersApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String updateUser(@PathParam("userId") final Long userId, final String apiRequestBodyAsJson) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateUser().withUrl("/users").withJson(apiRequestBodyAsJson) - .withEntityId(userId).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder() // + .updateUser(userId) // + .withJson(apiRequestBodyAsJson) // + .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); @@ -148,8 +152,9 @@ public class UsersApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String deleteUser(@PathParam("userId") final Long userId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteUser().withUrl("/users").withJson("{}") - .withEntityId(userId).build(); + final CommandWrapper commandRequest = new CommandWrapperBuilder() // + .updateUser(userId) // + .build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);