Search in sources :

Example 1 with Meeting

use of com.marshalchen.common.uimodule.standuptimer.model.Meeting in project UltimateAndroid by cymcsg.

the class MeetingDAO method findAllByTeam.

public List<Meeting> findAllByTeam(Team team) {
    List<Meeting> meetings = new ArrayList<Meeting>();
    Cursor cursor = null;
    try {
        SQLiteDatabase db = getReadableDatabase();
        cursor = db.query(MEETINGS_TABLE_NAME, MEETINGS_ALL_COLUMS, MEETINGS_TEAM_NAME + " = ?", new String[] { team.getName() }, null, null, MEETINGS_MEETING_TIME);
        while (cursor.moveToNext()) {
            meetings.add(createMeetingFromCursorData(cursor));
        }
    } finally {
        closeCursor(cursor);
    }
    Logger.d("Found " + meetings.size() + " meetings");
    Collections.reverse(meetings);
    return meetings;
}
Also used : Meeting(com.marshalchen.common.uimodule.standuptimer.model.Meeting) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 2 with Meeting

use of com.marshalchen.common.uimodule.standuptimer.model.Meeting in project UltimateAndroid by cymcsg.

the class MeetingDAO method findById.

public Meeting findById(Long id) {
    Cursor cursor = null;
    Meeting meeting = null;
    try {
        SQLiteDatabase db = getReadableDatabase();
        cursor = db.query(MEETINGS_TABLE_NAME, MEETINGS_ALL_COLUMS, _ID + " = ?", new String[] { id.toString() }, null, null, null);
        if (cursor.getCount() == 1) {
            if (cursor.moveToFirst()) {
                meeting = createMeetingFromCursorData(cursor);
            }
        }
    } finally {
        closeCursor(cursor);
    }
    return meeting;
}
Also used : Meeting(com.marshalchen.common.uimodule.standuptimer.model.Meeting) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 3 with Meeting

use of com.marshalchen.common.uimodule.standuptimer.model.Meeting in project UltimateAndroid by cymcsg.

the class MeetingDAO method createNewMeeting.

private Meeting createNewMeeting(SQLiteDatabase db, Meeting meeting) {
    Logger.d("Creating new meeting for " + meeting.getTeam().getName() + " with a date/time of '" + meeting.getDateTime() + "'");
    ContentValues values = createContentValues(meeting);
    long id = db.insertOrThrow(MEETINGS_TABLE_NAME, null, values);
    return new Meeting(id, meeting);
}
Also used : ContentValues(android.content.ContentValues) Meeting(com.marshalchen.common.uimodule.standuptimer.model.Meeting)

Example 4 with Meeting

use of com.marshalchen.common.uimodule.standuptimer.model.Meeting in project UltimateAndroid by cymcsg.

the class MeetingDAO method createMeetingFromCursorData.

private Meeting createMeetingFromCursorData(Cursor cursor) {
    long id = cursor.getLong(0);
    String teamName = cursor.getString(1);
    Date meetingTime = new Date(cursor.getLong(2));
    int numParticipants = cursor.getInt(3);
    int individualStatusLength = cursor.getInt(4);
    int meetingLength = cursor.getInt(5);
    int quickestStatus = cursor.getInt(6);
    int longestStatus = cursor.getInt(7);
    return new Meeting(id, new Team(teamName), meetingTime, numParticipants, individualStatusLength, meetingLength, quickestStatus, longestStatus);
}
Also used : Meeting(com.marshalchen.common.uimodule.standuptimer.model.Meeting) Team(com.marshalchen.common.uimodule.standuptimer.model.Team) Date(java.util.Date)

Example 5 with Meeting

use of com.marshalchen.common.uimodule.standuptimer.model.Meeting in project UltimateAndroid by cymcsg.

the class MeetingDAO method findByTeamAndDate.

public Meeting findByTeamAndDate(Team team, Date date) {
    Cursor cursor = null;
    Meeting meeting = null;
    try {
        long startTime = date.getTime();
        Date endDate = new Date(date.getTime());
        endDate.setSeconds(endDate.getSeconds() + 1);
        long endTime = endDate.getTime();
        SQLiteDatabase db = getReadableDatabase();
        cursor = db.query(MEETINGS_TABLE_NAME, MEETINGS_ALL_COLUMS, MEETINGS_TEAM_NAME + " = ? and " + MEETINGS_MEETING_TIME + " >= ? and " + MEETINGS_MEETING_TIME + " < ?", new String[] { team.getName(), Long.toString(startTime), Long.toString(endTime) }, null, null, null);
        if (cursor.getCount() == 1) {
            if (cursor.moveToFirst()) {
                meeting = createMeetingFromCursorData(cursor);
            }
        }
    } finally {
        closeCursor(cursor);
    }
    return meeting;
}
Also used : Meeting(com.marshalchen.common.uimodule.standuptimer.model.Meeting) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor) Date(java.util.Date)

Aggregations

Meeting (com.marshalchen.common.uimodule.standuptimer.model.Meeting)5 Cursor (android.database.Cursor)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)3 Date (java.util.Date)2 ContentValues (android.content.ContentValues)1 Team (com.marshalchen.common.uimodule.standuptimer.model.Team)1 ArrayList (java.util.ArrayList)1