Examples of LoanShark


Examples of org.springframework.integration.samples.loanbroker.loanshark.domain.LoanShark

  @Transactional
  @Ignore
  public void test() {
    accumulator.accumulate(new SharkQuote("fred", 6.0d));
    accumulator.accumulate(new SharkQuote("fred", 6.2d));
    LoanShark shark = (LoanShark) LoanShark.findLoanSharksByName("fred").getSingleResult();
    assertEquals(new Long(2), shark.getCounter());
    assertEquals(new Double(6.1), shark.getAverageRate());
  }
View Full Code Here

Examples of org.springframework.integration.samples.loanbroker.loanshark.domain.LoanShark

@Service
public class Accumulator {

  @Transactional
  public void accumulate(SharkQuote quote) {
    LoanShark shark = null;
    try {
      shark = (LoanShark) LoanShark.findLoanSharksByName(
          quote.getSharkName()).getSingleResult();
    } catch (DataAccessException dae) {}
    if (shark == null) {
      shark = new LoanShark();
      shark.setName(quote.getSharkName());
      shark.setCounter(new Long(0));
      shark.setAverageRate(0.0d);
      shark.persist();
    }
    Double current = shark.getCounter() * shark.getAverageRate();
    shark.setCounter(shark.getCounter().longValue() + 1);
    shark.setAverageRate((current + quote.getSharkRate()) / shark.getCounter());
  }
View Full Code Here

Examples of org.springframework.integration.samples.loanbroker.loanshark.domain.LoanShark

    return "redirect:/loansharks/" + loanShark.getId();
  }

  @RequestMapping(params = "form", method = RequestMethod.GET)
  public String createForm(Model model) {
    model.addAttribute("loanShark", new LoanShark());
    return "loansharks/create";
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.