/**
   * Gets the all events.
   *
   * @return the all events
   */
  public List<Event> getAllEvents() {
    List<Event> events = new ArrayList<Event>();
    String selectQuery = "SELECT  * FROM " + TABLE_EVENT;

    Log.e(LOG, selectQuery);

    SQLiteDatabase db = this.getReadableDatabase();
    Cursor c = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (c.moveToFirst()) {
      do {
        Event ev = new Event();
        ev.setId(c.getInt((c.getColumnIndex(KEY_ID))));
        ev.setTitle((c.getString(c.getColumnIndex(KEY_EVENT_TITLE))));
        ev.setStartDate((c.getString(c.getColumnIndex(KEY_EVENT_STARTDATE))));
        ev.setEndDate((c.getString(c.getColumnIndex(KEY_EVENT_ENDDATE))));
        ev.setStartTime((c.getString(c.getColumnIndex(KEY_EVENT_STARTTIME))));
        ev.setEndTime((c.getString(c.getColumnIndex(KEY_EVENT_ENDTIME))));
        ev.setDescription((c.getString(c.getColumnIndex(KEY_EVENT_DESCRIPTION))));
        ev.setRepeat((c.getString(c.getColumnIndex(KEY_EVENT_REPEAT))));

        // adding to event list
        events.add(ev);
      } while (c.moveToNext());
    }
    return events;
  }
 /*
  * get top 3 (today and tomorrow) events that most people are attending
  */
 public ArrayList<Event> getDayHotEvent() {
   ArrayList<Event> list = new ArrayList<Event>();
   String query = " SELECT a.att_evn_id, e.* , COUNT(att_evn_id) AS count ";
   query += " FROM tb_events e JOIN tb_attending a ON e.evn_id = a.att_evn_id ";
   query += " WHERE evn_start_time BETWEEN now() AND DATE_ADD(NOW(), INTERVAL 1 DAY) ";
   query += " GROUP BY a.att_evn_id ";
   query += " ORDER BY COUNT(att_evn_id) DESC LIMIT 3";
   List<HashMap<String, String>> result =
       DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_SELECT, query);
   Log.i(LOG_TAG, query);
   for (int i = 1; i < result.size(); i++) {
     Event e = new Event();
     for (Map.Entry<String, String> item : result.get(i).entrySet()) {
       if (item.getKey().equalsIgnoreCase("evn_id")) {
         e.setId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_titile")) {
         e.setTitle(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_description")) {
         e.setDescription(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_location")) {
         e.setLocation(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_start_time")) {
         e.setStartDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_end_time")) {
         e.setEndDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_created_time")) {
         e.setCreatedDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_contact_info")) {
         e.setContact(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_cat_id")) {
         e.setCategory(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_url")) {
         e.setUrl(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_like")) {
         e.setLike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_dislike")) {
         e.setDislike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_status")) {
         e.setStatus(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag")) {
         e.setTags(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag_id")) {
         e.setTagId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("count")) {
         e.setCount(Integer.parseInt(item.getValue().trim()));
       }
     }
     list.add(e);
   } // eventList now holds all events
   return list;
 }
 public boolean createEvent(Event e) {
   if (eventList.contains(e)) return true;
   String query =
       "INSERT INTO tb_events (evn_id, evn_titile, evn_description, evn_location, evn_start_time, evn_end_time, evn_created_time, evn_created_by, evn_contact_info, evn_cat_id, evn_url, evn_count_like, evn_count_dislike, evn_status, evn_tag, evn_tag_id)";
   query =
       query
           + " VALUES (NULL, '"
           + e.getTitle()
           + "', '"
           + e.getDescription()
           + "', '"
           + e.getLocation()
           + "', '"
           + e.getStartDayTime()
           + "', '"
           + e.getEndDayTime()
           + "', '"
           + e.getCreatedDayTime()
           + "', "
           + e.getCreatedBy()
           + ", '"
           + e.getContact()
           + "', "
           + e.getCategory()
           + ", '"
           + e.getUrl()
           + "', "
           + e.getLike()
           + ", "
           + e.getDislike()
           + ", "
           + e.getStatus()
           + ", '"
           + e.getTags()
           + "', NULL)";
   Log.i(LOG_TAG, query);
   List<HashMap<String, String>> result =
       DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_INSERT, query);
   e.setId(result.get(0).get("evn_id"));
   eventList.add(e);
   // add all Tags into Tag Table
   /*	for (int i =0; i< e.getTagList().size();i++)
   {
   	String query2 = "INSERT INTO tb_tags (tag_id, tag_name)"+ " VALUES (NULL, '"+e.getTagList().get(i)+"')";
   	List<HashMap<String, String>> result2 = DBComunicationLayer.executeHttpPost( DBComunicationLayer.PHP_INSERT, query2);
   } */
   //	return result.get( 0 ).get( "result" ).equals( "1" );
   return true;
 }
 /*
  * get top 3 (today and tomorrow) events that most people are attending
  */
 public ArrayList<Event> getEventById(String id) {
   ArrayList<Event> list = new ArrayList<Event>();
   String query = " SELECT * FROM tb_events ";
   query += " WHERE env_id = '" + id + "'";
   List<HashMap<String, String>> result =
       DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_SELECT, query);
   Log.i(LOG_TAG, query);
   for (int i = 1; i < result.size(); i++) {
     Event e = new Event();
     for (Map.Entry<String, String> item : result.get(i).entrySet()) {
       if (item.getKey().equalsIgnoreCase("evn_id")) {
         e.setId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_titile")) {
         e.setTitle(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_description")) {
         e.setDescription(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_location")) {
         e.setLocation(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_start_time")) {
         e.setStartDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_end_time")) {
         e.setEndDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_created_time")) {
         e.setCreatedDayTime(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_contact_info")) {
         e.setContact(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_cat_id")) {
         e.setCategory(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_url")) {
         e.setUrl(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_like")) {
         e.setLike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_count_dislike")) {
         e.setDislike(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_status")) {
         e.setStatus(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag")) {
         e.setTags(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("evn_tag_id")) {
         e.setTagId(item.getValue().trim());
       } else if (item.getKey().equalsIgnoreCase("count")) {
         e.setCount(Integer.parseInt(item.getValue().trim()));
       }
     }
     list.add(e);
   } // eventList now holds all events
   return list;
 }
  public boolean getAllEvents() {
    resetEventList();
    String query = "SELECT * FROM tb_events";
    List<HashMap<String, String>> result =
        DBComunicationLayer.executeHttpPost(DBComunicationLayer.PHP_SELECT, query);
    for (int i = 1; i < result.size(); i++) {
      Event e = new Event();
      for (Map.Entry<String, String> item : result.get(i).entrySet()) {

        if (item.getKey().equalsIgnoreCase("evn_id")) {
          e.setId(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_titile")) {
          e.setTitle(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_description")) {
          e.setDescription(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_location")) {
          e.setLocation(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_start_time")) {
          e.setStartDayTime(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_end_time")) {
          e.setEndDayTime(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_created_time")) {
          e.setCreatedDayTime(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_contact_info")) {
          e.setContact(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_cat_id")) {
          e.setCategory(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_url")) {
          e.setUrl(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_count_like")) {
          e.setLike(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_count_dislike")) {
          e.setDislike(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_status")) {
          e.setStatus(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_tag")) {
          e.setTags(item.getValue().trim());
        } else if (item.getKey().equalsIgnoreCase("evn_tag_id")) {
          e.setTagId(item.getValue().trim());
        }
      }
      if (!eventList.contains(e)) eventList.add(e);
    }
    //	return Integer.parseInt( result.get( 0 ).get( "result" ) ) == 1;
    return true;
  }
  /**
   * Gets the event.
   *
   * @param title the title
   * @return the event
   */
  public Event getEvent(String title) {
    SQLiteDatabase db = this.getReadableDatabase();
    String selectQuery =
        "SELECT  * FROM " + TABLE_EVENT + " WHERE " + KEY_EVENT_TITLE + " = '" + title + "'";

    Log.e(LOG, selectQuery);
    Cursor c = db.rawQuery(selectQuery, null);
    if (c != null) c.moveToFirst();

    Event ev = new Event();
    ev.setId(c.getInt(c.getColumnIndex(KEY_ID)));
    ev.setTitle((c.getString(c.getColumnIndex(KEY_EVENT_TITLE))));
    ev.setStartDate((c.getString(c.getColumnIndex(KEY_EVENT_STARTDATE))));
    ev.setEndDate((c.getString(c.getColumnIndex(KEY_EVENT_ENDDATE))));
    ev.setStartTime((c.getString(c.getColumnIndex(KEY_EVENT_STARTTIME))));
    ev.setEndTime((c.getString(c.getColumnIndex(KEY_EVENT_ENDTIME))));
    ev.setDescription((c.getString(c.getColumnIndex(KEY_EVENT_DESCRIPTION))));
    ev.setRepeat((c.getString(c.getColumnIndex(KEY_EVENT_REPEAT))));

    return ev;
  }
 public Event getEventFromCommand() {
   Event e = new Event();
   if (Id != 0) {
     e.setId(Id);
   }
   if (!detail.equals(NO_CHANGE_FOR_DETAIL)) {
     e.setDetails(detail);
   }
   if (!startDate.equals(NO_CHANGE_FOR_STARTDATE)) {
     e.setStartDate(startDate);
   }
   if (!endDate.equals(NO_CHANGE_FOR_ENDDATE)) {
     e.setEndDate(endDate);
   }
   if (priority != NO_CHANGE_FOR_PRIORITY) {
     e.setPriority(priority);
   }
   if (!tag.equals(NO_CHANGE_FOR_TAG)) {
     e.setTag(tag);
   }
   return e;
 }
Beispiel #8
0
  private Event makeEvent(Properties p, boolean fetchAlarm) {
    Event event = null;
    String id = p.getProperty("eventID");
    String start = p.getProperty("startDateTime");
    String end = p.getProperty("endDateTime");
    String location = p.getProperty("location");
    String description = p.getProperty("description");
    String isMeeting = p.getProperty("isMeeting");

    if (isMeeting.equals(BIT_FALSE)) {
      event = new Appointment();
    } else if (isMeeting.equals(BIT_TRUE)) {
      event = new Meeting();
    }
    event.setId(Integer.parseInt(id));
    event.setStartDateTime(start);
    event.setEndDateTime(end);
    event.setLocation(location);
    event.setDescription(description);
    if (fetchAlarm) {
      event.setAlarm(queryAlarm(currentUser, Integer.parseInt(id)));
    }
    event.setRoom(queryReservedRoom(Integer.parseInt(id)));
    if (event instanceof Appointment) {
      ((Appointment) event).setOwner(queryOwner(Integer.parseInt(id)));
    } else if (event instanceof Meeting) {
      ((Meeting) event).setLeader(queryOwner(Integer.parseInt(id)));
      ArrayList<User> invited = queryParticipants(Integer.parseInt(id), PARTICIPANT_STATUS_INVITED);
      ArrayList<User> accepted =
          queryParticipants(Integer.parseInt(id), PARTICIPANT_STATUS_ACCEPTED);
      ArrayList<User> declined =
          queryParticipants(Integer.parseInt(id), PARTICIPANT_STATUS_DECLINED);
      ((Meeting) event).setUsersInvited(invited);
      ((Meeting) event).setUsersAccepted(accepted);
      ((Meeting) event).setUsersDeclined(declined);
    }
    return event;
  }
    // Code which runs after doInBackground is ran
    protected void onPostExecute(String result) {

      Log.d("Result", (result));

      // Creates JSON array by parsing the result string
      try {

        json = (JSONArray) new JSONParser().parse(result);

        Log.d("JSON Size", String.valueOf(json.size()));

        for (int i = 0; i < json.size(); i++) {

          json_data = (JSONObject) json.get(i);

          Event event = new Event();
          event.setId((String) json_data.get("EventID"));
          event.setName((String) json_data.get("EName"));
          event.setDate((String) json_data.get("EDate"));
          event.setFromTime((String) json_data.get("FromTime"));
          event.setUntilTime((String) json_data.get("UntilTime"));
          event.setDesc((String) json_data.get("Descr"));
          event.setEntry((String) json_data.get("Entry"));
          event.setOneTimeEvent((String) json_data.get("OTE"));
          event.setFb((String) json_data.get("Facebook"));
          event.setTwitter((String) json_data.get("Twitter"));
          event.setRegDay((String) json_data.get("RegDay"));

          VenueActivity.events.add(event);
        }

        Log.d("returnedEvents", events.toString());
        Log.d("Desc", events.get(0).getDesc());

        Log.d("sizeOfEvents", String.valueOf(events.size()));

        if (events.size() > 0) {

          TextView noEvents = (TextView) findViewById(R.id.no_events);
          RelativeLayout event1Layout = (RelativeLayout) findViewById(R.id.event1_layout);
          TextView event1 = (TextView) findViewById(R.id.event1);
          TextView event1Date = (TextView) findViewById(R.id.event_date1);

          noEvents.setVisibility(View.GONE);
          event1Layout.setVisibility(View.VISIBLE);
          event1.setText(events.get(0).getName());

          if (events.get(0).getDate() == null) {
            event1Date.setText(events.get(0).getRegDay());
          } else event1Date.setText(events.get(0).getDate());

          event1Layout.setOnClickListener(
              new View.OnClickListener() {
                public void onClick(View view) {
                  onClickEvent(events.get(0));
                }
              });

          if (events.size() > 1) {

            RelativeLayout event2Layout = (RelativeLayout) findViewById(R.id.event2_layout);
            TextView event2 = (TextView) findViewById(R.id.event2);
            TextView event2Date = (TextView) findViewById(R.id.event_date2);

            event2Layout.setVisibility(View.VISIBLE);
            event2.setText(events.get(1).getName());

            if (events.get(1).getDate() == null) {
              event2Date.setText(events.get(1).getRegDay());
            } else event2Date.setText(events.get(1).getDate());

            event2Layout.setOnClickListener(
                new View.OnClickListener() {
                  public void onClick(View view) {
                    onClickEvent(events.get(1));
                  }
                });

            if (events.size() > 2) {

              RelativeLayout event3Layout = (RelativeLayout) findViewById(R.id.event3_layout);
              TextView event3 = (TextView) findViewById(R.id.event3);
              TextView event3Date = (TextView) findViewById(R.id.event_date3);

              event3Layout.setVisibility(View.VISIBLE);
              event3.setText((CharSequence) events.get(2).getName());

              if (events.get(2).getDate() == null) {
                event3Date.setText(events.get(2).getRegDay());
              } else event3Date.setText(events.get(2).getDate());

              event3Layout.setOnClickListener(
                  new View.OnClickListener() {
                    public void onClick(View view) {
                      onClickEvent(events.get(2));
                    }
                  });

              if (events.size() > 3) {

                TextView eventShowMore = (TextView) findViewById(R.id.show_more_events);
                eventShowMore.setVisibility(View.VISIBLE);
                eventShowMore.setOnClickListener(
                    new View.OnClickListener() {
                      public void onClick(View view) {
                        Intent intent = new Intent(VenueActivity.this, AllEventsActivity.class);
                        intent.putExtra("events", events);
                        intent.putExtra("venue", VenueActivity.receivedVenue);

                        VenueActivity.this.startActivity(intent);
                      }
                    });
              }
            }
          }
        }

      } catch (Exception e) {
        // Log.d("caughtException", e.getMessage());
      }
    }