Package org.gtugs.domain

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


    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

  }

  @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

  }

  @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

    }
  }

  @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

     
      list = new JSONArray();
      for (Event event : events) {
        JSONObject map = new JSONObject();
        map.put("chapterId", event.getChapterId());
        Chapter chapter=chaptersMap.get(event.getChapterId());
        if (chapter!=null) {
          map.put("chapterName", chapter.getName());
          map.put("chapterUrl", "http://www.gtugs.org/chapter.jsp?id=" +
              chapter.getId());
          map.put("chapterWebsite", chapter.getWebsite());
          map.put("chapterStatus", chapter.getStatus());
        }
        map.put("id", event.getId());
        map.put("name", event.getName());
        map.put("timeZone", event.getTimeZone());
        map.put("startDate", event.getStartDate());
View Full Code Here

        int numEvents = chapters.get(i).getNumEvents();
        int j = i - 1;
        boolean done = false;
        do {
          if (chapters.get(j).getNumEvents() < numEvents) {
            Chapter swapped = chapters.remove(j + 1);
            chapters.add(j, swapped);
            j--;
            if (j < 0) {
              done = true;
            }
View Full Code Here

      model.put("errorText", errorText);

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

    Chapter chapter = retrieveChapter(event.getChapterId());

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

          "\" -- event not found.";

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

    Chapter chapter = retrieveChapter(event.getChapterId());

    if (chapter == null) {
      String errorText = "Failed to retrieve chapter with ID \"" +
          event.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 the " +
          "chapter associated with this event. Please sign in with an " +
          "organizer's account to access this page.";

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

    event.setName(cmd.getName());
    event.setTimeZone(cmd.getTimeZone());
    event.setStartDate(cmd.getStartDate());
    event.setEndDate(cmd.getEndDate());
    event.setStreetAddress(cmd.getStreetAddress());
    event.setRoom(cmd.getRoom());
    event.setCity(cmd.getCity());
    event.setState(cmd.getState());
    event.setZipCode(cmd.getZipCode());
    event.setCountry(cmd.getCountry());
    event.setLatitude(cmd.getLatitude());
    event.setLongitude(cmd.getLongitude());
    event.setUrl(cmd.getUrl());
    event.setDescription(cmd.getDescription());
    event.setAttendeeCount(cmd.getAttendeeCount());
    event.setNotes(cmd.getNotes());

    event.getTopics().clear();
    if (cmd.getOnAndroid()) {
      event.addTopic(Topic.ANDROID);
    }
    if (cmd.getOnGoogleAjaxApis()) {
      event.addTopic(Topic.GOOGLE_AJAX_APIS);
    }
    if (cmd.getOnGoogleAppEngine()) {
      event.addTopic(Topic.GOOGLE_APP_ENGINE);
    }
    if (cmd.getOnGoogleChromeExtensions()) {
      event.addTopic(Topic.GOOGLE_CHROME_EXTENSIONS);
    }
    if (cmd.getOnGoogleEarthApis()) {
      event.addTopic(Topic.GOOGLE_EARTH_APIS);
    }
    if (cmd.getOnGoogleMapsApis()) {
      event.addTopic(Topic.GOOGLE_MAPS_APIS);
    }
    if (cmd.getOnGoogleWaveApis()) {
      event.addTopic(Topic.GOOGLE_WAVE_APIS);
    }
    if (cmd.getOnGoogleWebToolkit()) {
      event.addTopic(Topic.GOOGLE_WEB_TOOLKIT);
    }
    if (cmd.getOnOpenSocial()) {
      event.addTopic(Topic.OPENSOCIAL);
    }
    if (cmd.getOnOther() && cmd.getCustomTopic() != null &&
        !cmd.getCustomTopic().equals("")) {
      event.addTopic(cmd.getCustomTopic());
    }

    eventManager.storeEvent(event);

    return new ModelAndView(new RedirectView(getSuccessView() + "?id=" +
        chapter.getId() + "&t=events"));
  }
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.