refactoring worker to look at yesterdays seminars

This commit is contained in:
fred-fri 2013-05-28 17:05:04 +09:00
parent 1779a6c98d
commit 3b9de5135d
9 changed files with 23 additions and 96 deletions

@ -2,11 +2,10 @@ ALTER TABLE `general_system_settings` DROP `thesisReviewsMandatory`;
ALTER TABLE `general_system_settings` DROP `punishMailDate`;
ALTER TABLE `general_system_settings` DROP `daysAheadToUploadThesisReviewForExaminer`;
ALTER TABLE `general_system_settings` ADD `examinerPunishMailDate` datetime DEFAULT NULL;
ALTER TABLE `general_system_settings` ADD `examinerThesisReviewsMandatory` tinyint(1) NOT NULL;
ALTER TABLE `general_system_settings` ADD `supervisorPunishMailDate` datetime DEFAULT NULL;
ALTER TABLE `general_system_settings` ADD `supervisorThesisReviewsMandatory` tinyint(1) NOT NULL;
ALTER TABLE `general_system_settings` ADD `reviewerPunishMailDate` datetime DEFAULT NULL;
ALTER TABLE `general_system_settings` ADD `reviewerThesisReviewsMandatory` tinyint(1) NOT NULL;
ALTER TABLE `general_system_settings` ADD `reviewerThesisReviewsMandatory` tinyint(1) NOT NULL;
ALTER TABLE `final_seminar` DROP `punishChecked`;

