Package org.gtugs.domain

Examples of org.gtugs.domain.Event


      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
  protected void onBind(HttpServletRequest request, Object command)
      throws Exception {
    Event event = (Event) command;
    String endTime = event.getEndTime();
    String startTime = event.getStartTime();
    Calendar calendar = Calendar.getInstance();

    int endHour = Integer.parseInt(endTime.substring(0, 2));
    int endMinute = Integer.parseInt(endTime.substring(2, 4));
    int startHour = Integer.parseInt(startTime.substring(0, 2));
    int startMinute = Integer.parseInt(startTime.substring(2, 4));

    calendar.setTime(event.getStartDate());
    calendar.set(Calendar.HOUR_OF_DAY, startHour);
    calendar.set(Calendar.MINUTE, startMinute);
    event.setStartDate(calendar.getTime());

    calendar.setTime(event.getEndDate());
    calendar.set(Calendar.HOUR_OF_DAY, endHour);
    calendar.set(Calendar.MINUTE, endMinute);
    event.setEndDate(calendar.getTime());

    if (event.getOnAndroid()) {
      event.addTopic(Topic.ANDROID);
    }
    if (event.getOnGoogleAjaxApis()) {
      event.addTopic(Topic.GOOGLE_AJAX_APIS);
    }
    if (event.getOnGoogleAppEngine()) {
      event.addTopic(Topic.GOOGLE_APP_ENGINE);
    }
    if (event.getOnGoogleChromeExtensions()) {
      event.addTopic(Topic.GOOGLE_CHROME_EXTENSIONS);
    }
    if (event.getOnGoogleEarthApis()) {
      event.addTopic(Topic.GOOGLE_EARTH_APIS);
    }
    if (event.getOnGoogleMapsApis()) {
      event.addTopic(Topic.GOOGLE_MAPS_APIS);
    }
    if (event.getOnGoogleWaveApis()) {
      event.addTopic(Topic.GOOGLE_WAVE_APIS);
    }
    if (event.getOnGoogleWebToolkit()) {
      event.addTopic(Topic.GOOGLE_WEB_TOOLKIT);
    }
    if (event.getOnOpenSocial()) {
      event.addTopic(Topic.OPENSOCIAL);
    }
    if (event.getOnOther() && event.getCustomTopic() != null &&
        !event.getCustomTopic().equals("")) {
      event.addTopic(event.getCustomTopic());
    }
  }
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 " +
View Full Code Here

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

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

    if (event == null) {
      errors.rejectValue("name", null, null, "Name required");
    }
    else {
      if (event.getName() == null || event.getName().equals("")) {
        errors.rejectValue("name", null, null, "Name required");
      }
      if (event.getTimeZone() == null || event.getTimeZone().equals("")) {
        errors.rejectValue("timeZone", null, null, "Time zone required");
      }
      if (event.getStartDate() == null) {
        errors.rejectValue("startDate", null, null, "Start date required");
      } else if (event.getEndDate() == null) {
        errors.rejectValue("endDate", null, null, "End date required");
      } else if (event.getEndDate().before(event.getStartDate())) {
        errors.rejectValue("endDate", null, null,
            "End time must occur after start time");
      }
      if (event.getStreetAddress() == null ||
          event.getStreetAddress().equals("")) {
        errors.rejectValue("streetAddress", null, null, "Address required");
        locationErrors = true;
      }
      if (event.getCity() == null || event.getCity().equals("")) {
        errors.rejectValue("city", null, null, "City required");
        locationErrors = true;
      }
      if (event.getCountry() == null || event.getCountry().equals("")) {
        errors.rejectValue("country", null, null, "Country required");
        locationErrors = true;
      }
      if (event.getUrl() != null && !event.getUrl().equals("") &&
          !isValidUrl(event.getUrl())) {
        errors.rejectValue("url", null, null, "Invalid URL");
      }
      if (event.getDescription() == null ||
          event.getDescription().equals("")) {
        errors.rejectValue("description", null, null, "Description required");
      }

      if (!locationErrors) {
        Point point = mapsService.getCoordinates(event.getStreetAddress(),
            event.getCity(), event.getState(), event.getCountry());
        if (point == null) {
          errors.rejectValue("streetAddress", null, null, "Geocoding failed: given address may be invalid or geocoding service may be offline");
          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 {
          event.setLatitude(point.getLatitude());
          event.setLongitude(point.getLongitude());
        }
      }
    }
  }
View Full Code Here

    JSONObject jsonObj = (JSONObject) JSONValue.parse(json.toString());
    JSONArray results = (JSONArray) jsonObj.get("results");
    for (int i = 0; i < results.size(); i++) {
      JSONObject result = (JSONObject) results.get(i);
      Event e = new Event();
      e.setAttendeeCount(Integer.parseInt((String) result.get("rsvpcount")));
      // e.setChapterId();
      e.setCity((String) result.get("venue_city"));
      // e.setCountry();
      // e.setCustomTopic();
      e.setDescription((String) result.get("description"));
      // e.setEndDate();
      // e.setEndTime();
      e.setLatitude(Double.parseDouble((String) result.get("venue_lat")));
      e.setLongitude(Double.parseDouble((String) result.get("venue_lon")));
      e.setName((String) result.get("name"));
      // e.setNotes();
      // e.setRoom();

      Date myDate = null;
      String time = (String) result.get("time");
      try {
        myDate = meetupDateFormat.parse(time);
        e.setStartTime(timeDateFormat.format(myDate));
        e.setEndTime(timeDateFormat.format(myDate));
        e.setStartDate(myDate);
        e.setEndDate(myDate);

        String tz = tzDateFormat.format(myDate);
        if (tz != null && tz.startsWith("+")) {
          tz = tz.substring(1);
        }
        e.setTimeZone(Integer.toString(Integer.parseInt(tz)/100));
      } catch (ParseException ex) {
        ex.printStackTrace();
        continue;
      }

      e.setState((String) result.get("venue_state"));

      StringBuilder addressBuilder = new StringBuilder();
      if (result.get("venue_address1") != null) {
        addressBuilder.append((String) result.get("venue_address1") + " ");
      }
      if (result.get("venue_address2") != null) {
        addressBuilder.append((String) result.get("venue_address2") + " ");
      }
      if (result.get("venue_address3") != null) {
        addressBuilder.append((String) result.get("venue_address3") + " ");
      }
      if (result.get("venue_address4") != null) {
        addressBuilder.append((String) result.get("venue_address4"));
      }
      e.setStreetAddress(addressBuilder.toString().trim());
      e.setZipCode((String) result.get("venue_zip"));

      e.setUrl((String) result.get("event_url"));

      events.add(e);
    }

    return events;
