Examples of CHAPTER


Examples of org.gtugs.domain.Chapter

  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

Examples of org.gtugs.domain.Chapter

    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

Examples of org.gtugs.domain.Chapter

  }

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

    return chapter;
  }
View Full Code Here

Examples of org.gtugs.domain.Chapter

          "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

Examples of org.gtugs.domain.Chapter

  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

Examples of org.gtugs.domain.Chapter

  public boolean supports(Class c) {
    return Chapter.class.equals(c);
  }

  public void validate(Object obj, Errors errors) {
    Chapter chapter = (Chapter) obj;
    boolean locationErrors = false;

    if (chapter == null) {
      errors.rejectValue("name", null, null, "Name required");
    }
    else {
      if (chapter.getName() == null || chapter.getName().equals("")) {
        errors.rejectValue("name", null, null, "Name required");
      }
      if (chapter.getType() == null || chapter.getType().equals("")) {
        errors.rejectValue("type", null, null, "Type required");
      }
      /*if ((chapter.getCity() == null || chapter.getCity().equals("")) &&
          (chapter.getState() == null || chapter.getState().equals(""))) {
        errors.rejectValue("city", null, null, "City and/or state required");
        errors.rejectValue("state", null, null, "City and/or state required");
        locationErrors = true;
      }*/
      if (chapter.getCountry() == null || chapter.getCountry().equals("")) {
        errors.rejectValue("country", null, null, "Country required");
        locationErrors = true;
      }
      if (chapter.getStatus() == null || chapter.getStatus().equals("")) {
        errors.rejectValue("status", null, null, "Status required");
      }

      if (!locationErrors) {
        Point point = mapsService.getCoordinates(chapter.getCity(),
            chapter.getState(), chapter.getCountry());
        if (point == null) {
          errors.rejectValue("city", null, null, "Geocoding failed: given address may be invalid or geocoding service may be offline");
          errors.rejectValue("state", null, null, "Geocoding failed: given address may be invalid or geocoding service may be offline");
          errors.rejectValue("country", null, null, "Geocoding failed: given address may be invalid or geocoding service may be offline");
        } else {
          chapter.setLatitude(point.getLatitude());
          chapter.setLongitude(point.getLongitude());
        }
      }

      if ((chapter.getWebsite() == null || chapter.getWebsite().equals("")) &&
          (chapter.getMailingList() == null ||
          chapter.getMailingList().equals(""))) {
        errors.rejectValue("website", null, null,
            "Website and/or mailing list required");
        errors.rejectValue("mailingList", null, null,
            "Website and/or mailing list required");
      }
      if (chapter.getWebsite() != null &&
          !chapter.getWebsite().equals("")) {
        if (!isValidUrl(chapter.getWebsite())) {
          errors.rejectValue("website", null, null, "Invalid website");
        }
      }
      if (chapter.getMailingList() != null &&
          !chapter.getMailingList().equals("")) {
        if (!isValidUrl(chapter.getMailingList())) {
          errors.rejectValue("mailingList", null, null,
              "Invalid mailing list");
        }
      }

      for (int i = 0; i < chapter.getAdministrators().size(); i++) {
        User u = chapter.getAdministrators().get(i);

        if (u.getName() == null || u.getName().equals("")) {
          errors.rejectValue("administrators[" + i + "].name", null, null,
              "Name required");
        }
View Full Code Here

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);

      return new ModelAndView("admin_error", model);
    }
    if (!hasAccess(userService, chapter)) {
      userService.setAfterLogoutEndpoint("/admin");

      String errorText = "You are not listed as an organizer for this " +
          "chapter. Please sign in with an organizer's account to access " +
          "this page.";
      model.put("errorText", errorText);

      return new ModelAndView("admin_error", model);
    }

    map.put("chapter", chapter);
    map.put("countries", countryManager.getCountries());
    map.put("events", eventManager.getEventsForChapter(chapter.getId()));

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

Examples of org.gtugs.domain.Chapter

  }

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

    if (chapter == null) {
      return new Chapter();
    } else {
      // Workaround for IndexOutOfBoundsException
      List<User> administrators = new AutoPopulatingList(User.class);
      administrators.addAll(chapter.getAdministrators());
      chapter.setAdministrators(administrators);
    }

    return chapter;
  }
View Full Code Here

Examples of org.gtugs.domain.Chapter

  }

  @Override
  protected void onBind(HttpServletRequest request, Object command)
      throws Exception {
    Chapter chapter = (Chapter) command;
    List<User> administrators = chapter.getAdministrators();

    for (int i = administrators.size() - 1; i >= 0; i--) {
      if (administrators.get(i).getIsFlagged()) {
        administrators.remove(i);
      }
View Full Code Here

Examples of org.gtugs.domain.Chapter

    }
  }

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

    if (chapter == null) {
      String errorText = "Failed to update chapter with ID \"" + cmd.getId() +
          "\" -- 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);
    }

    chapter.setName(cmd.getName());
    chapter.setType(cmd.getType());
    chapter.setCity(cmd.getCity());
    chapter.setState(cmd.getState());
    chapter.setCountry(cmd.getCountry());
    chapter.setStatus(cmd.getStatus());
    chapter.setLatitude(cmd.getLatitude());
    chapter.setLongitude(cmd.getLongitude());
    chapter.setWebsite(cmd.getWebsite());
    chapter.setMeetupGroupUrlName(cmd.getMeetupGroupUrlName());
    chapter.setMailingList(cmd.getMailingList());
    chapter.setAdministrators(cmd.getAdministrators());
    chapter.setDescription(cmd.getDescription());
    chapterManager.storeChapter(chapter);

    return new ModelAndView(new RedirectView(getSuccessView()));
  }
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.