Beispiel #1
0
 public static void add_vote_location_User_ID_MySQL(String event_id, int vote_id, String user_id) {
   String[] vote_location = new String[Table_Vote_Location.Size()];
   vote_location[Table_Vote_Location.Event_ID_num] = event_id;
   vote_location[Table_Vote_Location.Vote_ID_num] = vote_id + "";
   vote_location[Table_Vote_Location.Description_num] = "";
   vote_location[Table_Vote_Location.User_ID_num] = user_id;
   sqlHelper.insert(Table_Vote_Location.Table_Name, vote_location);
 }
Beispiel #2
0
 private static void add_newVote_Location_Option_MySQL(
     Vote_Location_Helper vote_location_helper, int vote_id) {
   String[] vote_location = new String[Table_Vote_Location.Size()];
   vote_location[Table_Vote_Location.Event_ID_num] =
       Event_Helper.details[Table_Events.Event_ID_num];
   vote_location[Table_Vote_Location.Vote_ID_num] = vote_id + "";
   vote_location[Table_Vote_Location.Description_num] = vote_location_helper.getDescription();
   vote_location[Table_Vote_Location.User_ID_num] = Constants.UnCheck;
   sqlHelper.insert(Table_Vote_Location.Table_Name, vote_location);
 }
Beispiel #3
0
  private static void Update_Event_ServerSQL(Context context, String Event_ID) {
    // Update event (delete and then insert).
    new Event_AsyncTask_update(context).execute(Event_Helper.details);
    // Update Friends list invention.
    Friend_Helper friend_helper;
    for (String User_ID : Event_Helper.friends_tmp.keySet()) {
      friend_helper = Event_Helper.friends_tmp.get(User_ID);
      if (Event_Helper.friends.get(User_ID) == null) { // Add new friends.
        new EventUser_AsyncTask_insert(context)
            .execute(
                Event_ID, User_ID, friend_helper.getAttending(), friend_helper.getPermission());
      } else { // Change permission.
        if (!friend_helper
            .getPermission()
            .equals(Event_Helper.friends.get(User_ID).getPermission())) {
          new EventUser_AsyncTask_UpdatePermission(context)
              .execute(Event_ID, User_ID, friend_helper.getPermission());
        }
      }
    }
    // Delete friends.
    for (String User_ID : Event_Helper.friends.keySet()) {
      if (Event_Helper.friends_tmp.get(User_ID) == null) {
        new EventUser_AsyncTask_delete(context).execute(Event_ID, User_ID);
      }
    }

    // Update Tasks.
    boolean new_task, new_subTask;
    Task_Helper task_helper;
    for (int task_id : Event_Helper.task_tmp.keySet()) {
      task_helper = Event_Helper.task_tmp.get(task_id);
      new_task = Event_Helper.task.get(task_id) == null;
      if (new_task) { // Add new tasks.
        new Task_AsyncTask_insert(context)
            .execute(
                Event_ID,
                task_id + "",
                0 + "",
                task_helper.getType(),
                task_helper.getDescription(),
                task_helper.getUser_ID());
      } else { // Update task description.
        if (!task_helper.getDescription().equals(Event_Helper.task.get(task_id).getDescription())) {
          new Task_AsyncTask_update(context)
              .execute(
                  Event_ID,
                  task_id + "",
                  0 + "",
                  task_helper.getType(),
                  task_helper.getDescription(),
                  task_helper.getUser_ID());
        }
      }
      for (int subTask_id : task_helper.getSubTasks().keySet()) {
        new_subTask =
            (new_task || Event_Helper.task.get(task_id).getSubTasks().get(subTask_id) == null);
        if (new_subTask) { // Add new subTasks.
          new Task_AsyncTask_insert(context)
              .execute(
                  Event_ID,
                  task_id + "",
                  subTask_id + "",
                  task_helper.getType(),
                  task_helper.getSubTasks().get(subTask_id)[0],
                  task_helper.getUser_ID());
        } else { // Update subTask description.
          if (!task_helper
              .getSubTasks()
              .get(subTask_id)[0]
              .equals(Event_Helper.task.get(task_id).getSubTasks().get(subTask_id)[0])) {
            new Task_AsyncTask_update(context)
                .execute(
                    Event_ID,
                    task_id + "",
                    subTask_id + "",
                    task_helper.getType(),
                    task_helper.getSubTasks().get(subTask_id)[0],
                    task_helper.getUser_ID());
          }
        }
      }
    }
    // Delete Tasks.
    for (int task_id : Event_Helper.task.keySet()) {
      task_helper = Event_Helper.task.get(task_id);
      if (Event_Helper.task_tmp.get(task_id) == null) {
        new Task_AsyncTask_delete_Task(context).execute(Event_ID, task_id + "");
      } else {
        for (int subTask_id : task_helper.getSubTasks().keySet()) {
          if (Event_Helper.task_tmp.get(task_id).getSubTasks().get(subTask_id) == null) {
            new Task_AsyncTask_delete_subTask(context)
                .execute(Event_ID, task_id + "", subTask_id + "");
          }
        }
      }
    }

    // Update Vote_date.
    // Update vote will reset the votes users.
    boolean new_vote_date;
    Vote_Date_Helper vote_date_helper_tmp;
    Vote_Date_Helper vote_date_helper;
    for (int vote_id : Event_Helper.vote_date_tmp.keySet()) {
      vote_date_helper_tmp = Event_Helper.vote_date_tmp.get(vote_id);
      vote_date_helper = Event_Helper.vote_date.get(vote_id);
      new_vote_date = vote_date_helper == null;
      String[] vote = new String[Table_Vote_Date.Size()];
      vote[Table_Vote_Date.Event_ID_num] = Event_ID;
      vote[Table_Vote_Date.Vote_ID_num] = vote_id + "";
      vote[Table_Vote_Date.Start_Date_num] = vote_date_helper_tmp.getStart_Date();
      vote[Table_Vote_Date.End_Date_num] = vote_date_helper_tmp.getEnd_Date();
      vote[Table_Vote_Date.All_Day_Time_num] = vote_date_helper_tmp.getAll_Day();
      vote[Table_Vote_Date.Start_Time_num] = vote_date_helper_tmp.getStart_Time();
      vote[Table_Vote_Date.End_Time_num] = vote_date_helper_tmp.getEnd_Time();
      vote[Table_Vote_Date.User_ID_num] = Constants.UnCheck;
      if (new_vote_date) { // Add new vote.
        new Vote_Date_AsyncTask_insert(context).execute(vote);
      } else { // Update vote date.
        if (!vote_date_helper_tmp.getStart_Date().equals(vote_date_helper.getStart_Date())
            || !vote_date_helper_tmp.getEnd_Date().equals(vote_date_helper.getEnd_Date())
            || !vote_date_helper_tmp.getAll_Day().equals(vote_date_helper.getAll_Day())
            || !vote_date_helper_tmp.getStart_Time().equals(vote_date_helper.getStart_Time())
            || !vote_date_helper_tmp.getEnd_Time().equals(vote_date_helper.getStart_Time())) {
          // reset the votes users.
          new Vote_Date_AsyncTask_deleteByVote_ID(context).execute(Event_ID, vote_id + "");
          new Vote_Date_AsyncTask_insert(context).execute(vote);
        }
      }
    }
    // Delete Vote_date.
    for (int vote_id : Event_Helper.vote_date.keySet()) {
      vote_date_helper = Event_Helper.vote_date.get(vote_id);
      if (Event_Helper.vote_date_tmp.get(vote_id) == null) {
        new Vote_Date_AsyncTask_deleteByVote_ID(context).execute(Event_ID, vote_id + "");
      }
    }

    // Update Vote_location.
    // Update vote will reset the votes users.
    boolean new_vote_location;
    Vote_Location_Helper vote_location_helper_tmp;
    Vote_Location_Helper vote_location_helper;
    for (int vote_id : Event_Helper.vote_location_tmp.keySet()) {
      vote_location_helper_tmp = Event_Helper.vote_location_tmp.get(vote_id);
      vote_location_helper = Event_Helper.vote_location.get(vote_id);
      new_vote_location = vote_location_helper == null;
      String[] vote = new String[Table_Vote_Location.Size()];
      vote[Table_Vote_Location.Event_ID_num] = Event_ID;
      vote[Table_Vote_Location.Vote_ID_num] = vote_id + "";
      vote[Table_Vote_Location.Description_num] = vote_location_helper_tmp.getDescription();
      vote[Table_Vote_Location.User_ID_num] = Constants.UnCheck;
      if (new_vote_location) { // Add new vote.
        new Vote_Location_AsyncTask_insert(context).execute(vote);
      } else { // Update vote date.
        if (!vote_location_helper_tmp
            .getDescription()
            .equals(vote_location_helper.getDescription())) {
          // reset the votes users.
          new Vote_Location_AsyncTask_deleteByVote_ID(context).execute(Event_ID, vote_id + "");
          new Vote_Location_AsyncTask_insert(context).execute(vote);
        }
      }
    }
    // Delete Vote_location.
    for (int vote_id : Event_Helper.vote_location.keySet()) {
      vote_location_helper = Event_Helper.vote_location.get(vote_id);
      if (Event_Helper.vote_location_tmp.get(vote_id) == null) {
        update_section[vote_location_num] = Constants.Yes;
        sqlHelper.delete(
            Table_Vote_Location.Table_Name,
            new String[] {Table_Vote_Location.Event_ID, Table_Vote_Location.Vote_ID},
            new String[] {Event_ID, vote_id + ""},
            null);
      }
    }
  }