Skip to content

Instantly share code, notes, and snippets.

@tauren
Created October 15, 2011 02:31
Show Gist options
  • Save tauren/1288917 to your computer and use it in GitHub Desktop.
Save tauren/1288917 to your computer and use it in GitHub Desktop.
Integer filled = new Integer(value);
if (filled != null) {
switch (filled) {
case 4: // Unassigned games - Games with no assignments filled
// Pseudocode: select games where count(assignments with status = ACCEPTED) = 0 and count(positions) > 0
search.addFilterNone("assignments", Filter.equal("statusCode",AssignmentStatus.ACCEPTED.getCode()));
search.addFilterGreaterThan("schedule.positions.size", 0);
break;
case 3: // Partially assigned games - Games with some assignments filled
// Pseudocode: select games where count(assignments with status = ACCEPTED) < count(positions)
search.addFilterCustom("(select count(*) from {assignments} where statusCode = ?1 and game = {id}) < {schedule.positions.size}",
AssignmentStatus.ACCEPTED.getCode());
break;
case 2: // Fully assigned games - Games with all assignments filled
// Psuedocode: select games where count(assignments with status = ACCEPTED) = count(positions)
search.addFilterCustom("(select count(*) from {assignments} where statusCode = ?1 and game = {id}) = {schedule.positions.size}",
AssignmentStatus.ACCEPTED.getCode());
break;
case 1: // All games
// No filter
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment