use of org.mifos.core.MifosException in project head by mifos.
the class HomePageController method loadLoanOfficerCustomersHierarchyForSelectedDay.
private void loadLoanOfficerCustomersHierarchyForSelectedDay(Short userId, ModelAndView modelAndView, CustomerSearchFormBean customerSearchFormBean) throws MifosException {
CustomerHierarchyDto hierarchy;
List<String> nearestDates = new ArrayList<String>();
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", personnelServiceFacade.getUserPreferredLocale());
Date selectedDate = new LocalDate().toDateMidnight().toDate();
DateTime nextDate = new DateTime();
for (int i = 0; i < 7; i++) {
nearestDates.add(formatter.format(nextDate.toDate()));
nextDate = nextDate.plusDays(1);
}
if (customerSearchFormBean.getSelectedDateOption() != null) {
try {
selectedDate = formatter.parse(customerSearchFormBean.getSelectedDateOption());
} catch (ParseException e) {
throw new MifosException(e);
}
}
hierarchy = personnelServiceFacade.getLoanOfficerCustomersHierarchyForDay(userId, new DateTime(selectedDate));
modelAndView.addObject("nearestDates", nearestDates);
modelAndView.addObject("hierarchy", hierarchy);
}
use of org.mifos.core.MifosException in project head by mifos.
the class StandardTestingService method runIndividualBatchJob.
@Override
public void runIndividualBatchJob(final String requestedJob, final ServletContext ctx) throws MifosException {
logger.info("running batch job with name: " + requestedJob);
boolean jobFound = false;
String jobToRun = null;
final MifosScheduler mifosScheduler = (MifosScheduler) ctx.getAttribute(MifosScheduler.class.getName());
try {
for (String taskName : mifosScheduler.getTaskNames()) {
if (taskName.equals(requestedJob)) {
jobFound = true;
jobToRun = taskName;
break;
}
}
if (!jobFound) {
throw new IllegalArgumentException(requestedJob + " is unknown and will not be executed.");
}
mifosScheduler.runIndividualTask(jobToRun);
} catch (TaskSystemException se) {
throw new MifosException("Scheduler's inner exception while running individual batch job!", se);
}
}
use of org.mifos.core.MifosException in project head by mifos.
the class StandardTestingService method setLocale.
@Override
public void setLocale(String languageCode, String countryCode) throws MifosException {
try {
LocaleSetting configLocale = new LocaleSetting();
configLocale.setLanguageCode(languageCode);
configLocale.setCountryCode(countryCode);
Localization localization = Localization.getInstance();
localization.setConfigLocale(configLocale);
if (SecurityContextHolder.getContext() != null) {
if (SecurityContextHolder.getContext().getAuthentication() != null) {
if (SecurityContextHolder.getContext().getAuthentication().getPrincipal() != null) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
user.setPreferredLocaleId(Localization.getInstance().getLocaleId(Localization.getInstance().getConfiguredLocale()));
}
}
}
StaticHibernateUtil.startTransaction();
PersonnelBO p = (PersonnelBO) StaticHibernateUtil.getSessionTL().get(PersonnelBO.class, (short) 1);
p.setPreferredLocale(Localization.getInstance().getConfiguredLocaleId());
StaticHibernateUtil.getSessionTL().update(p);
StaticHibernateUtil.commitTransaction();
MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
configMgr.setProperty("Localization.LanguageCode", languageCode);
configMgr.setProperty("Localization.CountryCode", countryCode);
} catch (MifosRuntimeException e) {
throw new MifosException("The locale " + languageCode + "_" + countryCode + " is not supported by Mifos.");
}
}
Aggregations