View Full Code Here

    setPersistenceManagerFactory(PMF.get());
  }

  public Event getEvent(Long id) {
    PersistenceManager pm = getPersistenceManager();
    Event event = null;

    try {
      event = pm.getObjectById(Event.class, id);

      // Detach event
View Full Code Here

          List<Event> chapterEvents =
            meetupEventSite.lookupFutureEvents(meetupGroupId);
          for (Event event : chapterEvents) {
            event.setChapterId(chapter.getId());

            Event existingEvent = findExisting(event, existingEvents);
            if (existingEvent == null){
              eventManager.storeEvent(event);
              newEvents.add(event);
            } else{
              //DO NOTHING ON UPDATE
View Full Code Here

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

    Event event = retrieveEvent(eventId);

    if (event == null) {
      String errorText = "Failed to retrieve event with ID \"" + eventId +
          "\" -- event not found.";
      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);

      return new ModelAndView("admin_error", model);
    }
    if (!hasAccess(userService, chapter)) {
View Full Code Here

  }

  @Override
  protected Object formBackingObject(HttpServletRequest request) throws
      ServletException {
    Event event = retrieveEvent(request.getParameter("id"));

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

    Calendar calendar = Calendar.getInstance();

    calendar.setTime(event.getStartDate());
    if (calendar.get(Calendar.HOUR_OF_DAY) < 10) {
      event.setStartTime(("0" + calendar.get(Calendar.HOUR_OF_DAY) +
          calendar.get(Calendar.MINUTE) + "0").substring(0, 4));
    } else {
      event.setStartTime(("" + calendar.get(Calendar.HOUR_OF_DAY) +
          calendar.get(Calendar.MINUTE) + "0").substring(0, 4));
    }

    calendar.setTime(event.getEndDate());
    if (calendar.get(Calendar.HOUR_OF_DAY) < 10) {
      event.setEndTime(("0" + calendar.get(Calendar.HOUR_OF_DAY) +
          calendar.get(Calendar.MINUTE) + "0").substring(0, 4));
    } else {
      event.setEndTime(("" + calendar.get(Calendar.HOUR_OF_DAY) +
          calendar.get(Calendar.MINUTE) + "0").substring(0, 4));
    }

    for (String topic : event.getTopics()) {
      if (topic.equals(Topic.ANDROID)) {
        event.setOnAndroid(true);
      } else if (topic.equals(Topic.GOOGLE_AJAX_APIS)) {
        event.setOnGoogleAjaxApis(true);
      } else if (topic.equals(Topic.GOOGLE_APP_ENGINE)) {
        event.setOnGoogleAppEngine(true);
      } else if (topic.equals(Topic.GOOGLE_CHROME_EXTENSIONS)) {
        event.setOnGoogleChromeExtensions(true);
      } else if (topic.equals(Topic.GOOGLE_EARTH_APIS)) {
        event.setOnGoogleEarthApis(true);
      } else if (topic.equals(Topic.GOOGLE_MAPS_APIS)) {
        event.setOnGoogleMapsApis(true);
      } else if (topic.equals(Topic.GOOGLE_WAVE_APIS)) {
        event.setOnGoogleWaveApis(true);
      } else if (topic.equals(Topic.GOOGLE_WEB_TOOLKIT)) {
        event.setOnGoogleWebToolkit(true);
      } else if (topic.equals(Topic.OPENSOCIAL)) {
        event.setOnOpenSocial(true);
      } else {
        event.setOnOther(true);
        event.setCustomTopic(topic);
      }
    }

    return event;
  }
View Full Code Here

  }

  @Override
  protected void onBind(HttpServletRequest request, Object command)
      throws Exception {
    Event event = (Event) command;
    String endTime = event.getEndTime();
    String startTime = event.getStartTime();
    Calendar calendar = Calendar.getInstance();

    int endHour = Integer.parseInt(endTime.substring(0, 2));
    int endMinute = Integer.parseInt(endTime.substring(2, 4));
    int startHour = Integer.parseInt(startTime.substring(0, 2));
    int startMinute = Integer.parseInt(startTime.substring(2, 4));

    calendar.setTime(event.getStartDate());
    calendar.set(Calendar.HOUR_OF_DAY, startHour);
    calendar.set(Calendar.MINUTE, startMinute);
    event.setStartDate(calendar.getTime());

    calendar.setTime(event.getEndDate());
    calendar.set(Calendar.HOUR_OF_DAY, endHour);
    calendar.set(Calendar.MINUTE, endMinute);
    event.setEndDate(calendar.getTime());
  }
View Full Code Here

TOP

Related Classes of org.gtugs.domain.Event

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.