MIFOSX-97: update urls for getting data when viewing changes against existing data for maker-checker.

This commit is contained in:
Keith Woodlock
2013-01-09 00:09:45 +00:00
parent a0388e34d1
commit 986a3c5f91
18 changed files with 246 additions and 153 deletions
@@ -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;
}
}
@@ -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);
}
}
@@ -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);
@@ -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);
}
}
@@ -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);
@@ -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);
@@ -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);
}
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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<String>());
}
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);
@@ -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);
@@ -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);
@@ -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);