use of org.springframework.binding.message.MessageBuilder in project head by mifos.
the class LoanAccountController method retrieveLoanProducts.
public LoanCreationProductDetailsDto retrieveLoanProducts(int customerId, org.springframework.binding.message.MessageContext messageContext) {
LoanCreationProductDetailsDto loanProductDetails = this.loanAccountServiceFacade.retrieveGetProductDetailsForLoanAccountCreation(customerId);
if (loanProductDetails.getErrors().hasErrors()) {
List<ErrorEntry> errorList = loanProductDetails.getErrors().getErrorEntries();
for (int i = 0; i < errorList.size(); i++) {
MessageBuilder builder = new MessageBuilder().error().source(errorList.get(i).getFieldName()).codes(Arrays.asList(errorList.get(i).getErrorCode()).toArray(new String[1])).defaultText(errorList.get(i).getDefaultMessage());
messageContext.addMessage(builder.build());
}
}
return loanProductDetails;
}
use of org.springframework.binding.message.MessageBuilder in project head by mifos.
the class LoanScheduleFormBean method addErrorMessageToContext.
private void addErrorMessageToContext(MessageContext messageContext, ErrorEntry fieldError) {
String[] errorCodes = new String[1];
errorCodes[0] = fieldError.getErrorCode();
List<Object> args = new ArrayList<Object>();
if (fieldError.hasErrorArgs()) {
args = new ArrayList<Object>(fieldError.getArgs());
}
MessageBuilder builder = new MessageBuilder().error().source(fieldError.getFieldName()).codes(errorCodes).defaultText(fieldError.getDefaultMessage()).args(args.toArray());
messageContext.addMessage(builder.build());
}
use of org.springframework.binding.message.MessageBuilder in project head by mifos.
the class ClearOverpaymentController method applyOverpaymentClear.
// called by spring webflow
public String applyOverpaymentClear(final String overpaymentId, ClearOverpaymentFormBean clearOverpaymentFormBean, MessageContext messageContext) {
String returnCode = "";
try {
BigDecimal overpaymentAmount = null;
if (clearOverpaymentFormBean.getActualOverpaymentAmount() != null) {
overpaymentAmount = BigDecimal.valueOf(clearOverpaymentFormBean.getActualOverpaymentAmount().doubleValue());
}
this.loanAccountServiceFacade.applyOverpaymentClear(overpaymentId, overpaymentAmount);
returnCode = "success";
} catch (BusinessRuleException e) {
MessageBuilder builder = new MessageBuilder().error().source("overpaymentAmount").codes(Arrays.asList(e.getMessageKey()).toArray(new String[1])).defaultText(e.getMessage()).args(e.getMessageValues());
messageContext.addMessage(builder.build());
returnCode = "error";
}
return returnCode;
}
use of org.springframework.binding.message.MessageBuilder in project opennms by OpenNMS.
the class ReportParametersValidator method validateReportParameters.
/**
* <p>validateReportParameters</p>
*
* @param reportCriteria a {@link org.opennms.api.reporting.parameter.ReportParameters} object.
* @param context a {@link org.springframework.binding.validation.ValidationContext} object.
*/
public void validateReportParameters(ReportParameters reportCriteria, ValidationContext context) {
MessageContext messages = context.getMessageContext();
List<ReportDateParm> dateParms = reportCriteria.getDateParms();
for (Iterator<ReportDateParm> dateParmIter = dateParms.iterator(); dateParmIter.hasNext(); ) {
ReportDateParm dateParm = dateParmIter.next();
if (dateParm.getDate() == null) {
messages.addMessage(new MessageBuilder().error().source("date parms").defaultText("cannot have null date field" + dateParm.getDisplayName()).build());
}
}
List<ReportStringParm> stringParms = reportCriteria.getStringParms();
for (Iterator<ReportStringParm> stringParmIter = stringParms.iterator(); stringParmIter.hasNext(); ) {
ReportStringParm stringParm = stringParmIter.next();
if (stringParm.getValue() == "") {
messages.addMessage(new MessageBuilder().error().source("string parms").defaultText("cannot have empty string field" + stringParm.getDisplayName()).build());
}
}
List<ReportIntParm> intParms = reportCriteria.getIntParms();
for (Iterator<ReportIntParm> intParmIter = intParms.iterator(); intParmIter.hasNext(); ) {
ReportIntParm intParm = intParmIter.next();
// TODO add a more sensible check here - I think we probably can have zero int parm
if (intParm.getValue() == 0) {
messages.addMessage(new MessageBuilder().error().source("int parms").defaultText("cannot have zero integer field" + intParm.getDisplayName()).build());
}
}
List<ReportFloatParm> floatParms = reportCriteria.getFloatParms();
for (Iterator<ReportFloatParm> floatParmIter = floatParms.iterator(); floatParmIter.hasNext(); ) {
ReportFloatParm floatParm = floatParmIter.next();
if (floatParm.getValue() == null) {
messages.addMessage(new MessageBuilder().error().source("float parms").defaultText("cannot have null float field" + floatParm.getDisplayName()).build());
}
}
List<ReportDoubleParm> doubleParms = reportCriteria.getDoubleParms();
for (Iterator<ReportDoubleParm> doubleParmIter = doubleParms.iterator(); doubleParmIter.hasNext(); ) {
ReportDoubleParm doubleParm = doubleParmIter.next();
if (doubleParm.getValue() == null) {
messages.addMessage(new MessageBuilder().error().source("double parms").defaultText("cannot have null double field" + doubleParm.getDisplayName()).build());
}
}
}
use of org.springframework.binding.message.MessageBuilder in project opennms by OpenNMS.
the class DefaultSchedulerService method addCronTrigger.
/*
* (non-Javadoc)
* @see
* org.opennms.web.svclayer.support.SchedulerService#addCronTrigger(org
* .opennms.web.report.database.model.DatabaseReportCriteria,
* java.lang.String, java.lang.String, java.lang.String,
* org.springframework.webflow.execution.RequestContext)
*/
/** {@inheritDoc} */
@Override
public String addCronTrigger(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, String cronExpression, RequestContext context) {
CronTriggerImpl cronTrigger = null;
try {
if (m_reportWrapperService.validate(criteria, id) == false) {
LOG.error(PARAMETER_ERROR);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build());
return ERROR;
} else {
try {
cronTrigger = new CronTriggerImpl();
cronTrigger.setGroup(m_triggerGroup);
cronTrigger.setName(deliveryOptions.getInstanceId());
cronTrigger.setJobName(m_jobDetail.getKey().getName());
cronTrigger.setCronExpression(cronExpression);
// cronTrigger = new CronTrigger(triggerName, m_triggerGroup,
// cronExpression);
} catch (ParseException e) {
LOG.error(TRIGGER_PARSE_ERROR, e);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(TRIGGER_PARSE_ERROR).build());
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(e.getMessage()).build());
return ERROR;
}
cronTrigger.setJobName(m_jobDetail.getKey().getName());
cronTrigger.getJobDataMap().put("criteria", (ReportParameters) criteria);
cronTrigger.getJobDataMap().put("reportId", id);
cronTrigger.getJobDataMap().put("mode", ReportMode.SCHEDULED);
cronTrigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions);
try {
m_scheduler.scheduleJob(cronTrigger);
} catch (SchedulerException e) {
LOG.error(SCHEDULER_ERROR, e);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build());
return ERROR;
}
return SUCCESS;
}
} catch (ReportServiceLocatorException e) {
LOG.error(REPORTID_ERROR);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build());
return ERROR;
}
}
Aggregations