handle client resource and sub resources for notes and loanaccount summaries.
This commit is contained in:
@@ -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<LoanAccountData> pendingApprovalLoans = new ArrayList<LoanAccountData>();
|
||||
private List<LoanAccountData> awaitingDisbursalLoans = new ArrayList<LoanAccountData>();
|
||||
private List<LoanAccountData> openLoans = new ArrayList<LoanAccountData>();
|
||||
private List<LoanAccountData> closedLoans = new ArrayList<LoanAccountData>();
|
||||
|
||||
public ClientDataWithAccountsData() {
|
||||
//
|
||||
}
|
||||
|
||||
public ClientDataWithAccountsData(final ClientData clientInfo,
|
||||
final List<LoanAccountData> pendingApprovalLoans,
|
||||
final List<LoanAccountData> awaitingDisbursalLoans,
|
||||
final List<LoanAccountData> openLoans,
|
||||
final List<LoanAccountData> 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<LoanAccountData> getPendingApprovalLoans() {
|
||||
return this.pendingApprovalLoans;
|
||||
}
|
||||
|
||||
public void setPendingApprovalLoans(
|
||||
final List<LoanAccountData> pendingApprovalLoans) {
|
||||
this.pendingApprovalLoans = pendingApprovalLoans;
|
||||
}
|
||||
|
||||
public List<LoanAccountData> getAwaitingDisbursalLoans() {
|
||||
return this.awaitingDisbursalLoans;
|
||||
}
|
||||
|
||||
public void setAwaitingDisbursalLoans(
|
||||
final List<LoanAccountData> awaitingDisbursalLoans) {
|
||||
this.awaitingDisbursalLoans = awaitingDisbursalLoans;
|
||||
}
|
||||
|
||||
public List<LoanAccountData> getOpenLoans() {
|
||||
return this.openLoans;
|
||||
}
|
||||
|
||||
public void setOpenLoans(final List<LoanAccountData> openLoans) {
|
||||
this.openLoans = openLoans;
|
||||
}
|
||||
|
||||
public List<LoanAccountData> getClosedLoans() {
|
||||
return this.closedLoans;
|
||||
}
|
||||
|
||||
public void setClosedLoans(final List<LoanAccountData> closedLoans) {
|
||||
this.closedLoans = closedLoans;
|
||||
}
|
||||
|
||||
}
|
||||
+85
@@ -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<ClientLoanAccountSummaryData> pendingApprovalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
private List<ClientLoanAccountSummaryData> awaitingDisbursalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
private List<ClientLoanAccountSummaryData> openLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
private List<ClientLoanAccountSummaryData> closedLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
|
||||
public ClientLoanAccountSummaryCollectionData() {
|
||||
//
|
||||
}
|
||||
|
||||
public ClientLoanAccountSummaryCollectionData(
|
||||
final List<ClientLoanAccountSummaryData> pendingApprovalLoans,
|
||||
final List<ClientLoanAccountSummaryData> awaitingDisbursalLoans,
|
||||
final List<ClientLoanAccountSummaryData> openLoans,
|
||||
final List<ClientLoanAccountSummaryData> 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<ClientLoanAccountSummaryData> getPendingApprovalLoans() {
|
||||
return pendingApprovalLoans;
|
||||
}
|
||||
|
||||
public void setPendingApprovalLoans(
|
||||
List<ClientLoanAccountSummaryData> pendingApprovalLoans) {
|
||||
this.pendingApprovalLoans = pendingApprovalLoans;
|
||||
}
|
||||
|
||||
public List<ClientLoanAccountSummaryData> getAwaitingDisbursalLoans() {
|
||||
return awaitingDisbursalLoans;
|
||||
}
|
||||
|
||||
public void setAwaitingDisbursalLoans(
|
||||
List<ClientLoanAccountSummaryData> awaitingDisbursalLoans) {
|
||||
this.awaitingDisbursalLoans = awaitingDisbursalLoans;
|
||||
}
|
||||
|
||||
public List<ClientLoanAccountSummaryData> getOpenLoans() {
|
||||
return openLoans;
|
||||
}
|
||||
|
||||
public void setOpenLoans(List<ClientLoanAccountSummaryData> openLoans) {
|
||||
this.openLoans = openLoans;
|
||||
}
|
||||
|
||||
public List<ClientLoanAccountSummaryData> getClosedLoans() {
|
||||
return closedLoans;
|
||||
}
|
||||
|
||||
public void setClosedLoans(List<ClientLoanAccountSummaryData> closedLoans) {
|
||||
this.closedLoans = closedLoans;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
+2
-39
@@ -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<PermissionData> retrieveAllPermissions();
|
||||
|
||||
Collection<EnumOptionReadModel> retrieveAllPermissionGroups();
|
||||
|
||||
Collection<ClientData> retrieveAllIndividualClients();
|
||||
|
||||
Collection<LoanProductData> 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<NoteData> retrieveClientNotes(Long clientId);
|
||||
|
||||
ClientDataWithAccountsData retrieveClientAccount(Long clientId);
|
||||
|
||||
LoanAccountData retrieveLoanAccount(Long loanId);
|
||||
|
||||
NewLoanWorkflowStepOneData retrieveNewLoanApplicationDetails(Long clientId,
|
||||
Long productId);
|
||||
NewLoanWorkflowStepOneData retrieveNewLoanApplicationDetails(Long clientId, Long productId);
|
||||
}
|
||||
-253
@@ -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<ClientData> retrieveAllIndividualClients() {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/client/all"));
|
||||
|
||||
ResponseEntity<ClientList> s = this.oauthRestServiceTemplate.exchange(
|
||||
restUri, HttpMethod.GET, emptyRequest(), ClientList.class);
|
||||
|
||||
return s.getBody().getClients();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<LoanProductData> retrieveAllLoanProducts() {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
@@ -524,234 +501,4 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
return new HttpEntity<CalculateLoanScheduleCommand>(command,
|
||||
requestHeaders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier updateCurrentUserDetails(UserCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/current"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> 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<UserCommand> createUserRequest(final UserCommand command) {
|
||||
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
HttpEntity<UserCommand> requestEntity = new HttpEntity<UserCommand>(
|
||||
command, requestHeaders);
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PermissionData> retrieveAllPermissions() {
|
||||
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/permissions/all"));
|
||||
|
||||
ResponseEntity<PermissionList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
PermissionList.class);
|
||||
|
||||
return s.getBody().getPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumOptionReadModel> retrieveAllPermissionGroups() {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/permissiongroup/all"));
|
||||
|
||||
ResponseEntity<EnumOptionList> 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<ClientData> 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<ClientData> 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<EntityIdentifier> 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<EnrollClientCommand> enrollClientRequest(
|
||||
final EnrollClientCommand command) {
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
return new HttpEntity<EnrollClientCommand>(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<EntityIdentifier> 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<EntityIdentifier> 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<NoteData> 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<NoteData> retrieveClientNotes(Long clientId) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl()
|
||||
.concat("api/protected/client/")
|
||||
.concat(clientId.toString()).concat("/note/all"));
|
||||
|
||||
ResponseEntity<NoteDataList> 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<NoteCommand> noteRequest(final NoteCommand command) {
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
return new HttpEntity<NoteCommand>(command, requestHeaders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientDataWithAccountsData retrieveClientAccount(Long clientId) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl()
|
||||
.concat("api/protected/client/")
|
||||
.concat(clientId.toString()).concat("/withaccounts"));
|
||||
|
||||
ResponseEntity<ClientDataWithAccountsData> 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<LoanAccountData> 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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-50
@@ -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<ErrorResponse> 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";
|
||||
}
|
||||
}
|
||||
+74
@@ -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";
|
||||
}
|
||||
}
|
||||
-180
@@ -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<ErrorResponse> 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<ErrorResponse> validationErrors = new ArrayList<ErrorResponse>();
|
||||
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<NoteData> retrieveClientNotes(@PathVariable("clientId") Long clientId) {
|
||||
|
||||
Collection<NoteData> clientNotes = this.commonRestOperations.retrieveClientNotes(clientId);
|
||||
|
||||
return new ArrayList<NoteData>(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";
|
||||
}
|
||||
|
||||
}
|
||||
-30
@@ -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;
|
||||
}
|
||||
}
|
||||
-18
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
+94
-51
@@ -12,8 +12,6 @@
|
||||
<jsp:include page="../common-head.jsp" />
|
||||
<c:url value="/" var="rootContext" />
|
||||
<c:url value="/portfolio/client/${clientId}" var="clientUrl" />
|
||||
<c:url value="/portfolio/client/${clientId}/note/all" var="allClientNotesUrl" />
|
||||
|
||||
<style>
|
||||
div.notecontainer {wdith:300px;min-width:300px;max-width:400px;}
|
||||
span.noteusername {font-weight:bold;font-style: italic;}
|
||||
@@ -314,16 +312,17 @@ $(document).ready(function() {
|
||||
}).dialog('open');
|
||||
}
|
||||
|
||||
function popupDialogWithFormView(url, titleCode, templateSelector, width, height, tabIndex, minOffset, defaultOffset, maxOffset) {
|
||||
// function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, tabIndex, minOffset, defaultOffset, maxOffset) {
|
||||
function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
|
||||
var dialogDiv = $("<div id='dialog-form'></div>");
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
url: getUrl,
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
|
||||
console.log(data);
|
||||
var formHtml = $(templateSelector).render(data);
|
||||
|
||||
dialogDiv.append(formHtml);
|
||||
@@ -333,25 +332,29 @@ $(document).ready(function() {
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[saveButton] = function() {
|
||||
$('.multiSelectedItems option').each(function(i) {
|
||||
|
||||
$('#notSelectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
var form_data = $('#entityform').serialize();
|
||||
|
||||
|
||||
$('#selectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: form_data,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
dialogDiv.dialog("close");
|
||||
$newtabs.tabs('load', tabIndex);
|
||||
url: postUrl,
|
||||
type: submitType,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: newFormData,
|
||||
success: saveSuccessFunction,
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
}
|
||||
});
|
||||
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
};
|
||||
|
||||
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
|
||||
@@ -367,20 +370,19 @@ $(document).ready(function() {
|
||||
$(this).remove();
|
||||
},
|
||||
open: function (event, ui) {
|
||||
$('.multiadd').click(function() {
|
||||
return !$('.multiNotSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
|
||||
$('#add').click(function() {
|
||||
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
});
|
||||
|
||||
$('.multiremove').click(function() {
|
||||
return !$('.multiSelectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
$('#remove').click(function() {
|
||||
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
});
|
||||
|
||||
$('.datepickerfield').datepicker({constrainInput: true, minDate: minOffset, defaultDate: defaultOffset, maxDate: maxOffset, dateFormat: 'dd MM yy'});
|
||||
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
|
||||
|
||||
$("#entityform textarea").first().focus();
|
||||
$('#entityform input').first().focus();
|
||||
|
||||
calculateAnnualPercentageRate();
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
@@ -389,7 +391,7 @@ $(document).ready(function() {
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var tab_counter = 1;
|
||||
var $newtabs = $("#newtabs").tabs({
|
||||
@@ -410,6 +412,9 @@ $(document).ready(function() {
|
||||
$(anchor.hash).html("error occured while ajax loading.");
|
||||
},
|
||||
success: function(data, status, xhr) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
var currentTabIndex = $newtabs.tabs('option', 'selected');
|
||||
var currentTabAnchor = $newtabs.data('tabs').anchors[currentTabIndex];
|
||||
//$(currentTabAnchor).data('cache.tabs', true)
|
||||
@@ -421,12 +426,20 @@ $(document).ready(function() {
|
||||
var maxOffset = 0; // today
|
||||
|
||||
if (currentTabIndex < 1) {
|
||||
console.log("success: client tab.");
|
||||
var tableHtml = $("#clientDataTabTemplate").render(data);
|
||||
$("#clienttab").html(tableHtml);
|
||||
|
||||
$("#clienttabname").html(data.displayName);
|
||||
|
||||
// retrieve accounts summary info
|
||||
refreshLoanSummaryInfo();
|
||||
|
||||
// retrieve additional info
|
||||
var extraDataParams = {
|
||||
url: '${rootContext}',
|
||||
datasetType: "portfolio_client",
|
||||
datasetPKValue: data.clientInfo.id,
|
||||
datasetPKValue: data.id,
|
||||
datasetTypeDiv: "clientadditionaldata",
|
||||
headingPrefix: "",
|
||||
headingClass: "",
|
||||
@@ -435,6 +448,7 @@ $(document).ready(function() {
|
||||
};
|
||||
jQuery.stretchyData.displayAllExtraData(extraDataParams);
|
||||
|
||||
// bind click listeners to buttons.
|
||||
$('.casflowbtn').button().click(function(e) {
|
||||
var linkId = this.id;
|
||||
var clientId = linkId.replace("cashflowbtn", "");
|
||||
@@ -456,27 +470,23 @@ $(document).ready(function() {
|
||||
$('.addnotebtn').button().click(function(e) {
|
||||
var linkId = this.id;
|
||||
var clientId = linkId.replace("addnotebtn", "");
|
||||
var url = '${rootContext}portfolio/client/' + clientId + '/note/new';
|
||||
var getAndPostUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/' + clientId + '/notes';
|
||||
|
||||
var templateSelector = "#noteFormTemplate";
|
||||
var width = 600;
|
||||
var height = 400;
|
||||
var defaultOffset = data.clientInfo.maxJoinedOnOffsetFromToday;
|
||||
popupDialogWithFormView(url, "dialog.title.add.note", templateSelector, width, height, currentTabIndex, defaultOffset, defaultOffset, maxOffset);
|
||||
|
||||
var saveSuccessFunction = function(data, textStatus, jqXHR) {
|
||||
$("#dialog-form").dialog("close");
|
||||
refreshNoteWidget();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(getAndPostUrl, getAndPostUrl, 'POST', "dialog.title.add.note", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
$('button.addnotebtn span').text(jQuery.i18n.prop('dialog.button.add.note'));
|
||||
|
||||
$("a.openloanaccount").click( function(e) {
|
||||
var tab_title = $(this).attr('title');
|
||||
var tab_href = this.href;
|
||||
|
||||
$newtabs.tabs( "add", tab_href, tab_title );
|
||||
tab_counter++;
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
refreshNoteWidget();
|
||||
|
||||
refreshNoteWidget();
|
||||
|
||||
} else {
|
||||
|
||||
@@ -654,22 +664,52 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
// function to retrieve and display loan summary information in it placeholder
|
||||
function refreshLoanSummaryInfo() {
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/loans',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
var tableHtml = $("#clientAccountSummariesTemplate").render(data);
|
||||
$("#clientaccountssummary").html(tableHtml);
|
||||
|
||||
$("a.openloanaccount").click( function(e) {
|
||||
var tab_title = $(this).attr('title');
|
||||
var tab_href = this.href;
|
||||
|
||||
$newtabs.tabs( "add", tab_href, tab_title );
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
}
|
||||
|
||||
function refreshNoteWidget() {
|
||||
|
||||
var noteArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: '${allClientNotesUrl}',
|
||||
url: 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/notes',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
|
||||
var noteParent = new Object();
|
||||
noteParent.title = jQuery.i18n.prop('widget.notes.heading');
|
||||
noteParent.items = data;
|
||||
noteParent.items = data.notes;
|
||||
|
||||
var tableHtml = $("#noteListViewTemplate").render(noteParent);
|
||||
$("#clienttabrightpane").html(tableHtml);
|
||||
@@ -677,14 +717,17 @@ $(document).ready(function() {
|
||||
$('.editclientnote').click(function(e) {
|
||||
var linkId = this.id;
|
||||
var noteId = linkId.replace("editclientnotelink", "");
|
||||
var url = '${rootContext}portfolio/client/${clientId}/note/' + noteId;
|
||||
var getAndPutUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/notes/' + noteId;
|
||||
var templateSelector = "#noteFormTemplate";
|
||||
var width = 600;
|
||||
var height = 400;
|
||||
var defaultOffset = -400; // would be nice to return the max allowed offset for date for client note
|
||||
var maxOffset = 0;
|
||||
var currentTabIndex = 0;
|
||||
popupDialogWithFormView(url, "dialog.title.edit.note", templateSelector, width, height, currentTabIndex, defaultOffset, defaultOffset, maxOffset);
|
||||
|
||||
var saveSuccessFunction = function(data, textStatus, jqXHR) {
|
||||
$("#dialog-form").dialog("close");
|
||||
refreshNoteWidget();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(getAndPutUrl, getAndPutUrl, 'PUT', "dialog.title.edit.note", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
@@ -730,7 +773,7 @@ $(document).ready(function() {
|
||||
|
||||
<div id="newtabs">
|
||||
<ul>
|
||||
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}" title="clienttab" class="topleveltab">${clientDisplayName}</a></li>
|
||||
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}" title="clienttab" class="topleveltab"><span id="clienttabname">Loading...</span></a></li>
|
||||
</ul>
|
||||
<div id="clienttab">
|
||||
</div>
|
||||
|
||||
@@ -13,96 +13,72 @@
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
// these helpers are registered for the jsViews and jsRender functionality to fix bug with display zero!
|
||||
$.views.registerHelpers({
|
||||
|
||||
money: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "n" + digits);
|
||||
},
|
||||
moneyWithCurrency: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "c" + digits);
|
||||
},
|
||||
decimal: function(number, digits) {
|
||||
try {
|
||||
return number.toFixed(digits);
|
||||
} catch(e) {
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
number: function(number) {
|
||||
try {
|
||||
return number.toFixed(0);
|
||||
} catch(e) {
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
numberGreaterThanZero: function(number) {
|
||||
money: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "n" + digits);
|
||||
},
|
||||
moneyWithCurrency: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "c" + digits);
|
||||
},
|
||||
decimal: function(number, digits) {
|
||||
try {
|
||||
var num = number.toFixed(0);
|
||||
return num > 0;
|
||||
return Globalize.format(number, "n" + digits);
|
||||
} catch(e) {
|
||||
return false;
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
json: function(obj) {
|
||||
number: function(number) {
|
||||
try {
|
||||
return JSON.stringify(obj);
|
||||
return Globalize.format(number, "n0");
|
||||
} catch(e) {
|
||||
return "" + e;
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
globalDate: function(dateParts) {
|
||||
try {
|
||||
|
||||
var year = dateParts[0];
|
||||
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||
var day = dateParts[2];
|
||||
|
||||
var d = new Date();
|
||||
d.setFullYear(year,month,day);
|
||||
|
||||
return Globalize.format(d,"dd MMMM yyyy");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
},
|
||||
globalDateTime: function(dateParts) {
|
||||
try {
|
||||
var d = new Date(dateParts);
|
||||
|
||||
return Globalize.format(d,"F");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
numberGreaterThanZero: function(number) {
|
||||
try {
|
||||
var num = number.toFixed(0);
|
||||
return num > 0;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
globalDate: function(localDateAsISOString) {
|
||||
try {
|
||||
var dateParts = localDateAsISOString.split("-")
|
||||
var year = dateParts[0];
|
||||
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||
var day = dateParts[2];
|
||||
|
||||
var d = new Date();
|
||||
d.setFullYear(year,month,day);
|
||||
|
||||
return Globalize.format(d,"dd MMMM yyyy");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
},
|
||||
globalDateTime: function(dateInMillis) {
|
||||
try {
|
||||
var d = new Date(dateInMillis);
|
||||
|
||||
return Globalize.format(d,"F");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector, placeholderDiv) {
|
||||
if (jqXHR.status === 0) {
|
||||
alert('No connection. Verify application is running.');
|
||||
} else if (jqXHR.status == 401) {
|
||||
alert('Unauthorized. [401]');
|
||||
} else if (jqXHR.status == 404) {
|
||||
alert('Requested page not found. [404]');
|
||||
} else if (jqXHR.status == 405) {
|
||||
alert('HTTP verb not supported [405]: ' + errorThrown);
|
||||
} else if (jqXHR.status == 500) {
|
||||
alert('Internal Server Error [500].');
|
||||
} else if (errorThrown === 'parsererror') {
|
||||
alert('Requested JSON parse failed.');
|
||||
} else if (errorThrown === 'timeout') {
|
||||
alert('Time out error.');
|
||||
} else if (errorThrown === 'abort') {
|
||||
alert('Ajax request aborted.');
|
||||
} else {
|
||||
|
||||
function removeErrors(placeholderDiv) {
|
||||
// remove error class from all input fields
|
||||
var $inputs = $('#entityform :input');
|
||||
|
||||
@@ -111,102 +87,196 @@ function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector, placeh
|
||||
});
|
||||
|
||||
$(placeholderDiv).html("");
|
||||
|
||||
var jsonErrors = JSON.parse(jqXHR.responseText);
|
||||
|
||||
var errorArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
$.each(jsonErrors, function() {
|
||||
var fieldId = '#' + this.field;
|
||||
$(fieldId).addClass("ui-state-error");
|
||||
|
||||
var errorObj = new Object();
|
||||
errorObj.field = this.field;
|
||||
errorObj.code = this.code;
|
||||
errorObj.message = jQuery.i18n.prop(this.code, this.args);
|
||||
errorObj.value = this.value;
|
||||
|
||||
errorArray[arrayIndex] = errorObj;
|
||||
arrayIndex++
|
||||
});
|
||||
|
||||
var templateArray = new Array();
|
||||
var templateErrorObj = new Object();
|
||||
templateErrorObj.title = "You have the following errors:";
|
||||
templateErrorObj.errors = errorArray;
|
||||
|
||||
templateArray[0] = templateErrorObj;
|
||||
|
||||
var formErrorsHtml = $(templateSelector).render(templateArray);
|
||||
|
||||
$(placeholderDiv).append(formErrorsHtml);
|
||||
}
|
||||
}
|
||||
|
||||
function popupDialogWithFormView(url, titleCode, templateSelector, width, height, successFunction) {
|
||||
var dialogDiv = $("<div id='dialog-form'></div>");
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector, placeholderDiv) {
|
||||
if (jqXHR.status === 0) {
|
||||
alert('No connection. Verify application is running.');
|
||||
} else if (jqXHR.status == 401) {
|
||||
alert('Unauthorized. [401]');
|
||||
} else if (jqXHR.status == 404) {
|
||||
alert('Requested page not found. [404]');
|
||||
} else if (jqXHR.status == 405) {
|
||||
alert('HTTP verb not supported [405]: ' + errorThrown);
|
||||
} else if (jqXHR.status == 500) {
|
||||
alert('Internal Server Error [500].');
|
||||
} else if (errorThrown === 'parsererror') {
|
||||
alert('Requested JSON parse failed.');
|
||||
} else if (errorThrown === 'timeout') {
|
||||
alert('Time out error.');
|
||||
} else if (errorThrown === 'abort') {
|
||||
alert('Ajax request aborted.');
|
||||
} else {
|
||||
|
||||
var formHtml = $(templateSelector).render(data);
|
||||
removeErrors(placeholderDiv);
|
||||
|
||||
dialogDiv.append(formHtml);
|
||||
|
||||
var saveButton = jQuery.i18n.prop('dialog.button.save');
|
||||
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[saveButton] = function() {
|
||||
$('.multiSelectedItems option').each(function(i) {
|
||||
var jsonErrors = JSON.parse(jqXHR.responseText);
|
||||
console.log(jsonErrors);
|
||||
var valErrors = jsonErrors.errors;
|
||||
console.log(valErrors);
|
||||
var errorArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
$.each(valErrors, function() {
|
||||
var fieldId = '#' + this.parameterName;
|
||||
$(fieldId).addClass("ui-state-error");
|
||||
|
||||
var errorObj = new Object();
|
||||
errorObj.field = this.parameterName;
|
||||
errorObj.code = this.userMessageGlobalisationCode;
|
||||
|
||||
var argArray = new Array();
|
||||
var argArrayIndex = 0;
|
||||
$.each(this.args, function() {
|
||||
argArray[argArrayIndex] = this.value;
|
||||
argArrayIndex++;
|
||||
});
|
||||
console.log(argArray);
|
||||
// hardcoded support for six arguments
|
||||
errorObj.message = jQuery.i18n.prop(this.userMessageGlobalisationCode, argArray[0], argArray[1], argArray[2], argArray[3], argArray[4], argArray[5]);
|
||||
errorObj.value = this.value;
|
||||
|
||||
errorArray[arrayIndex] = errorObj;
|
||||
arrayIndex++
|
||||
});
|
||||
|
||||
var templateArray = new Array();
|
||||
var templateErrorObj = new Object();
|
||||
templateErrorObj.title = jQuery.i18n.prop('error.msg.header');
|
||||
templateErrorObj.errors = errorArray;
|
||||
|
||||
templateArray[0] = templateErrorObj;
|
||||
|
||||
var formErrorsHtml = $(templateSelector).render(templateArray);
|
||||
|
||||
$(placeholderDiv).append(formErrorsHtml);
|
||||
}
|
||||
}
|
||||
|
||||
function showNotAvailableDialog(titleCode) {
|
||||
var dialogDiv = $("<div id='notavailable-dialog-form'></div>");
|
||||
|
||||
dialogDiv.append("<p>" + jQuery.i18n.prop('dialog.messages.functionality.not.available') + "</p>");
|
||||
|
||||
var okButton = jQuery.i18n.prop('dialog.button.ok');
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[okButton] = function() {$(this).dialog("close");};
|
||||
|
||||
dialogDiv.dialog({
|
||||
title: jQuery.i18n.prop(titleCode),
|
||||
width: 300,
|
||||
height: 200,
|
||||
modal: true,
|
||||
buttons: buttonsOpts,
|
||||
close: function() {
|
||||
// if i dont do this, theres a problem with errors being appended to dialog view second time round
|
||||
$(this).remove();
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
|
||||
$.fn.serializeObject = function()
|
||||
{
|
||||
var o = {};
|
||||
var a = this.serializeArray();
|
||||
$.each(a, function() {
|
||||
if (o[this.name] !== undefined) {
|
||||
if (!o[this.name].push) {
|
||||
o[this.name] = [o[this.name]];
|
||||
}
|
||||
o[this.name].push(this.value || '');
|
||||
} else {
|
||||
|
||||
if (this.name === 'selectedItems' || this.name === 'notSelectedItems') {
|
||||
o[this.name] = new Array();
|
||||
o[this.name].push(this.value || '');
|
||||
} else {
|
||||
o[this.name] = this.value || '';
|
||||
}
|
||||
}
|
||||
});
|
||||
return o;
|
||||
};
|
||||
|
||||
function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
|
||||
var dialogDiv = $("<div id='dialog-form'></div>");
|
||||
var jqxhr = $.ajax({
|
||||
url: getUrl,
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
var formHtml = $(templateSelector).render(data);
|
||||
|
||||
dialogDiv.append(formHtml);
|
||||
|
||||
var saveButton = jQuery.i18n.prop('dialog.button.save');
|
||||
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[saveButton] = function() {
|
||||
|
||||
$('#notSelectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
$('#selectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
var form_data = $('#entityform').serialize();
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: form_data,
|
||||
success: successFunction,
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
|
||||
|
||||
dialogDiv.dialog({
|
||||
title: jQuery.i18n.prop(titleCode),
|
||||
width: width,
|
||||
height: height,
|
||||
modal: true,
|
||||
buttons: buttonsOpts,
|
||||
close: function() {
|
||||
// if i dont do this, theres a problem with errors being appended to dialog view second time round
|
||||
$(this).remove();
|
||||
},
|
||||
open: function (event, ui) {
|
||||
$('.multiadd').click(function() {
|
||||
return !$('.multiNotSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
});
|
||||
|
||||
$('.multiremove').click(function() {
|
||||
return !$('.multiSelectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
});
|
||||
|
||||
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: postUrl,
|
||||
type: submitType,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: newFormData,
|
||||
success: saveSuccessFunction,
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
|
||||
|
||||
dialogDiv.dialog({
|
||||
title: jQuery.i18n.prop(titleCode),
|
||||
width: width,
|
||||
height: height,
|
||||
modal: true,
|
||||
buttons: buttonsOpts,
|
||||
close: function() {
|
||||
// if i dont do this, theres a problem with errors being appended to dialog view second time round
|
||||
$(this).remove();
|
||||
},
|
||||
open: function (event, ui) {
|
||||
|
||||
$('#add').click(function() {
|
||||
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
});
|
||||
|
||||
$('#remove').click(function() {
|
||||
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
});
|
||||
|
||||
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
|
||||
|
||||
$("#entityform textarea").first().focus();
|
||||
$('#entityform input').first().focus();
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
});
|
||||
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
}
|
||||
|
||||
$("#tabs").tabs({
|
||||
"ajaxOptions": {
|
||||
@@ -234,13 +304,13 @@ function popupDialogWithFormView(url, titleCode, templateSelector, width, height
|
||||
}
|
||||
|
||||
$("#addclient").button().click(function(e) {
|
||||
|
||||
var url = '${rootContext}portfolio/client/new';
|
||||
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/template';
|
||||
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients';
|
||||
var templateSelector = "#clientFormTemplate";
|
||||
var width = 600;
|
||||
var height = 350;
|
||||
|
||||
popupDialogWithFormView(url, 'dialog.title.add.client', templateSelector, width, height, addClientSuccessFunction);
|
||||
popupDialogWithFormView(getUrl, postUrl, 'POST', 'dialog.title.add.client', templateSelector, width, height, addClientSuccessFunction);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
@@ -253,9 +323,6 @@ function popupDialogWithFormView(url, titleCode, templateSelector, width, height
|
||||
<div id="container">
|
||||
<jsp:include page="top-navigation.jsp" />
|
||||
|
||||
<c:url value="/portfolio/client/all" var="allClientsUrl" />
|
||||
<c:url value="/portfolio/client/add" var="addClientUrl" />
|
||||
|
||||
<div style="float:none; clear:both;">
|
||||
<div id="spacer" style="line-height: 15px;"> </div>
|
||||
<div id="content">
|
||||
@@ -264,7 +331,7 @@ function popupDialogWithFormView(url, titleCode, templateSelector, width, height
|
||||
</sec:authorize>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="${allClientsUrl}" title="searchtab"><spring:message code="tab.search"/></a></li>
|
||||
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients" title="searchtab"><spring:message code="tab.search"/></a></li>
|
||||
</ul>
|
||||
<div id="searchtab"></div>
|
||||
</div>
|
||||
|
||||
@@ -325,7 +325,7 @@
|
||||
<form id="entityform">
|
||||
<div id="formerrors"></div>
|
||||
<label for="office"><spring:message code="label.office"/></label>
|
||||
<select id="office" name="office" title="">
|
||||
<select id="officeId" name="officeId" title="">
|
||||
<option value=""><spring:message code="option.office.first.choice"/></option>
|
||||
{{#each allowedOffices}}
|
||||
{{#if $ctx.number($parent.parent.data.officeId)===$ctx.number(id)}}
|
||||
@@ -355,43 +355,13 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<label for="joiningDate"><spring:message code="label.joiningdate"/></label>
|
||||
<input id="joiningDate" name="joiningDate" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(joinedDate)}}"/>
|
||||
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
||||
<label for="joiningDateFormatted"><spring:message code="label.joiningdate"/></label>
|
||||
<input id="joiningDateFormatted" name="joiningDateFormatted" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(joinedDate)}}"/>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<script id="clientDataTabTemplate" type="text/x-jquery-tmpl">
|
||||
<c:url value="/" var="rootContext" />
|
||||
|
||||
<span id="toolbar" class="ui-widget-header ui-corner-all">
|
||||
<!--
|
||||
<button id="cashflowbtn{{=clientInfo.id}}" class="casflowbtn">New cashflow analysis</button>
|
||||
-->
|
||||
<sec:authorize access="hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE', 'CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE')">
|
||||
<button id="newloanbtn{{=clientInfo.id}}" class="newloanbtn">New loan application</button>
|
||||
</sec:authorize>
|
||||
|
||||
<button id="addnotebtn{{=clientInfo.id}}" class="addnotebtn">Add note</button>
|
||||
</span>
|
||||
<hr/>
|
||||
|
||||
<div id="clienttabcontent">
|
||||
<div id="clienttableftpane" style="float:left; max-width: 700px; width: 700px;">
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.name"/></span>
|
||||
<span class="rowvalue">{{=clientInfo.displayName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.branch"/></span>
|
||||
<span class="rowvalue">{{=clientInfo.officeName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.joinedon"/></span>
|
||||
<span class="rowvalue">{{=$ctx.globalDate(clientInfo.joinedDate)}}</span>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<p><b><spring:message code="heading.client.account.account.overview"/></b></p>
|
||||
<script id="clientAccountSummariesTemplate" type="text/x-jquery-tmpl">
|
||||
{{#if $ctx.numberGreaterThanZero(anyLoanCount)}}
|
||||
|
||||
{{#if $ctx.numberGreaterThanZero(pendingApprovalLoanCount)}}
|
||||
@@ -399,7 +369,7 @@
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.pending.approval.loans"/> ({{=$ctx.number(pendingApprovalLoanCount)}}):</span>
|
||||
<span class="rowvalue">
|
||||
{{#each pendingApprovalLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -410,7 +380,7 @@
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.pending.disbursal.loans"/> ({{=$ctx.number(awaitingDisbursalLoanCount)}}):</span>
|
||||
<span class="rowvalue">
|
||||
{{#each awaitingDisbursalLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -421,7 +391,7 @@
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.active.loans"/> ({{=$ctx.number(activeLoanCount)}}):</span>
|
||||
<span class="rowvalue">
|
||||
{{#each openLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -432,7 +402,7 @@
|
||||
<div class="longrowlabel"><spring:message code="label.client.account.closed.loans"/> ({{=$ctx.number(closedLoanCount)}}):</div>
|
||||
<div class="rowvalue">
|
||||
{{#each closedLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -443,14 +413,45 @@
|
||||
<spring:message code="label.client.account.no.loans.exist"/>
|
||||
</div>
|
||||
{{/if}}
|
||||
</script>
|
||||
|
||||
<div id="clientadditionaldata"></div>
|
||||
</div>
|
||||
<!-- end of left pane content -->
|
||||
<script id="clientDataTabTemplate" type="text/x-jquery-tmpl">
|
||||
<span id="toolbar" class="ui-widget-header ui-corner-all">
|
||||
<!--
|
||||
<button id="cashflowbtn{{=id}}" class="casflowbtn">New cashflow analysis</button>
|
||||
-->
|
||||
<sec:authorize access="hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE', 'CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE')">
|
||||
<button id="newloanbtn{{=id}}" class="newloanbtn">New loan application</button>
|
||||
</sec:authorize>
|
||||
|
||||
<div id="clienttabrightpane" style="float:right;">
|
||||
</div>
|
||||
<button id="addnotebtn{{=id}}" class="addnotebtn">Add note</button>
|
||||
</span>
|
||||
<hr/>
|
||||
|
||||
<div id="clienttabcontent">
|
||||
<div id="clienttableftpane" style="float:left; max-width: 700px; width: 700px;">
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.name"/></span>
|
||||
<span class="rowvalue">{{=displayName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.branch"/></span>
|
||||
<span class="rowvalue">{{=officeName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.joinedon"/></span>
|
||||
<span class="rowvalue">{{=$ctx.globalDate(joinedDate)}}</span>
|
||||
</div>
|
||||
|
||||
<p><b><spring:message code="heading.client.account.account.overview"/></b></p>
|
||||
<div id="clientaccountssummary"></div>
|
||||
|
||||
<div id="clientadditionaldata"></div>
|
||||
</div>
|
||||
<!-- end of left pane content -->
|
||||
|
||||
<!-- placeholder for notes content -->
|
||||
<div id="clienttabrightpane" style="float:right;"></div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</script>
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.platform.exceptions.NewDataValidationException;
|
||||
|
||||
public class EnrollClientCommandValidator {
|
||||
|
||||
private final EnrollClientCommand command;
|
||||
|
||||
public EnrollClientCommandValidator(EnrollClientCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
List<ErrorResponse> dataValidationErrors = new ArrayList<ErrorResponse>();
|
||||
|
||||
if (command.getOfficeId() == null || command.getOfficeId().equals(Long.valueOf(-1))) {
|
||||
ErrorResponse error = new ErrorResponse("validation.msg.client.office.cannot.be.blank", "officeId");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getFullname()) && (StringUtils.isNotBlank(command.getFirstname()) || StringUtils.isNotBlank(command.getLastname()))) {
|
||||
ErrorResponse error = new ErrorResponse("validation.msg.client.fullname.cannot.entered.when.firstname.or.lastname.entered", "fullname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(command.getFirstname()) && StringUtils.isBlank(command.getLastname()) ) {
|
||||
|
||||
if (StringUtils.isBlank(command.getFullname())) {
|
||||
ErrorResponse error = new ErrorResponse("validation.msg.client.fullname.must.be.provide.or.firstname.lastname", "fullname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isBlank(command.getFirstname())) {
|
||||
ErrorResponse error = new ErrorResponse("validation.msg.client.firstname.cannot.be.blank", "firstname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(command.getLastname())) {
|
||||
ErrorResponse error = new ErrorResponse("validation.msg.client.lastname.cannot.be.blank", "lastname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
|
||||
if (command.getJoiningDate() == null) {
|
||||
ErrorResponse error = new ErrorResponse("validation.msg.client.joining.date.cannot.be.blank", "joiningDate");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new NewDataValidationException(dataValidationErrors, "Data validation erros exist.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,20 +2,15 @@ package org.mifosng.platform;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientDataWithAccountsData;
|
||||
import org.mifosng.data.LoanAccountData;
|
||||
import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.OrganisationReadModel;
|
||||
|
||||
public interface ReadPlatformService {
|
||||
|
||||
Collection<OrganisationReadModel> retrieveAll();
|
||||
|
||||
ClientDataWithAccountsData retrieveClientAccountDetails(Long clientId);
|
||||
|
||||
NewLoanWorkflowStepOneData retrieveClientAndProductDetails(Long clientId, Long productId);
|
||||
|
||||
LoanAccountData retrieveLoanAccountDetails(Long loanId);
|
||||
@@ -25,11 +20,4 @@ public interface ReadPlatformService {
|
||||
LoanRepaymentData retrieveNewLoanWaiverDetails(Long loanId);
|
||||
|
||||
LoanRepaymentData retrieveLoanRepaymentDetails(Long loanId, Long repaymentId);
|
||||
|
||||
ClientData retrieveNewClientDetails();
|
||||
|
||||
Collection<NoteData> retrieveAllClientNotes(Long clientId);
|
||||
|
||||
NoteData retrieveClientNote(Long clientId, Long noteId);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import static org.mifosng.platform.Specifications.clientsThatMatch;
|
||||
import static org.mifosng.platform.Specifications.loanTransactionsThatMatch;
|
||||
import static org.mifosng.platform.Specifications.loansThatMatch;
|
||||
|
||||
@@ -8,16 +7,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientDataWithAccountsData;
|
||||
import org.mifosng.data.CurrencyData;
|
||||
import org.mifosng.data.DerivedLoanData;
|
||||
import org.mifosng.data.LoanAccountData;
|
||||
@@ -25,16 +19,12 @@ import org.mifosng.data.LoanProductData;
|
||||
import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.MoneyData;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.OfficeData;
|
||||
import org.mifosng.data.OrganisationReadModel;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrency;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrencyRepository;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
import org.mifosng.platform.exceptions.PlatformResourceNotFoundException;
|
||||
import org.mifosng.platform.exceptions.UnAuthenticatedUserException;
|
||||
import org.mifosng.platform.loan.domain.Loan;
|
||||
import org.mifosng.platform.loan.domain.LoanRepository;
|
||||
@@ -44,7 +34,6 @@ import org.mifosng.platform.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.mifosng.platform.user.domain.AppUser;
|
||||
import org.mifosng.platform.user.service.AppUserReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.security.core.Authentication;
|
||||
@@ -127,189 +116,6 @@ public class ReadPlatformServiceImpl implements ReadPlatformService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoteData retrieveClientNote(Long clientId, Long noteId) {
|
||||
|
||||
try {
|
||||
AppUser currentUser = extractAuthenticatedUser();
|
||||
|
||||
Collection<AppUserData> allUsers = this.appUserReadPlatformService.retrieveAllUsers();
|
||||
|
||||
NoteMapper noteMapper = new NoteMapper(allUsers);
|
||||
|
||||
String sql = "select " + noteMapper.schema()
|
||||
+ " where n.org_id = ? and n.client_id = ? and n.id = ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, noteMapper,
|
||||
new Object[] { currentUser.getOrganisation().getId(),
|
||||
clientId, noteId });
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new PlatformResourceNotFoundException(
|
||||
"error.msg.client.id.invalid",
|
||||
"Client with identifier {0} does not exist", clientId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<NoteData> retrieveAllClientNotes(Long clientId) {
|
||||
|
||||
AppUser currentUser = extractAuthenticatedUser();
|
||||
|
||||
Collection<AppUserData> allUsers = this.appUserReadPlatformService.retrieveAllUsers();
|
||||
|
||||
NoteMapper noteMapper = new NoteMapper(allUsers);
|
||||
|
||||
String sql = "select "
|
||||
+ noteMapper.schema()
|
||||
+ " where n.org_id = ? and n.client_id = ? order by n.created_date DESC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, noteMapper, new Object[] {
|
||||
currentUser.getOrganisation().getId(), clientId });
|
||||
}
|
||||
|
||||
protected static final class NoteMapper implements RowMapper<NoteData> {
|
||||
|
||||
private final Collection<AppUserData> allUsers;
|
||||
|
||||
public NoteMapper(Collection<AppUserData> allUsers) {
|
||||
this.allUsers = allUsers;
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return "n.id as id, n.client_id as clientId, n.loan_id as loanId, n.loan_transaction_id as transactionId, n.note_type_enum as noteTypeEnum, n.note as note, "
|
||||
+ "n.created_date as createdDate, n.createdby_id as createdById, n.lastmodified_date as lastModifiedDate, n.lastmodifiedby_id as lastModifiedById"
|
||||
+ " from portfolio_note n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoteData mapRow(final ResultSet rs, final int rowNum)
|
||||
throws SQLException {
|
||||
|
||||
Long id = rs.getLong("id");
|
||||
Long clientId = rs.getLong("clientId");
|
||||
Long loanId = rs.getLong("loanId");
|
||||
Long transactionId = rs.getLong("transactionId");
|
||||
Integer noteTypeId = rs.getInt("noteTypeEnum");
|
||||
String note = rs.getString("note");
|
||||
|
||||
DateTime createdDate = new DateTime(rs.getTimestamp("createdDate"));
|
||||
Long createdById = rs.getLong("createdById");
|
||||
String createdByUsername = findUserById(createdById, allUsers);
|
||||
|
||||
DateTime lastModifiedDate = new DateTime(
|
||||
rs.getTimestamp("lastModifiedDate"));
|
||||
Long lastModifiedById = rs.getLong("lastModifiedById");
|
||||
String updatedByUsername = findUserById(createdById, allUsers);
|
||||
|
||||
return new NoteData(id, clientId, loanId, transactionId,
|
||||
noteTypeId, note, createdDate, createdById,
|
||||
createdByUsername, lastModifiedDate, lastModifiedById,
|
||||
updatedByUsername);
|
||||
}
|
||||
|
||||
private String findUserById(Long createdById,
|
||||
Collection<AppUserData> allUsers) {
|
||||
String username = "";
|
||||
for (AppUserData appUserData : allUsers) {
|
||||
if (appUserData.getId().equals(createdById)) {
|
||||
username = appUserData.getUsername();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return username;
|
||||
}
|
||||
}
|
||||
|
||||
private List<OfficeData> retrieveOffices() {
|
||||
|
||||
AppUser currentUser = extractAuthenticatedUser();
|
||||
|
||||
String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
String hierarchySearchString = hierarchy + "%";
|
||||
|
||||
OfficeMapper rm = new OfficeMapper();
|
||||
String sql = "select "
|
||||
+ rm.officeSchema()
|
||||
+ "where o.org_id = ? and o.hierarchy like ? order by o.hierarchy";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {
|
||||
currentUser.getOrganisation().getId(), hierarchySearchString });
|
||||
}
|
||||
|
||||
protected static final class OfficeMapper implements RowMapper<OfficeData> {
|
||||
|
||||
public String officeSchema() {
|
||||
return " o.id as id, o.name as name, o.external_id as externalId, o.opening_date as openingDate, o.hierarchy as hierarchy, parent.id as parentId, parent.name as parentName "
|
||||
+ "from org_office o LEFT JOIN org_office AS parent ON parent.id = o.parent_id ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeData mapRow(final ResultSet rs, final int rowNum)
|
||||
throws SQLException {
|
||||
|
||||
Long id = rs.getLong("id");
|
||||
String name = rs.getString("name");
|
||||
String externalId = rs.getString("externalId");
|
||||
LocalDate openingDate = new LocalDate(rs.getDate("openingDate"));
|
||||
String hierarchy = rs.getString("hierarchy");
|
||||
Long parentId = rs.getLong("parentId");
|
||||
String parentName = rs.getString("parentName");
|
||||
|
||||
return new OfficeData(id, name, externalId, openingDate, hierarchy,
|
||||
parentId, parentName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientDataWithAccountsData retrieveClientAccountDetails(
|
||||
final Long clientId) {
|
||||
|
||||
AppUser currentUser = extractAuthenticatedUser();
|
||||
|
||||
ClientData clientAccount = this.clientReadPlatformService.retrieveIndividualClient(clientId);
|
||||
|
||||
// TODO - rewrite using jdbc sql approach
|
||||
Client client = this.clientRepository.findOne(clientsThatMatch(
|
||||
currentUser.getOrganisation(), clientId));
|
||||
|
||||
Collection<Loan> allLoans = this.loanRepository.findAll(loansThatMatch(
|
||||
currentUser.getOrganisation(), client));
|
||||
|
||||
List<LoanAccountData> pendingApprovalLoans = new ArrayList<LoanAccountData>();
|
||||
List<LoanAccountData> awaitingDisbursalLoans = new ArrayList<LoanAccountData>();
|
||||
List<LoanAccountData> openLoans = new ArrayList<LoanAccountData>();
|
||||
List<LoanAccountData> closedLoans = new ArrayList<LoanAccountData>();
|
||||
|
||||
for (Loan realLoan : allLoans) {
|
||||
|
||||
ApplicationCurrency currency = this.applicationCurrencyRepository
|
||||
.findOneByCode(realLoan.getLoanRepaymentScheduleDetail()
|
||||
.getPrincipal().getCurrencyCode());
|
||||
|
||||
CurrencyData currencyData = new CurrencyData(currency.getCode(),
|
||||
currency.getName(), currency.getDecimalPlaces(),
|
||||
currency.getDisplaySymbol(), currency.getNameCode());
|
||||
|
||||
LoanAccountData loan = convertToData(realLoan, currencyData);
|
||||
|
||||
if (loan.isClosed() || loan.isInterestRebateOutstanding()) {
|
||||
closedLoans.add(loan);
|
||||
} else if (loan.isPendingApproval()) {
|
||||
pendingApprovalLoans.add(loan);
|
||||
} else if (loan.isWaitingForDisbursal()) {
|
||||
awaitingDisbursalLoans.add(loan);
|
||||
} else if (loan.isOpen()) {
|
||||
openLoans.add(loan);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(closedLoans, new ClosedLoanComparator());
|
||||
|
||||
return new ClientDataWithAccountsData(clientAccount,
|
||||
pendingApprovalLoans, awaitingDisbursalLoans, openLoans,
|
||||
closedLoans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanRepaymentData retrieveNewLoanRepaymentDetails(Long loanId) {
|
||||
|
||||
@@ -562,25 +368,4 @@ public class ReadPlatformServiceImpl implements ReadPlatformService {
|
||||
.getRepaymentPeriodFrequencyType().toString(),
|
||||
tolerance, loanData, waiveAllowed, interestRebateOwed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientData retrieveNewClientDetails() {
|
||||
|
||||
AppUser currentUser = extractAuthenticatedUser();
|
||||
|
||||
List<OfficeData> offices = retrieveOffices();
|
||||
|
||||
ClientData clientData = new ClientData();
|
||||
clientData.setOfficeId(currentUser.getOffice().getId());
|
||||
clientData.setOrganisationId(currentUser.getOrganisation().getId());
|
||||
clientData.setAllowedOffices(offices);
|
||||
|
||||
clientData.setDisplayName("");
|
||||
clientData.setFirstname("");
|
||||
clientData.setLastname("");
|
||||
clientData.setId(Long.valueOf(-1));
|
||||
clientData.setJoinedDate(new LocalDate());
|
||||
|
||||
return clientData;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,8 @@ package org.mifosng.platform;
|
||||
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
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;
|
||||
@@ -16,9 +14,6 @@ public interface WritePlatformService {
|
||||
|
||||
void updateUsernamePasswordOnFirstTimeLogin(UpdateUsernamePasswordCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_ENROLL_NEW_CLIENT_ROLE')")
|
||||
Long enrollClient(EnrollClientCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_DELETE_LOAN_THAT_IS_SUBMITTED_AND_NOT_APPROVED')")
|
||||
EntityIdentifier deleteLoan(Long loanId);
|
||||
|
||||
@@ -49,8 +44,4 @@ public interface WritePlatformService {
|
||||
EntityIdentifier adjustLoanTransaction(AdjustLoanTransactionCommand command);
|
||||
|
||||
EntityIdentifier waiveLoanAmount(LoanTransactionCommand command);
|
||||
|
||||
EntityIdentifier addClientNote(NoteCommand command);
|
||||
|
||||
EntityIdentifier updateNote(NoteCommand command);
|
||||
}
|
||||
-60
@@ -1,7 +1,6 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import static org.mifosng.platform.Specifications.loansThatMatch;
|
||||
import static org.mifosng.platform.Specifications.officesThatMatch;
|
||||
import static org.mifosng.platform.Specifications.usersThatMatch;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -18,10 +17,8 @@ import org.mifosng.data.MoneyData;
|
||||
import org.mifosng.data.ScheduledLoanInstallment;
|
||||
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;
|
||||
@@ -56,8 +53,6 @@ import org.mifosng.platform.loan.domain.LoanStatusRepository;
|
||||
import org.mifosng.platform.loan.domain.LoanTransaction;
|
||||
import org.mifosng.platform.loan.domain.LoanTransactionRepository;
|
||||
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
import org.mifosng.platform.organisation.domain.OfficeRepository;
|
||||
import org.mifosng.platform.user.domain.AppUser;
|
||||
import org.mifosng.platform.user.domain.AppUserRepository;
|
||||
import org.mifosng.platform.user.domain.PlatformUserRepository;
|
||||
@@ -72,7 +67,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
public class WritePlatformServiceJpaRepositoryImpl implements WritePlatformService {
|
||||
|
||||
private final OfficeRepository officeRepository;
|
||||
private final PlatformUserRepository platformUserRepository;
|
||||
private final PlatformPasswordEncoder platformPasswordEncoder;
|
||||
private final ClientRepository clientRepository;
|
||||
@@ -85,7 +79,6 @@ public class WritePlatformServiceJpaRepositoryImpl implements WritePlatformServi
|
||||
|
||||
@Autowired
|
||||
public WritePlatformServiceJpaRepositoryImpl(
|
||||
final OfficeRepository officeRepository,
|
||||
final PlatformUserRepository platformUserRepository,
|
||||
final PlatformPasswordEncoder platformPasswordEncoder,
|
||||
final ClientRepository clientRepository,
|
||||
@@ -96,7 +89,6 @@ public class WritePlatformServiceJpaRepositoryImpl implements WritePlatformServi
|
||||
final LoanStatusRepository loanStatusRepository,
|
||||
final CalculationPlatformService calculationPlatformService
|
||||
) {
|
||||
this.officeRepository = officeRepository;
|
||||
this.platformUserRepository = platformUserRepository;
|
||||
this.platformPasswordEncoder = platformPasswordEncoder;
|
||||
this.clientRepository = clientRepository;
|
||||
@@ -136,32 +128,6 @@ public class WritePlatformServiceJpaRepositoryImpl implements WritePlatformServi
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Long enrollClient(final EnrollClientCommand command) {
|
||||
|
||||
AppUser currentUser = extractAuthenticatedUser();
|
||||
|
||||
EnrollClientCommandValidator validator = new EnrollClientCommandValidator(command);
|
||||
validator.validate();
|
||||
|
||||
Office clientOffice = this.officeRepository.findOne(officesThatMatch(
|
||||
currentUser.getOrganisation(), command.getOfficeId()));
|
||||
|
||||
String firstname = command.getFirstname();
|
||||
String lastname = command.getLastname();
|
||||
if (StringUtils.isNotBlank(command.getFullname())) {
|
||||
lastname = command.getFullname();
|
||||
firstname = null;
|
||||
}
|
||||
|
||||
Client newClient = Client.newClient(currentUser.getOrganisation(), clientOffice, firstname, lastname, command.getJoiningDate(), command.getExternalId());
|
||||
|
||||
this.clientRepository.save(newClient);
|
||||
|
||||
return newClient.getId();
|
||||
}
|
||||
|
||||
private AppUser extractAuthenticatedUser() {
|
||||
AppUser currentUser = null;
|
||||
SecurityContext context = SecurityContextHolder.getContext();
|
||||
@@ -678,30 +644,4 @@ public class WritePlatformServiceJpaRepositoryImpl implements WritePlatformServi
|
||||
|
||||
return new EntityIdentifier(loan.getClient().getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier addClientNote(NoteCommand command) {
|
||||
|
||||
AppUser currentUser = extractAuthenticatedUser();
|
||||
|
||||
Client clientForUpdate = this.clientRepository.findOne(command.getClientId());
|
||||
|
||||
Note note = Note.clientNote(currentUser.getOrganisation(), clientForUpdate, command.getNote());
|
||||
|
||||
this.noteRepository.save(note);
|
||||
|
||||
return new EntityIdentifier(note.getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateNote(NoteCommand command) {
|
||||
|
||||
Note noteForUpdate = this.noteRepository.findOne(command.getId());
|
||||
|
||||
noteForUpdate.update(command.getNote());
|
||||
|
||||
return new EntityIdentifier(noteForUpdate.getId());
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,26 @@ import java.util.Collection;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientList;
|
||||
import org.mifosng.platform.WritePlatformService;
|
||||
import org.mifosng.data.ClientLoanAccountSummaryCollectionData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.NoteDataList;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
import org.mifosng.platform.client.service.ClientWritePlatformService;
|
||||
import org.mifosng.platform.user.domain.AppUser;
|
||||
import org.mifosng.platform.user.domain.AppUserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,7 +43,10 @@ public class ClientApiResource {
|
||||
private ClientReadPlatformService clientReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private WritePlatformService writePlatformService;
|
||||
private ClientWritePlatformService clientWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private AppUserRepository appUserRepository;
|
||||
@@ -71,77 +84,102 @@ public class ClientApiResource {
|
||||
return Response.ok().entity(clientData).build();
|
||||
}
|
||||
|
||||
// @GET
|
||||
// @Path("template")
|
||||
// @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
// @Produces({ MediaType.APPLICATION_JSON})
|
||||
// public Response newClientDetails() {
|
||||
//
|
||||
// hardcodeUserIntoSecurityContext();
|
||||
//
|
||||
// ClientData clientData = this.clientReadPlatformService.retrieveNewClientDetails();
|
||||
//
|
||||
// return Response.ok().entity(clientData).build();
|
||||
// }
|
||||
//
|
||||
// @POST
|
||||
// @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
// @Produces({ MediaType.APPLICATION_JSON })
|
||||
// public Response enrollClient(final EnrollClientCommand command) {
|
||||
//
|
||||
// hardcodeUserIntoSecurityContext();
|
||||
//
|
||||
// Long clientId = this.writePlatformService.enrollClient(command);
|
||||
//
|
||||
// return Response.ok().entity(new EntityIdentifier(clientId)).build();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @GET
|
||||
// @Path("{clientId}/withaccounts")
|
||||
// @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
// @Produces({ MediaType.APPLICATION_JSON })
|
||||
// public Response retrieveClientAccount(@PathParam("clientId") final Long clientId) {
|
||||
//
|
||||
// hardcodeUserIntoSecurityContext();
|
||||
//
|
||||
// ClientDataWithAccountsData clientAccount = this.clientReadPlatformService.retrieveClientAccountDetails(clientId);
|
||||
//
|
||||
// return Response.ok().entity(clientAccount).build();
|
||||
// }
|
||||
//
|
||||
// @POST
|
||||
// @Path("{clientId}/note/new")
|
||||
// @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
// @Produces({ MediaType.APPLICATION_JSON})
|
||||
// public Response addNewClientNote(@PathParam("clientId") final Long clientId, final NoteCommand command) {
|
||||
//
|
||||
// hardcodeUserIntoSecurityContext();
|
||||
//
|
||||
// EntityIdentifier identifier = this.writePlatformService.addClientNote(command);
|
||||
//
|
||||
// return Response.ok().entity(identifier).build();
|
||||
// }
|
||||
//
|
||||
// @GET
|
||||
// @Path("{clientId}/note/all")
|
||||
// @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
// @Produces({ MediaType.APPLICATION_JSON})
|
||||
// public Response retrieveAllClientNotes(@PathParam("clientId") final Long clientId) {
|
||||
//
|
||||
// Collection<NoteData> notes = this.clientReadPlatformService.retrieveAllClientNotes(clientId);
|
||||
//
|
||||
// return Response.ok().entity(new NoteDataList(notes)).build();
|
||||
// }
|
||||
//
|
||||
// @GET
|
||||
// @Path("{clientId}/note/{noteId}")
|
||||
// @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
// @Produces({ MediaType.APPLICATION_JSON })
|
||||
// public Response retrieveClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId) {
|
||||
//
|
||||
// NoteData note = this.clientReadPlatformService.retrieveClientNote(clientId, noteId);
|
||||
//
|
||||
// return Response.ok().entity(note).build();
|
||||
// }
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response newClientDetails() {
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService.retrieveNewClientDetails();
|
||||
|
||||
return Response.ok().entity(clientData).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response enrollClient(final EnrollClientCommand command) {
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
LocalDate joiningDate = apiDataConversionService.convertFrom(command.getJoiningDateFormatted(), "joiningDateFormatted", command.getDateFormat());
|
||||
command.setJoiningDate(joiningDate);
|
||||
|
||||
Long clientId = this.clientWritePlatformService.enrollClient(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(clientId)).build();
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/loans")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response retrieveClientAccount(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
ClientLoanAccountSummaryCollectionData clientAccount = this.clientReadPlatformService.retrieveClientAccountDetails(clientId);
|
||||
|
||||
return Response.ok().entity(clientAccount).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/notes")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response retrieveAllClientNotes(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
Collection<NoteData> notes = this.clientReadPlatformService.retrieveAllClientNotes(clientId);
|
||||
|
||||
return Response.ok().entity(new NoteDataList(notes)).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{clientId}/notes")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response addNewClientNote(@PathParam("clientId") final Long clientId, final NoteCommand command) {
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
command.setClientId(clientId);
|
||||
|
||||
EntityIdentifier identifier = this.clientWritePlatformService.addClientNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/notes/{noteId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response retrieveClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId) {
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
NoteData note = this.clientReadPlatformService.retrieveClientNote(clientId, noteId);
|
||||
|
||||
return Response.ok().entity(note).build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{clientId}/notes/{noteId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId, final NoteCommand command) {
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
command.setClientId(clientId);
|
||||
command.setId(noteId);
|
||||
|
||||
EntityIdentifier identifier = this.clientWritePlatformService.updateNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package org.mifosng.platform.api.infrastructure;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
public interface ApiDataConversionService {
|
||||
|
||||
LocalDate convertFrom(String dateAsString, String parameterName, String dateFormat);
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package org.mifosng.platform.api.infrastructure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
|
||||
@Override
|
||||
public LocalDate convertFrom(String dateAsString, String parameterName, String dateFormat) {
|
||||
LocalDate eventLocalDate = null;
|
||||
if (StringUtils.isNotBlank(dateAsString)) {
|
||||
try {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
eventLocalDate = DateTimeFormat.forPattern(dateFormat).withLocale(locale).parseLocalDate(dateAsString.toLowerCase(locale));
|
||||
} catch (IllegalArgumentException e) {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.format", "The parameter " + parameterName + " is invalid.", parameterName, dateAsString);
|
||||
dataValidationErrors.add(error);
|
||||
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
return eventLocalDate;
|
||||
}
|
||||
}
|
||||
+9
-31
@@ -1,9 +1,6 @@
|
||||
package org.mifosng.platform.api.office;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
@@ -15,22 +12,18 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.OfficeData;
|
||||
import org.mifosng.data.OfficeList;
|
||||
import org.mifosng.data.command.OfficeCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||
import org.mifosng.platform.user.domain.AppUser;
|
||||
import org.mifosng.platform.user.domain.AppUserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
@@ -48,6 +41,9 @@ public class OfficeApiResource {
|
||||
@Autowired
|
||||
private OfficeWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private AppUserRepository appUserRepository;
|
||||
|
||||
@@ -88,7 +84,7 @@ public class OfficeApiResource {
|
||||
public Response createOffice(final OfficeCommand command) {
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
LocalDate openingDate = parseStringToLocalDate(command.getOpeningDateFormatted(), "openingDateFormatted", command.getDateFormat());
|
||||
LocalDate openingDate = apiDataConversionService.convertFrom(command.getOpeningDateFormatted(), "openingDateFormatted", command.getDateFormat());
|
||||
command.setOpeningDate(openingDate);
|
||||
|
||||
Long officeId = this.writePlatformService.createOffice(command);
|
||||
@@ -113,33 +109,15 @@ public class OfficeApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response updateOffice(@PathParam("officeId") final Long officeId, final OfficeCommand command) {
|
||||
|
||||
LocalDate openingDate = parseStringToLocalDate(command.getOpeningDateFormatted(), "openingDateFormatted", command.getDateFormat());
|
||||
|
||||
|
||||
hardcodeUserIntoSecurityContext();
|
||||
|
||||
command.setId(officeId);
|
||||
LocalDate openingDate = apiDataConversionService.convertFrom(command.getOpeningDateFormatted(), "openingDateFormatted", command.getDateFormat());
|
||||
command.setOpeningDate(openingDate);
|
||||
command.setId(officeId);
|
||||
|
||||
Long entityId = this.writePlatformService.updateOffice(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(entityId)).build();
|
||||
}
|
||||
|
||||
private LocalDate parseStringToLocalDate(String eventDate, String dateFieldIdentifier, String dateFormat) {
|
||||
LocalDate eventLocalDate = null;
|
||||
if (StringUtils.isNotBlank(eventDate)) {
|
||||
try {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
eventLocalDate = DateTimeFormat.forPattern(dateFormat).withLocale(locale).parseLocalDate(eventDate.toLowerCase(locale));
|
||||
} catch (IllegalArgumentException e) {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.format", "The parameter " + dateFieldIdentifier + " is invalid.", dateFieldIdentifier, eventDate);
|
||||
dataValidationErrors.add(error);
|
||||
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
return eventLocalDate;
|
||||
}
|
||||
}
|
||||
+10
@@ -3,10 +3,20 @@ package org.mifosng.platform.client.service;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientLoanAccountSummaryCollectionData;
|
||||
import org.mifosng.data.NoteData;
|
||||
|
||||
public interface ClientReadPlatformService {
|
||||
|
||||
Collection<ClientData> retrieveAllIndividualClients();
|
||||
|
||||
ClientData retrieveIndividualClient(Long clientId);
|
||||
|
||||
ClientData retrieveNewClientDetails();
|
||||
|
||||
ClientLoanAccountSummaryCollectionData retrieveClientAccountDetails(Long clientId);
|
||||
|
||||
Collection<NoteData> retrieveAllClientNotes(Long clientId);
|
||||
|
||||
NoteData retrieveClientNote(Long clientId, Long noteId);
|
||||
}
|
||||
+238
-1
@@ -9,14 +9,20 @@ import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientLoanAccountSummaryCollectionData;
|
||||
import org.mifosng.data.ClientLoanAccountSummaryData;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.OfficeData;
|
||||
import org.mifosng.platform.exceptions.PlatformResourceNotFoundException;
|
||||
import org.mifosng.platform.organisation.domain.Organisation;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosng.platform.user.domain.AppUser;
|
||||
import org.mifosng.platform.user.service.AppUserReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
@@ -29,11 +35,14 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
private final SimpleJdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
private final OfficeReadPlatformService officeReadPlatformService;
|
||||
private final AppUserReadPlatformService appUserReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public ClientReadPlatformServiceImpl(final PlatformSecurityContext context, final DataSource dataSource, final OfficeReadPlatformService officeReadPlatformService) {
|
||||
public ClientReadPlatformServiceImpl(final PlatformSecurityContext context, final DataSource dataSource, final OfficeReadPlatformService officeReadPlatformService,
|
||||
final AppUserReadPlatformService appUserReadPlatformService) {
|
||||
this.context = context;
|
||||
this.officeReadPlatformService = officeReadPlatformService;
|
||||
this.appUserReadPlatformService = appUserReadPlatformService;
|
||||
this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@@ -87,6 +96,27 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientData retrieveNewClientDetails() {
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
List<OfficeData> offices = new ArrayList<OfficeData>(officeReadPlatformService.retrieveAllOffices());
|
||||
|
||||
ClientData clientData = new ClientData();
|
||||
clientData.setOfficeId(currentUser.getOffice().getId());
|
||||
clientData.setOrganisationId(currentUser.getOrganisation().getId());
|
||||
clientData.setAllowedOffices(offices);
|
||||
|
||||
clientData.setDisplayName("");
|
||||
clientData.setFirstname("");
|
||||
clientData.setLastname("");
|
||||
clientData.setId(Long.valueOf(-1));
|
||||
clientData.setJoinedDate(new LocalDate());
|
||||
|
||||
return clientData;
|
||||
}
|
||||
|
||||
private static final class ClientMapper implements RowMapper<ClientData> {
|
||||
|
||||
private final List<OfficeData> offices;
|
||||
@@ -140,4 +170,211 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientLoanAccountSummaryCollectionData retrieveClientAccountDetails(final Long clientId) {
|
||||
|
||||
try {
|
||||
AppUser currentUser = this.context.authenticatedUser();
|
||||
|
||||
List<ClientLoanAccountSummaryData> pendingApprovalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
List<ClientLoanAccountSummaryData> awaitingDisbursalLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
List<ClientLoanAccountSummaryData> openLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
List<ClientLoanAccountSummaryData> closedLoans = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
|
||||
ClientLoanAccountSummaryDataMapper rm = new ClientLoanAccountSummaryDataMapper();
|
||||
|
||||
String sql = "select " + rm.loanAccountSummarySchema() + " where l.client_id = ? and l.org_id = ?";
|
||||
|
||||
List<ClientLoanAccountSummaryData> results = this.jdbcTemplate.query(sql, rm, new Object[] {clientId, currentUser.getOrganisation().getId()});
|
||||
if (results != null) {
|
||||
for (ClientLoanAccountSummaryData row : results) {
|
||||
if (row.isOpen()) {
|
||||
openLoans.add(row);
|
||||
} else if (row.isWaitingForDisbursal()) {
|
||||
awaitingDisbursalLoans.add(row);
|
||||
} else if (row.isPendingApproval()) {
|
||||
pendingApprovalLoans.add(row);
|
||||
} else {
|
||||
closedLoans.add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ClientLoanAccountSummaryCollectionData(pendingApprovalLoans, awaitingDisbursalLoans, openLoans, closedLoans);
|
||||
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new PlatformResourceNotFoundException(
|
||||
"error.msg.client.id.invalid",
|
||||
"Client with identifier {0} does not exist", clientId);
|
||||
}
|
||||
|
||||
// Collection<Loan> allLoans = this.loanRepository.findAll(loansThatMatch(currentUser.getOrganisation(), client));
|
||||
//
|
||||
// List<LoanAccountData> pendingApprovalLoans = new ArrayList<LoanAccountData>();
|
||||
// List<LoanAccountData> awaitingDisbursalLoans = new ArrayList<LoanAccountData>();
|
||||
// List<LoanAccountData> openLoans = new ArrayList<LoanAccountData>();
|
||||
// List<LoanAccountData> closedLoans = new ArrayList<LoanAccountData>();
|
||||
//
|
||||
// for (Loan realLoan : allLoans) {
|
||||
//
|
||||
// ApplicationCurrency currency = this.applicationCurrencyRepository
|
||||
// .findOneByCode(realLoan.getLoanRepaymentScheduleDetail()
|
||||
// .getPrincipal().getCurrencyCode());
|
||||
//
|
||||
// CurrencyData currencyData = new CurrencyData(currency.getCode(),
|
||||
// currency.getName(), currency.getDecimalPlaces(),
|
||||
// currency.getDisplaySymbol(), currency.getNameCode());
|
||||
//
|
||||
// LoanAccountData loan = convertToData(realLoan, currencyData);
|
||||
//
|
||||
// if (loan.isClosed() || loan.isInterestRebateOutstanding()) {
|
||||
// closedLoans.add(loan);
|
||||
// } else if (loan.isPendingApproval()) {
|
||||
// pendingApprovalLoans.add(loan);
|
||||
// } else if (loan.isWaitingForDisbursal()) {
|
||||
// awaitingDisbursalLoans.add(loan);
|
||||
// } else if (loan.isOpen()) {
|
||||
// openLoans.add(loan);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Collections.sort(closedLoans, new ClosedLoanComparator());
|
||||
//
|
||||
// return new ClientDataWithAccountsData(clientAccount,
|
||||
// pendingApprovalLoans, awaitingDisbursalLoans, openLoans,
|
||||
// closedLoans);
|
||||
}
|
||||
|
||||
private static final class ClientLoanAccountSummaryDataMapper implements RowMapper<ClientLoanAccountSummaryData> {
|
||||
|
||||
public String loanAccountSummarySchema() {
|
||||
|
||||
StringBuilder loanAccountSummary = new StringBuilder("l.id as id, l.external_id as externalId,");
|
||||
loanAccountSummary.append("l.product_id as productId, lp.name as productName,")
|
||||
.append("l.loan_status_id as statusId, ls.display_name as statusName ")
|
||||
.append("from portfolio_loan l ")
|
||||
.append("LEFT JOIN portfolio_product_loan AS lp ON lp.id = l.product_id ")
|
||||
.append("LEFT JOIN ref_loan_status AS ls ON ls.id = l.loan_status_id ");
|
||||
|
||||
return loanAccountSummary.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientLoanAccountSummaryData mapRow(final ResultSet rs, final int rowNum) throws SQLException {
|
||||
|
||||
Long id = rs.getLong("id");
|
||||
String externalId = rs.getString("externalId");
|
||||
Long productId = rs.getLong("productId");
|
||||
String loanProductName = rs.getString("productName");
|
||||
Integer loanStatusId = rs.getInt("statusId");
|
||||
String lifeCycleStatusText = rs.getString("statusName");
|
||||
|
||||
LoanStatusMapper statusMapper = new LoanStatusMapper(loanStatusId);
|
||||
|
||||
boolean pendingApproval = statusMapper.isPendingApproval();
|
||||
boolean waitingForDisbursal = statusMapper.isAwaitingDisbursal();
|
||||
boolean open = statusMapper.isOpen();
|
||||
boolean closed = statusMapper.isClosed();
|
||||
// LocalDate lifeCycleStatusDate;
|
||||
|
||||
return new ClientLoanAccountSummaryData(id, externalId, productId, loanProductName, loanStatusId, lifeCycleStatusText, pendingApproval, waitingForDisbursal, open, closed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NoteData retrieveClientNote(Long clientId, Long noteId) {
|
||||
|
||||
try {
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
// FIXME - use join on sql query to fetch user information for note rather than fetching users?
|
||||
Collection<AppUserData> allUsers = this.appUserReadPlatformService.retrieveAllUsers();
|
||||
|
||||
NoteMapper noteMapper = new NoteMapper(allUsers);
|
||||
|
||||
String sql = "select " + noteMapper.schema()
|
||||
+ " where n.org_id = ? and n.client_id = ? and n.id = ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, noteMapper,
|
||||
new Object[] { currentUser.getOrganisation().getId(),
|
||||
clientId, noteId });
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new PlatformResourceNotFoundException(
|
||||
"error.msg.client.id.invalid",
|
||||
"Client with identifier {0} does not exist", clientId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<NoteData> retrieveAllClientNotes(Long clientId) {
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
// FIXME - use join on sql query to fetch user information for note rather than fetching users?
|
||||
Collection<AppUserData> allUsers = this.appUserReadPlatformService.retrieveAllUsers();
|
||||
|
||||
NoteMapper noteMapper = new NoteMapper(allUsers);
|
||||
|
||||
String sql = "select "
|
||||
+ noteMapper.schema()
|
||||
+ " where n.org_id = ? and n.client_id = ? order by n.created_date DESC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, noteMapper, new Object[] {
|
||||
currentUser.getOrganisation().getId(), clientId });
|
||||
}
|
||||
|
||||
private static final class NoteMapper implements RowMapper<NoteData> {
|
||||
|
||||
private final Collection<AppUserData> allUsers;
|
||||
|
||||
public NoteMapper(Collection<AppUserData> allUsers) {
|
||||
this.allUsers = allUsers;
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return "n.id as id, n.client_id as clientId, n.loan_id as loanId, n.loan_transaction_id as transactionId, n.note_type_enum as noteTypeEnum, n.note as note, "
|
||||
+ "n.created_date as createdDate, n.createdby_id as createdById, n.lastmodified_date as lastModifiedDate, n.lastmodifiedby_id as lastModifiedById"
|
||||
+ " from portfolio_note n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoteData mapRow(final ResultSet rs, final int rowNum)
|
||||
throws SQLException {
|
||||
|
||||
Long id = rs.getLong("id");
|
||||
Long clientId = rs.getLong("clientId");
|
||||
Long loanId = rs.getLong("loanId");
|
||||
Long transactionId = rs.getLong("transactionId");
|
||||
Integer noteTypeId = rs.getInt("noteTypeEnum");
|
||||
String note = rs.getString("note");
|
||||
|
||||
DateTime createdDate = new DateTime(rs.getTimestamp("createdDate"));
|
||||
Long createdById = rs.getLong("createdById");
|
||||
String createdByUsername = findUserById(createdById, allUsers);
|
||||
|
||||
DateTime lastModifiedDate = new DateTime(
|
||||
rs.getTimestamp("lastModifiedDate"));
|
||||
Long lastModifiedById = rs.getLong("lastModifiedById");
|
||||
String updatedByUsername = findUserById(createdById, allUsers);
|
||||
|
||||
return new NoteData(id, clientId, loanId, transactionId,
|
||||
noteTypeId, note, createdDate, createdById,
|
||||
createdByUsername, lastModifiedDate, lastModifiedById,
|
||||
updatedByUsername);
|
||||
}
|
||||
|
||||
private String findUserById(Long createdById,
|
||||
Collection<AppUserData> allUsers) {
|
||||
String username = "";
|
||||
for (AppUserData appUserData : allUsers) {
|
||||
if (appUserData.getId().equals(createdById)) {
|
||||
username = appUserData.getUsername();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return username;
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.mifosng.platform.client.service;
|
||||
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface ClientWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_ENROLL_NEW_CLIENT_ROLE')")
|
||||
Long enrollClient(EnrollClientCommand command);
|
||||
|
||||
// FIXME - add permission for adding and updating client notes.
|
||||
EntityIdentifier addClientNote(NoteCommand command);
|
||||
|
||||
EntityIdentifier updateNote(NoteCommand command);
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package org.mifosng.platform.client.service;
|
||||
|
||||
import static org.mifosng.platform.Specifications.officesThatMatch;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.client.domain.Note;
|
||||
import org.mifosng.platform.client.domain.NoteRepository;
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
import org.mifosng.platform.organisation.domain.OfficeRepository;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosng.platform.user.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final ClientRepository clientRepository;
|
||||
private final OfficeRepository officeRepository;
|
||||
private final NoteRepository noteRepository;
|
||||
|
||||
@Autowired
|
||||
public ClientWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, final ClientRepository clientRepository,
|
||||
final OfficeRepository officeRepository, NoteRepository noteRepository) {
|
||||
this.context = context;
|
||||
this.clientRepository = clientRepository;
|
||||
this.officeRepository = officeRepository;
|
||||
this.noteRepository = noteRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Long enrollClient(final EnrollClientCommand command) {
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
EnrollClientCommandValidator validator = new EnrollClientCommandValidator(command);
|
||||
validator.validate();
|
||||
|
||||
Office clientOffice = this.officeRepository.findOne(officesThatMatch(currentUser.getOrganisation(), command.getOfficeId()));
|
||||
|
||||
String firstname = command.getFirstname();
|
||||
String lastname = command.getLastname();
|
||||
if (StringUtils.isNotBlank(command.getFullname())) {
|
||||
lastname = command.getFullname();
|
||||
firstname = null;
|
||||
}
|
||||
|
||||
Client newClient = Client.newClient(currentUser.getOrganisation(), clientOffice, firstname, lastname, command.getJoiningDate(), command.getExternalId());
|
||||
|
||||
this.clientRepository.save(newClient);
|
||||
|
||||
return newClient.getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier addClientNote(NoteCommand command) {
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
// FIXME - check resource is found for current organisation - throw PlatformXXXException if not found.
|
||||
Client clientForUpdate = this.clientRepository.findOne(command.getClientId());
|
||||
|
||||
Note note = Note.clientNote(currentUser.getOrganisation(), clientForUpdate, command.getNote());
|
||||
|
||||
this.noteRepository.save(note);
|
||||
|
||||
return new EntityIdentifier(note.getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateNote(NoteCommand command) {
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
// FIXME - check resource is found for current organisation - throw PlatformXXXException if not found.
|
||||
Note noteForUpdate = this.noteRepository.findOne(command.getId());
|
||||
|
||||
noteForUpdate.update(command.getNote());
|
||||
|
||||
return new EntityIdentifier(noteForUpdate.getId());
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package org.mifosng.platform.client.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class EnrollClientCommandValidator {
|
||||
|
||||
private final EnrollClientCommand command;
|
||||
|
||||
public EnrollClientCommandValidator(EnrollClientCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
if (command.getOfficeId() == null || command.getOfficeId().equals(Long.valueOf(-1))) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.client.office.cannot.be.blank", "The parameter officeId cannot be blank.", "officeId");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getFullname()) && (StringUtils.isNotBlank(command.getFirstname()) || StringUtils.isNotBlank(command.getLastname()))) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.client.fullname.cannot.entered.when.firstname.or.lastname.entered", "The parameter fullname cannot be blank.", "fullname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(command.getFirstname()) && StringUtils.isBlank(command.getLastname()) ) {
|
||||
|
||||
if (StringUtils.isBlank(command.getFullname())) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.client.fullname.must.be.provide.or.firstname.lastname", "The parameter fullname cannot be blank or firstName and lastName must be both provided.", "fullname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isBlank(command.getFirstname())) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.client.firstname.cannot.be.blank", "The parameter firstname cannot be blank.", "firstname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(command.getLastname())) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.client.lastname.cannot.be.blank", "The parameter lastname cannot be blank.", "lastname");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
|
||||
if (command.getJoiningDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.client.joining.date.cannot.be.blank", "The parameter joiningDate cannot be blank.", "joiningDate");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package org.mifosng.platform.client.service;
|
||||
|
||||
public class LoanStatusMapper {
|
||||
|
||||
private final Integer statusId;
|
||||
|
||||
public LoanStatusMapper(Integer statusId) {
|
||||
this.statusId = statusId;
|
||||
}
|
||||
|
||||
public boolean isPendingApproval() {
|
||||
return Integer.valueOf(100).equals(statusId);
|
||||
}
|
||||
|
||||
public boolean isAwaitingDisbursal() {
|
||||
return Integer.valueOf(200).equals(statusId);
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return Integer.valueOf(300).equals(statusId);
|
||||
}
|
||||
|
||||
public boolean isWithdrawnByClient() {
|
||||
return Integer.valueOf(400).equals(statusId);
|
||||
}
|
||||
|
||||
public boolean isRejected() {
|
||||
return Integer.valueOf(500).equals(statusId);
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return Integer.valueOf(600).equals(statusId) || isWithdrawnByClient() || isRejected();
|
||||
}
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
package org.mifosng.platform.rest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
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.ErrorResponseList;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.NoteDataList;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.ReadPlatformService;
|
||||
import org.mifosng.platform.WritePlatformService;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
import org.mifosng.platform.exceptions.ApplicationDomainRuleException;
|
||||
import org.mifosng.platform.exceptions.UnAuthenticatedUserException;
|
||||
import org.mifosng.platform.exceptions.NewDataValidationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/protected/client")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ClientResource {
|
||||
|
||||
@Autowired
|
||||
private ReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private ClientReadPlatformService clientReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private WritePlatformService writePlatformService;
|
||||
|
||||
@GET
|
||||
@Path("all")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public Response retrieveAllIndividualClients() {
|
||||
|
||||
Collection<ClientData> clients = this.clientReadPlatformService.retrieveAllIndividualClients();
|
||||
|
||||
return Response.ok().entity(new ClientList(clients)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("new")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response newClientDetails() {
|
||||
|
||||
try {
|
||||
ClientData clientData = this.readPlatformService.retrieveNewClientDetails();
|
||||
|
||||
return Response.ok().entity(clientData).build();
|
||||
} catch (UnAuthenticatedUserException e) {
|
||||
throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
|
||||
} catch (AccessDeniedException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse("error.msg.no.permission", "id");
|
||||
ErrorResponseList list = new ErrorResponseList(Arrays.asList(errorResponse));
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(list).build());
|
||||
} catch (ApplicationDomainRuleException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getErrors())).build());
|
||||
} catch (NewDataValidationException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getValidationErrors())).build());
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("new")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response enrollClient(final EnrollClientCommand command) {
|
||||
|
||||
try {
|
||||
Long clientId = this.writePlatformService.enrollClient(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(clientId)).build();
|
||||
} catch (UnAuthenticatedUserException e) {
|
||||
throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
|
||||
} catch (AccessDeniedException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse("error.msg.no.permission", "id");
|
||||
ErrorResponseList list = new ErrorResponseList(Arrays.asList(errorResponse));
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(list).build());
|
||||
} catch (ApplicationDomainRuleException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getErrors())).build());
|
||||
} catch (NewDataValidationException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getValidationErrors())).build());
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response retrieveClientData(
|
||||
@PathParam("clientId") final Long clientId) {
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService
|
||||
.retrieveIndividualClient(clientId);
|
||||
|
||||
return Response.ok().entity(clientData).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/withaccounts")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response retrieveClientAccount(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
try {
|
||||
ClientDataWithAccountsData clientAccount = this.readPlatformService
|
||||
.retrieveClientAccountDetails(clientId);
|
||||
|
||||
return Response.ok().entity(clientAccount).build();
|
||||
} catch (UnAuthenticatedUserException e) {
|
||||
throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
|
||||
} catch (AccessDeniedException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse("error.msg.no.permission", "id");
|
||||
ErrorResponseList list = new ErrorResponseList(Arrays.asList(errorResponse));
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(list).build());
|
||||
} catch (ApplicationDomainRuleException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getErrors())).build());
|
||||
} catch (NewDataValidationException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getValidationErrors())).build());
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{clientId}/note/new")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response addNewClientNote(@PathParam("clientId") final Long clientId, final NoteCommand command) {
|
||||
|
||||
try {
|
||||
EntityIdentifier identifier = this.writePlatformService.addClientNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
} catch (UnAuthenticatedUserException e) {
|
||||
throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
|
||||
} catch (AccessDeniedException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse("error.msg.no.permission", "id");
|
||||
ErrorResponseList list = new ErrorResponseList(Arrays.asList(errorResponse));
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(list).build());
|
||||
} catch (ApplicationDomainRuleException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getErrors())).build());
|
||||
} catch (NewDataValidationException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getValidationErrors())).build());
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/note/all")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response retrieveAllClientNotes(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
try {
|
||||
Collection<NoteData> notes = this.readPlatformService.retrieveAllClientNotes(clientId);
|
||||
|
||||
return Response.ok().entity(new NoteDataList(notes)).build();
|
||||
} catch (UnAuthenticatedUserException e) {
|
||||
throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
|
||||
} catch (AccessDeniedException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse("error.msg.no.permission", "id");
|
||||
ErrorResponseList list = new ErrorResponseList(Arrays.asList(errorResponse));
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(list).build());
|
||||
} catch (ApplicationDomainRuleException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getErrors())).build());
|
||||
} catch (NewDataValidationException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getValidationErrors())).build());
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/note/{noteId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response retrieveClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId) {
|
||||
|
||||
try {
|
||||
NoteData note = this.readPlatformService.retrieveClientNote(clientId, noteId);
|
||||
|
||||
return Response.ok().entity(note).build();
|
||||
} catch (UnAuthenticatedUserException e) {
|
||||
throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
|
||||
} catch (AccessDeniedException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse("error.msg.no.permission", "id");
|
||||
ErrorResponseList list = new ErrorResponseList(Arrays.asList(errorResponse));
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(list).build());
|
||||
} catch (ApplicationDomainRuleException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getErrors())).build());
|
||||
} catch (NewDataValidationException e) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(new ErrorResponseList(e.getValidationErrors())).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package org.mifosng.platform.rest;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.WritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/protected/note")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class NoteResource {
|
||||
|
||||
@Autowired
|
||||
private WritePlatformService writePlatformService;
|
||||
|
||||
@POST
|
||||
@Path("{noteId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
public Response updateClientAccount(@PathParam("noteId") final Long noteId, final NoteCommand command) {
|
||||
|
||||
EntityIdentifier identifier = this.writePlatformService.updateNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user