public Group queryGroup(int groupID) { ArrayList<Properties> pl = dbComm.query( String.format(SELECT_FROM_WHERE, FIELDS_GROUPS, TABLE_GROUPS, "groupID=" + groupID)); Properties p = pl.get(0); return makeGroup(p); }
public Event queryEvent(int eventID, boolean fetchAlarm) { ArrayList<Properties> pl = dbComm.query( String.format(SELECT_FROM_WHERE, FIELDS_EVENT, TABLE_EVENT, "eventID=" + eventID)); Properties p = pl.get(0); return makeEvent(p, fetchAlarm); }
public ArrayList<User> queryUsers() { ArrayList<User> users = new ArrayList<User>(); ArrayList<Properties> pl = dbComm.query(String.format(SELECT_FROM, FIELDS_USER, TABLE_USER)); for (Properties p : pl) { users.add(makeUser(p)); } return users; }
public ArrayList<Alarm> queryAlarms() { ArrayList<Alarm> alarms = new ArrayList<Alarm>(); ArrayList<Properties> pl = dbComm.query(String.format(SELECT_FROM, FIELDS_ALARM, TABLE_ALARM)); for (Properties p : pl) { alarms.add(makeAlarm(p, true)); } return alarms; }
public ArrayList<Room> queryRooms() { ArrayList<Room> rooms = new ArrayList<Room>(); ArrayList<Properties> pl = dbComm.query(String.format(SELECT_FROM, FIELDS_ROOM, TABLE_ROOM)); for (Properties p : pl) { rooms.add(makeRoom(p)); } return rooms; }
public ArrayList<Event> queryEvents() { ArrayList<Event> events = new ArrayList<Event>(); ArrayList<Properties> pl = dbComm.query(String.format(SELECT_FROM, FIELDS_EVENT, TABLE_EVENT)); for (Properties p : pl) { events.add(makeEvent(p, true)); } return events; }
public ArrayList<Notification> queryNotifications() { ArrayList<Notification> notifications = new ArrayList<Notification>(); ArrayList<Properties> pl = dbComm.query(String.format(SELECT_FROM, FIELDS_NOTIFICATION, TABLE_NOTIFICATION)); for (Properties p : pl) { notifications.add(makeNotification(p)); } return notifications; }
public ArrayList<Group> queryGroups() { ArrayList<Group> groups = new ArrayList<Group>(); ArrayList<Properties> pl = dbComm.query(String.format(SELECT_FROM, FIELDS_GROUPS, TABLE_GROUPS)); for (Properties p : pl) { groups.add(makeGroup(p)); } return groups; }
public Notification queryNotification(int notificationID) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_NOTIFICATION, TABLE_NOTIFICATION, "notificationID=" + notificationID)); Properties p = pl.get(0); return makeNotification(p); }
private ArrayList<User> queryMembers(int groupID) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_IS_MEMBER_OF, TABLE_IS_MEMBER_OF, "groupID=" + groupID)); ArrayList<User> members = new ArrayList<User>(); for (Properties p : pl) { members.add(queryUser(p.getProperty("username"))); } return members; }
public User queryUser(String username) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_USER, TABLE_USER, "username='******'")); if (pl.size() > 0) { Properties p = pl.get(0); return makeUser(p); } else { return null; } }
private User queryOwner(int eventID) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_IS_OWNER, TABLE_IS_OWNER, "eventID=" + eventID)); if (pl.size() != 0) { Properties p = pl.get(0); return queryUser(p.getProperty("username")); } else { return null; } }
public ArrayList<Event> queryEvents(User user) { ArrayList<Event> events = new ArrayList<Event>(); String query = String.format( SELECT_FROM_WHERE, "event." + FIELDS_EVENT, TABLE_EVENT + " JOIN " + TABLE_IS_OWNER + " ON event.eventID=isOwner.eventID ", "username='******'"); ArrayList<Properties> pl = dbComm.query(query); for (Properties p : pl) { events.add(makeEvent(p, true)); } return events; }
public ArrayList<Notification> queryNotificationsTo(String username) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_NOTIFICATION_TO, TABLE_NOTIFICATION_TO, "username='******'")); ArrayList<Notification> notifications = new ArrayList<Notification>(); for (Properties p : pl) { notifications.add(queryNotification(Integer.parseInt(p.getProperty("notificationID")))); } return notifications; }
private ArrayList<User> queryParticipants(int eventID, String status) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_IS_PARTICIPANT, TABLE_IS_PARTICIPANT, "eventID=" + eventID + " and status=" + status)); ArrayList<User> users = new ArrayList<User>(); for (Properties p : pl) { users.add(queryUser(p.getProperty("username"))); } return users; }
private Alarm queryAlarm(User user, int eventID) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_ALARM, TABLE_ALARM, "username='******' and eventID=" + eventID)); if (pl.size() > 0) { Properties p = pl.get(0); return makeAlarm(p, false); } else { return null; } }
private User queryNotificationTo(int notificationID) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_NOTIFICATION_TO, TABLE_NOTIFICATION_TO, "notificationID=" + notificationID)); User user = null; if (pl.size() > 0) { Properties p = pl.get(0); user = queryUser(p.getProperty("username")); } return user; }
private Room queryReservedRoom(int eventID) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_RESERVED_ROOM, TABLE_RESERVED_ROOM, "eventID=" + eventID)); Room room = null; if (pl.size() > 0) { Properties p = pl.get(0); room = queryRoom(Integer.parseInt(p.getProperty("roomID"))); } return room; }
private Event queryNotificationEvent(int notificationID) { ArrayList<Properties> pl = dbComm.query( String.format( SELECT_FROM_WHERE, FIELDS_NOTIFICATION_FOR_EVENT, TABLE_NOTIFICATION_FOR_EVENT, "notificationID=" + notificationID)); Event event = null; if (pl.size() > 0) { Properties p = pl.get(0); event = queryEvent(Integer.parseInt(p.getProperty("eventID")), true); } return event; }
public Room queryRoom(int roomID) { ArrayList<Properties> pl = dbComm.query(String.format(SELECT_FROM_WHERE, FIELDS_ROOM, TABLE_ROOM, "roomID=" + roomID)); Properties p = pl.get(0); return makeRoom(p); }