Package org.gtugs.domain

Examples of org.gtugs.domain.Chapter


    AppEngineUserService userService = new AppEngineUserService();
    map.put("userService", userService);
    model.put("model", map);

    Chapter chapter = retrieveChapter(chapterId);

    if (chapter == null) {
      String errorText = "Failed to retrieve chapter with ID \"" + chapterId +
          "\" -- chapter not found.";
      model.put("errorText", errorText);
View Full Code Here


  @Override
  protected Object formBackingObject(HttpServletRequest request) throws
      ServletException {
    String chapterId = request.getParameter("id");
    Chapter chapter = retrieveChapter(chapterId);

    if (chapter == null) {
      return new Event();
    }

    Event event = new Event();
    event.setChapterId(chapter.getId());
    event.setStartDate(new Date());
    event.setStartTime("1900");
    event.setEndDate(new Date());
    event.setEndTime("2100");
    event.setCity(chapter.getCity());
    event.setState(chapter.getState());
    event.setCountry(chapter.getCountry());

    return event;
  }
View Full Code Here

  }

  @Override
  public ModelAndView onSubmit(Object command) throws ServletException {
    Event cmd = (Event) command;
    Chapter chapter = retrieveChapter(cmd.getChapterId());
    AppEngineUserService userService = new AppEngineUserService();

    if (chapter == null) {
      String errorText = "Failed to update chapter with ID \"" +
          cmd.getChapterId() + "\" -- chapter not found.";

      return new ModelAndView("admin_error", "errorText", errorText);
    }
    if (!hasAccess(userService, chapter)) {
      String errorText = "You are not listed as an organizer for this " +
          "chapter. Please sign in with an organizer's account to access " +
          "this page.";

      return new ModelAndView("error", "errorText", errorText);
    }

    eventManager.storeEvent(cmd);

    return new ModelAndView(new RedirectView(getSuccessView() + "?id=" +
        chapter.getId() + "&t=events"));
  }
View Full Code Here

    response.setContentType("text/plain");
    MemcacheService ms = MemcacheServiceFactory.getMemcacheService();
    ms.clearAll();

    String chapterId = request.getParameter("id");
    Chapter chapter = retrieveChapter(chapterId);

    if (chapter == null) {
      response.getWriter().println("Geocode update failed: chapter not found");
      return;
    }

    response.getWriter().println(chapter.getName());

    Point point = mapsService.getCoordinates(chapter.getCity(),
        chapter.getState(), chapter.getCountry());
    if (point == null) {
      response.getWriter().println("Geocode update failed: point not found");
      return;
    } else {
      chapter.setLatitude(point.getLatitude());
      chapter.setLongitude(point.getLongitude());

      PersistenceManager pm = PMF.get().getPersistenceManager();
      try {
        pm.makePersistent(chapter);
      } catch (Exception e) {
        response.getWriter().println("Geocode update failed: JDO error");
        return;
      } finally {
        pm.close();
      }
    }

    chapter = null;
    chapter = retrieveChapter(chapterId);

    if (chapter == null) {
      response.getWriter().println("Geocode update failed: chapter not found");
      return;
    }

    response.getWriter().println("Geocode update succeeded");
    response.getWriter().println(point.getLatitude() + ", " + point.getLongitude());
    response.getWriter().println(chapter.getLatitude() + ", " + chapter.getLongitude());
  }
View Full Code Here

  protected void setUp() throws Exception {
    chapterManager = new SimpleChapterManager();
    chapters = new ArrayList<Chapter>();

    Chapter chapter = new Chapter();
    chapter.setName(GTUG_A_NAME);
    chapters.add(chapter);

    chapter = new Chapter();
    chapter.setName(GTUG_B_NAME);
    chapters.add(chapter);

    ChapterDao chapterDao = new InMemoryChapterDao(chapters);
    chapterManager.setChapterDao(chapterDao);
  }
View Full Code Here

  public void testGetChapters() {
    List<Chapter> chapters = chapterManager.getChapters();
    assertNotNull(chapters);
    assertEquals(CHAPTER_COUNT, chapterManager.getChapters().size());

    Chapter chapter = chapters.get(0);
    assertEquals(GTUG_A_NAME, chapter.getName());

    chapter = chapters.get(1);
    assertEquals(GTUG_B_NAME, chapter.getName());
  }
View Full Code Here

    return count;
  }

  public Chapter getChapter(Long id) {
    PersistenceManager pm = getPersistenceManager();
    Chapter chapter = null;

    try {
      chapter = pm.getObjectById(Chapter.class, id);

      // Lazily load administrator list
      chapter.getAdministrators();

      // Detach chapter
      chapter = pm.detachCopy(chapter);
    } catch (JDOObjectNotFoundException e) {
      return null;
View Full Code Here

  }

  @Override
  protected Object formBackingObject(HttpServletRequest request) throws
      ServletException {
    Chapter chapter = new Chapter();
    chapter.getAdministrators().add(new User());

    return chapter;
  }
View Full Code Here

          "this page.";

      return new ModelAndView("error", "errorText", errorText);
    }

    Chapter chapter = (Chapter) command;
    chapter.setCreatedOn(new Date());
    chapterManager.storeChapter(chapter);

    return new ModelAndView(new RedirectView(getSuccessView()));
  }
View Full Code Here

  private EventManager eventManager;

  @RequestMapping("/chapter")
  public ModelAndView getChapter(@RequestParam("id")String id) throws ServletException, IOException {
   
    Chapter chapter = retrieveChapter(id);

    if (chapter == null) {
      String errorText = "Failed to retrieve chapter with ID \"" + id +
          "\" -- chapter not found.";

      return new ModelAndView("error", "errorText", errorText);
    }

    chapter.setNumEvents(0);

    List<Event> pastEvents = eventManager.getPastEvents(chapter.getId());
    if (pastEvents != null) {
      chapter.setNumEvents(pastEvents.size());

      int totalAttendees = 0;
      int totalEvents = 0;
      for (Event event : pastEvents) {
        if (event.getAttendeeCount() != null) {
          totalAttendees += event.getAttendeeCount();
          totalEvents++;
        }
      }

      if (totalEvents > 0) {
        chapter.setAverageAttendees(totalAttendees/totalEvents);
      }
    }

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("chapter", chapter);
    model.put("events", eventManager.getEventsForChapter(chapter.getId(), true));
    model.put("pastevents", pastEvents);

    return new ModelAndView("chapter", "model", model);
  }
View Full Code Here

TOP

Related Classes of org.gtugs.domain.Chapter

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.