Search in sources :

Example 11 with Meeting

use of net.johnpwood.android.standuptimer.model.Meeting in project standup-timer by jwood.

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(net.johnpwood.android.standuptimer.model.Meeting) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor) Date(java.util.Date)

Example 12 with Meeting

use of net.johnpwood.android.standuptimer.model.Meeting in project standup-timer by jwood.

the class TeamDetails method createMeetingListAdapter.

private ArrayAdapter<String> createMeetingListAdapter() {
    List<String> meetingDescriptions = new ArrayList<String>();
    if (team != null) {
        List<Meeting> meetings = team.findAllMeetings(TeamDetails.this);
        for (Meeting meeting : meetings) {
            meetingDescriptions.add(meeting.getDescription());
        }
    }
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(TeamDetails.this, android.R.layout.simple_list_item_1, meetingDescriptions);
    return adapter;
}
Also used : Meeting(net.johnpwood.android.standuptimer.model.Meeting) ArrayList(java.util.ArrayList) ArrayAdapter(android.widget.ArrayAdapter)

Example 13 with Meeting

use of net.johnpwood.android.standuptimer.model.Meeting in project standup-timer by jwood.

the class MeetingDAOTest method test_delete_all_by_team.

@MediumTest
public void test_delete_all_by_team() {
    Team team = new Team("Test Team");
    dao.save(new Meeting(team, new GregorianCalendar(2010, 1, 5, 10, 15, 0).getTime(), 5, 240, 300, 30, 120));
    dao.save(new Meeting(team, new GregorianCalendar(2010, 1, 4, 10, 15, 0).getTime(), 5, 240, 300, 30, 120));
    assertFalse(dao.findAllByTeam(team).isEmpty());
    dao.deleteAllByTeam(team);
    assertTrue(dao.findAllByTeam(team).isEmpty());
}
Also used : Meeting(net.johnpwood.android.standuptimer.model.Meeting) GregorianCalendar(java.util.GregorianCalendar) Team(net.johnpwood.android.standuptimer.model.Team) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 14 with Meeting

use of net.johnpwood.android.standuptimer.model.Meeting in project standup-timer by jwood.

the class MeetingDAOTest method test_find_all_meetings_by_team_in_cronological_order.

@MediumTest
public void test_find_all_meetings_by_team_in_cronological_order() {
    Team team = new Team("Test Team");
    dao.save(new Meeting(team, new GregorianCalendar(2010, 1, 5, 10, 15, 0).getTime(), 5, 240, 300, 30, 120));
    dao.save(new Meeting(team, new GregorianCalendar(2010, 1, 4, 10, 15, 0).getTime(), 5, 240, 300, 30, 120));
    dao.save(new Meeting(team, new GregorianCalendar(2010, 1, 7, 10, 15, 0).getTime(), 5, 240, 300, 30, 120));
    dao.save(new Meeting(team, new GregorianCalendar(2010, 1, 1, 10, 15, 0).getTime(), 5, 240, 300, 30, 120));
    dao.save(new Meeting(team, new GregorianCalendar(2010, 1, 2, 10, 15, 0).getTime(), 5, 240, 300, 30, 120));
    List<Meeting> meetings = dao.findAllByTeam(team);
    assertEquals(5, meetings.size());
    assertEquals(new GregorianCalendar(2010, 1, 7, 10, 15, 0).getTime(), meetings.get(0).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 5, 10, 15, 0).getTime(), meetings.get(1).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 4, 10, 15, 0).getTime(), meetings.get(2).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 2, 10, 15, 0).getTime(), meetings.get(3).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 1, 10, 15, 0).getTime(), meetings.get(4).getDateTime());
}
Also used : Meeting(net.johnpwood.android.standuptimer.model.Meeting) GregorianCalendar(java.util.GregorianCalendar) Team(net.johnpwood.android.standuptimer.model.Team) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 15 with Meeting

use of net.johnpwood.android.standuptimer.model.Meeting in project standup-timer by jwood.

the class MeetingTest method test_find_all_meetings_by_team.

@MediumTest
public void test_find_all_meetings_by_team() {
    Team team = new Team("Test Team");
    new Meeting(team, new GregorianCalendar(2010, 1, 5, 10, 15, 0).getTime(), 5, 240, 300, 30, 120).save(mContext);
    new Meeting(team, new GregorianCalendar(2010, 1, 4, 10, 15, 0).getTime(), 5, 240, 300, 30, 120).save(mContext);
    ;
    new Meeting(team, new GregorianCalendar(2010, 1, 7, 10, 15, 0).getTime(), 5, 240, 300, 30, 120).save(mContext);
    ;
    new Meeting(team, new GregorianCalendar(2010, 1, 1, 10, 15, 0).getTime(), 5, 240, 300, 30, 120).save(mContext);
    ;
    new Meeting(team, new GregorianCalendar(2010, 1, 2, 10, 15, 0).getTime(), 5, 240, 300, 30, 120).save(mContext);
    ;
    List<Meeting> meetings = Meeting.findAllByTeam(team, mContext);
    assertEquals(5, meetings.size());
    assertEquals(new GregorianCalendar(2010, 1, 7, 10, 15, 0).getTime(), meetings.get(0).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 5, 10, 15, 0).getTime(), meetings.get(1).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 4, 10, 15, 0).getTime(), meetings.get(2).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 2, 10, 15, 0).getTime(), meetings.get(3).getDateTime());
    assertEquals(new GregorianCalendar(2010, 1, 1, 10, 15, 0).getTime(), meetings.get(4).getDateTime());
}
Also used : Meeting(net.johnpwood.android.standuptimer.model.Meeting) GregorianCalendar(java.util.GregorianCalendar) Team(net.johnpwood.android.standuptimer.model.Team) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

Meeting (net.johnpwood.android.standuptimer.model.Meeting)24 Team (net.johnpwood.android.standuptimer.model.Team)17 GregorianCalendar (java.util.GregorianCalendar)16 MediumTest (android.test.suitebuilder.annotation.MediumTest)14 Date (java.util.Date)5 Cursor (android.database.Cursor)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)3 Context (android.content.Context)2 RenamingDelegatingContext (android.test.RenamingDelegatingContext)2 ArrayList (java.util.ArrayList)2 MeetingDAO (net.johnpwood.android.standuptimer.dao.MeetingDAO)2 TeamDAO (net.johnpwood.android.standuptimer.dao.TeamDAO)2 ContentValues (android.content.ContentValues)1 ArrayAdapter (android.widget.ArrayAdapter)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 CannotUpdateMeetingException (net.johnpwood.android.standuptimer.dao.CannotUpdateMeetingException)1 MeetingStats (net.johnpwood.android.standuptimer.model.MeetingStats)1