Package com.gracevallorani.jpa.factories

Examples of com.gracevallorani.jpa.factories.ShortSectionStrategy


public class ShortsController {
  @RequestMapping(value = "index", method = RequestMethod.GET)
  public String showIndex(
      Model model,
      @RequestParam(value = "id", required = false, defaultValue = "0") int id) {
    ShortSectionStrategy strategy = new ShortSectionStrategy(new J2eeConfig());
   
    try {
      List<ShortSection> list = strategy.getAll();
      List<Shorts> shortsList = new ArrayList<Shorts>();
     
      for (ShortSection shortSection: list) {
        Collections.sort(shortSection.getShorts(), new ShortOrderComparator());
        shortsList.addAll(shortSection.getShorts());
      }
     
      model.addAttribute("list", list);     
     
      Shorts displayShort = null;
      for (Shorts shorts: shortsList) {
        if (shorts.getId() == id) {
          displayShort = shorts;
         
          break;
        }
      }
     
     
      if (displayShort == null) {
        displayShort = shortsList.get(0);
      }
     
      model.addAttribute("current", displayShort);
      return "/WEB-INF/website/shorts/index.jsp";
    } finally {
      strategy.close();
    }
  }
View Full Code Here

TOP

Related Classes of com.gracevallorani.jpa.factories.ShortSectionStrategy

Copyright © 2018 www.massapicom. 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.