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;
}
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());
}
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;
}
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);
}
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());
}
Aggregations