finish off integration of organisation admin functions in UI with backend services through cross origin request from jQuery.
This commit is contained in:
@@ -6,7 +6,6 @@ import java.util.Map;
|
||||
import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientDataWithAccountsData;
|
||||
import org.mifosng.data.CurrencyData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.EnumOptionReadModel;
|
||||
import org.mifosng.data.LoanAccountData;
|
||||
@@ -15,23 +14,19 @@ import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.OfficeData;
|
||||
import org.mifosng.data.PermissionData;
|
||||
import org.mifosng.data.RoleData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.ChangePasswordCommand;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.LoanProductCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.data.command.OfficeCommand;
|
||||
import org.mifosng.data.command.RoleCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoLoanApprovalCommand;
|
||||
import org.mifosng.data.command.UndoLoanDisbursalCommand;
|
||||
import org.mifosng.data.command.UpdateOrganisationCurrencyCommand;
|
||||
import org.mifosng.data.command.UserCommand;
|
||||
import org.mifosng.data.reports.GenericResultset;
|
||||
import org.springframework.security.oauth.consumer.ProtectedResourceDetails;
|
||||
@@ -43,12 +38,6 @@ public interface CommonRestOperations {
|
||||
void updateProtectedResource(
|
||||
ProtectedResourceDetails loadProtectedResourceDetailsById);
|
||||
|
||||
void updateOrganisationCurrencies(UpdateOrganisationCurrencyCommand command);
|
||||
|
||||
Collection<OfficeData> retrieveAllOffices();
|
||||
|
||||
OfficeData retrieveOffice(Long officeId);
|
||||
|
||||
Collection<AppUserData> retrieveAllUsers();
|
||||
|
||||
AppUserData retrieveNewUserDetails();
|
||||
@@ -79,34 +68,10 @@ public interface CommonRestOperations {
|
||||
|
||||
EntityIdentifier createRole(RoleCommand command);
|
||||
|
||||
EntityIdentifier createOffice(OfficeCommand command);
|
||||
|
||||
EntityIdentifier updateOffice(OfficeCommand command);
|
||||
|
||||
Collection<ClientData> retrieveAllIndividualClients();
|
||||
|
||||
Collection<LoanProductData> retrieveAllLoanProducts();
|
||||
|
||||
Collection<CurrencyData> retrieveAllowedCurrencies();
|
||||
|
||||
Collection<CurrencyData> retrieveAllPlatformCurrencies();
|
||||
|
||||
Collection<EnumOptionReadModel> retrieveAllowedLoanAmortizationMethodOptions();
|
||||
|
||||
Collection<EnumOptionReadModel> retrieveAllowedLoanInterestMethodOptions();
|
||||
|
||||
Collection<EnumOptionReadModel> retrieveAllowedRepaymentFrequencyOptions();
|
||||
|
||||
Collection<EnumOptionReadModel> retrieveAllowedNominalInterestFrequencyOptions();
|
||||
|
||||
EntityIdentifier createLoanProduct(LoanProductCommand command);
|
||||
|
||||
EntityIdentifier updateLoanProduct(LoanProductCommand command);
|
||||
|
||||
LoanProductData retrieveLoanProductDetails(Long selectedLoanProductOption);
|
||||
|
||||
LoanProductData retrieveNewLoanProductDetails();
|
||||
|
||||
LoanSchedule calculateLoanSchedule(CalculateLoanScheduleCommand command);
|
||||
|
||||
NewLoanWorkflowStepOneData retrieveNewLoanApplicationStepOneDetails(
|
||||
|
||||
-287
@@ -13,8 +13,6 @@ import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.ClientData;
|
||||
import org.mifosng.data.ClientDataWithAccountsData;
|
||||
import org.mifosng.data.ClientList;
|
||||
import org.mifosng.data.CurrencyData;
|
||||
import org.mifosng.data.CurrencyList;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.EnumOptionList;
|
||||
import org.mifosng.data.EnumOptionReadModel;
|
||||
@@ -28,8 +26,6 @@ import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.NoteDataList;
|
||||
import org.mifosng.data.OfficeData;
|
||||
import org.mifosng.data.OfficeList;
|
||||
import org.mifosng.data.PermissionData;
|
||||
import org.mifosng.data.PermissionList;
|
||||
import org.mifosng.data.RoleData;
|
||||
@@ -39,16 +35,13 @@ import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.ChangePasswordCommand;
|
||||
import org.mifosng.data.command.EnrollClientCommand;
|
||||
import org.mifosng.data.command.LoanProductCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.data.command.OfficeCommand;
|
||||
import org.mifosng.data.command.RoleCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoLoanApprovalCommand;
|
||||
import org.mifosng.data.command.UndoLoanDisbursalCommand;
|
||||
import org.mifosng.data.command.UpdateOrganisationCurrencyCommand;
|
||||
import org.mifosng.data.command.UserCommand;
|
||||
import org.mifosng.data.reports.GenericResultset;
|
||||
import org.mifosng.ui.loanproduct.ClientValidationException;
|
||||
@@ -129,38 +122,7 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
return s.getBody().getProducts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier createLoanProduct(final LoanProductCommand command) {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/product/loan/new"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate.postForEntity(restUri,
|
||||
updateLoanProductRequest(command), EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier updateLoanProduct(LoanProductCommand command) {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/product/loan/update"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri, updateLoanProductRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
private ErrorResponseList parseErrors(HttpStatusCodeException e) {
|
||||
|
||||
@@ -184,53 +146,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
}
|
||||
return errorList;
|
||||
}
|
||||
|
||||
private HttpEntity<LoanProductCommand> updateLoanProductRequest(
|
||||
final LoanProductCommand command) {
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
HttpEntity<LoanProductCommand> requestEntity = new HttpEntity<LoanProductCommand>(
|
||||
command, requestHeaders);
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanProductData retrieveLoanProductDetails(
|
||||
final Long selectedLoanProductOption) {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/product/loan/"
|
||||
+ selectedLoanProductOption));
|
||||
|
||||
ResponseEntity<LoanProductData> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
LoanProductData.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanProductData retrieveNewLoanProductDetails() {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/product/loan/empty"));
|
||||
|
||||
ResponseEntity<LoanProductData> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
LoanProductData.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanSchedule calculateLoanSchedule(
|
||||
@@ -587,116 +502,7 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
return new HttpEntity<CalculateLoanScheduleCommand>(command,
|
||||
requestHeaders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<CurrencyData> retrieveAllowedCurrencies() {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/config/currency/allowed"));
|
||||
|
||||
ResponseEntity<CurrencyList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
CurrencyList.class);
|
||||
|
||||
return s.getBody().getCurrencies();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumOptionReadModel> retrieveAllowedLoanAmortizationMethodOptions() {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/config/loan/amortization/allowed"));
|
||||
|
||||
ResponseEntity<EnumOptionList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
EnumOptionList.class);
|
||||
|
||||
return s.getBody().getOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumOptionReadModel> retrieveAllowedLoanInterestMethodOptions() {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/config/loan/interestcalculation/allowed"));
|
||||
|
||||
ResponseEntity<EnumOptionList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
EnumOptionList.class);
|
||||
|
||||
return s.getBody().getOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumOptionReadModel> retrieveAllowedRepaymentFrequencyOptions() {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/config/loan/repaymentfrequency/allowed"));
|
||||
|
||||
ResponseEntity<EnumOptionList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
EnumOptionList.class);
|
||||
|
||||
return s.getBody().getOptions();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<EnumOptionReadModel> retrieveAllowedNominalInterestFrequencyOptions() {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/config/loan/interestfrequency/allowed"));
|
||||
|
||||
ResponseEntity<EnumOptionList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
EnumOptionList.class);
|
||||
|
||||
return s.getBody().getOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<CurrencyData> retrieveAllPlatformCurrencies() {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/config/currency/all"));
|
||||
|
||||
ResponseEntity<CurrencyList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
CurrencyList.class);
|
||||
|
||||
return s.getBody().getCurrencies();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrganisationCurrencies(UpdateOrganisationCurrencyCommand command) {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/config/currency/update"));
|
||||
|
||||
this.oauthRestServiceTemplate.exchange(restUri, HttpMethod.PUT,
|
||||
updateCurrencyRequest(command),
|
||||
UpdateOrganisationCurrencyCommand.class);
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
private HttpEntity<UpdateOrganisationCurrencyCommand> updateCurrencyRequest(
|
||||
final UpdateOrganisationCurrencyCommand command) {
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
HttpEntity<UpdateOrganisationCurrencyCommand> requestEntity = new HttpEntity<UpdateOrganisationCurrencyCommand>(
|
||||
command, requestHeaders);
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier createUser(final UserCommand command) {
|
||||
try {
|
||||
@@ -950,99 +756,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<OfficeData> retrieveAllOffices() {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/office/all"));
|
||||
|
||||
ResponseEntity<OfficeList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
OfficeList.class);
|
||||
|
||||
return s.getBody().getOffices();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeData retrieveOffice(final Long officeId) {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/office/"
|
||||
+ officeId));
|
||||
|
||||
ResponseEntity<OfficeData> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
OfficeData.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier createOffice(final OfficeCommand command) {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/office/new"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri, createOfficeRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier updateOffice(final OfficeCommand command) {
|
||||
try {
|
||||
URI restUri = URI
|
||||
.create(getBaseServerUrl().concat("api/protected/office/update"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri, updateOfficeRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
private HttpEntity<OfficeCommand> createOfficeRequest(
|
||||
final OfficeCommand command) {
|
||||
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
HttpEntity<OfficeCommand> requestEntity = new HttpEntity<OfficeCommand>(
|
||||
command, requestHeaders);
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
private HttpEntity<OfficeCommand> updateOfficeRequest(
|
||||
final OfficeCommand command) {
|
||||
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept", "application/xml");
|
||||
requestHeaders.set("Content-Type", "application/xml");
|
||||
|
||||
HttpEntity<OfficeCommand> requestEntity = new HttpEntity<OfficeCommand>(
|
||||
command, requestHeaders);
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientData retrieveNewIndividualClient() {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat("api/protected/client/new"));
|
||||
|
||||
+1
-46
@@ -1,35 +1,24 @@
|
||||
package org.mifosng.ui.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.mifosng.configuration.ApplicationConfigurationService;
|
||||
import org.mifosng.configuration.OAuthProviderDetails;
|
||||
import org.mifosng.data.ConfigurationData;
|
||||
import org.mifosng.data.CurrencyData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.command.UpdateOrganisationCurrencyCommand;
|
||||
import org.mifosng.oauth.RefreshableProtectedResourceDetailsService;
|
||||
import org.mifosng.ui.CommonRestOperations;
|
||||
import org.mifosng.ui.loanproduct.ClientValidationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.oauth.consumer.ProtectedResourceDetailsService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@@ -66,38 +55,6 @@ public class ConfigurationController {
|
||||
return ex.getValidationErrors();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "org/configuration/edit", method = RequestMethod.GET)
|
||||
public @ResponseBody ConfigurationData viewConfigurationDetails() {
|
||||
|
||||
List<CurrencyData> selectedCurrencyOptions = new ArrayList<CurrencyData>(this.commonRestOperations.retrieveAllowedCurrencies());
|
||||
List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>(this.commonRestOperations.retrieveAllPlatformCurrencies());
|
||||
|
||||
// remove selected currency options
|
||||
currencyOptions.removeAll(selectedCurrencyOptions);
|
||||
|
||||
ConfigurationData configurationData = new ConfigurationData();
|
||||
configurationData.setCurrencyOptions(currencyOptions);
|
||||
configurationData.setSelectedCurrencyOptions(selectedCurrencyOptions);
|
||||
|
||||
return configurationData;
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "org/configuration/edit", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier updateOrganisationCurrencies(@RequestParam(value="selectedItems", required=false) String[] selectedCurrencies) {
|
||||
|
||||
List<String> codes = new ArrayList<String>();
|
||||
if (selectedCurrencies != null) {
|
||||
codes = Arrays.asList(selectedCurrencies);
|
||||
}
|
||||
|
||||
UpdateOrganisationCurrencyCommand command = new UpdateOrganisationCurrencyCommand(codes);
|
||||
|
||||
this.commonRestOperations.updateOrganisationCurrencies(command);
|
||||
|
||||
return new EntityIdentifier(Long.valueOf(1));
|
||||
}
|
||||
|
||||
@ModelAttribute("oauthSettingsFormBean")
|
||||
@RequestMapping(value = "oauth/configuration/edit", method = RequestMethod.GET)
|
||||
public ModelAndView showOAuthConfiguration() {
|
||||
@@ -114,9 +71,7 @@ public class ConfigurationController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "oauth/configuration/edit", method = RequestMethod.POST)
|
||||
public ModelAndView updateOAuthConfiguration(
|
||||
@ModelAttribute final OauthSettingsFormBean oauthSettingsFormBean,
|
||||
final BindingResult result) {
|
||||
public ModelAndView updateOAuthConfiguration(@ModelAttribute final OauthSettingsFormBean oauthSettingsFormBean) {
|
||||
|
||||
ModelAndView mav = new ModelAndView("redirect:/");
|
||||
|
||||
|
||||
-195
@@ -1,195 +0,0 @@
|
||||
package org.mifosng.ui.loanproduct;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.LoanProductData;
|
||||
import org.mifosng.data.command.LoanProductCommand;
|
||||
import org.mifosng.ui.CommonRestOperations;
|
||||
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.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 LoanProductController {
|
||||
|
||||
private final CommonRestOperations commonRestOperations;
|
||||
|
||||
@Autowired
|
||||
public LoanProductController(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 BigDecimal parseStringToBigDecimal(String source) {
|
||||
try {
|
||||
BigDecimal number = null;
|
||||
|
||||
if (StringUtils.isNotBlank(source)) {
|
||||
String sourceWithoutSpaces = source.replaceAll(" ", "");
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
NumberFormat format = NumberFormat.getNumberInstance(locale);
|
||||
Number parsedNumber = format.parse(sourceWithoutSpaces);
|
||||
number = BigDecimal.valueOf(Double.valueOf(parsedNumber
|
||||
.doubleValue()));
|
||||
}
|
||||
|
||||
return number;
|
||||
} catch (ParseException e) {
|
||||
List<ErrorResponse> validationErrors = new ArrayList<ErrorResponse>();
|
||||
validationErrors.add(new ErrorResponse("validation.msg.invalid.number.format", "amount", source));
|
||||
throw new ClientValidationException(validationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/product/loan/all", method = RequestMethod.GET)
|
||||
public @ResponseBody Collection<LoanProductData> viewAllLoanProducts() {
|
||||
|
||||
return this.commonRestOperations.retrieveAllLoanProducts();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/product/loan/new", method = RequestMethod.GET)
|
||||
public @ResponseBody LoanProductData viewNewLoanProductForm() {
|
||||
|
||||
return this.commonRestOperations.retrieveNewLoanProductDetails();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/product/loan/new", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier createLoanProduct(
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("description") String description,
|
||||
@RequestParam("selectedCurrency") String currencyCode, @RequestParam("selectedDigitsAfterDecimal") Integer digitsAfterDecimal,
|
||||
@RequestParam("amount") String principalAsNumber,
|
||||
@RequestParam("repaidEvery") Integer repaymentEvery,
|
||||
@RequestParam("selectedRepaymentFrequencyOption") Integer repaymentFrequency,
|
||||
@RequestParam("numberOfRepayments") Integer numberOfRepayments,
|
||||
@RequestParam("selectedAmortizationMethodOption") Integer amortizationMethod,
|
||||
@RequestParam("inArrearsTolerance") String inArrearsToleranceAsNumber,
|
||||
@RequestParam("nominalInterestRate") String nominalInterestRatePerPeriodAsNumber,
|
||||
@RequestParam("selectedInterestFrequencyOption") Integer nominalInterestRatePerPeriodFrequency,
|
||||
@RequestParam("selectedInterestMethodOption") Integer interestMethod,
|
||||
@RequestParam(value="interestRateCalculatedInPeriod", required=false) Integer interestCalculationPeriodMethod
|
||||
) {
|
||||
|
||||
LoanProductCommand command = new LoanProductCommand();
|
||||
command.setName(name);
|
||||
command.setDescription(description);
|
||||
command.setCurrencyCode(currencyCode);
|
||||
command.setDigitsAfterDecimal(digitsAfterDecimal);
|
||||
|
||||
if (StringUtils.isNotBlank(principalAsNumber)) {
|
||||
BigDecimal principal = parseStringToBigDecimal(principalAsNumber);
|
||||
command.setPrincipal(principal);
|
||||
}
|
||||
|
||||
command.setRepaymentEvery(repaymentEvery);
|
||||
command.setRepaymentFrequency(repaymentFrequency);
|
||||
command.setNumberOfRepayments(numberOfRepayments);
|
||||
command.setAmortizationMethod(amortizationMethod);
|
||||
|
||||
if (StringUtils.isNotBlank(inArrearsToleranceAsNumber)) {
|
||||
BigDecimal inArrearsToleranceAmount = parseStringToBigDecimal(inArrearsToleranceAsNumber);
|
||||
command.setInArrearsToleranceAmount(inArrearsToleranceAmount);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(nominalInterestRatePerPeriodAsNumber)) {
|
||||
BigDecimal interestRatePerPeriod = parseStringToBigDecimal(nominalInterestRatePerPeriodAsNumber);
|
||||
command.setInterestRatePerPeriod(interestRatePerPeriod);
|
||||
}
|
||||
command.setInterestRateFrequencyMethod(nominalInterestRatePerPeriodFrequency);
|
||||
command.setInterestMethod(interestMethod);
|
||||
command.setInterestCalculationPeriodMethod(interestCalculationPeriodMethod);
|
||||
|
||||
return this.commonRestOperations.createLoanProduct(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/product/loan/{productId}", method = RequestMethod.GET)
|
||||
public @ResponseBody LoanProductData viewLoanProduct(@PathVariable("productId") final Long productId) {
|
||||
|
||||
return this.commonRestOperations.retrieveLoanProductDetails(productId);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/product/loan/{productId}", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier updateLoanProduct(@PathVariable("productId") final Long productId,
|
||||
@RequestParam("name") String name, @RequestParam("description") String description,
|
||||
@RequestParam("selectedCurrency") String currencyCode, @RequestParam("selectedDigitsAfterDecimal") Integer digitsAfterDecimal,
|
||||
@RequestParam("amount") String principalAsNumber,
|
||||
@RequestParam("repaidEvery") Integer repaymentEvery,
|
||||
@RequestParam("selectedRepaymentFrequencyOption") Integer repaymentFrequency,
|
||||
@RequestParam("numberOfRepayments") Integer numberOfRepayments,
|
||||
@RequestParam("selectedAmortizationMethodOption") Integer amortizationMethod,
|
||||
@RequestParam("inArrearsTolerance") String inArrearsToleranceAsNumber,
|
||||
@RequestParam("nominalInterestRate") String nominalInterestRatePerPeriodAsNumber,
|
||||
@RequestParam("selectedInterestFrequencyOption") Integer nominalInterestRatePerPeriodFrequency,
|
||||
@RequestParam("selectedInterestMethodOption") Integer interestMethod,
|
||||
@RequestParam(value="interestRateCalculatedInPeriod", required=false) Integer interestCalculationPeriodMethod
|
||||
) {
|
||||
|
||||
LoanProductCommand command = new LoanProductCommand();
|
||||
command.setId(productId);
|
||||
command.setName(name);
|
||||
command.setDescription(description);
|
||||
command.setExternalId(null);
|
||||
command.setCurrencyCode(currencyCode);
|
||||
command.setDigitsAfterDecimal(digitsAfterDecimal);
|
||||
|
||||
if (StringUtils.isNotBlank(principalAsNumber)) {
|
||||
BigDecimal principal = parseStringToBigDecimal(principalAsNumber);
|
||||
command.setPrincipal(principal);
|
||||
}
|
||||
|
||||
command.setRepaymentEvery(repaymentEvery);
|
||||
command.setRepaymentFrequency(repaymentFrequency);
|
||||
command.setNumberOfRepayments(numberOfRepayments);
|
||||
command.setAmortizationMethod(amortizationMethod);
|
||||
|
||||
if (StringUtils.isNotBlank(inArrearsToleranceAsNumber)) {
|
||||
BigDecimal inArrearsToleranceAmount = parseStringToBigDecimal(inArrearsToleranceAsNumber);
|
||||
command.setInArrearsToleranceAmount(inArrearsToleranceAmount);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(nominalInterestRatePerPeriodAsNumber)) {
|
||||
BigDecimal interestRatePerPeriod = parseStringToBigDecimal(nominalInterestRatePerPeriodAsNumber);
|
||||
command.setInterestRatePerPeriod(interestRatePerPeriod);
|
||||
}
|
||||
command.setInterestRateFrequencyMethod(nominalInterestRatePerPeriodFrequency);
|
||||
command.setInterestMethod(interestMethod);
|
||||
command.setInterestCalculationPeriodMethod(interestCalculationPeriodMethod);
|
||||
|
||||
return this.commonRestOperations.updateLoanProduct(command);
|
||||
}
|
||||
}
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
package org.mifosng.ui.office;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
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.EntityIdentifier;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.OfficeData;
|
||||
import org.mifosng.data.command.OfficeCommand;
|
||||
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.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 OfficeController {
|
||||
|
||||
private final CommonRestOperations commonRestOperations;
|
||||
|
||||
@Autowired
|
||||
public OfficeController(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 = "/org/office/all", method = RequestMethod.GET)
|
||||
public @ResponseBody Collection<OfficeData> viewAllOffices() {
|
||||
|
||||
return this.commonRestOperations.retrieveAllOffices();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/org/office/new", method = RequestMethod.GET)
|
||||
public @ResponseBody OfficeData viewNewOfficeForm() {
|
||||
|
||||
OfficeData newOffice = new OfficeData();
|
||||
newOffice.setOpeningDate(new LocalDate());
|
||||
|
||||
Collection<OfficeData> allOffices = this.commonRestOperations.retrieveAllOffices();
|
||||
List<OfficeData> allowedParents = new ArrayList<OfficeData>(allOffices);
|
||||
|
||||
newOffice.setAllowedParents(allowedParents);
|
||||
|
||||
return newOffice;
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/org/office/new", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier createOffice(
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam(value="parentId", required=false) Long parentId,
|
||||
@RequestParam("openingDate") String openingDate,
|
||||
@RequestParam(value="externalId", required=false) String externalId) {
|
||||
|
||||
LocalDate openingLocalDate = parseStringToLocalDate(openingDate, "openingDate");
|
||||
|
||||
OfficeCommand command = new OfficeCommand(name, externalId, parentId, openingLocalDate);
|
||||
return this.commonRestOperations.createOffice(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/org/office/{officeId}", method = RequestMethod.GET)
|
||||
public @ResponseBody OfficeData viewOffice(@PathVariable("officeId") final Long officeId) {
|
||||
|
||||
return this.commonRestOperations.retrieveOffice(officeId);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/org/office/{officeId}", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier updateOffice(@PathVariable("officeId") final Long officeId,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam(value="parentId", required=false) Long parentId,
|
||||
@RequestParam("openingDate") String openingDate,
|
||||
@RequestParam(value="externalId", required=false) String externalId) {
|
||||
|
||||
LocalDate openingLocalDate = parseStringToLocalDate(openingDate, "openingDate");
|
||||
|
||||
OfficeCommand command = new OfficeCommand(officeId, name, externalId, parentId, openingLocalDate);
|
||||
return this.commonRestOperations.updateOffice(command);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user