Search in sources :

Example 1 with Team

use of com.marshalchen.common.usefulModule.standuptimer.model.Team in project UltimateAndroid by cymcsg.

the class TeamDAO method findByName.

public Team findByName(String name) {
    Cursor cursor = null;
    Team team = null;
    name = name.trim();
    try {
        SQLiteDatabase db = getReadableDatabase();
        cursor = db.query(TEAMS_TABLE_NAME, TEAMS_ALL_COLUMS, TEAMS_NAME + " = ?", new String[] { name }, null, null, null);
        if (cursor.getCount() == 1) {
            if (cursor.moveToFirst()) {
                long id = cursor.getLong(0);
                name = cursor.getString(1);
                team = new Team(id, name);
            }
        }
    } finally {
        closeCursor(cursor);
    }
    Logger.d((team == null ? "Unsuccessfully" : "Successfully") + " found team with a name of '" + name + "'");
    return team;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Team(com.marshalchen.common.usefulModule.standuptimer.model.Team) Cursor(android.database.Cursor)

Example 2 with Team

use of com.marshalchen.common.usefulModule.standuptimer.model.Team in project UltimateAndroid by cymcsg.

the class TeamDAO method createNewTeam.

private Team createNewTeam(SQLiteDatabase db, Team team) {
    if (team.getName() == null || team.getName().trim().length() == 0) {
        String msg = "Attempting to create a team with an empty name";
        Logger.w(msg);
        throw new InvalidTeamNameException(msg);
    }
    if (attemptingToCreateDuplicateTeam(team)) {
        String msg = "Attempting to create duplicate team with the name " + team.getName();
        Logger.w(msg);
        throw new DuplicateTeamException(msg);
    }
    Logger.d("Creating new team with a name of '" + team.getName() + "'");
    ContentValues values = new ContentValues();
    values.put(TEAMS_NAME, team.getName());
    long id = db.insertOrThrow(TEAMS_TABLE_NAME, null, values);
    return new Team(id, team.getName());
}
Also used : ContentValues(android.content.ContentValues) Team(com.marshalchen.common.usefulModule.standuptimer.model.Team)

Example 3 with Team

use of com.marshalchen.common.usefulModule.standuptimer.model.Team in project UltimateAndroid by cymcsg.

the class TeamDAO method findById.

public Team findById(Long id) {
    Cursor cursor = null;
    Team team = null;
    try {
        SQLiteDatabase db = getReadableDatabase();
        cursor = db.query(TEAMS_TABLE_NAME, TEAMS_ALL_COLUMS, _ID + " = ?", new String[] { id.toString() }, null, null, null);
        if (cursor.getCount() == 1) {
            if (cursor.moveToFirst()) {
                String name = cursor.getString(1);
                team = new Team(id, name);
            }
        }
    } finally {
        closeCursor(cursor);
    }
    return team;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Team(com.marshalchen.common.usefulModule.standuptimer.model.Team) Cursor(android.database.Cursor)

Example 4 with Team

use of com.marshalchen.common.usefulModule.standuptimer.model.Team 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.usefulModule.standuptimer.model.Meeting) Team(com.marshalchen.common.usefulModule.standuptimer.model.Team) Date(java.util.Date)

Example 5 with Team

use of com.marshalchen.common.usefulModule.standuptimer.model.Team in project UltimateAndroid by cymcsg.

the class TeamDAO method updateExistingTeam.

private Team updateExistingTeam(SQLiteDatabase db, Team team) {
    Logger.d("Updating team with the name of '" + team.getName() + "'");
    ContentValues values = new ContentValues();
    values.put(TEAMS_NAME, team.getName());
    long id = db.update(TEAMS_TABLE_NAME, values, _ID + " = ?", new String[] { team.getId().toString() });
    return new Team(id, team.getName());
}
Also used : ContentValues(android.content.ContentValues) Team(com.marshalchen.common.usefulModule.standuptimer.model.Team)

Aggregations

Team (com.marshalchen.common.usefulModule.standuptimer.model.Team)7 ContentValues (android.content.ContentValues)2 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 Date (java.util.Date)2 Meeting (com.marshalchen.common.usefulModule.standuptimer.model.Meeting)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1