diff --git a/mifosng-data/src/main/java/org/mifosng/data/ClientDataWithAccountsData.java b/mifosng-data/src/main/java/org/mifosng/data/ClientDataWithAccountsData.java deleted file mode 100644 index 27db88b10..000000000 --- a/mifosng-data/src/main/java/org/mifosng/data/ClientDataWithAccountsData.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.mifosng.data; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class ClientDataWithAccountsData { - - private ClientData clientInfo; - private List pendingApprovalLoans = new ArrayList(); - private List awaitingDisbursalLoans = new ArrayList(); - private List openLoans = new ArrayList(); - private List closedLoans = new ArrayList(); - - public ClientDataWithAccountsData() { - // - } - - public ClientDataWithAccountsData(final ClientData clientInfo, - final List pendingApprovalLoans, - final List awaitingDisbursalLoans, - final List openLoans, - final List closedLoans) { - this.clientInfo = clientInfo; - this.pendingApprovalLoans = pendingApprovalLoans; - this.awaitingDisbursalLoans = awaitingDisbursalLoans; - this.openLoans = openLoans; - this.closedLoans = closedLoans; - } - - public Integer getAnyLoanCount() { - return getPendingApprovalLoanCount() + getAwaitingDisbursalLoanCount() - + getActiveLoanCount() + getClosedLoanCount(); - } - - public Integer getPendingApprovalLoanCount() { - return this.pendingApprovalLoans.size(); - } - - public Integer getAwaitingDisbursalLoanCount() { - return this.awaitingDisbursalLoans.size(); - } - - public Integer getActiveLoanCount() { - return this.openLoans.size(); - } - - public Integer getClosedLoanCount() { - return this.closedLoans.size(); - } - - public ClientData getClientInfo() { - return this.clientInfo; - } - - public void setClientInfo(final ClientData clientInfo) { - this.clientInfo = clientInfo; - } - - public List getPendingApprovalLoans() { - return this.pendingApprovalLoans; - } - - public void setPendingApprovalLoans( - final List pendingApprovalLoans) { - this.pendingApprovalLoans = pendingApprovalLoans; - } - - public List getAwaitingDisbursalLoans() { - return this.awaitingDisbursalLoans; - } - - public void setAwaitingDisbursalLoans( - final List awaitingDisbursalLoans) { - this.awaitingDisbursalLoans = awaitingDisbursalLoans; - } - - public List getOpenLoans() { - return this.openLoans; - } - - public void setOpenLoans(final List openLoans) { - this.openLoans = openLoans; - } - - public List getClosedLoans() { - return this.closedLoans; - } - - public void setClosedLoans(final List closedLoans) { - this.closedLoans = closedLoans; - } - -} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/ClientLoanAccountSummaryCollectionData.java b/mifosng-data/src/main/java/org/mifosng/data/ClientLoanAccountSummaryCollectionData.java new file mode 100644 index 000000000..168df62fa --- /dev/null +++ b/mifosng-data/src/main/java/org/mifosng/data/ClientLoanAccountSummaryCollectionData.java @@ -0,0 +1,85 @@ +package org.mifosng.data; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class ClientLoanAccountSummaryCollectionData { + + private List pendingApprovalLoans = new ArrayList(); + private List awaitingDisbursalLoans = new ArrayList(); + private List openLoans = new ArrayList(); + private List closedLoans = new ArrayList(); + + public ClientLoanAccountSummaryCollectionData() { + // + } + + public ClientLoanAccountSummaryCollectionData( + final List pendingApprovalLoans, + final List awaitingDisbursalLoans, + final List openLoans, + final List closedLoans) { + this.pendingApprovalLoans = pendingApprovalLoans; + this.awaitingDisbursalLoans = awaitingDisbursalLoans; + this.openLoans = openLoans; + this.closedLoans = closedLoans; + } + + public Integer getAnyLoanCount() { + return getPendingApprovalLoanCount() + getAwaitingDisbursalLoanCount() + + getActiveLoanCount() + getClosedLoanCount(); + } + + public Integer getPendingApprovalLoanCount() { + return this.pendingApprovalLoans.size(); + } + + public Integer getAwaitingDisbursalLoanCount() { + return this.awaitingDisbursalLoans.size(); + } + + public Integer getActiveLoanCount() { + return this.openLoans.size(); + } + + public Integer getClosedLoanCount() { + return this.closedLoans.size(); + } + + public List getPendingApprovalLoans() { + return pendingApprovalLoans; + } + + public void setPendingApprovalLoans( + List pendingApprovalLoans) { + this.pendingApprovalLoans = pendingApprovalLoans; + } + + public List getAwaitingDisbursalLoans() { + return awaitingDisbursalLoans; + } + + public void setAwaitingDisbursalLoans( + List awaitingDisbursalLoans) { + this.awaitingDisbursalLoans = awaitingDisbursalLoans; + } + + public List getOpenLoans() { + return openLoans; + } + + public void setOpenLoans(List openLoans) { + this.openLoans = openLoans; + } + + public List getClosedLoans() { + return closedLoans; + } + + public void setClosedLoans(List closedLoans) { + this.closedLoans = closedLoans; + } +} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/ClientLoanAccountSummaryData.java b/mifosng-data/src/main/java/org/mifosng/data/ClientLoanAccountSummaryData.java new file mode 100644 index 000000000..9d1db9f76 --- /dev/null +++ b/mifosng-data/src/main/java/org/mifosng/data/ClientLoanAccountSummaryData.java @@ -0,0 +1,142 @@ +package org.mifosng.data; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.joda.time.LocalDate; + +@XmlRootElement(name = "clientLoanAccountSummary") +public class ClientLoanAccountSummaryData implements Serializable { + + private Long id; + private String externalId; + private Long loanProductId; + private String loanProductName; + + private Integer loanStatusId; + private boolean pendingApproval; + private boolean waitingForDisbursal; + private boolean open; + private boolean closed; + + private String lifeCycleStatusText; + private LocalDate lifeCycleStatusDate; + +// private LocalDate submittedOnDate; +// private LocalDate approvedOnDate; +// private LocalDate expectedDisbursementDate; +// private LocalDate actualDisbursementDate; +// private LocalDate expectedFirstRepaymentOnDate; +// private LocalDate interestCalculatedFromDate; +// private LocalDate expectedMaturityDate; +// private LocalDate closedOnDate; + + public ClientLoanAccountSummaryData() { + // + } + + public ClientLoanAccountSummaryData(Long id, String externalId, + Long productId, String loanProductName, Integer loanStatusId, + String lifeCycleStatusText, boolean pendingApproval, + boolean waitingForDisbursal, boolean open, boolean closed) { + this.id = id; + this.externalId = externalId; + this.loanProductId = productId; + this.loanProductName = loanProductName; + this.loanStatusId = loanStatusId; + this.lifeCycleStatusText = lifeCycleStatusText; + this.pendingApproval = pendingApproval; + this.waitingForDisbursal = waitingForDisbursal; + this.open = open; + this.closed = closed; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getExternalId() { + return externalId; + } + + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public String getLoanProductName() { + return loanProductName; + } + + public void setLoanProductName(String loanProductName) { + this.loanProductName = loanProductName; + } + + public boolean isPendingApproval() { + return pendingApproval; + } + + public void setPendingApproval(boolean pendingApproval) { + this.pendingApproval = pendingApproval; + } + + public boolean isWaitingForDisbursal() { + return waitingForDisbursal; + } + + public void setWaitingForDisbursal(boolean waitingForDisbursal) { + this.waitingForDisbursal = waitingForDisbursal; + } + + public boolean isOpen() { + return open; + } + + public void setOpen(boolean open) { + this.open = open; + } + + public boolean isClosed() { + return closed; + } + + public void setClosed(boolean closed) { + this.closed = closed; + } + + public String getLifeCycleStatusText() { + return lifeCycleStatusText; + } + + public void setLifeCycleStatusText(String lifeCycleStatusText) { + this.lifeCycleStatusText = lifeCycleStatusText; + } + + public LocalDate getLifeCycleStatusDate() { + return lifeCycleStatusDate; + } + + public void setLifeCycleStatusDate(LocalDate lifeCycleStatusDate) { + this.lifeCycleStatusDate = lifeCycleStatusDate; + } + + public Long getLoanProductId() { + return loanProductId; + } + + public void setLoanProductId(Long loanProductId) { + this.loanProductId = loanProductId; + } + + public Integer getLoanStatusId() { + return loanStatusId; + } + + public void setLoanStatusId(Integer loanStatusId) { + this.loanStatusId = loanStatusId; + } +} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/EnrollClientCommand.java b/mifosng-data/src/main/java/org/mifosng/data/command/EnrollClientCommand.java index 34fd16a82..5b67334cd 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/EnrollClientCommand.java +++ b/mifosng-data/src/main/java/org/mifosng/data/command/EnrollClientCommand.java @@ -12,6 +12,9 @@ public class EnrollClientCommand { private String fullname; private Long officeId; private String externalId; + + private String dateFormat; + private String joiningDateFormatted; private LocalDate joiningDate; protected EnrollClientCommand() { @@ -73,4 +76,20 @@ public class EnrollClientCommand { public void setFullname(String fullname) { this.fullname = fullname; } + + public String getDateFormat() { + return dateFormat; + } + + public void setDateFormat(String dateFormat) { + this.dateFormat = dateFormat; + } + + public String getJoiningDateFormatted() { + return joiningDateFormatted; + } + + public void setJoiningDateFormatted(String joiningDateFormatted) { + this.joiningDateFormatted = joiningDateFormatted; + } } \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperations.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperations.java index 71f6f775b..b718b4b0a 100644 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperations.java +++ b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperations.java @@ -2,27 +2,18 @@ package org.mifosng.ui; import java.util.Collection; -import org.mifosng.data.ClientData; -import org.mifosng.data.ClientDataWithAccountsData; import org.mifosng.data.EntityIdentifier; -import org.mifosng.data.EnumOptionReadModel; -import org.mifosng.data.LoanAccountData; import org.mifosng.data.LoanProductData; import org.mifosng.data.LoanRepaymentData; import org.mifosng.data.LoanSchedule; import org.mifosng.data.NewLoanWorkflowStepOneData; -import org.mifosng.data.NoteData; -import org.mifosng.data.PermissionData; import org.mifosng.data.command.AdjustLoanTransactionCommand; import org.mifosng.data.command.CalculateLoanScheduleCommand; -import org.mifosng.data.command.EnrollClientCommand; import org.mifosng.data.command.LoanStateTransitionCommand; import org.mifosng.data.command.LoanTransactionCommand; -import org.mifosng.data.command.NoteCommand; import org.mifosng.data.command.SubmitLoanApplicationCommand; import org.mifosng.data.command.UndoLoanApprovalCommand; import org.mifosng.data.command.UndoLoanDisbursalCommand; -import org.mifosng.data.command.UserCommand; import org.springframework.security.oauth.consumer.ProtectedResourceDetails; public interface CommonRestOperations { @@ -31,18 +22,11 @@ public interface CommonRestOperations { void updateProtectedResource(ProtectedResourceDetails loadProtectedResourceDetailsById); - Collection retrieveAllPermissions(); - - Collection retrieveAllPermissionGroups(); - - Collection retrieveAllIndividualClients(); - Collection retrieveAllLoanProducts(); LoanSchedule calculateLoanSchedule(CalculateLoanScheduleCommand command); - NewLoanWorkflowStepOneData retrieveNewLoanApplicationStepOneDetails( - Long clientId); + NewLoanWorkflowStepOneData retrieveNewLoanApplicationStepOneDetails(Long clientId); Long submitLoanApplication(SubmitLoanApplicationCommand command); @@ -72,26 +56,5 @@ public interface CommonRestOperations { EntityIdentifier waiveLoanAmount(LoanTransactionCommand command); - EntityIdentifier updateCurrentUserDetails(UserCommand command); - - ClientData retrieveNewIndividualClient(); - - ClientData retrieveClientDetails(Long clientId); - - EntityIdentifier enrollClient(EnrollClientCommand command); - - EntityIdentifier addNote(NoteCommand command); - - EntityIdentifier updateNote(NoteCommand command); - - NoteData retrieveClientNote(Long clientId, Long noteId); - - Collection retrieveClientNotes(Long clientId); - - ClientDataWithAccountsData retrieveClientAccount(Long clientId); - - LoanAccountData retrieveLoanAccount(Long loanId); - - NewLoanWorkflowStepOneData retrieveNewLoanApplicationDetails(Long clientId, - Long productId); + NewLoanWorkflowStepOneData retrieveNewLoanApplicationDetails(Long clientId, Long productId); } \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperationsImpl.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperationsImpl.java index c53946a40..2077f147d 100644 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperationsImpl.java +++ b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/CommonRestOperationsImpl.java @@ -6,34 +6,22 @@ import java.util.Collection; import java.util.List; import org.mifosng.configuration.ApplicationConfigurationService; -import org.mifosng.data.ClientData; -import org.mifosng.data.ClientDataWithAccountsData; import org.mifosng.data.ClientList; import org.mifosng.data.EntityIdentifier; -import org.mifosng.data.EnumOptionList; -import org.mifosng.data.EnumOptionReadModel; import org.mifosng.data.ErrorResponse; import org.mifosng.data.ErrorResponseList; -import org.mifosng.data.LoanAccountData; import org.mifosng.data.LoanProductData; import org.mifosng.data.LoanProductList; import org.mifosng.data.LoanRepaymentData; import org.mifosng.data.LoanSchedule; import org.mifosng.data.NewLoanWorkflowStepOneData; -import org.mifosng.data.NoteData; -import org.mifosng.data.NoteDataList; -import org.mifosng.data.PermissionData; -import org.mifosng.data.PermissionList; import org.mifosng.data.command.AdjustLoanTransactionCommand; import org.mifosng.data.command.CalculateLoanScheduleCommand; -import org.mifosng.data.command.EnrollClientCommand; import org.mifosng.data.command.LoanStateTransitionCommand; import org.mifosng.data.command.LoanTransactionCommand; -import org.mifosng.data.command.NoteCommand; import org.mifosng.data.command.SubmitLoanApplicationCommand; import org.mifosng.data.command.UndoLoanApprovalCommand; import org.mifosng.data.command.UndoLoanDisbursalCommand; -import org.mifosng.data.command.UserCommand; import org.mifosng.ui.loanproduct.ClientValidationException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -94,17 +82,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations { return requestEntity; } - @Override - public Collection retrieveAllIndividualClients() { - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/client/all")); - - ResponseEntity s = this.oauthRestServiceTemplate.exchange( - restUri, HttpMethod.GET, emptyRequest(), ClientList.class); - - return s.getBody().getClients(); - } - @Override public Collection retrieveAllLoanProducts() { URI restUri = URI.create(getBaseServerUrl().concat( @@ -524,234 +501,4 @@ public class CommonRestOperationsImpl implements CommonRestOperations { return new HttpEntity(command, requestHeaders); } - - @Override - public EntityIdentifier updateCurrentUserDetails(UserCommand command) { - try { - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/admin/user/current")); - - ResponseEntity s = this.oauthRestServiceTemplate - .postForEntity(restUri, createUserRequest(command), - EntityIdentifier.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - private HttpEntity createUserRequest(final UserCommand command) { - - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.set("Accept", "application/xml"); - requestHeaders.set("Content-Type", "application/xml"); - - HttpEntity requestEntity = new HttpEntity( - command, requestHeaders); - return requestEntity; - } - - @Override - public Collection retrieveAllPermissions() { - - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/admin/permissions/all")); - - ResponseEntity s = this.oauthRestServiceTemplate - .exchange(restUri, HttpMethod.GET, emptyRequest(), - PermissionList.class); - - return s.getBody().getPermissions(); - } - - @Override - public Collection retrieveAllPermissionGroups() { - try { - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/admin/permissiongroup/all")); - - ResponseEntity s = this.oauthRestServiceTemplate - .exchange(restUri, HttpMethod.GET, emptyRequest(), - EnumOptionList.class); - - return s.getBody().getOptions(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - @Override - public ClientData retrieveNewIndividualClient() { - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/client/new")); - - ResponseEntity s = this.oauthRestServiceTemplate.exchange( - restUri, HttpMethod.GET, emptyRequest(), ClientData.class); - - return s.getBody(); - } - - @Override - public ClientData retrieveClientDetails(Long clientId) { - try { - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/client/").concat(clientId.toString())); - - ResponseEntity s = this.oauthRestServiceTemplate - .exchange(restUri, HttpMethod.GET, emptyRequest(), - ClientData.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - @Override - public EntityIdentifier enrollClient(EnrollClientCommand command) { - try { - - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/client/new")); - - ResponseEntity s = this.oauthRestServiceTemplate - .postForEntity(restUri, enrollClientRequest(command), - EntityIdentifier.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - private HttpEntity enrollClientRequest( - final EnrollClientCommand command) { - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.set("Accept", "application/xml"); - requestHeaders.set("Content-Type", "application/xml"); - - return new HttpEntity(command, requestHeaders); - } - - @Override - public EntityIdentifier addNote(NoteCommand command) { - try { - URI restUri = URI.create(getBaseServerUrl() - .concat("api/protected/client/") - .concat(command.getClientId().toString()) - .concat("/note/new")); - - ResponseEntity s = this.oauthRestServiceTemplate - .postForEntity(restUri, noteRequest(command), - EntityIdentifier.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - @Override - public EntityIdentifier updateNote(NoteCommand command) { - try { - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/note/").concat(command.getId().toString())); - - ResponseEntity s = this.oauthRestServiceTemplate - .postForEntity(restUri, noteRequest(command), - EntityIdentifier.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - @Override - public NoteData retrieveClientNote(Long clientId, Long noteId) { - try { - URI restUri = URI.create(getBaseServerUrl() - .concat("api/protected/client/") - .concat(clientId.toString()).concat("/note/") - .concat(noteId.toString())); - - ResponseEntity s = this.oauthRestServiceTemplate - .exchange(restUri, HttpMethod.GET, emptyRequest(), - NoteData.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - @Override - public Collection retrieveClientNotes(Long clientId) { - try { - URI restUri = URI.create(getBaseServerUrl() - .concat("api/protected/client/") - .concat(clientId.toString()).concat("/note/all")); - - ResponseEntity s = this.oauthRestServiceTemplate - .exchange(restUri, HttpMethod.GET, emptyRequest(), - NoteDataList.class); - - return s.getBody().getNotes(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - private HttpEntity noteRequest(final NoteCommand command) { - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.set("Accept", "application/xml"); - requestHeaders.set("Content-Type", "application/xml"); - - return new HttpEntity(command, requestHeaders); - } - - @Override - public ClientDataWithAccountsData retrieveClientAccount(Long clientId) { - try { - URI restUri = URI.create(getBaseServerUrl() - .concat("api/protected/client/") - .concat(clientId.toString()).concat("/withaccounts")); - - ResponseEntity s = this.oauthRestServiceTemplate - .exchange(restUri, HttpMethod.GET, emptyRequest(), - ClientDataWithAccountsData.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - - @Override - public LoanAccountData retrieveLoanAccount(Long loanId) { - try { - URI restUri = URI.create(getBaseServerUrl().concat( - "api/protected/loan/" + loanId)); - - ResponseEntity s = this.oauthRestServiceTemplate - .exchange(restUri, HttpMethod.GET, emptyRequest(), - LoanAccountData.class); - - return s.getBody(); - } catch (HttpStatusCodeException e) { - ErrorResponseList errorList = parseErrors(e); - throw new ClientValidationException(errorList.getErrors()); - } - } - } \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/AdministrationController.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/AdministrationController.java deleted file mode 100644 index 85312c9cd..000000000 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/AdministrationController.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.mifosng.ui.admin; - -import java.util.Collection; - -import javax.servlet.http.HttpServletResponse; - -import org.mifosng.data.ErrorResponse; -import org.mifosng.ui.loanproduct.ClientValidationException; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * Controller for user and organisation administration functions. - */ -@Controller -public class AdministrationController { - - @ExceptionHandler(AccessDeniedException.class) - public String accessDeniedException() { - return "unAuthorizedAction"; - } - - @ExceptionHandler(ClientValidationException.class) - public @ResponseBody Collection validationException(ClientValidationException ex, HttpServletResponse response) { - - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.setContentType("application/json"); - - return ex.getValidationErrors(); - } - - @RequestMapping(value = "/org/admin", method = RequestMethod.GET) - public String organisationAdminScreen() { - return "admin/orghome"; - } - - @RequestMapping(value = "/org/admin/user", method = RequestMethod.GET) - public String userAdminScreen() { - return "admin/userhome"; - } - - @RequestMapping(value = "/org/admin/settings", method = RequestMethod.GET) - public String userSettingsScreen() { - return "admin/accountsettings"; - } -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/ApplicationPagesRoutesController.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/ApplicationPagesRoutesController.java new file mode 100644 index 000000000..a0c61f39a --- /dev/null +++ b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/admin/ApplicationPagesRoutesController.java @@ -0,0 +1,74 @@ +package org.mifosng.ui.admin; + +import org.mifosng.ui.reporting.ReportingRestOperations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +/** + * Controller responsible for routing requests on client application to correct jsp page. + */ +@Controller +public class ApplicationPagesRoutesController { + + private final ReportingRestOperations reportingRestOperations; + + @Autowired + public ApplicationPagesRoutesController(final ReportingRestOperations reportingRestOperations) { + this.reportingRestOperations = reportingRestOperations; + } + + @ExceptionHandler(AccessDeniedException.class) + public String accessDeniedException() { + return "unAuthorizedAction"; + } + + @RequestMapping(value="/forceOAuth", method = RequestMethod.GET) + public String forceOAuth() { + this.reportingRestOperations.hackToForceAuthentication(); + return "redirect:/home"; + } + + @RequestMapping(value="/", method = RequestMethod.GET) + public String redirectToIndexPage() { + return "redirect:/home"; + } + + @RequestMapping(value = "/home", method = RequestMethod.GET) + public ModelAndView showIndividualClientsOnHomePage() { + return new ModelAndView("/home"); + } + + @RequestMapping(value="/switchToClient", method = RequestMethod.POST) + public String switchToClientView(@RequestParam("client") final Long client) { + return "redirect:/portfolio/client/" + client; + } + + @RequestMapping(value = "/portfolio/client/{clientId}", method = RequestMethod.GET) + public String viewClientAccount(final Model model, @PathVariable("clientId") final Long clientId) { + model.addAttribute("clientId", clientId); + return "client/viewClientAccount"; + } + + @RequestMapping(value = "/org/admin", method = RequestMethod.GET) + public String organisationAdminScreen() { + return "admin/orghome"; + } + + @RequestMapping(value = "/org/admin/user", method = RequestMethod.GET) + public String userAdminScreen() { + return "admin/userhome"; + } + + @RequestMapping(value = "/org/admin/settings", method = RequestMethod.GET) + public String userSettingsScreen() { + return "admin/accountsettings"; + } +} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/ClientController.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/ClientController.java deleted file mode 100644 index 6ba43282c..000000000 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/ClientController.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.mifosng.ui.client; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Locale; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang.StringUtils; -import org.joda.time.LocalDate; -import org.joda.time.format.DateTimeFormat; -import org.mifosng.data.ClientData; -import org.mifosng.data.ClientDataWithAccountsData; -import org.mifosng.data.ClientList; -import org.mifosng.data.EntityIdentifier; -import org.mifosng.data.ErrorResponse; -import org.mifosng.data.LoanAccountData; -import org.mifosng.data.NoteData; -import org.mifosng.data.command.EnrollClientCommand; -import org.mifosng.data.command.NoteCommand; -import org.mifosng.ui.CommonRestOperations; -import org.mifosng.ui.loanproduct.ClientValidationException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.http.HttpStatus; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -@Controller -public class ClientController { - - private final CommonRestOperations commonRestOperations; - - @Autowired - public ClientController(final CommonRestOperations commonRestOperations) { - this.commonRestOperations = commonRestOperations; - } - - @ExceptionHandler(AccessDeniedException.class) - public String accessDeniedException() { - return "unAuthorizedAction"; - } - - @ExceptionHandler(ClientValidationException.class) - public @ResponseBody Collection validationException(ClientValidationException ex, HttpServletResponse response) { - - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.setContentType("application/json"); - - return ex.getValidationErrors(); - } - - private LocalDate parseStringToLocalDate(String eventDate, String dateFieldIdentifier) { - LocalDate eventLocalDate = null; - if (StringUtils.isNotBlank(eventDate)) { - try { - Locale locale = LocaleContextHolder.getLocale(); - eventLocalDate = DateTimeFormat.forPattern("dd MMMM yyyy").withLocale(locale).parseLocalDate(eventDate.toLowerCase(locale)); - } catch (IllegalArgumentException e) { - List validationErrors = new ArrayList(); - validationErrors.add(new ErrorResponse("validation.msg.invalid.date.format", dateFieldIdentifier, eventDate)); - throw new ClientValidationException(validationErrors); - } - } - - return eventLocalDate; - } - - @RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/{clientId}/note/all", method = RequestMethod.GET) - public @ResponseBody List retrieveClientNotes(@PathVariable("clientId") Long clientId) { - - Collection clientNotes = this.commonRestOperations.retrieveClientNotes(clientId); - - return new ArrayList(clientNotes); - } - - @RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/{clientId}/note/new", method = RequestMethod.GET) - public @ResponseBody NoteData retrieveNewNoteDetails(@PathVariable("clientId") Long clientId) { - - NoteData noteData = new NoteData(); - noteData.setClientId(clientId); - - return noteData; - } - - @RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/client/{clientId}/note/new", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.OK) - public @ResponseBody EntityIdentifier addClientNote(@PathVariable("clientId") Long clientId, - @RequestParam(value="note", required=false) String note) { - - NoteCommand command = new NoteCommand(); - command.setClientId(clientId); - command.setNote(note); - - return this.commonRestOperations.addNote(command); - } - - @RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/{clientId}/note/{noteId}", method = RequestMethod.GET) - public @ResponseBody NoteData retrieveExistingNoteDetails(@PathVariable("clientId") Long clientId, @PathVariable("noteId") Long noteId) { - - return this.commonRestOperations.retrieveClientNote(clientId, noteId); - } - - @RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/client/{clientId}/note/{noteId}", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.OK) - public @ResponseBody EntityIdentifier updateClientNote(@PathVariable("clientId") Long clientId, @PathVariable("noteId") Long noteId, - @RequestParam(value="note", required=false) String note) { - - NoteCommand command = new NoteCommand(); - command.setId(noteId); - command.setClientId(clientId); - command.setNote(note); - - return this.commonRestOperations.updateNote(command); - } - - @RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/all", method = RequestMethod.GET) - public @ResponseBody ClientList viewAllClients() { - - return new ClientList(this.commonRestOperations.retrieveAllIndividualClients()); - } - - @RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/new", method = RequestMethod.GET) - public @ResponseBody ClientData newIndividualClientDetails() { - - ClientData clientData = this.commonRestOperations.retrieveNewIndividualClient(); - return clientData; - } - - @RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/client/new", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.OK) - public @ResponseBody EntityIdentifier createClient(HttpServletRequest request, - @RequestParam(value="office", required=false) Long officeId, - @RequestParam(value="firstname", required=false) String firstname, - @RequestParam(value="lastname", required=false) String lastname, - @RequestParam(value="fullname", required=false) String fullname, - @RequestParam(value="joiningDate", required=false) String joiningDate, - @RequestParam(value="externalId", required=false) String externalId) { - - - LocalDate joiningLocalDate = parseStringToLocalDate(joiningDate, "joiningDate"); - - EnrollClientCommand command = new EnrollClientCommand(firstname, lastname, fullname, officeId, joiningLocalDate); - return this.commonRestOperations.enrollClient(command); - } - - @RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/{clientId}", method = RequestMethod.GET) - public @ResponseBody ClientDataWithAccountsData viewClientAccountData(@PathVariable("clientId") Long clientId) { - - return this.commonRestOperations.retrieveClientAccount(clientId); - } - - @RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/loan/{loanId}", method = RequestMethod.GET) - public @ResponseBody LoanAccountData viewLoanAccountData(@PathVariable("loanId") Long loanId) { - - return this.commonRestOperations.retrieveLoanAccount(loanId); - } - - @RequestMapping(value = "/portfolio/client/{clientId}", method = RequestMethod.GET) - public String viewClientAccount(final Model model, @PathVariable("clientId") final Long clientId) { - - ClientData clientData = this.commonRestOperations.retrieveClientDetails(clientId); - - model.addAttribute("clientId", clientId); - model.addAttribute("clientDisplayName", clientData.getDisplayName()); - - return "client/viewClientAccount"; - } - -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/DropdownOption.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/DropdownOption.java deleted file mode 100644 index fa82f8485..000000000 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/DropdownOption.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.mifosng.ui.client; - -public class DropdownOption { - - private String label; - private String value; - - public static DropdownOption of(String label, String value) { - DropdownOption option = new DropdownOption(); - option.setLabel(label); - option.setValue(value); - return option; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/PayoffFormBean.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/PayoffFormBean.java deleted file mode 100644 index d7f8533cc..000000000 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/client/PayoffFormBean.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.mifosng.ui.client; - -import org.joda.time.DateTime; -import org.springframework.format.annotation.DateTimeFormat; - -public class PayoffFormBean { - - @DateTimeFormat(pattern = "yyyy-MM-dd") - private DateTime payoffDate = new DateTime(); - - public DateTime getPayoffDate() { - return this.payoffDate; - } - - public void setPayoffDate(final DateTime payoffDate) { - this.payoffDate = payoffDate; - } -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/home/HomeController.java b/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/home/HomeController.java deleted file mode 100644 index 24cc69b50..000000000 --- a/mifosng-individual-lending-app/src/main/java/org/mifosng/ui/home/HomeController.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.mifosng.ui.home; - -import org.mifosng.ui.reporting.ReportingRestOperations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.servlet.ModelAndView; - -@Controller -public class HomeController { - - private final ReportingRestOperations reportingRestOperations; - - @Autowired - public HomeController(final ReportingRestOperations reportingRestOperations) { - this.reportingRestOperations = reportingRestOperations; - } - - @RequestMapping(value="/forceOAuth", method = RequestMethod.GET) - public String forceOAuth() { - - this.reportingRestOperations.hackToForceAuthentication(); - - return "redirect:/home"; - } - - @RequestMapping(value="/", method = RequestMethod.GET) - public String redirectToIndexPage() { - return "redirect:/home"; - } - - @RequestMapping(value = "/home", method = RequestMethod.GET) - public ModelAndView showIndividualClientsOnHomePage() { - return new ModelAndView("/home"); - } - - @RequestMapping(value="/switchToClient", method = RequestMethod.POST) - public String switchToClientView(@RequestParam("client") final Long client) { - return "redirect:/portfolio/client/" + client; - } -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp index fec22d873..2edc7733a 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp @@ -12,8 +12,6 @@ - -