added recipient set for authors with project ideas waiting to be confirmed

This commit is contained in:
Emil Siverhall 2012-01-24 16:24:53 +01:00
parent f48bcc0ce8
commit 64f43d9355
2 changed files with 30 additions and 25 deletions
src/main/java/se/su/dsv/scipro
admin/panels
data/facade

@ -46,6 +46,7 @@ public class AdminMailPanel extends Panel {
private final String AUTHORS_ACTIVE_BACHELOR = "Authors with active bachelor projects";
private final String AUTHORS_ACTIVE_MASTER = "Authors with active master projects";
private final String AUTHORS_CONFIRMED = "Authors with confirmed project ideas";
private final String AUTHORS_UNCONFIRMED = "Authors with project ideas waiting to be confirmed";
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";
@ -128,7 +129,7 @@ public class AdminMailPanel extends Panel {
}
private void setUpRadioButtons() {
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});
List<String> options = Arrays.asList(new String[]{"None",AUTHORS_ACTIVE_PROJECT,AUTHORS_ACTIVE_BACHELOR,AUTHORS_ACTIVE_MASTER,AUTHORS_CONFIRMED,AUTHORS_UNCONFIRMED,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)).
@ -151,34 +152,37 @@ public class AdminMailPanel extends Panel {
private Set<User> getRecipients(String choiceInput) {
Set<User> recipients = new HashSet<User>();
if(choiceInput.equals(AUTHORS_JUSTME)) {
if(choiceInput.equals(AUTHORS_JUSTME)){
recipients = mailFacade.addJustMe();
}
else if(choiceInput.equals(AUTHORS_ACTIVE_PROJECT)) {
else if(choiceInput.equals(AUTHORS_ACTIVE_PROJECT)){
recipients = mailFacade.addActiveAuthors();
}
else if(choiceInput.equals(AUTHORS_ACTIVE_BACHELOR)) {
else if(choiceInput.equals(AUTHORS_ACTIVE_BACHELOR)){
recipients = mailFacade.addActiveBachelorAuthors();
}
else if(choiceInput.equals(AUTHORS_ACTIVE_MASTER)) {
else if(choiceInput.equals(AUTHORS_ACTIVE_MASTER)){
recipients = mailFacade.addActiveMasterAuthors();
}
else if(choiceInput.equals(AUTHORS_CONFIRMED)) {
else if(choiceInput.equals(AUTHORS_CONFIRMED)){
recipients = mailFacade.addAuthorsWithConfirmedIdeas();
}
else if(choiceInput.equals(AUTHORS_REFUSED)) {
else if(choiceInput.equals(AUTHORS_UNCONFIRMED)){
recipients = mailFacade.addAuthorsWithUnconfirmedIdeas();
}
else if(choiceInput.equals(AUTHORS_REFUSED)){
recipients = mailFacade.addAuthorsWithRefusedIdeas();
}
else if(choiceInput.equals(SUPERVISOR_ALL)) {
else if(choiceInput.equals(SUPERVISOR_ALL)){
recipients = mailFacade.addAllSupervisors();
}
else if(choiceInput.equals(SUPERVISOR_ALL_ACTIVE)) {
else if(choiceInput.equals(SUPERVISOR_ALL_ACTIVE)){
recipients = mailFacade.addSupervisorsWithActiveProjects();
}
else if(choiceInput.equals(SUPERVISOR_CONFIRMED)) {
else if(choiceInput.equals(SUPERVISOR_CONFIRMED)){
recipients = mailFacade.addSupervisorsWithConfirmedIdeas();
}
else if(choiceInput.equals(SUPERVISOR_UNCONFIRMED)) {
else if(choiceInput.equals(SUPERVISOR_UNCONFIRMED)){
recipients = mailFacade.addSupervisorsWithUnconfirmedIdeas();
}
return recipients;

@ -46,17 +46,6 @@ public class MailFacade {
recipients.add(userDao.getUserByEmail("emil-siv@dsv.su.se"));
return recipients;
}
public Set<User> addAllSupervisors() {
recipients = new HashSet<User>();
List<Employee> allSupervisors = supervisorDao.findAll();
for (Employee e : allSupervisors) {
recipients.add(e.getUser());
}
return recipients;
}
public Set<User> addActiveAuthors() {
setProjectParams(ProjectStatus.ACTIVE, null);
@ -82,7 +71,21 @@ public class MailFacade {
setProjectIdeaParams(Match.Status.CONFIRMED);
return authorsFromProjectIdeas();
}
public Set<User> addAuthorsWithUnconfirmedIdeas() {
setProjectIdeaParams(Match.Status.PUBLISHED);
return authorsFromProjectIdeas();
}
public Set<User> addAllSupervisors() {
recipients = new HashSet<User>();
List<Employee> allSupervisors = supervisorDao.findAll();
for (Employee e : allSupervisors) {
recipients.add(e.getUser());
}
return recipients;
}
public Set<User> addSupervisorsWithActiveProjects() {
setProjectParams(ProjectStatus.ACTIVE, null);
return supervisorsFromProjects();
@ -102,7 +105,6 @@ public class MailFacade {
projectIdeaParams = new ProjectIdeaDao.Params();
if(matchStatus != null)
projectIdeaParams.setStatuses(Arrays.asList(new Status[]{matchStatus}));
}
private void setProjectParams(ProjectStatus status, String projectClass) {
@ -152,5 +154,4 @@ public class MailFacade {
}
return recipients;
}
}