Merge branch 'notification' into develop
This commit is contained in:
commit
265fd6a8da
src
main
java/se/su/dsv/scipro
commentthread/panels
conference
pages
panels
data
json/pages
message
models
pages
panels
opponent/panels
EditFinalSeminarFormPanel.javaOpponentListViewPanel.javaOpponentPanel.htmlOpponentPanel.javaProjectFinalSeminarPanel.java
peer
data/dao/controllers
panels
project
supervisor/pages
resources
test/java/se/su/dsv/scipro/wicket
@ -33,6 +33,7 @@
|
||||
<div wicket:id="navigator" class="comment-pager last"></div>
|
||||
</div>
|
||||
<div class="last comment-form">
|
||||
<div wicket:id="feedbackPanel"></div>
|
||||
<form wicket:id="commentForm">
|
||||
<div class="last">
|
||||
<strong>Comment:</strong>
|
||||
|
@ -19,6 +19,7 @@ import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.PageableListView;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
@ -70,6 +71,7 @@ public class CommentThreadPanel extends Panel {
|
||||
private final Set<SubscriberModel> subscriberModels;
|
||||
private final String title;
|
||||
private final Long classId;
|
||||
private final FeedbackPanel feedbackPanel;
|
||||
|
||||
public CommentThreadPanel(final String id, final Commentable keyObject,
|
||||
final int numberOfComments, final Set<SubscriberModel> subscriberModels,
|
||||
@ -111,6 +113,10 @@ public class CommentThreadPanel extends Panel {
|
||||
dialog.setWidth(470);
|
||||
dialog.add(dialogContainer);
|
||||
add(dialog);
|
||||
feedbackPanel = new FeedbackPanel("feedbackPanel");
|
||||
feedbackPanel.setOutputMarkupId(true);
|
||||
add(feedbackPanel);
|
||||
|
||||
|
||||
dialogContainer.setOutputMarkupId(true);
|
||||
editCommentForm = new EditCommentForm("editCommentForm",
|
||||
@ -176,30 +182,35 @@ public class CommentThreadPanel extends Panel {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
|
||||
Comment comment = (Comment) form.getDefaultModelObject();
|
||||
comment = commentDao.save(comment);
|
||||
System.out.println(subscriberModels);
|
||||
if (subscriberModels != null) {
|
||||
for (SubscriberModel sm : subscriberModels) {
|
||||
createNotification(sm.getUser(), comment.getComment(),
|
||||
sm.getNotificationPriority(), sm.getAbsolutePath());
|
||||
if (comment.getComment() == null || comment.getComment().length() < 1) {
|
||||
error("Comment can't be empty");
|
||||
|
||||
} else {
|
||||
comment = commentDao.save(comment);
|
||||
if (subscriberModels != null) {
|
||||
for (SubscriberModel sm : subscriberModels) {
|
||||
notificationController.notifyForComment(sm.getUser(), comment.getComment(),
|
||||
sm.getNotificationPriority(), title, classId.toString(), sm.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Do not, on purpose set the forms defaultModelObject to
|
||||
* the now persisted object, we leave the original object so
|
||||
* it can be re reused for any number of submits *
|
||||
*/
|
||||
/*
|
||||
* Do not, on purpose set the forms defaultModelObject
|
||||
* to the now persisted object, we leave the original
|
||||
* object so it can be re reused for any number of
|
||||
* submits *
|
||||
*/
|
||||
|
||||
webMarkupContainer.remove(commentListView);
|
||||
webMarkupContainer.remove(customPagingNavigator);
|
||||
textArea.setDefaultModelObject("");
|
||||
generateCommentListView();
|
||||
webMarkupContainer.add(commentListView);
|
||||
webMarkupContainer.add(customPagingNavigator);
|
||||
target.addComponent(textArea);
|
||||
target.addComponent(webMarkupContainer);
|
||||
webMarkupContainer.remove(commentListView);
|
||||
webMarkupContainer.remove(customPagingNavigator);
|
||||
textArea.setDefaultModelObject("");
|
||||
generateCommentListView();
|
||||
webMarkupContainer.add(commentListView);
|
||||
webMarkupContainer.add(customPagingNavigator);
|
||||
target.addComponent(textArea);
|
||||
target.addComponent(webMarkupContainer);
|
||||
}
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
|
||||
};
|
||||
@ -338,29 +349,4 @@ public class CommentThreadPanel extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
private void createNotification(final User user, final String message,
|
||||
final NotificationPriority notificationPriority, final String absolutePath) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String conferenceNotification = props.getProperty("conferenceNotificationComment");
|
||||
String twoNewLines = props.getProperty("twoNewLines");
|
||||
|
||||
String webNotificationMessage = SciProSession.get().getUser() + conferenceNotification
|
||||
+ title;
|
||||
|
||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
notificationController.processNotification(user, notificationMessage, absolutePath+"&"+classId
|
||||
,
|
||||
notificationPriority);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class ProjectConferencePage extends ProjectPage {
|
||||
subscriberModel.add(new SubscriberModel(projectModel.getObject()
|
||||
.getHeadSupervisor().getUser(),
|
||||
SupervisorConferencePage
|
||||
.getAbsoluteForSupervisorConferenceURL(projectModel.getObject()
|
||||
.getAbsoluteURL(projectModel.getObject()
|
||||
.getId()), NotificationPriority.LOW));
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public class ProjectConferencePage extends ProjectPage {
|
||||
.getProjectFollowers()) {
|
||||
subscriberModel.add(new SubscriberModel(
|
||||
projectFollower.getFollower().getUser(), SupervisorConferencePage
|
||||
.getAbsoluteForSupervisorConferenceURL(projectModel.getObject()
|
||||
.getAbsoluteURL(projectModel.getObject()
|
||||
.getId()), NotificationPriority.LOW));
|
||||
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class ProjectConferencePage extends ProjectPage {
|
||||
if (!student.getUser().equals(SciProSession.get().getUser()))
|
||||
subscriberModel
|
||||
.add(new SubscriberModel(student.getUser(),
|
||||
getAbsoluteForProjectConferenceURL(projectModel.getObject()
|
||||
getAbsoluteURL(projectModel.getObject()
|
||||
.getId()), NotificationPriority.LOW));
|
||||
// Test-kod
|
||||
// subscriberModel.add(new
|
||||
@ -162,7 +162,7 @@ public class ProjectConferencePage extends ProjectPage {
|
||||
.getAccessDeniedPage());
|
||||
}
|
||||
|
||||
public static String getAbsoluteForProjectConferenceURL(Long id) {
|
||||
public static String getAbsoluteURL(Long id) {
|
||||
PageParameters pageParameters = new PageParameters();
|
||||
pageParameters.put(PROJECTID, id.toString());
|
||||
return RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
|
@ -95,7 +95,7 @@ public class SupervisorConferencePage extends AbstractSupervisorPage {
|
||||
if (!user.equals(SciProSession.get().getUser())) {
|
||||
subscriberModel
|
||||
.add(new SubscriberModel(user,
|
||||
getAbsoluteForSupervisorConferenceURL(projectModel.getObject()
|
||||
getAbsoluteURL(projectModel.getObject()
|
||||
.getId()), NotificationPriority.LOW));
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ public class SupervisorConferencePage extends AbstractSupervisorPage {
|
||||
.getProjectFollowers()) {
|
||||
if (!user.equals(SciProSession.get().getUser())) {
|
||||
subscriberModel.add(new SubscriberModel(projectFollower.getFollower()
|
||||
.getUser(), getAbsoluteForSupervisorConferenceURL(projectModel
|
||||
.getUser(), getAbsoluteURL(projectModel
|
||||
.getObject().getId()), NotificationPriority.LOW));
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class SupervisorConferencePage extends AbstractSupervisorPage {
|
||||
|
||||
for (Student student : projectModel.getObject().getProjectParticipants()) {
|
||||
subscriberModel.add(new SubscriberModel(student.getUser(),
|
||||
ProjectConferencePage.getAbsoluteForProjectConferenceURL(projectModel
|
||||
ProjectConferencePage.getAbsoluteURL(projectModel
|
||||
.getObject().getId()), NotificationPriority.LOW));
|
||||
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class SupervisorConferencePage extends AbstractSupervisorPage {
|
||||
.getAccessDeniedPage());
|
||||
}
|
||||
|
||||
public static String getAbsoluteForSupervisorConferenceURL(Long id) {
|
||||
public static String getAbsoluteURL(Long id) {
|
||||
PageParameters pageParameters = new PageParameters();
|
||||
pageParameters.add(PROJECTID, id.toString());
|
||||
return RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
|
@ -6,27 +6,27 @@
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
|
||||
<div class="margin rounded-border">
|
||||
<div wicket:id="feedbackPanel"></div>
|
||||
<form wicket:id="sendForm">
|
||||
<textarea wicket:id="textArea"></textarea>
|
||||
<div>
|
||||
<button type="submit" wicket:id="ajaxButton">
|
||||
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt="" />Send
|
||||
Message
|
||||
</button>
|
||||
<button type="submit" wicket:id="ajaxButton">
|
||||
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt="" />Send
|
||||
Message
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div wicket:id="container" class="margin clear">
|
||||
<div wicket:id="boardMessageDataView" class="rounded-border">
|
||||
<span wicket:id="messageUser" class="small"> </span>
|
||||
<span wicket:id="messageDate" class="small"></span>
|
||||
<span><a href="#"
|
||||
wicket:id="delete" class="right-corner-resource"> <img class="icon-12"
|
||||
src="images/icons/delete_16x16.png" alt="Delete" title="Delete" />
|
||||
</a>
|
||||
</span>
|
||||
<span wicket:id="messageUser" class="small"> </span> <span
|
||||
wicket:id="messageDate" class="small"></span> <span><a
|
||||
href="#" wicket:id="delete" class="right-corner-resource"> <img
|
||||
class="icon-12" src="images/icons/delete_16x16.png" alt="Delete"
|
||||
title="Delete" /> </a> </span>
|
||||
<div wicket:id="messageLabel" class="margin"></div>
|
||||
<div>
|
||||
<a href="#" wicket:id="showComments"><span
|
||||
|
@ -15,6 +15,7 @@ import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
@ -59,6 +60,7 @@ public class ConferencePanel extends Panel {
|
||||
private IModel<MessageBoard> messageBoardModel;
|
||||
private IModel<BoardMessage> boardMessageModel;
|
||||
private Set<SubscriberModel> subscriberModels;
|
||||
private FeedbackPanel feedbackPanel;
|
||||
|
||||
public ConferencePanel(String id, IModel<MessageBoard> messageBoardModel,
|
||||
Set<SubscriberModel> subscriberModels, IModel<BoardMessage> boardMessageModel) {
|
||||
@ -75,6 +77,10 @@ public class ConferencePanel extends Panel {
|
||||
}
|
||||
|
||||
private void initPanel() {
|
||||
feedbackPanel = new FeedbackPanel("feedbackPanel");
|
||||
feedbackPanel.setOutputMarkupId(true);
|
||||
add(feedbackPanel);
|
||||
|
||||
add(new SendWallMessageForm("sendForm"));
|
||||
webMarkupContainer = new WebMarkupContainer("container");
|
||||
loadUserDataView(new BoardMessageDataProvider(messageBoardModel));
|
||||
@ -140,7 +146,7 @@ public class ConferencePanel extends Panel {
|
||||
subscriberModels, messageBoardModel.getObject().getTitle());
|
||||
ctp.setOutputMarkupPlaceholderTag(true);
|
||||
webMarkupContainer.add(ctp);
|
||||
|
||||
|
||||
if (boardMessageModel != null && boardMessageModel.getObject().equals(bm)) {
|
||||
comment.setDefaultModelObject("Hide comments");
|
||||
webMarkupContainer.setVisible(true);
|
||||
@ -231,25 +237,30 @@ public class ConferencePanel extends Panel {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
if (message == null || message.length() < 1) {
|
||||
error("Post can't be empty");
|
||||
} else {
|
||||
BoardMessage bm = new BoardMessage();
|
||||
bm.setMessage(message);
|
||||
bm.setMessageBoard(messageBoardModel.getObject());
|
||||
bm.setFromUser(SciProSession.get().getUser());
|
||||
bm = boardMessageDao.save(bm);
|
||||
|
||||
BoardMessage bm = new BoardMessage();
|
||||
bm.setMessage(message);
|
||||
bm.setMessageBoard(messageBoardModel.getObject());
|
||||
bm.setFromUser(SciProSession.get().getUser());
|
||||
bm = boardMessageDao.save(bm);
|
||||
|
||||
for (SubscriberModel subscriberModel : subscriberModels) {
|
||||
createNotification(subscriberModel.getUser(), message,
|
||||
subscriberModel.getNotificationPriority(),
|
||||
subscriberModel.getAbsolutePath());
|
||||
for (SubscriberModel subscriberModel : subscriberModels) {
|
||||
notificationController.notifyConferencePost(subscriberModel.getUser(), message, messageBoardModel.getObject().getTitle(),
|
||||
subscriberModel.getNotificationPriority(),
|
||||
subscriberModel.getAbsolutePath());
|
||||
}
|
||||
messageTextArea.setDefaultModelObject("");
|
||||
webMarkupContainer.removeAll();
|
||||
loadUserDataView(new BoardMessageDataProvider(messageBoardModel));
|
||||
webMarkupContainer.add(dataView);
|
||||
webMarkupContainer.add(new PagingNavigator("pagingNavigator", dataView));
|
||||
target.addComponent(webMarkupContainer);
|
||||
target.addComponent(messageTextArea);
|
||||
|
||||
}
|
||||
messageTextArea.setDefaultModelObject("");
|
||||
webMarkupContainer.removeAll();
|
||||
loadUserDataView(new BoardMessageDataProvider(messageBoardModel));
|
||||
webMarkupContainer.add(dataView);
|
||||
webMarkupContainer.add(new PagingNavigator("pagingNavigator", dataView));
|
||||
target.addComponent(webMarkupContainer);
|
||||
target.addComponent(messageTextArea);
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
};
|
||||
|
||||
@ -257,28 +268,4 @@ public class ConferencePanel extends Panel {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void createNotification(final User user, final String message,
|
||||
final NotificationPriority notificationPriority, final String absolutePath) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String conferenceNotification = props.getProperty("conferenceNotification");
|
||||
String twoNewLines = props.getProperty("twoNewLines");
|
||||
|
||||
String webNotificationMessage = SciProSession.get().getUser() + conferenceNotification
|
||||
+ messageBoardModel.getObject().getTitle();
|
||||
|
||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
notificationController.processNotification(user, notificationMessage, absolutePath,
|
||||
notificationPriority);
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,4 @@ public interface FinalSeminarUploadController extends IClusterable {
|
||||
void storeSeminarDocument(FileUpload upload, User uploader, FinalSeminar seminar) throws Exception;
|
||||
|
||||
void storeOpposition(FileUpload upload, User uploader, FinalSeminarOpposition opposition) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
package se.su.dsv.scipro.data.controllers;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerRequest;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -10,5 +16,38 @@ import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
*/
|
||||
public interface NotificationController {
|
||||
|
||||
public void processNotification(User usertoNotify, NotificationMessage notificationMessage, String absoluteUrl, NotificationPriority notificationPriority);
|
||||
public void notifyPrivateMessage(final User user, final String message,
|
||||
final String url);
|
||||
|
||||
public void notifyConferencePost(final User user, final String message,
|
||||
final String messageboardTitle, final NotificationPriority notificationPriority,
|
||||
final String absolutePath);
|
||||
|
||||
public void notifyForComment(final User user, final String message,
|
||||
final NotificationPriority notificationPriority, final String title,
|
||||
final String classId, final String absolutePath);
|
||||
|
||||
public void notifyReplyPrivateMessage(final User user, final String message,
|
||||
final String url);
|
||||
|
||||
public void notifyFinalSeminarEdited(final User user,
|
||||
final FinalSeminar finalSeminar, final NotificationPriority notificationPriority,
|
||||
final String absolutePath);
|
||||
|
||||
public void notifyCreateFinalSeminar(final User user, final FinalSeminar finalSemniar,
|
||||
final NotificationPriority notificationPriority, final String absolutePath, final boolean opponent);
|
||||
|
||||
public void notifyThesisUploaded(final User user,
|
||||
final FinalSeminar finalSeminar, final NotificationPriority notificationPriority,
|
||||
final String absolutePath);
|
||||
|
||||
public void notifyOppositionUploaded(final User user,
|
||||
final FinalSeminarOpposition opposition,
|
||||
final NotificationPriority notificationPriority, final String absolutePath);
|
||||
|
||||
public void notifyOfReviewRating(PeerReview review);
|
||||
|
||||
public void notifyCompletionOfReview(PeerReview review);
|
||||
|
||||
public void notifyAcceptOfReview(PeerRequest request, Student student, Project project);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import se.su.dsv.scipro.data.controllers.FinalSeminarUploadController;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckPlagiarismEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarDao;
|
||||
@ -22,12 +23,18 @@ import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckPlagiarismEvent;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarActiveParticipation;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectFollower;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import se.su.dsv.scipro.project.pages.ProjectOppositionPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectStartPage;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
import se.su.dsv.scipro.repository.util.FileStorageException;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorProjectsFinalSeminarPage;
|
||||
|
||||
@Controller("seminarUploadController")
|
||||
public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadController {
|
||||
@ -57,6 +64,9 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
||||
@Autowired
|
||||
private CheckPlagiarismEventDao checkPlagiarismEventDao;
|
||||
|
||||
@Autowired
|
||||
private NotificationController notificationController;
|
||||
|
||||
private FileDescription store(FileUpload upload, String storeToPath) throws IOException {
|
||||
fileRepository.storeFile(upload, storeToPath);
|
||||
List<FileDescription> fds = fileRepository.searchFiles(storeToPath);
|
||||
@ -148,6 +158,27 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
||||
checkPlagiarismEventDao.save(checkPlagiarismEvent);
|
||||
}
|
||||
|
||||
for (FinalSeminarActiveParticipation fa : seminar.getActiveParticipations()) {
|
||||
|
||||
notificationController.notifyThesisUploaded(fa.getUser(), seminar,
|
||||
NotificationPriority.HIGH, ProjectOppositionPage.getAbsoluteURL());
|
||||
}
|
||||
|
||||
for (FinalSeminarOpposition fo : seminar.getOppositions()) {
|
||||
notificationController.notifyThesisUploaded(fo.getOpponent().getUser(), seminar,
|
||||
NotificationPriority.HIGH, ProjectOppositionPage.getAbsoluteURL());
|
||||
}
|
||||
|
||||
for (ProjectFollower pf : seminar.getProject().getProjectFollowers()) {
|
||||
notificationController.notifyThesisUploaded(pf.getFollower().getUser(), seminar,
|
||||
NotificationPriority.HIGH, SupervisorProjectsFinalSeminarPage.getAbsoluteURL());
|
||||
}
|
||||
if (seminar.getProject().getHeadSupervisor() != null) {
|
||||
notificationController.notifyThesisUploaded(seminar.getProject().getHeadSupervisor()
|
||||
.getUser(), seminar, NotificationPriority.HIGH,
|
||||
SupervisorProjectsFinalSeminarPage.getAbsoluteURL());
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing seminardocument: " + e.getMessage());
|
||||
@ -178,6 +209,20 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
||||
opposition.setOpponentReport(fd);
|
||||
opposition.setDateReported(new Date());
|
||||
opposition = finalSeminarOppositionDao.save(opposition);
|
||||
|
||||
for (Student student : opposition.getFinalSeminar().getProject().getProjectParticipants()) {
|
||||
notificationController.notifyOppositionUploaded(student.getUser(), opposition,
|
||||
NotificationPriority.HIGH, ProjectStartPage.getAbsoluteURL());
|
||||
}
|
||||
for (ProjectFollower pf : opposition.getFinalSeminar().getProject().getProjectFollowers()) {
|
||||
notificationController.notifyOppositionUploaded(pf.getFollower().getUser(), opposition,
|
||||
NotificationPriority.HIGH, SupervisorProjectsFinalSeminarPage.getAbsoluteURL());
|
||||
}
|
||||
if (opposition.getFinalSeminar().getProject().getHeadSupervisor() != null) {
|
||||
notificationController.notifyOppositionUploaded(opposition.getFinalSeminar().getProject().getHeadSupervisor()
|
||||
.getUser(), opposition, NotificationPriority.HIGH,
|
||||
SupervisorProjectsFinalSeminarPage.getAbsoluteURL());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing opposition report: " + e.getMessage());
|
||||
@ -205,4 +250,10 @@ public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadContr
|
||||
+ String.valueOf(o.getId()) + "/";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,37 @@
|
||||
package se.su.dsv.scipro.data.controllers.impl;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.protocol.http.RequestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationMessage;
|
||||
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.UserSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.WebNotificationDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.MailEvent;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.UserSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.WebNotification;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerRequest;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerStatsPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerReviewPage;
|
||||
import se.su.dsv.scipro.util.PropsUtils;
|
||||
|
||||
/**
|
||||
@ -43,8 +58,7 @@ public class NotificationControllerImpl implements NotificationController {
|
||||
@Autowired
|
||||
protected MailEventDao mailEventDao;
|
||||
|
||||
@Override
|
||||
public void processNotification(User usertoNotify, NotificationMessage notificationMessage,
|
||||
private void processNotification(User usertoNotify, NotificationMessage notificationMessage,
|
||||
String absoluteUrl, NotificationPriority notificationPriorityForEvent) {
|
||||
GeneralSystemSettings generalSystemSettings = generalSystemSettingsDao
|
||||
.getGeneralSystemSettingsInstance();
|
||||
@ -138,4 +152,358 @@ public class NotificationControllerImpl implements NotificationController {
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPrivateMessage(final User user, final String message,
|
||||
final String url) {
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String privateMessageNotification = props.getProperty("privateMessageNotification");
|
||||
String twoNewLines = props.getProperty("twoNewLines");
|
||||
|
||||
String webNotificationMessage = SciProSession.get().getUser() + privateMessageNotification;
|
||||
|
||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, url, NotificationPriority.MEDIUM);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyConferencePost(final User user, final String message,
|
||||
final String messageboardTitle, final NotificationPriority notificationPriority,
|
||||
final String absolutePath) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String conferenceNotification = props.getProperty("conferenceNotification");
|
||||
String twoNewLines = props.getProperty("twoNewLines");
|
||||
String quote = props.getProperty("quote");
|
||||
|
||||
String webNotificationMessage = SciProSession.get().getUser() + conferenceNotification
|
||||
+ quote + messageboardTitle + quote;
|
||||
|
||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, absolutePath, notificationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForComment(final User user, final String message,
|
||||
final NotificationPriority notificationPriority, final String title,
|
||||
final String classId, final String absolutePath) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String conferenceNotification = props.getProperty("conferenceNotificationComment");
|
||||
String twoNewLines = props.getProperty("twoNewLines");
|
||||
|
||||
String webNotificationMessage = SciProSession.get().getUser() + conferenceNotification
|
||||
+ title;
|
||||
|
||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, absolutePath + "&" + classId,
|
||||
notificationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyReplyPrivateMessage(final User user, final String message,
|
||||
final String absolutePath) {
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String privateMessageNotification = props.getProperty("privateMessageReplyNotification");
|
||||
String twoNewLines = props.getProperty("twoNewLines");
|
||||
|
||||
String webNotificationMessage = SciProSession.get().getUser() + privateMessageNotification;
|
||||
|
||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, absolutePath, NotificationPriority.MEDIUM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyFinalSeminarEdited(final User user,
|
||||
final FinalSeminar finalSeminar, final NotificationPriority notificationPriority,
|
||||
final String absolutePath) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String finalSeminarReportEdited = props.getProperty("finalSeminarOppositionReportEdited");
|
||||
String finalSeminarOppositionReportBeenEdited = props
|
||||
.getProperty("finalSeminarOppositionReportBeenEdited");
|
||||
String quote = props.getProperty("quote");
|
||||
|
||||
String webNotificationMessage = finalSeminarReportEdited + quote
|
||||
+ finalSeminar.getProject().getTitle() + quote
|
||||
+ finalSeminarOppositionReportBeenEdited;
|
||||
String mailMessage = webNotificationMessage;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, absolutePath, notificationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyCreateFinalSeminar(final User user,
|
||||
final FinalSeminar finalSemniar, final NotificationPriority notificationPriority,
|
||||
final String absolutePath, final boolean opponent) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String created = props.getProperty("finalSeminarCreated");
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String project = "";
|
||||
if (!opponent) {
|
||||
project = props.getProperty("finalSeminarProject");
|
||||
} else {
|
||||
project = props.getProperty("finalSeminarProjectOpponnent");
|
||||
}
|
||||
|
||||
String comma = props.getProperty("comma");
|
||||
String space = props.getProperty("space");
|
||||
String quote = props.getProperty("quote");
|
||||
|
||||
DateFormat dfFrom = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
DateFormat dfTo = new SimpleDateFormat("-HH:mm");
|
||||
String webNotificationMessage = created + quote + finalSemniar.getProject().getTitle()
|
||||
+ quote + project + finalSemniar.getRoom() + comma + space
|
||||
+ dfFrom.format(finalSemniar.getStartDate())
|
||||
+ dfTo.format(finalSemniar.getEndDate());
|
||||
|
||||
String mailMessage = webNotificationMessage;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, absolutePath, notificationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyThesisUploaded(final User user,
|
||||
final FinalSeminar finalSeminar, final NotificationPriority notificationPriority,
|
||||
final String absolutePath) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String finalSeminarReportUploaded = props.getProperty("finalSeminarReportUploaded");
|
||||
String finalSeminarReportBeenUploaded = props.getProperty("finalSeminarReportBeenUploaded");
|
||||
String quote = props.getProperty("quote");
|
||||
|
||||
String webNotificationMessage = finalSeminarReportUploaded + quote
|
||||
+ finalSeminar.getProject().getTitle() + quote + finalSeminarReportBeenUploaded;
|
||||
String mailMessage = webNotificationMessage;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, absolutePath, notificationPriority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOppositionUploaded(final User user,
|
||||
final FinalSeminarOpposition opposition,
|
||||
final NotificationPriority notificationPriority, final String absolutePath) {
|
||||
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String finalSeminarOppositionReportUploaded = props
|
||||
.getProperty("finalSeminarOppositionReportUploaded");
|
||||
String finalSeminarOppositionReportBeenUploaded = props
|
||||
.getProperty("finalSeminarOppositionReportBeenUploaded");
|
||||
String dot = props.getProperty("dot");
|
||||
String quote = props.getProperty("quote");
|
||||
String space = props.getProperty("space");
|
||||
|
||||
String webNotificationMessage = finalSeminarOppositionReportUploaded + quote
|
||||
+ opposition.getFinalSeminar().getProject().getTitle() + quote
|
||||
+ finalSeminarOppositionReportBeenUploaded
|
||||
+ opposition.getOpponent().getUser().getFirstName() + space
|
||||
+ opposition.getOpponent().getUser().getLastName() + dot;
|
||||
String mailMessage = webNotificationMessage;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, mailMessage);
|
||||
processNotification(user, notificationMessage, absolutePath, notificationPriority);
|
||||
}
|
||||
|
||||
public void notifyAcceptOfReview(PeerRequest request, Student student, Project project) {
|
||||
try {
|
||||
Properties props = null;
|
||||
|
||||
props = PropsUtils.load("notification.properties");
|
||||
|
||||
String mailSubject = props.getProperty("acceptPeerReviewSubject");
|
||||
String requestAccepted = props.getProperty("requestAccepted");
|
||||
String heShe = props.getProperty("heShe");
|
||||
String complete = props.getProperty("complete");
|
||||
|
||||
User requestingUser = request.getRequester().getUser();
|
||||
|
||||
String messageBody = requestAccepted
|
||||
+ student.getUser().toString()
|
||||
+ heShe
|
||||
+ project.getProjectClass().getProjectClassSettings()
|
||||
.getNumDaysToSubmitPeerReview() + complete;
|
||||
|
||||
String webNotificationMessage = requestAccepted + student.getUser().toString();
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(
|
||||
webNotificationMessage, mailSubject, messageBody);
|
||||
|
||||
PageParameters pp = new PageParameters();
|
||||
|
||||
String peerStatsUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectPeerStatsPage.class, pp).toString());
|
||||
|
||||
processNotification(requestingUser, notificationMessage, peerStatsUrl,
|
||||
NotificationPriority.MEDIUM);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void notifyCompletionOfReview(PeerReview review) {
|
||||
try {
|
||||
|
||||
Properties props = null;
|
||||
props = PropsUtils.load("notification.properties");
|
||||
String mailSubject = props.getProperty("completedReviewSubject");
|
||||
String requestReviewed = props.getProperty("requestReviewed");
|
||||
String supervisorMessageBody = props.getProperty("supervisorMessageBody");
|
||||
String supervisorMessageBody2 = props.getProperty("supervisorMessageBody2");
|
||||
String supervisorMessageBody3 = props.getProperty("supervisorMessageBody3");
|
||||
String commaWithLinebreak = props.getProperty("commaWithLinebreak");
|
||||
String inProject = props.getProperty("inProject");
|
||||
String hasPerformed = props.getProperty("hasPerformed");
|
||||
PeerRequest peerRequest = review.getPeerRequest();
|
||||
User requestingUser = peerRequest.getRequester().getUser();
|
||||
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.add(PeerReview.PP_PEER_REVIEW_ID, review.getId().toString());
|
||||
|
||||
String reviewUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectPeerReviewPage.class, pp).toString());
|
||||
String supervisorReviewUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(SupervisorPeerReviewPage.class, pp).toString());
|
||||
|
||||
// Message for student when his/her review request is completed.
|
||||
String messageBody = requestReviewed;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(messageBody,
|
||||
mailSubject, messageBody);
|
||||
|
||||
processNotification(requestingUser, notificationMessage, reviewUrl,
|
||||
NotificationPriority.MEDIUM);
|
||||
|
||||
// Message for supervisor of the project with a completed review.
|
||||
messageBody = supervisorMessageBody + peerRequest.getProject().getTitle()
|
||||
+ supervisorMessageBody2;
|
||||
User requestSupervisor = peerRequest.getProject().getHeadSupervisor().getUser();
|
||||
|
||||
NotificationMessage notificationMessageSupervisorOfProject = new NotificationMessage(
|
||||
messageBody, mailSubject, messageBody);
|
||||
|
||||
processNotification(requestSupervisor, notificationMessageSupervisorOfProject,
|
||||
supervisorReviewUrl, NotificationPriority.MEDIUM);
|
||||
|
||||
// Message for supervisor of the reviewer that have made a review
|
||||
// for another project.
|
||||
|
||||
String webNotificationMessage = review.getReviewer().getUser().toString() + inProject
|
||||
+ review.getProject().getTitle() + hasPerformed;
|
||||
|
||||
messageBody = supervisorMessageBody + review.getProject().getTitle()
|
||||
+ commaWithLinebreak + review.getReviewer().getUser().toString()
|
||||
+ supervisorMessageBody3;
|
||||
|
||||
User reviewSupervisor = review.getProject().getHeadSupervisor().getUser();
|
||||
NotificationMessage notificationMessageSupervisorOfReviewer = new NotificationMessage(
|
||||
webNotificationMessage, mailSubject, messageBody);
|
||||
|
||||
processNotification(reviewSupervisor, notificationMessageSupervisorOfReviewer,
|
||||
supervisorReviewUrl, NotificationPriority.MEDIUM);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Rewrite
|
||||
*
|
||||
* @param review
|
||||
*/
|
||||
public void notifyOfReviewRating(PeerReview review) {
|
||||
try {
|
||||
Properties props = null;
|
||||
props = PropsUtils.load("notification.properties");
|
||||
String mailSubject = props.getProperty("reviewRatedSubject");
|
||||
String reviewRatedBody = props.getProperty("reviewRatedBody");
|
||||
User reviewingUser = review.getReviewer().getUser();
|
||||
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.add(PeerReview.PP_PEER_REVIEW_ID, review.getId().toString());
|
||||
String projectReviewUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectPeerReviewPage.class, pp).toString());
|
||||
|
||||
String messageBody = reviewRatedBody;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(messageBody,
|
||||
mailSubject, messageBody);
|
||||
|
||||
processNotification(reviewingUser, notificationMessage, projectReviewUrl,
|
||||
NotificationPriority.MEDIUM);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,6 @@ import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
@ -17,8 +15,6 @@ import javax.persistence.JoinTable;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import se.su.dsv.scipro.data.enums.NotificationEventType;
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
|
@ -35,7 +35,6 @@ public class PrivateMessage extends LazyDeletableDomainObject{
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
//TODO Fix column size and validate this in any page that uses it
|
||||
|
||||
@Lob
|
||||
private String subject;
|
||||
|
@ -3,6 +3,7 @@
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
@ -32,14 +33,17 @@ public class WebNotification extends DomainObject{
|
||||
private Long id;
|
||||
|
||||
@Lob
|
||||
@Basic(optional=false)
|
||||
private String infoText;
|
||||
|
||||
@Lob
|
||||
@Basic(optional=false)
|
||||
private String url;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private User user;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean readByUser = false;
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.PrivateMessageDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RecipientDao;
|
||||
@ -16,6 +17,7 @@ import se.su.dsv.scipro.data.dataobjects.Recipient;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.UserSettings;
|
||||
import se.su.dsv.scipro.jsonobjects.JsonPrivateMessage;
|
||||
import se.su.dsv.scipro.message.pages.PrivateMessagesPage;
|
||||
import se.su.dsv.scipro.util.PushApple;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@ -38,12 +40,15 @@ public class JsonNewMessagePage extends WebPage {
|
||||
@SpringBean
|
||||
UserSettingsDao userSettingsDao;
|
||||
|
||||
@SpringBean
|
||||
NotificationController notificationController;
|
||||
|
||||
public JsonNewMessagePage(final PageParameters pp) {
|
||||
final Gson gson = new Gson();
|
||||
final JsonObject jsonOutput = new JsonObject();
|
||||
String loginString = pp.getString("json");
|
||||
JsonPrivateMessage jsonPrivateMessage = gson.fromJson(loginString,
|
||||
JsonPrivateMessage.class);
|
||||
JsonPrivateMessage jsonPrivateMessage = gson
|
||||
.fromJson(loginString, JsonPrivateMessage.class);
|
||||
long userId = jsonPrivateMessage.userid;
|
||||
String apikey = jsonPrivateMessage.apikey;
|
||||
User user = userDao.load(userId);
|
||||
@ -53,8 +58,7 @@ public class JsonNewMessagePage extends WebPage {
|
||||
userSettings = new UserSettings(user);
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
}
|
||||
if (userSettings.getApiKey() != null
|
||||
&& userSettings.getApiKey().equals(apikey)) {
|
||||
if (userSettings.getApiKey() != null && userSettings.getApiKey().equals(apikey)) {
|
||||
PrivateMessage pm = new PrivateMessage();
|
||||
pm.setFromUser(user);
|
||||
pm.setMessage(jsonPrivateMessage.message);
|
||||
@ -66,6 +70,9 @@ public class JsonNewMessagePage extends WebPage {
|
||||
rec.setToUser(selectedUser);
|
||||
rec.setPrivateMessage(pm);
|
||||
rec = recipientDao.save(rec);
|
||||
notificationController.notifyPrivateMessage(selectedUser,
|
||||
jsonPrivateMessage.subject + "\n\n" + jsonPrivateMessage.message,
|
||||
PrivateMessagesPage.getAbsoluteURL());
|
||||
}
|
||||
jsonOutput.addProperty("apikey", "success");
|
||||
} else {
|
||||
@ -79,8 +86,7 @@ public class JsonNewMessagePage extends WebPage {
|
||||
|
||||
public void respond(RequestCycle requestCycle) {
|
||||
// Add JSON-encoded string to the response.
|
||||
requestCycle.getResponse().setContentType(
|
||||
"application/json; charset=UTF-8");
|
||||
requestCycle.getResponse().setContentType("application/json; charset=UTF-8");
|
||||
requestCycle.getResponse().setCharacterEncoding("UTF-8");
|
||||
requestCycle.getResponse().write(gson.toJson(jsonOutput));
|
||||
|
||||
@ -91,12 +97,10 @@ public class JsonNewMessagePage extends WebPage {
|
||||
User selectedUser = userDao.load(id);
|
||||
if (userSettingsDao.getUserSettings(selectedUser) != null) {
|
||||
|
||||
PushApple
|
||||
.sendPushMessage(
|
||||
userSettingsDao.getUserSettings(selectedUser).getiPhoneId(),
|
||||
recipientDao
|
||||
.getNumberOfUnreadMessagesForUser(selectedUser),
|
||||
"New message received");
|
||||
PushApple.sendPushMessage(userSettingsDao.getUserSettings(selectedUser)
|
||||
.getiPhoneId(),
|
||||
recipientDao.getNumberOfUnreadMessagesForUser(selectedUser),
|
||||
"New message received");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,39 +74,10 @@ public class PrivateMessageModel implements IClusterable {
|
||||
rec.setToUser(selectedUser);
|
||||
rec.setPrivateMessage(pm);
|
||||
rec = recipientDao.save(rec);
|
||||
notificationController.notifyPrivateMessage(selectedUser, subject +"\n\n" + textMessage, PrivateMessagesPage.getAbsoluteURL());
|
||||
}
|
||||
for(User user: users){
|
||||
createNotification(user, subject +"\n\n" + textMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createNotification(final User user,final String message){
|
||||
Properties props = null;
|
||||
try {
|
||||
props = PropsUtils.load("notification.properties");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String mailSubject = props.getProperty("mailSubject");
|
||||
String privateMessageNotification = props.getProperty("privateMessageNotification");
|
||||
String twoNewLines = props.getProperty("twoNewLines");
|
||||
|
||||
|
||||
String webNotificationMessage = SciProSession.get()
|
||||
.getUser()
|
||||
+ privateMessageNotification;
|
||||
|
||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage, mailSubject, mailMessage);
|
||||
notificationController.processNotification(user, notificationMessage,
|
||||
getAbsoluteForPrivateMessageURL(), NotificationPriority.MEDIUM);
|
||||
|
||||
}
|
||||
|
||||
private String getAbsoluteForPrivateMessageURL() {
|
||||
PageParameters pageParameters = new PageParameters();
|
||||
return RequestUtils.toAbsolutePath(RequestCycle.get().urlFor(PrivateMessagesPage.class, pageParameters).toString());
|
||||
}
|
||||
}
|
@ -1,17 +1,23 @@
|
||||
package se.su.dsv.scipro.message.models;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.injection.web.InjectorHolder;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationMessage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.PrivateMessageDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RecipientDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.PrivateMessage;
|
||||
import se.su.dsv.scipro.data.dataobjects.Recipient;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import se.su.dsv.scipro.message.pages.PrivateMessagesPage;
|
||||
import se.su.dsv.scipro.util.PropsUtils;
|
||||
|
||||
public class ReplyMessageModel implements IClusterable {
|
||||
|
||||
@ -21,6 +27,8 @@ public class ReplyMessageModel implements IClusterable {
|
||||
private PrivateMessageDao pmDao;
|
||||
@SpringBean
|
||||
private RecipientDao recipientDao;
|
||||
@SpringBean
|
||||
private NotificationController notificationController;
|
||||
|
||||
private PrivateMessage originalMessage;
|
||||
|
||||
@ -81,5 +89,10 @@ public class ReplyMessageModel implements IClusterable {
|
||||
r.setToUser(originalMessage.getFromUser());
|
||||
r.setPrivateMessage(pm);
|
||||
r = recipientDao.save(r);
|
||||
notificationController.notifyReplyPrivateMessage(originalMessage.getFromUser(), getReplySubject() +"\n\n" + getReplyText(), PrivateMessagesPage.getAbsoluteURL());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package se.su.dsv.scipro.message.pages;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
|
||||
@ -14,6 +15,7 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.protocol.http.RequestUtils;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
import org.odlabs.wiquery.ui.tabs.Tabs;
|
||||
@ -192,5 +194,11 @@ public class PrivateMessagesPage extends MenuPage {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getAbsoluteURL() {
|
||||
PageParameters pageParameters = new PageParameters();
|
||||
return RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(PrivateMessagesPage.class, pageParameters).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,18 +95,16 @@ public class PrivateMessagesPanel extends Panel {
|
||||
PageableListView<Recipient> lv = new PageableListView<Recipient>("message-list-item", new PropertyModel<List<Recipient>>(messageListModel, "privateMessages"), PAGE_LIMIT) {
|
||||
|
||||
private static final long serialVersionUID = 7851212974239684966L;
|
||||
protected Recipient rec;
|
||||
protected PrivateMessage pm;
|
||||
|
||||
@Override
|
||||
protected void populateItem(final ListItem<Recipient> item) {
|
||||
this.rec = item.getModelObject();
|
||||
this.pm = rec.getPrivateMessage();
|
||||
final Recipient rec = item.getModelObject();
|
||||
final PrivateMessage pm = rec.getPrivateMessage();
|
||||
item.add(new Label("dateField", dateFormat.format(pm.getDateCreated())));
|
||||
item.add(new Label("fromField", pm.getFromUser().getFirstName() + " "
|
||||
+ pm.getFromUser().getLastName()));
|
||||
item.add(new Label("subjectField", pm.getSubject()));
|
||||
if (this.rec.getDateRead() == null)
|
||||
if (rec.getDateRead() == null)
|
||||
item.add(new SimpleAttributeModifier("class", "unread-message-table-row"));
|
||||
item.add(new AjaxLink<String>("readLink") {
|
||||
|
||||
@ -114,13 +112,12 @@ public class PrivateMessagesPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
pm = pmDao.reLoad(pm);
|
||||
currentMessage = pm;
|
||||
currentMessage = pmDao.reLoad(pm);
|
||||
|
||||
rec = recipientDao.reLoad(item.getModelObject());
|
||||
if (rec.getDateRead() == null) {
|
||||
rec.setDateRead(GregorianCalendar.getInstance().getTime());
|
||||
recipientDao.save(rec);
|
||||
Recipient rec2 = recipientDao.reLoad(item.getModelObject());
|
||||
if (rec2.getDateRead() == null) {
|
||||
rec2.setDateRead(GregorianCalendar.getInstance().getTime());
|
||||
recipientDao.save(rec2);
|
||||
}
|
||||
|
||||
messageContainer = new WebMarkupContainer("messageContainer");
|
||||
|
@ -26,12 +26,14 @@ import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.odlabs.wiquery.ui.datepicker.DatePicker;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AdminFinalSeminarPage;
|
||||
import se.su.dsv.scipro.components.autocomplete.AutoCompletionChoicesProvider;
|
||||
import se.su.dsv.scipro.components.autocomplete.MultiObjectAutoCompleteObjectConverter;
|
||||
import se.su.dsv.scipro.components.autocomplete.MultiObjectAutoCompleteRenderer;
|
||||
import se.su.dsv.scipro.components.autocomplete.UserProjectMultiObjectAutoCompleteBuilder;
|
||||
import se.su.dsv.scipro.components.autocomplete.UserProjectMultiObjectAutoCompleteField;
|
||||
import se.su.dsv.scipro.data.controllers.FinalSeminarUploadController;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarActiveParticipationDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarOppositionDao;
|
||||
@ -41,10 +43,14 @@ import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarActiveParticipation;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectFollower;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.FinalSeminarLanguages;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import se.su.dsv.scipro.opponent.models.OpponentModel;
|
||||
import se.su.dsv.scipro.project.pages.ProjectOppositionPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectStartPage;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorProjectsFinalSeminarPage;
|
||||
|
||||
/**
|
||||
@ -71,6 +77,9 @@ public class EditFinalSeminarFormPanel extends Panel {
|
||||
@SpringBean
|
||||
private FinalSeminarActiveParticipationDao finalSeminarActiveParticipationDao;
|
||||
|
||||
@SpringBean
|
||||
private NotificationController notificationController;
|
||||
|
||||
private FeedbackPanel feedbackPanel;
|
||||
private FinalSeminar editSeminar;
|
||||
private DatePicker<Date> startDateField;
|
||||
@ -81,16 +90,14 @@ public class EditFinalSeminarFormPanel extends Panel {
|
||||
private TextField<String> projectLabel;
|
||||
private DropDownChoice<FinalSeminarLanguages> presentationLanguage;
|
||||
private DropDownChoice<FinalSeminarLanguages> reportLanguage;
|
||||
private boolean admin;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public EditFinalSeminarFormPanel(final String id, final FinalSeminar seminar) {
|
||||
public EditFinalSeminarFormPanel(final String id, final FinalSeminar seminar,
|
||||
final boolean admin) {
|
||||
super(id);
|
||||
|
||||
this.admin = admin;
|
||||
add(new EditSeminarForm("editSeminarForm"));
|
||||
|
||||
|
||||
FinalSeminar seminar2 = finalSeminarDao.reLoad(seminar);
|
||||
editSeminar = seminar2;
|
||||
startDateField.setDefaultModelObject(seminar2.getStartDate());
|
||||
@ -159,7 +166,6 @@ public class EditFinalSeminarFormPanel extends Panel {
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(new OpponentModel()));
|
||||
add(feedbackPanel = new FeedbackPanel("feedbackPanel"));
|
||||
feedbackPanel.setOutputMarkupId(true);
|
||||
|
||||
|
||||
add(projectLabel = new TextField<String>("project"));
|
||||
projectLabel.setEnabled(false);
|
||||
@ -231,7 +237,6 @@ public class EditFinalSeminarFormPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public Iterator<FinalSeminarActiveParticipation> getChoices(String input) {
|
||||
// TODO Auto-generated method stub
|
||||
List<FinalSeminarActiveParticipation> active = new ArrayList<FinalSeminarActiveParticipation>();
|
||||
for (User user : userDao.findUserQuery(input, 10)) {
|
||||
FinalSeminarActiveParticipation ac = new FinalSeminarActiveParticipation();
|
||||
@ -381,8 +386,48 @@ public class EditFinalSeminarFormPanel extends Panel {
|
||||
}
|
||||
|
||||
}
|
||||
editSeminar = finalSeminarDao.reLoad(editSeminar);
|
||||
|
||||
setResponsePage(SupervisorProjectsFinalSeminarPage.class);
|
||||
for (ProjectFollower pf : editSeminar.getProject().getProjectFollowers()) {
|
||||
notificationController.notifyFinalSeminarEdited(pf
|
||||
.getFollower().getUser(), editSeminar,
|
||||
NotificationPriority.MEDIUM, SupervisorProjectsFinalSeminarPage
|
||||
.getAbsoluteURL());
|
||||
|
||||
}
|
||||
for (Student student : editSeminar.getProject().getProjectParticipants()) {
|
||||
notificationController.notifyFinalSeminarEdited(student
|
||||
.getUser(), editSeminar, NotificationPriority.HIGH,
|
||||
ProjectStartPage.getAbsoluteURL());
|
||||
|
||||
}
|
||||
|
||||
//This may not work dependent on matched by in data object hasnt updated
|
||||
for (FinalSeminarActiveParticipation pf : editSeminar
|
||||
.getActiveParticipations()) {
|
||||
notificationController.notifyFinalSeminarEdited(pf
|
||||
.getUser(), editSeminar, NotificationPriority.MEDIUM,
|
||||
ProjectOppositionPage.getAbsoluteURL());
|
||||
}
|
||||
|
||||
//This may not work dependent on matched by in data object hasnt updated
|
||||
for (FinalSeminarOpposition pf : editSeminar.getOppositions()) {
|
||||
notificationController.notifyFinalSeminarEdited(pf
|
||||
.getOpponent().getUser(), editSeminar,
|
||||
NotificationPriority.MEDIUM, ProjectOppositionPage.getAbsoluteURL());
|
||||
}
|
||||
|
||||
if (admin) {
|
||||
if (editSeminar.getProject().getHeadSupervisor() != null) {
|
||||
notificationController.notifyFinalSeminarEdited(
|
||||
editSeminar.getProject().getHeadSupervisor().getUser(),
|
||||
editSeminar, NotificationPriority.HIGH,
|
||||
SupervisorProjectsFinalSeminarPage.getAbsoluteURL());
|
||||
}
|
||||
setResponsePage(AdminFinalSeminarPage.class);
|
||||
} else {
|
||||
setResponsePage(SupervisorProjectsFinalSeminarPage.class);
|
||||
}
|
||||
} else if (!notSameProject && error) {
|
||||
error("Opponent/Active participant is an author in the final seminar");
|
||||
error("Must select a Project for the Opponent/Active participant");
|
||||
@ -401,6 +446,5 @@ public class EditFinalSeminarFormPanel extends Panel {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
|
||||
public EditSeminarForm(String name) {
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(new OpponentModel()));
|
||||
editSeminarDialog.setTitle("Edit Seminar");
|
||||
editSeminarDialog.setTitle("Edit Final Seminar");
|
||||
add(new EmptyPanel("editSeminarDetails"));
|
||||
}
|
||||
}
|
||||
@ -272,7 +272,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
FinalSeminar seminar2 = finalSeminarDao.reLoad(seminar);
|
||||
editSeminarForm.removeAll();
|
||||
editSeminarForm.add(new EditFinalSeminarFormPanel("editSeminarDetails", seminar2));
|
||||
editSeminarForm.add(new EditFinalSeminarFormPanel("editSeminarDetails", seminar2, true));
|
||||
target.addComponent(editSeminarForm);
|
||||
editSeminarDialog.open(target);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<p><a href="#" wicket:id="addSeminar">Create Seminar</a></p>
|
||||
<p><a href="#" wicket:id="addSeminar">Create Final Seminar</a></p>
|
||||
<div wicket:id="dialog">
|
||||
<div wicket:id="dialogContainer">
|
||||
<form wicket:id="addSeminarForm">
|
||||
|
@ -34,6 +34,7 @@ import se.su.dsv.scipro.components.autocomplete.MultiObjectAutoCompleteObjectCon
|
||||
import se.su.dsv.scipro.components.autocomplete.MultiObjectAutoCompleteRenderer;
|
||||
import se.su.dsv.scipro.components.autocomplete.UserProjectMultiObjectAutoCompleteBuilder;
|
||||
import se.su.dsv.scipro.components.autocomplete.UserProjectMultiObjectAutoCompleteField;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarOppositionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
@ -45,10 +46,14 @@ import se.su.dsv.scipro.data.dataobjects.FinalSeminarActiveParticipation;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectFollower;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.FinalSeminarLanguages;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import se.su.dsv.scipro.opponent.models.OpponentModel;
|
||||
import se.su.dsv.scipro.project.pages.ProjectOppositionPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectStartPage;
|
||||
import se.su.dsv.scipro.security.auth.MetaDataActionStrategy;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorProjectsFinalSeminarPage;
|
||||
@ -80,6 +85,9 @@ public class OpponentPanel extends Panel {
|
||||
@SpringBean
|
||||
private FinalSeminarOppositionDao finalSeminarOppositionDao;
|
||||
|
||||
@SpringBean
|
||||
NotificationController notificationController;
|
||||
|
||||
private Project project;
|
||||
|
||||
public OpponentPanel(String id, Project project) {
|
||||
@ -96,13 +104,12 @@ public class OpponentPanel extends Panel {
|
||||
addSeminarDialogContainer.add(new AddSeminarForm("addSeminarForm"));
|
||||
|
||||
AjaxLink<String> addSeminar;
|
||||
add(addSeminar = new AjaxLink<String>("addSeminar", new Model<String>(
|
||||
"Create Seminar")) {
|
||||
add(addSeminar = new AjaxLink<String>("addSeminar", new Model<String>("Create Seminar")) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
@ -121,15 +128,14 @@ public class OpponentPanel extends Panel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AddSeminarForm(String name) {
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(
|
||||
new OpponentModel()));
|
||||
final WebMarkupContainer feedbackContainer = new WebMarkupContainer(
|
||||
"feedbackContainer");
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(new OpponentModel()));
|
||||
final WebMarkupContainer feedbackContainer = new WebMarkupContainer("feedbackContainer");
|
||||
project = projectDao.reLoad(project);
|
||||
feedbackContainer.setOutputMarkupId(true);
|
||||
|
||||
//ComponentFeedbackPanel fungerade inte
|
||||
WebMarkupContainer feedbackPanel = new FormFeedbackPanel<OpponentModel>("feedbackPanel", this);
|
||||
|
||||
// ComponentFeedbackPanel fungerade inte
|
||||
WebMarkupContainer feedbackPanel = new FormFeedbackPanel<OpponentModel>(
|
||||
"feedbackPanel", this);
|
||||
feedbackContainer.add(feedbackPanel);
|
||||
add(feedbackContainer);
|
||||
|
||||
@ -138,7 +144,7 @@ public class OpponentPanel extends Panel {
|
||||
add(projectLabel = new TextField<String>("project"));
|
||||
projectLabel.setEnabled(false);
|
||||
projectLabel.setDefaultModelObject(project.getTitle(30));
|
||||
|
||||
|
||||
DatePicker<Date> startDateField = new DatePicker<Date>("date") {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -167,47 +173,49 @@ public class OpponentPanel extends Panel {
|
||||
add(room = new TextField<String>("room"));
|
||||
room.setRequired(true);
|
||||
add(startDateField);
|
||||
|
||||
String[] hourArray = new String[] { "00", "01", "02", "03", "04",
|
||||
"05", "06", "07", "08", "09", "10", "11", "12",
|
||||
"13", "14", "15", "16", "17", "18", "19", "20",
|
||||
|
||||
String[] hourArray = new String[] { "00", "01", "02", "03", "04", "05", "06", "07",
|
||||
"08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
|
||||
"21", "22", "23" };
|
||||
|
||||
String[] minuteArray = new String[] { "00", "05", "10",
|
||||
"15", "20", "25", "30", "35", "40", "45", "50",
|
||||
"55" };
|
||||
|
||||
String[] minuteArray = new String[] { "00", "05", "10", "15", "20", "25", "30", "35",
|
||||
"40", "45", "50", "55" };
|
||||
|
||||
DropDownChoice<String> hour = new DropDownChoice<String>("startHour",
|
||||
Arrays.asList(hourArray));
|
||||
add(hour);
|
||||
hour.setRequired(false);
|
||||
DropDownChoice<String> minute = new DropDownChoice<String>(
|
||||
"startMinute", Arrays.asList(minuteArray));
|
||||
DropDownChoice<String> minute = new DropDownChoice<String>("startMinute",
|
||||
Arrays.asList(minuteArray));
|
||||
add(minute);
|
||||
minute.setRequired(false);
|
||||
|
||||
|
||||
DropDownChoice<String> endHour = new DropDownChoice<String>("endHour",
|
||||
Arrays.asList(hourArray));
|
||||
add(endHour);
|
||||
endHour.setRequired(false);
|
||||
DropDownChoice<String> endMinute = new DropDownChoice<String>(
|
||||
"endMinute", Arrays.asList(minuteArray));
|
||||
DropDownChoice<String> endMinute = new DropDownChoice<String>("endMinute",
|
||||
Arrays.asList(minuteArray));
|
||||
add(endMinute);
|
||||
endMinute.setRequired(false);
|
||||
|
||||
List<FinalSeminarLanguages> languageOptions = new ArrayList<FinalSeminarLanguages>( Arrays.asList(FinalSeminarLanguages.values()) );
|
||||
|
||||
List<FinalSeminarLanguages> languageOptions = new ArrayList<FinalSeminarLanguages>(
|
||||
Arrays.asList(FinalSeminarLanguages.values()));
|
||||
|
||||
FinalSeminarLanguages defaultValue = FinalSeminarLanguages.ENGLISH;
|
||||
if(project.getProjectClass().getCode().equals(ProjectClass.BACHELOR)){ //Sorry for ugly hard-code, this had to be done and deployed in an afternoon
|
||||
// Sorry for ugly hard-code, this had to be deployed in an afternoon
|
||||
if (project.getProjectClass().getCode().equals(ProjectClass.BACHELOR)) {
|
||||
defaultValue = FinalSeminarLanguages.SWEDISH;
|
||||
}
|
||||
|
||||
DropDownChoice<FinalSeminarLanguages> presentationLanguage = new DropDownChoice<FinalSeminarLanguages>("presentationLanguage", languageOptions );
|
||||
|
||||
DropDownChoice<FinalSeminarLanguages> presentationLanguage = new DropDownChoice<FinalSeminarLanguages>(
|
||||
"presentationLanguage", languageOptions);
|
||||
add(presentationLanguage);
|
||||
presentationLanguage.setModelObject(defaultValue);
|
||||
presentationLanguage.setRequired(true);
|
||||
|
||||
DropDownChoice<FinalSeminarLanguages> reportLanguage = new DropDownChoice<FinalSeminarLanguages>("reportLanguage", languageOptions );
|
||||
|
||||
DropDownChoice<FinalSeminarLanguages> reportLanguage = new DropDownChoice<FinalSeminarLanguages>(
|
||||
"reportLanguage", languageOptions);
|
||||
add(reportLanguage);
|
||||
reportLanguage.setModelObject(defaultValue);
|
||||
reportLanguage.setRequired(true);
|
||||
@ -243,8 +251,8 @@ public class OpponentPanel extends Panel {
|
||||
|
||||
public String getTextValue(FinalSeminarActiveParticipation al) {
|
||||
User u = al.getUser();
|
||||
return u.getFirstName() + " " + u.getLastName() + " <"
|
||||
+ u.getEmailAddress() + ">";
|
||||
return u.getFirstName() + " " + u.getLastName() + " <" + u.getEmailAddress()
|
||||
+ ">";
|
||||
}
|
||||
|
||||
protected String getIdValue(FinalSeminarActiveParticipation al) {
|
||||
@ -280,31 +288,26 @@ public class OpponentPanel extends Panel {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
OpponentModel opponentModel = (OpponentModel) form
|
||||
.getDefaultModelObject();
|
||||
OpponentModel opponentModel = (OpponentModel) form.getDefaultModelObject();
|
||||
boolean notSameProject = true;
|
||||
boolean error = false;
|
||||
project = projectDao.reLoad(project);
|
||||
for (Student student : project.getProjectParticipants()) {
|
||||
if (!notSameProject)
|
||||
break;
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getOpponentList()) {
|
||||
if (student.getUser().equals(al.getUser())
|
||||
&& !al.isPreDeleted()) {
|
||||
for (FinalSeminarActiveParticipation al : opponentModel.getOpponentList()) {
|
||||
if (student.getUser().equals(al.getUser()) && !al.isPreDeleted()) {
|
||||
notSameProject = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (project.getProjectClass().equals(
|
||||
projectClassDao
|
||||
.getProjectClass(ProjectClass.UNKNOWN))) {
|
||||
projectClassDao.getProjectClass(ProjectClass.UNKNOWN))) {
|
||||
error = true;
|
||||
}
|
||||
for (FinalSeminarActiveParticipation al : opponentModel.getOpponentList()) {
|
||||
if (al.getProject() == null
|
||||
&& !al.isPreDeleted()) {
|
||||
if (al.getProject() == null && !al.isPreDeleted()) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
@ -315,42 +318,54 @@ public class OpponentPanel extends Panel {
|
||||
Date date = opponentModel.getDate();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.set(Calendar.HOUR_OF_DAY,
|
||||
Integer.valueOf(opponentModel.getStartHour()));
|
||||
cal.set(Calendar.MINUTE,
|
||||
Integer.valueOf(opponentModel.getStartMinute()));
|
||||
cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(opponentModel.getStartHour()));
|
||||
cal.set(Calendar.MINUTE, Integer.valueOf(opponentModel.getStartMinute()));
|
||||
seminar.setStartDate(cal.getTime());
|
||||
|
||||
|
||||
Calendar endCal = Calendar.getInstance();
|
||||
endCal.setTime(date);
|
||||
endCal.set(Calendar.HOUR_OF_DAY,
|
||||
Integer.valueOf(opponentModel.getEndHour()));
|
||||
endCal.set(Calendar.MINUTE,
|
||||
Integer.valueOf(opponentModel.getEndMinute()));
|
||||
endCal.set(Calendar.MINUTE, Integer.valueOf(opponentModel.getEndMinute()));
|
||||
seminar.setEndDate(endCal.getTime());
|
||||
|
||||
|
||||
|
||||
seminar.setProject(project);
|
||||
seminar.setRoom(opponentModel.getRoom());
|
||||
|
||||
|
||||
seminar.setReportLanguage(opponentModel.getReportLanguage());
|
||||
seminar.setPresentationLanguage(opponentModel.getPresentationLanguage());
|
||||
|
||||
seminar = finalSeminarDao.save(seminar);
|
||||
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getOpponentList()) {
|
||||
|
||||
for (FinalSeminarActiveParticipation al : opponentModel.getOpponentList()) {
|
||||
|
||||
if (!al.isPreDeleted()) {
|
||||
FinalSeminarOpposition opposition1 = new FinalSeminarOpposition();
|
||||
opposition1.setOpponent(roleDao.makeStudent(al
|
||||
.getUser()));
|
||||
opposition1.setOpponent(roleDao.makeStudent(al.getUser()));
|
||||
opposition1.setProject(al.getProject());
|
||||
opposition1.setFinalSeminar(seminar);
|
||||
opposition1 = finalSeminarOppositionDao
|
||||
.save(opposition1);
|
||||
opposition1 = finalSeminarOppositionDao.save(opposition1);
|
||||
}
|
||||
}
|
||||
seminar = finalSeminarDao.reLoad(seminar);
|
||||
for (Student student : project.getProjectParticipants()) {
|
||||
notificationController.notifyCreateFinalSeminar(
|
||||
student.getUser(), seminar, NotificationPriority.HIGH,
|
||||
ProjectStartPage.getAbsoluteURL(), false);
|
||||
}
|
||||
|
||||
for (ProjectFollower pf : project.getProjectFollowers()) {
|
||||
notificationController.notifyCreateFinalSeminar(pf
|
||||
.getFollower().getUser(), seminar, NotificationPriority.HIGH,
|
||||
SupervisorProjectsFinalSeminarPage.getAbsoluteURL(), false);
|
||||
}
|
||||
|
||||
// This doesn't load must reload seminar in som way to get it.
|
||||
for (FinalSeminarOpposition pf : seminar.getOppositions()) {
|
||||
notificationController.notifyCreateFinalSeminar(pf
|
||||
.getOpponent().getUser(), seminar, NotificationPriority.HIGH,
|
||||
ProjectOppositionPage.getAbsoluteURL(), true);
|
||||
}
|
||||
setResponsePage(SupervisorProjectsFinalSeminarPage.class);
|
||||
} else if (!notSameProject && error) {
|
||||
error("Opponent is an author in the final seminar");
|
||||
@ -358,18 +373,18 @@ public class OpponentPanel extends Panel {
|
||||
} else if (notSameProject && error) {
|
||||
error("Must choose a project group for opponent");
|
||||
error("Unknown project class for the project and/or must select a Project for opponent");
|
||||
} else {
|
||||
} else {
|
||||
error("Opponent is an author in the final seminar");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form<?> form) {
|
||||
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
|
||||
target.addComponent(feedbackContainer);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
|
||||
public EditSeminarForm(String name) {
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(new OpponentModel()));
|
||||
editSeminarDialog.setTitle("Edit Seminar");
|
||||
editSeminarDialog.setTitle("Edit Final Seminar");
|
||||
add(new EmptyPanel("editSeminarDetails"));
|
||||
}
|
||||
}
|
||||
@ -419,7 +419,7 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
public EditForm(String name, final FinalSeminar seminar) {
|
||||
super(name);
|
||||
|
||||
add(new AjaxButton("edit", new Model<String>("Edit Seminar")) {
|
||||
add(new AjaxButton("edit", new Model<String>("Edit Final Seminar")) {
|
||||
|
||||
private static final long serialVersionUID = 4575255075365450180L;
|
||||
|
||||
@ -427,7 +427,7 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
FinalSeminar seminar2 = finalSeminarDao.reLoad(seminar);
|
||||
editSeminarForm.removeAll();
|
||||
editSeminarForm.add(new EditFinalSeminarFormPanel("editSeminarDetails", seminar2));
|
||||
editSeminarForm.add(new EditFinalSeminarFormPanel("editSeminarDetails", seminar2, false));
|
||||
target.addComponent(editSeminarForm);
|
||||
editSeminarDialog.open(target);
|
||||
}
|
||||
|
@ -26,8 +26,5 @@ public interface PeerPortalController {
|
||||
|
||||
PeerRequest storePeerRequest(final FileUpload upload, PeerRequest request) throws Exception;
|
||||
|
||||
void notifyOfReviewRating(PeerReview review);
|
||||
|
||||
void notifyCompletionOfReview(PeerReview review);
|
||||
|
||||
}
|
||||
|
@ -5,22 +5,16 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
import org.apache.wicket.protocol.http.RequestUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.conference.pages.SupervisorConferencePage;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationMessage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
@ -28,22 +22,14 @@ import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.NotificationEventType;
|
||||
import se.su.dsv.scipro.data.enums.NotificationPriority;
|
||||
import se.su.dsv.scipro.exceptions.UpdatedSincePageLoadException;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerRequestDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerRequest;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.enums.RequestStatus;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerStatsPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerReviewPage;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
import se.su.dsv.scipro.repository.util.FileStorageException;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.util.PropsUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -247,7 +233,7 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
request = peerRequestDao.save(request);
|
||||
|
||||
// Notify the requester
|
||||
notifyAcceptOfReview(request, student, project);
|
||||
notificationController.notifyAcceptOfReview(request, student, project);
|
||||
|
||||
return review;
|
||||
} catch (Exception e) {
|
||||
@ -267,151 +253,7 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Rewrite using template engine of some sort
|
||||
*
|
||||
* @param request
|
||||
* @param student
|
||||
* @param project
|
||||
*/
|
||||
protected void notifyAcceptOfReview(PeerRequest request, Student student, Project project) {
|
||||
try {
|
||||
Properties props = null;
|
||||
|
||||
props = PropsUtils.load("notification.properties");
|
||||
|
||||
String mailSubject = props.getProperty("acceptPeerReviewSubject");
|
||||
String requestAccepted = props.getProperty("requestAccepted");
|
||||
String heShe = props.getProperty("heShe");
|
||||
String complete = props.getProperty("complete");
|
||||
|
||||
User requestingUser = request.getRequester().getUser();
|
||||
|
||||
String messageBody = requestAccepted
|
||||
+ student.getUser().toString()
|
||||
+ heShe
|
||||
+ project.getProjectClass().getProjectClassSettings()
|
||||
.getNumDaysToSubmitPeerReview() + complete;
|
||||
|
||||
String webNotificationMessage = requestAccepted + student.getUser().toString();
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, messageBody);
|
||||
|
||||
PageParameters pp = new PageParameters();
|
||||
|
||||
String peerStatsUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectPeerStatsPage.class, pp).toString());
|
||||
|
||||
notificationController.processNotification(requestingUser, notificationMessage,
|
||||
peerStatsUrl, NotificationPriority.MEDIUM);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Rewrite
|
||||
*
|
||||
* @param review
|
||||
*/
|
||||
public void notifyCompletionOfReview(PeerReview review) {
|
||||
try {
|
||||
|
||||
Properties props = null;
|
||||
props = PropsUtils.load("notification.properties");
|
||||
String mailSubject = props.getProperty("completedReviewSubject");
|
||||
String requestReviewed = props.getProperty("requestReviewed");
|
||||
String supervisorMessageBody = props.getProperty("supervisorMessageBody");
|
||||
String supervisorMessageBody2 = props.getProperty("supervisorMessageBody2");
|
||||
String supervisorMessageBody3 = props.getProperty("supervisorMessageBody3");
|
||||
String commaWithLinebreak = props.getProperty("commaWithLinebreak");
|
||||
String inProject = props.getProperty("inProject");
|
||||
String hasPerformed = props.getProperty("hasPerformed");
|
||||
PeerRequest peerRequest = review.getPeerRequest();
|
||||
User requestingUser = peerRequest.getRequester().getUser();
|
||||
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.add(PeerReview.PP_PEER_REVIEW_ID, review.getId().toString());
|
||||
|
||||
String reviewUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectPeerReviewPage.class, pp).toString());
|
||||
String supervisorReviewUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(SupervisorPeerReviewPage.class, pp).toString());
|
||||
|
||||
//Message for student when his/her review request is completed.
|
||||
String messageBody = requestReviewed;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(messageBody,
|
||||
mailSubject, messageBody);
|
||||
|
||||
notificationController.processNotification(requestingUser, notificationMessage,
|
||||
reviewUrl, NotificationPriority.MEDIUM);
|
||||
|
||||
//Message for supervisor of the project with a completed review.
|
||||
messageBody =
|
||||
supervisorMessageBody
|
||||
+ peerRequest.getProject().getTitle()
|
||||
+ supervisorMessageBody2;
|
||||
User requestSupervisor = peerRequest.getProject().getHeadSupervisor().getUser();
|
||||
|
||||
NotificationMessage notificationMessageSupervisorOfProject = new NotificationMessage(messageBody,
|
||||
mailSubject, messageBody);
|
||||
|
||||
notificationController.processNotification(requestSupervisor,
|
||||
notificationMessageSupervisorOfProject, supervisorReviewUrl, NotificationPriority.MEDIUM);
|
||||
|
||||
//Message for supervisor of the reviewer that have made a review for another project.
|
||||
|
||||
String webNotificationMessage = review.getReviewer().getUser().toString() + inProject + review.getProject().getTitle() + hasPerformed;
|
||||
|
||||
messageBody = supervisorMessageBody
|
||||
+ review.getProject().getTitle()
|
||||
+ commaWithLinebreak + review.getReviewer().getUser().toString()
|
||||
+ supervisorMessageBody3;
|
||||
|
||||
User reviewSupervisor = review.getProject().getHeadSupervisor().getUser();
|
||||
NotificationMessage notificationMessageSupervisorOfReviewer = new NotificationMessage(webNotificationMessage,
|
||||
mailSubject, messageBody);
|
||||
|
||||
notificationController.processNotification(reviewSupervisor, notificationMessageSupervisorOfReviewer, supervisorReviewUrl, NotificationPriority.MEDIUM);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Rewrite
|
||||
*
|
||||
* @param review
|
||||
*/
|
||||
public void notifyOfReviewRating(PeerReview review) {
|
||||
try {
|
||||
Properties props = null;
|
||||
props = PropsUtils.load("notification.properties");
|
||||
String mailSubject = props.getProperty("reviewRatedSubject");
|
||||
String reviewRatedBody = props.getProperty("reviewRatedBody");
|
||||
User reviewingUser = review.getReviewer().getUser();
|
||||
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.add(PeerReview.PP_PEER_REVIEW_ID, review.getId().toString());
|
||||
String projectReviewUrl = RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectPeerReviewPage.class, pp).toString());
|
||||
|
||||
|
||||
String messageBody = reviewRatedBody;
|
||||
|
||||
NotificationMessage notificationMessage = new NotificationMessage(messageBody,
|
||||
mailSubject, messageBody);
|
||||
|
||||
notificationController.processNotification(reviewingUser, notificationMessage,
|
||||
projectReviewUrl, NotificationPriority.MEDIUM);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store file to a pre-populated PeerRequest
|
||||
|
@ -33,6 +33,7 @@ import org.odlabs.wiquery.core.javascript.JsStatement;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.components.JavascriptCountdown;
|
||||
import se.su.dsv.scipro.data.DomainObjectDetachableModel;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.PeerPortalController;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerRequestDao;
|
||||
@ -66,6 +67,9 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
@SpringBean
|
||||
private PeerPortalController peerPortalController;
|
||||
|
||||
@SpringBean
|
||||
private NotificationController notificationController;
|
||||
|
||||
public PeerReviewPerformReviewPanel(String id, final PeerReview peerReview) {
|
||||
super(id);
|
||||
/*
|
||||
@ -257,7 +261,7 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
peerReview.setSubmitted(true);
|
||||
peerRequest.setStatus(RequestStatus.FINISHED);
|
||||
getSession().info("Your review has been saved, thank you!");
|
||||
peerPortalController.notifyCompletionOfReview(peerReview);
|
||||
notificationController.notifyCompletionOfReview(peerReview);
|
||||
}
|
||||
|
||||
peerRequest = peerRequestDao.save(peerRequest);
|
||||
|
@ -19,6 +19,7 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.components.StarRater;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.PeerPortalController;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewRatingDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
@ -31,7 +32,7 @@ public class PeerReviewRatingPanel extends Panel {
|
||||
@SpringBean
|
||||
private ReviewRatingDao reviewRatingDao;
|
||||
@SpringBean
|
||||
private PeerPortalController peerPortalController;
|
||||
private NotificationController notificationController;
|
||||
|
||||
public PeerReviewRatingPanel(String id, final IModel<PeerReview> model) {
|
||||
super(id, model);
|
||||
@ -108,7 +109,7 @@ public class PeerReviewRatingPanel extends Panel {
|
||||
starRating.setReadOnly(true);
|
||||
target.addComponent(PeerReviewRatingPanel.this);
|
||||
|
||||
peerPortalController.notifyOfReviewRating(rating.getPeerReview());
|
||||
notificationController.notifyOfReviewRating(rating.getPeerReview());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.protocol.http.RequestUtils;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
@ -22,8 +23,6 @@ public class ProjectOppositionPage extends ProjectPage {
|
||||
@SpringBean
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@SpringBean
|
||||
private FinalSeminarDao finalSeminarDao;
|
||||
|
||||
public ProjectOppositionPage(PageParameters pp) {
|
||||
super(pp);
|
||||
@ -48,5 +47,11 @@ public class ProjectOppositionPage extends ProjectPage {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static String getAbsoluteURL() {
|
||||
PageParameters pageParameters = new PageParameters();
|
||||
return RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectOppositionPage.class, pageParameters).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,10 @@ package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import org.apache.wicket.Page;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.protocol.http.RequestUtils;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
@ -53,6 +55,12 @@ public class ProjectStartPage extends ProjectPage {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String getAbsoluteURL() {
|
||||
PageParameters pageParameters = new PageParameters();
|
||||
return RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(ProjectStartPage.class, pageParameters).toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -117,6 +117,7 @@ public class NotificationsPanel extends Panel {
|
||||
webnotification.setReadByUser(true);
|
||||
webNotificationDao.save(webnotification);
|
||||
}
|
||||
countOfNotifications = numberOfNotificationsModel.getObject();
|
||||
target.addComponent(webMarkupContainer);
|
||||
}
|
||||
|
||||
|
@ -5,25 +5,24 @@ package se.su.dsv.scipro.supervisor.pages;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarDao;
|
||||
import se.su.dsv.scipro.dataproviders.FinalSeminarAfterNowDataProvider;
|
||||
import se.su.dsv.scipro.opponent.panels.ChangeViewPanel;
|
||||
import se.su.dsv.scipro.opponent.panels.OpponentListViewPanel;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SupervisorFinalSeminarListingPage extends AbstractSupervisorFinalSeminarPage {
|
||||
|
||||
|
||||
public SupervisorFinalSeminarListingPage(PageParameters pp) {
|
||||
super(pp);
|
||||
WebMarkupContainer container = new WebMarkupContainer("container");
|
||||
container.setOutputMarkupId(true);
|
||||
container.add(new OpponentListViewPanel("finalSeminar", new FinalSeminarAfterNowDataProvider(), false, false));
|
||||
container.add(new OpponentListViewPanel("finalSeminar",
|
||||
new FinalSeminarAfterNowDataProvider(), false, false));
|
||||
add(new ChangeViewPanel("changeViewPanel", container, false));
|
||||
add(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
@ -13,6 +14,7 @@ import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.protocol.http.RequestUtils;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.core.effects.EffectSpeed;
|
||||
|
||||
@ -26,20 +28,20 @@ import se.su.dsv.scipro.util.SelectOption;
|
||||
import se.su.dsv.scipro.util.WiQueryCoreEffectsHelper;
|
||||
|
||||
public class SupervisorProjectsFinalSeminarPage extends AbstractSupervisorFinalSeminarPage {
|
||||
|
||||
public static final String MAIN_MENU_LABEL = "Final Seminars";
|
||||
|
||||
|
||||
public static final String MAIN_MENU_LABEL = "Final Seminars";
|
||||
|
||||
@SpringBean
|
||||
private ProjectDao projectDao;
|
||||
|
||||
|
||||
private ProjectStatus selectedStatus;
|
||||
private User loggedInUser;
|
||||
|
||||
public SupervisorProjectsFinalSeminarPage(final PageParameters pp){
|
||||
|
||||
public SupervisorProjectsFinalSeminarPage(final PageParameters pp) {
|
||||
super(pp);
|
||||
this.selectedStatus = ProjectStatus.ACTIVE;
|
||||
this.loggedInUser = SciProSession.get().getUser();
|
||||
|
||||
|
||||
final LoadableDetachableModel<List<Project>> projectsModel = new LoadableDetachableModel<List<Project>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -47,56 +49,68 @@ public class SupervisorProjectsFinalSeminarPage extends AbstractSupervisorFinalS
|
||||
protected List<Project> load() {
|
||||
return projectDao.getProjectsByHeadSupervisor(loggedInUser, selectedStatus);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
final WebMarkupContainer projectListContainer = new WebMarkupContainer("projectListContainer");
|
||||
|
||||
final WebMarkupContainer projectListContainer = new WebMarkupContainer(
|
||||
"projectListContainer");
|
||||
projectListContainer.setOutputMarkupId(true);
|
||||
|
||||
final ListView<Project> activeProjectsListView = new ListView<Project>("activeProjectsListView", projectsModel){
|
||||
|
||||
final ListView<Project> activeProjectsListView = new ListView<Project>(
|
||||
"activeProjectsListView", projectsModel) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Project> item) {
|
||||
final Project project = item.getModelObject();
|
||||
item.add(new Label("projectTitle", project.getTitle()));
|
||||
item.add(new ProjectFinalSeminarContainerPanel("projectSeminarContainer", project, true));
|
||||
item.add(new ProjectFinalSeminarContainerPanel("projectSeminarContainer", project,
|
||||
true));
|
||||
add(item);
|
||||
}
|
||||
};
|
||||
|
||||
projectListContainer.add(new Label("noProjectsFoundMessage", "No projects found"){
|
||||
|
||||
projectListContainer.add(new Label("noProjectsFoundMessage", "No projects found") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
public boolean isVisible() {
|
||||
return activeProjectsListView.getModelObject().size() == 0;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
projectListContainer.add(activeProjectsListView);
|
||||
add(projectListContainer);
|
||||
|
||||
|
||||
final List<SelectOption<ProjectStatus>> statusOptions = new ArrayList<SelectOption<ProjectStatus>>();
|
||||
statusOptions.add(new SelectOption<ProjectStatus>("Active projects", ProjectStatus.ACTIVE));
|
||||
statusOptions.add(new SelectOption<ProjectStatus>("Inactive projects", ProjectStatus.INACTIVE));
|
||||
statusOptions.add(new SelectOption<ProjectStatus>("Completed projects", ProjectStatus.COMPLETED));
|
||||
|
||||
final DropDownChoice<SelectOption<ProjectStatus>> statusOptionsDD =
|
||||
new DropDownChoice<SelectOption<ProjectStatus>>("statusOptionsDD",
|
||||
new Model<SelectOption<ProjectStatus>>(statusOptions.get(0)), statusOptions);
|
||||
|
||||
statusOptionsDD.add(new AjaxFormComponentUpdatingBehavior("onchange"){
|
||||
statusOptions.add(new SelectOption<ProjectStatus>("Inactive projects",
|
||||
ProjectStatus.INACTIVE));
|
||||
statusOptions.add(new SelectOption<ProjectStatus>("Completed projects",
|
||||
ProjectStatus.COMPLETED));
|
||||
|
||||
final DropDownChoice<SelectOption<ProjectStatus>> statusOptionsDD = new DropDownChoice<SelectOption<ProjectStatus>>(
|
||||
"statusOptionsDD", new Model<SelectOption<ProjectStatus>>(statusOptions.get(0)),
|
||||
statusOptions);
|
||||
|
||||
statusOptionsDD.add(new AjaxFormComponentUpdatingBehavior("onchange") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
selectedStatus = statusOptionsDD.getModelObject().value;
|
||||
target.addComponent(WiQueryCoreEffectsHelper.fadeIn(projectListContainer, EffectSpeed.FAST));
|
||||
target.addComponent(WiQueryCoreEffectsHelper.fadeIn(projectListContainer,
|
||||
EffectSpeed.FAST));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
add(statusOptionsDD);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String getAbsoluteURL() {
|
||||
PageParameters pageParameters = new PageParameters();
|
||||
return RequestUtils.toAbsolutePath(RequestCycle.get()
|
||||
.urlFor(SupervisorProjectsFinalSeminarPage.class, pageParameters).toString());
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,17 @@ mailSubject=Notification for SciPro
|
||||
hello=Hello
|
||||
autogenerated=This is an auto-generated message from SciPro
|
||||
colon=:
|
||||
comma=,
|
||||
dot=.
|
||||
space=\
|
||||
quote="
|
||||
#Conference
|
||||
conferenceNotification=\ posted on conference
|
||||
conferenceNotificationComment=\ commented on conference
|
||||
#Private message
|
||||
privateMessageNotification=\ wrote a private message to you.
|
||||
#Private message reply
|
||||
privateMessageReplyNotification=\ replied with a private message to you.
|
||||
#Peer accepted
|
||||
acceptPeerReviewSubject=Your request for peer-review has been accepted
|
||||
requestAccepted=Your peer request was accepted by
|
||||
@ -31,3 +37,16 @@ commaWithLinebreak=".\n
|
||||
#Peer rated
|
||||
reviewRatedSubject=You have received a rating for a review you have done!
|
||||
reviewRatedBody=Your review has been rated.
|
||||
#Final seminar created
|
||||
finalSeminarCreated=Head supervisor for
|
||||
finalSeminarProject=\ has created a final seminar, room
|
||||
finalSeminarProjectOpponnent=\ has created a final seminar and added you as an opponent, room
|
||||
#Final seminar report uploaded
|
||||
finalSeminarReportUploaded=Thesis for the project
|
||||
finalSeminarReportBeenUploaded=\ has been uploaded.
|
||||
#Final seminar opposition report uploaded
|
||||
finalSeminarOppositionReportUploaded=Opposition-report for the project
|
||||
finalSeminarOppositionReportBeenUploaded=\ has been uploaded by
|
||||
#Final seminar edited
|
||||
finalSeminarOppositionReportEdited=Final seminar for project
|
||||
finalSeminarOppositionReportBeenEdited=\ has been edited.
|
||||
|
@ -49,6 +49,7 @@ public class TestWicketPages extends BaseWicketTest {
|
||||
activeUser.setFirstName("Hugo");
|
||||
activeProject = new Project();
|
||||
activeProject.setProjectClass(bachelor);
|
||||
activeProject.setId(1L);
|
||||
|
||||
Mockito.when(projectDao.load(Mockito.eq(1L))).thenReturn(activeProject);
|
||||
Mockito.when(projectDao.isPartOf(activeUser, activeProject)).thenReturn(true);
|
||||
@ -133,6 +134,12 @@ public class TestWicketPages extends BaseWicketTest {
|
||||
tester.assertRenderedPage(ProjectFilePage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectConferencePage() {
|
||||
tester.startPage(ProjectConferencePage.class);
|
||||
tester.assertRenderedPage(ProjectConferencePage.class);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Supervisor pages
|
||||
|
Loading…
x
Reference in New Issue
Block a user