@ -23,21 +23,6 @@ public abstract class GeneralSystemSettingsForm extends Form<GeneralSystemSettin
@Override
protected void onSubmit() {
if (getModelObject().isExaminerThesisReviewsMandatory()){
getModelObject().setExaminerPunishMailDate(new Date());
} else {
getModelObject().setExaminerPunishMailDate(null);
}
if (getModelObject().isSupervisorThesisReviewsMandatory()){
getModelObject().setSupervisorPunishMailDate(new Date());
} else {
getModelObject().setSupervisorPunishMailDate(null);
}
if (getModelObject().isReviewerThesisReviewsMandatory()){
getModelObject().setReviewerPunishMailDate(new Date());
} else {
getModelObject().setReviewerPunishMailDate(null);
}
setModelObject(settingsService.save(getModelObject()));
getSession().info("Settings saved");
setResponsePage(getPage().getClass());

@ -108,7 +108,6 @@ public class FinalSeminar extends DomainObject implements Commentable, Membershi
private int maxOpponents = 2;
private int maxParticipants = 5;
private boolean punishChecked = false;
public Project getProject() {
return project;
@ -283,12 +282,4 @@ public class FinalSeminar extends DomainObject implements Commentable, Membershi
public Examiner getExaminer() {
return examiner;
}
public boolean isPunishChecked() {
return punishChecked;
}
public void setPunishChecked(boolean punishChecked) {
this.punishChecked = punishChecked;
}
}

@ -177,21 +177,12 @@ public class GeneralSystemSettings extends DomainObject{
@Basic(optional = false)
private boolean examinerThesisReviewsMandatory = false;
@Basic(optional=true)
private Date examinerPunishMailDate;
@Basic(optional = false)
private boolean supervisorThesisReviewsMandatory = false;
@Basic(optional=true)
private Date supervisorPunishMailDate;
@Basic(optional = false)
private boolean reviewerThesisReviewsMandatory = false;
@Basic(optional=true)
private Date reviewerPunishMailDate;
public boolean isSupervisorThesisReviewsMandatory() {
return supervisorThesisReviewsMandatory;
}
@ -200,14 +191,6 @@ public class GeneralSystemSettings extends DomainObject{
this.supervisorThesisReviewsMandatory = supervisorThesisReviewsMandatory;
}
public Date getSupervisorPunishMailDate() {
return supervisorPunishMailDate;
}
public void setSupervisorPunishMailDate(Date supervisorPunishMailDate) {
this.supervisorPunishMailDate = supervisorPunishMailDate;
}
public boolean isReviewerThesisReviewsMandatory() {
return reviewerThesisReviewsMandatory;
}
@ -216,22 +199,6 @@ public class GeneralSystemSettings extends DomainObject{
this.reviewerThesisReviewsMandatory = reviewerThesisReviewsMandatory;
}
public Date getReviewerPunishMailDate() {
return reviewerPunishMailDate;
}
public void setReviewerPunishMailDate(Date reviewerPunishMailDate) {
this.reviewerPunishMailDate = reviewerPunishMailDate;
}
public Date getExaminerPunishMailDate() {
return examinerPunishMailDate;
}
public void setExaminerPunishMailDate(Date examinerPunishMailDate) {
this.examinerPunishMailDate = examinerPunishMailDate;
}
public GeneralSystemSettings(){
}
/**

@ -92,11 +92,6 @@ public class FinalSeminarServiceImpl extends AbstractQueryService<FinalSeminar,
return finalSeminarRepo.findAll(startDateIsBefore(date));
}
@Override
public Iterable<FinalSeminar> findPunishCandidates() {
return finalSeminarRepo.findAll(startDateIsAfter(generalSystemSettingsService.getExaminerPunishMailDate()).and(notPunishChecked()).and(startDateIsBefore(new Date())));
}
@Override
public Iterable<FinalSeminar> findYesterdaysSeminars() {
Date yesterday = new DateTime().minusDays(1).toDate();

@ -86,9 +86,4 @@ public class GeneralSystemSettingsServiceImpl extends AbstractQueryService<Gener
public String getSystemFromMail() {
return getGeneralSystemSettingsInstance().getSystemFromMail();
}
@Override
public Date getExaminerPunishMailDate() {
return getGeneralSystemSettingsInstance().getExaminerPunishMailDate();
}
}

@ -22,7 +22,6 @@ public interface FinalSeminarService extends GenericService<FinalSeminar, Long>,
Iterable<FinalSeminar> findByStartDateAfter(Date date);
Iterable<FinalSeminar> findByStartDateBefore(Date date);
Iterable<FinalSeminar> findPunishCandidates();
Iterable<FinalSeminar> findYesterdaysSeminars();
public Page<FinalSeminar> findPastOrFutureSeminars(Date date, FilterParams params, Pageable pageable);

@ -15,6 +15,5 @@ public interface GeneralSystemSettingsService extends GenericService<GeneralSyst
boolean isExaminerThesisReviewsMandatory();
String getSystemFromName();
String getSystemFromMail();
Date getExaminerPunishMailDate();
}

@ -33,43 +33,43 @@ public class ThesisCommentPunishWorker extends AbstractWorker {
this.beginTransaction();
GeneralSystemSettings systemSettings = systemSettingsService.getGeneralSystemSettingsInstance();
if (systemSettings.isExaminerThesisReviewsMandatory() || systemSettings.isSupervisorThesisReviewsMandatory() || systemSettings.isReviewerThesisReviewsMandatory()){
try {
/**
* Get all seminars that havent yet been punish checked
*/
Iterator<FinalSeminar> it = finalSeminarService.findPunishCandidates().iterator();
Iterator<FinalSeminar> it = finalSeminarService.findYesterdaysSeminars().iterator();
while (it.hasNext()) {
FinalSeminar fs = it.next();
String mail = "Final seminar for project " + fs.getProject().getTitle() + " held on " + dateService.format(fs.getStartDate(), DateStyle.DATETIME) + " did not get thesis " +
"comments from the following people: ";
// boolean hsReviewed = false;
boolean hsReviewed = false;
boolean eReviewed = false;
// boolean rReviewed = false;
boolean rReviewed = false;
for (ThesisReview tr : fs.getThesisReviews()) {
// if (tr.getUploader().equals(fs.getProject().getHeadSupervisor().getUser())) {
// hsReviewed = true;
// }
if (tr.getUploader().equals(fs.getProject().getHeadSupervisor().getUser())) {
hsReviewed = true;
}
if (fs.getExaminer() != null && tr.getUploader().equals(fs.getExaminer())) {
eReviewed = true;
}
// if (fs.getProject().getReviewer() != null && tr.getUploader().equals(fs.getProject().getReviewer())) {
// rReviewed = true;
// }
if (fs.getProject().getReviewer() != null && tr.getUploader().equals(fs.getProject().getReviewer())) {
rReviewed = true;
}
}
// if (!hsReviewed) {
// mail += "\n\n* Head supervisor " + fs.getProject().getHeadSupervisor().getUser().getFullName();
// }
if (systemSettings.isExaminerThesisReviewsMandatory() && systemSettings.getExaminerPunishMailDate() != null && fs.getExaminer() != null && !eReviewed) {
if (systemSettings.isSupervisorThesisReviewsMandatory() && !hsReviewed) {
mail += "\n\n* Head supervisor " + fs.getProject().getHeadSupervisor().getUser().getFullName();
}
if (systemSettings.isExaminerThesisReviewsMandatory() && !eReviewed) {
mail += "\n\n* Examiner " + fs.getExaminer().getUser().getFullName();
}
// if (fs.getProject().getReviewer() != null && !rReviewed) {
// mail += "\n\n* Reviewer " + fs.getProject().getReviewer().getUser().getFullName();
// }
if (systemSettings.isReviewerThesisReviewsMandatory() && !rReviewed) {
mail += "\n\n* Reviewer " + fs.getProject().getReviewer().getUser().getFullName();
}
MailEvent me = new MailEvent("Final seminar " + fs.getProject().getTitle() + " missing thesis comments", mail, new ArrayList<User>(), systemSettings.getMailFromName(), systemSettings.getSystemFromMail());
me.setNonUserRecipients(new HashSet<String>(systemSettings.getPunishMails()));
@ -77,9 +77,6 @@ public class ThesisCommentPunishWorker extends AbstractWorker {
logger.log(Level.INFO, mail + "\n\n");
me = mailEventDao.save(me);
fs.setPunishChecked(true);
fs = finalSeminarService.save(fs);
}
commitTransaction();
@ -87,6 +84,6 @@ public class ThesisCommentPunishWorker extends AbstractWorker {
this.rollbackTransaction();
this.setSuccessfulWorker(false);
throw new RuntimeException(e);
}
}}
}
}