code refactoring and addition of missing recipient sets
This commit is contained in:
parent
039d72ed41
commit
06f0378d28
src/main/java/se/su/dsv/scipro
admin/panels
components
data/facade
@ -38,12 +38,13 @@ import se.su.dsv.scipro.components.ProjectIdeaMailChoice;
|
||||
import se.su.dsv.scipro.components.ProjectMailChoice;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.MailEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.MailEvent;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.ProjectStatus;
|
||||
import se.su.dsv.scipro.data.facade.MailFacade;
|
||||
import se.su.dsv.scipro.match.dataobject.Match;
|
||||
|
||||
/**
|
||||
* Panel for mass mailing to predefined recipient sets.
|
||||
@ -265,31 +266,39 @@ public class AdminMailPanel extends Panel {
|
||||
if(choiceInput.equals(ProjectMailChoice.THESIS_SUPPORT))
|
||||
recipients = mailFacade.addThesisSupport();
|
||||
else if(choiceInput.equals(ProjectMailChoice.AUTHORS_ACTIVE_PROJECT)){
|
||||
recipients = mailFacade.addActiveAuthors(pc, startDate, endDate);
|
||||
recipients = mailFacade.addProjectAuthors(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectIdeaMailChoice.AUTHORS_SUBMITTED)){
|
||||
recipients = mailFacade.addIdeaAuthors(null, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectIdeaMailChoice.AUTHORS_CONFIRMED)){
|
||||
recipients = mailFacade.addAuthorsWithConfirmedIdeas(pc, startDate, endDate);
|
||||
recipients = mailFacade.addIdeaAuthors(Match.Status.CONFIRMED, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectIdeaMailChoice.AUTHORS_UNCONFIRMED)){
|
||||
recipients = mailFacade.addAuthorsWithUnconfirmedIdeas(pc, startDate, endDate);
|
||||
recipients = mailFacade.addIdeaAuthors(Match.Status.PUBLISHED, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectIdeaMailChoice.AUTHORS_REFUSED)){
|
||||
recipients = mailFacade.addAuthorsWithRefusedIdeas(pc, startDate, endDate);
|
||||
recipients = mailFacade.addIdeaAuthors(Match.Status.REFUSED, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectMailChoice.SUPERVISOR_ALL_ACTIVE)){
|
||||
recipients = mailFacade.addSupervisorsWithActiveProjects(pc, startDate, endDate);
|
||||
else if(choiceInput.equals(ProjectMailChoice.ACTIVE_SUPERVISORS)){
|
||||
recipients = mailFacade.addProjectSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectMailChoice.ALL_FOLLOWERS)){
|
||||
recipients.addAll(mailFacade.addProjectSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate));
|
||||
recipients.addAll(mailFacade.addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate));
|
||||
recipients.addAll(mailFacade.addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate));
|
||||
}
|
||||
else if(choiceInput.equals(ProjectIdeaMailChoice.SUPERVISOR_CONFIRMED)){
|
||||
recipients = mailFacade.addSupervisorsWithConfirmedIdeas(pc, startDate, endDate);
|
||||
recipients = mailFacade.addIdeaSupervisors(Match.Status.CONFIRMED, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectIdeaMailChoice.SUPERVISOR_UNCONFIRMED)){
|
||||
recipients = mailFacade.addSupervisorsWithUnconfirmedIdeas(pc, startDate, endDate);
|
||||
recipients = mailFacade.addIdeaSupervisors(Match.Status.PUBLISHED, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectMailChoice.ACTIVE_REVIEWERS)){
|
||||
recipients = mailFacade.addActiveReviewers(pc, startDate, endDate);
|
||||
recipients = mailFacade.addProjectReviewers(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
}
|
||||
else if(choiceInput.equals(ProjectMailChoice.ACTIVE_CO_SUPERVISORS)){
|
||||
recipients = mailFacade.addActiveCoSupervisors(pc, startDate, endDate);
|
||||
recipients = mailFacade.addProjectCoSupervisors(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
}
|
||||
return recipients;
|
||||
}
|
||||
@ -339,8 +348,6 @@ public class AdminMailPanel extends Panel {
|
||||
userSet = getRecipients(selectedRecipientSet, projectClassModel);
|
||||
try {
|
||||
if(userSet != null && !userSet.isEmpty()) {
|
||||
//Always add thesis support to mail list
|
||||
//userSet.add( THESIS SUPPORT USER )
|
||||
MailEvent me = new MailEvent(mailSubjectField.getInput(), mailBodyField.getInput(), userSet, fromName, fromEmail);
|
||||
me = mailEventDao.save(me);
|
||||
info("E-mail sent successfully to the selected recipients");
|
||||
|
@ -10,7 +10,8 @@ import org.apache.wicket.model.Model;
|
||||
public class ProjectIdeaMailChoice extends RadioChoice<String> {
|
||||
|
||||
private static final long serialVersionUID = 2266943297142066435L;
|
||||
public final static String THESIS_SUPPORT = "Thesis support (emil.siverhall@gmail.com)";
|
||||
public final static String THESIS_SUPPORT = "Thesis support";
|
||||
public final static String AUTHORS_SUBMITTED = "All authors with submitted project ideas";
|
||||
public final static String AUTHORS_CONFIRMED = "Authors with confirmed project ideas";
|
||||
public final static String AUTHORS_UNCONFIRMED = "Authors with project ideas waiting to be confirmed";
|
||||
public final static String AUTHORS_REFUSED = "Authors with refused project ideas";
|
||||
@ -30,7 +31,7 @@ public class ProjectIdeaMailChoice extends RadioChoice<String> {
|
||||
}
|
||||
|
||||
private void initChoices() {
|
||||
List<String> options = Arrays.asList(new String[]{THESIS_SUPPORT,AUTHORS_CONFIRMED,AUTHORS_UNCONFIRMED,AUTHORS_REFUSED,SUPERVISOR_CONFIRMED, SUPERVISOR_UNCONFIRMED});
|
||||
List<String> options = Arrays.asList(new String[]{THESIS_SUPPORT,AUTHORS_SUBMITTED,AUTHORS_CONFIRMED,AUTHORS_UNCONFIRMED,AUTHORS_REFUSED,SUPERVISOR_CONFIRMED, SUPERVISOR_UNCONFIRMED});
|
||||
setChoices(options);
|
||||
|
||||
}
|
||||
|
@ -10,11 +10,12 @@ import org.apache.wicket.model.Model;
|
||||
public class ProjectMailChoice extends RadioChoice<String> {
|
||||
|
||||
private static final long serialVersionUID = 2266943297142066435L;
|
||||
public final static String THESIS_SUPPORT = "Thesis support (emil.siverhall@gmail.com)";
|
||||
public final static String THESIS_SUPPORT = "Thesis support";
|
||||
public final static String AUTHORS_ACTIVE_PROJECT = "Authors with active projects";
|
||||
public final static String SUPERVISOR_ALL_ACTIVE = "Head supervisors with active projects";
|
||||
public final static String ACTIVE_SUPERVISORS = "Head supervisors with active projects";
|
||||
public final static String ACTIVE_CO_SUPERVISORS = "Co-supervisors with active projects";
|
||||
public final static String ACTIVE_REVIEWERS = "Reviewers of active projects";
|
||||
public final static String ALL_FOLLOWERS = "All supervisors and reviewers of active projects";
|
||||
|
||||
public ProjectMailChoice(String id) {
|
||||
super(id);
|
||||
@ -29,7 +30,7 @@ public class ProjectMailChoice extends RadioChoice<String> {
|
||||
}
|
||||
|
||||
private void initChoices() {
|
||||
List<String> options = Arrays.asList(new String[]{THESIS_SUPPORT,AUTHORS_ACTIVE_PROJECT,SUPERVISOR_ALL_ACTIVE,ACTIVE_CO_SUPERVISORS,ACTIVE_REVIEWERS});
|
||||
List<String> options = Arrays.asList(new String[]{THESIS_SUPPORT,AUTHORS_ACTIVE_PROJECT,ACTIVE_SUPERVISORS,ACTIVE_CO_SUPERVISORS,ACTIVE_REVIEWERS, ALL_FOLLOWERS});
|
||||
setChoices(options);
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.ProjectStatus;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ProjectIdeaDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Match;
|
||||
import se.su.dsv.scipro.match.dataobject.Match.Status;
|
||||
import se.su.dsv.scipro.match.dataobject.ProjectIdea;
|
||||
|
||||
@ -36,50 +35,36 @@ public class MailFacade {
|
||||
private ProjectIdeaDao.Params projectIdeaParams;
|
||||
private Set<User> recipients;
|
||||
|
||||
public Set<User> addActiveAuthors(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
public Set<User> addProjectAuthors(ProjectStatus ps, ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ps, pc, startDate, endDate);
|
||||
return authorsFromProjects();
|
||||
}
|
||||
|
||||
public Set<User> addAuthorsWithRefusedIdeas(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectIdeaParams(Match.Status.REFUSED, pc, startDate, endDate);
|
||||
return authorsFromProjectIdeas();
|
||||
}
|
||||
|
||||
public Set<User> addAuthorsWithConfirmedIdeas(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectIdeaParams(Match.Status.CONFIRMED, pc, startDate, endDate);
|
||||
return authorsFromProjectIdeas();
|
||||
}
|
||||
|
||||
public Set<User> addAuthorsWithUnconfirmedIdeas(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectIdeaParams(Match.Status.PUBLISHED, pc, startDate, endDate);
|
||||
return authorsFromProjectIdeas();
|
||||
}
|
||||
|
||||
public Set<User> addSupervisorsWithActiveProjects(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
public Set<User> addProjectSupervisors(ProjectStatus ps, ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ps, pc, startDate, endDate);
|
||||
return supervisorsFromProjects();
|
||||
}
|
||||
|
||||
public Set<User> addSupervisorsWithUnconfirmedIdeas(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectIdeaParams(Match.Status.PUBLISHED, pc, startDate, endDate);
|
||||
return supervisorsFromProjectIdeas();
|
||||
}
|
||||
|
||||
public Set<User> addSupervisorsWithConfirmedIdeas(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectIdeaParams(Match.Status.CONFIRMED, pc, startDate, endDate);
|
||||
return supervisorsFromProjectIdeas();
|
||||
}
|
||||
|
||||
public Set<User> addActiveCoSupervisors(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
public Set<User> addProjectCoSupervisors(ProjectStatus ps, ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ps, pc, startDate, endDate);
|
||||
return coSupervisorsFromProjects();
|
||||
}
|
||||
|
||||
public Set<User> addActiveReviewers(ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ProjectStatus.ACTIVE, pc, startDate, endDate);
|
||||
public Set<User> addProjectReviewers(ProjectStatus ps, ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectParams(ps, pc, startDate, endDate);
|
||||
return reviewersFromProjects();
|
||||
}
|
||||
|
||||
public Set<User> addIdeaAuthors(Status status, ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectIdeaParams(status, pc, startDate, endDate);
|
||||
return authorsFromProjectIdeas();
|
||||
}
|
||||
|
||||
public Set<User> addIdeaSupervisors(Status status, ProjectClass pc, Date startDate, Date endDate) {
|
||||
setProjectIdeaParams(status, pc, startDate, endDate);
|
||||
return supervisorsFromProjectIdeas();
|
||||
}
|
||||
|
||||
|
||||
private void setProjectIdeaParams(Status matchStatus, ProjectClass projectClass, Date startDate, Date endDate) {
|
||||
projectIdeaParams = new ProjectIdeaDao.Params();
|
||||
@ -112,6 +97,7 @@ public class MailFacade {
|
||||
for (Student s : idea.getAuthors())
|
||||
recipients.add(s.getUser());
|
||||
}
|
||||
recipients.addAll(addThesisSupport());
|
||||
return recipients;
|
||||
}
|
||||
|
||||
@ -122,6 +108,7 @@ public class MailFacade {
|
||||
if (idea.getMatch().getSupervisor() != null)
|
||||
recipients.add(idea.getMatch().getSupervisor().getUser());
|
||||
}
|
||||
recipients.addAll(addThesisSupport());
|
||||
return recipients;
|
||||
}
|
||||
|
||||
@ -132,6 +119,7 @@ public class MailFacade {
|
||||
for (Student s : p.getProjectParticipants())
|
||||
recipients.add(s.getUser());
|
||||
}
|
||||
recipients.addAll(addThesisSupport());
|
||||
return recipients;
|
||||
}
|
||||
|
||||
@ -142,6 +130,7 @@ public class MailFacade {
|
||||
if(p.getHeadSupervisor() != null)
|
||||
recipients.add(p.getHeadSupervisor().getUser());
|
||||
}
|
||||
recipients.addAll(addThesisSupport());
|
||||
return recipients;
|
||||
}
|
||||
|
||||
@ -154,6 +143,7 @@ public class MailFacade {
|
||||
recipients.add(pf.getFollower().getUser());
|
||||
}
|
||||
}
|
||||
recipients.addAll(addThesisSupport());
|
||||
return recipients;
|
||||
}
|
||||
|
||||
@ -166,15 +156,24 @@ public class MailFacade {
|
||||
recipients.add(pf.getFollower().getUser());
|
||||
}
|
||||
}
|
||||
recipients.addAll(addThesisSupport());
|
||||
return recipients;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method for always adding thesissupport@dsv.su.se to recipients, for backup of sent mail.
|
||||
*
|
||||
* @return
|
||||
* Set of users with thesis support added. Set is used if more than one address would like to be added.
|
||||
*/
|
||||
public Set<User> addThesisSupport() {
|
||||
recipients = new HashSet<User>();
|
||||
//this needs to be changed to Thesis support user. needs to be created?
|
||||
recipients.add(userDao.getUserByEmail("emil.siverhall@gmail.com"));
|
||||
recipients.add(userDao.getUserByEmail("emil-siv@dsv.su.se"));
|
||||
return recipients;
|
||||
Set<User> thesisSupportSet = new HashSet<User>();
|
||||
User thesisSupport = userDao.getUserByEmail("emil.siverhall@gmail.com");//Remove after testing
|
||||
// User thesisSupport = userDao.getUserByEmail("thesissupport@dsv.su.se");
|
||||
if (thesisSupport!=null)
|
||||
thesisSupportSet.add(thesisSupport);
|
||||
return thesisSupportSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user