added recipient set for supervisors with active projects

This commit is contained in:
Emil Siverhall 2012-01-24 16:17:11 +01:00
parent cca16fda2f
commit f48bcc0ce8
2 changed files with 22 additions and 6 deletions
src/main/java/se/su/dsv/scipro
admin/panels
data/facade

@ -48,6 +48,7 @@ public class AdminMailPanel extends Panel {
private final String AUTHORS_CONFIRMED = "Authors with confirmed project ideas";
private final String AUTHORS_REFUSED = "Authors with refused project ideas";
private final String SUPERVISOR_ALL = "All supervisors";
private final String SUPERVISOR_ALL_ACTIVE = "All supervisors with active projects";
private final String SUPERVISOR_CONFIRMED = "Supervisors with confirmed project ideas";
private final String SUPERVISOR_UNCONFIRMED = "Supervisors with project ideas waiting to be confirmed";
@ -127,8 +128,8 @@ public class AdminMailPanel extends Panel {
}
private void setUpRadioButtons() {
List<String> options = Arrays.asList(new String[]{AUTHORS_JUSTME,AUTHORS_ACTIVE_PROJECT,AUTHORS_ACTIVE_BACHELOR,AUTHORS_ACTIVE_MASTER,AUTHORS_CONFIRMED,AUTHORS_REFUSED,SUPERVISOR_ALL,SUPERVISOR_CONFIRMED, SUPERVISOR_UNCONFIRMED});
final RadioChoice<String> choice = new RadioChoice<String>("radioChoices",Model.of(AUTHORS_JUSTME), options);
List<String> options = Arrays.asList(new String[]{"None",AUTHORS_ACTIVE_PROJECT,AUTHORS_ACTIVE_BACHELOR,AUTHORS_ACTIVE_MASTER,AUTHORS_CONFIRMED,AUTHORS_REFUSED,SUPERVISOR_ALL,SUPERVISOR_ALL_ACTIVE,SUPERVISOR_CONFIRMED, SUPERVISOR_UNCONFIRMED});
final RadioChoice<String> choice = new RadioChoice<String>("radioChoices",Model.of("None"), options);
//Default values, taken from RadioChoice constructor above (Model.of(your choice)).
userSet = new HashSet<User>();
@ -171,6 +172,9 @@ public class AdminMailPanel extends Panel {
else if(choiceInput.equals(SUPERVISOR_ALL)) {
recipients = mailFacade.addAllSupervisors();
}
else if(choiceInput.equals(SUPERVISOR_ALL_ACTIVE)) {
recipients = mailFacade.addSupervisorsWithActiveProjects();
}
else if(choiceInput.equals(SUPERVISOR_CONFIRMED)) {
recipients = mailFacade.addSupervisorsWithConfirmedIdeas();
}

@ -83,6 +83,11 @@ public class MailFacade {
return authorsFromProjectIdeas();
}
public Set<User> addSupervisorsWithActiveProjects() {
setProjectParams(ProjectStatus.ACTIVE, null);
return supervisorsFromProjects();
}
public Set<User> addSupervisorsWithUnconfirmedIdeas() {
setProjectIdeaParams(Match.Status.PUBLISHED);
return supervisorsFromProjectIdeas();
@ -122,7 +127,8 @@ public class MailFacade {
List<ProjectIdea> listOfIdeas = projectIdeaDao.findProjectIdeas(projectIdeaParams);
recipients = new HashSet<User>();
for (ProjectIdea idea : listOfIdeas) {
recipients.add(idea.getMatch().getSupervisor().getUser());
if (idea.getMatch().getSupervisor() != null)
recipients.add(idea.getMatch().getSupervisor().getUser());
}
return recipients;
}
@ -136,9 +142,15 @@ public class MailFacade {
}
return recipients;
}
private Set<User> supervisorsFromProjects() {
List<Project> listOfProjects = projectDao.findProjects(projectParams);
recipients = new HashSet<User>();
for (Project p : listOfProjects) {
if(p.getHeadSupervisor() != null)
recipients.add(p.getHeadSupervisor().getUser());
}
return recipients;
}
}