handles urls to rest sites

Change-Id: I19f9342bd601042a7daedf29b242f27a08303c8c
This commit is contained in:
joha-asc 2011-07-18 17:06:26 +02:00
parent b1b38584cb
commit 49eb2dbba4

@ -5,7 +5,7 @@ package se.su.dsv.scipro.project.panels;
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.markup.html.AjaxLink;
import org.apache.wicket.markup.html.WebMarkupContainer;
@ -16,18 +16,18 @@ import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.protocol.http.RequestUtils;
import org.apache.wicket.request.target.basic.RedirectRequestTarget;
import org.apache.wicket.spring.injection.annot.SpringBean;
import se.su.dsv.scipro.SciProSession;
import se.su.dsv.scipro.conference.pages.ProjectConferencePage;
import se.su.dsv.scipro.conference.pages.SupervisorConferencePage;
import se.su.dsv.scipro.data.dao.interfaces.NotificationDao;
import se.su.dsv.scipro.data.dao.interfaces.WebNotificationDao;
import se.su.dsv.scipro.data.dataobjects.WebNotification;
import se.su.dsv.scipro.data.dataobjects.Project;
import se.su.dsv.scipro.data.enums.NotificationEventType;
import se.su.dsv.scipro.message.pages.PrivateMessagesPage;
import se.su.dsv.scipro.security.auth.roles.Roles;
import se.su.dsv.scipro.supervisor.pages.SupervisorProjectDetailsPage;
/**
* @author Johan Aschan <aschan@dsv.su.se>
@ -38,7 +38,7 @@ public class NotificationsPanel extends Panel {
private static final long serialVersionUID = 1L;
@SpringBean
private NotificationDao notificationDao;
private WebNotificationDao notificationDao;
/**
* @param id
@ -52,7 +52,7 @@ public class NotificationsPanel extends Panel {
@Override
protected List<WebNotification> load() {
return notificationDao.getNotifications(SciProSession.get().getUser());
return notificationDao.getWebNotifications(SciProSession.get().getUser());
}
};
@ -62,7 +62,7 @@ public class NotificationsPanel extends Panel {
@Override
protected Integer load() {
return notificationDao.getNumberOfNotifications(SciProSession.get().getUser());
return notificationDao.getNumberOfWebNotifications(SciProSession.get().getUser());
}
};
@ -89,21 +89,9 @@ public class NotificationsPanel extends Panel {
WebNotification notification = item.getModel().getObject();
notification.setReadByUser(true);
notification = notificationDao.save(notification);
if (notification.getNotificationEventType().equals(
NotificationEventType.NEW_MESSAGE_IN_CONFERENCE)) {
if (notification.getRole().equals(Roles.STUDENT))
setResponsePage(new ProjectConferencePage(getPage()
.getPageParameters(), item.getModel().getObject()
.getTypeId()));
else
setResponsePage(new SupervisorConferencePage(getPage()
.getPageParameters(), item.getModel().getObject()
.getTypeId()));
} else if (notification.getNotificationEventType().equals(
NotificationEventType.NEW_PRIVATE_MESSAGE)) {
setResponsePage(PrivateMessagesPage.class);
}
String url = RequestUtils.toAbsolutePath(RequestCycle.get().getRequest().getRelativePathPrefixToWicketHandler());
url += notification.getRestRelativeURL();
getRequestCycle().setRequestTarget(new RedirectRequestTarget(notification.getRestRelativeURL()));
}
});
item.add(new AjaxLink<Void>("readNotification") {