dataproivder for web notification
Change-Id: I39ddd4dcacefe2fe096a405d9a361c6dc17aaf17
This commit is contained in:
parent
a45766eb6f
commit
693c89bd35
@ -0,0 +1,69 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.dataproviders;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.wicket.injection.web.InjectorHolder;
|
||||
import org.apache.wicket.markup.repeater.data.IDataProvider;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.DomainObjectDetachableModel;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.WebNotificationDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.WebNotification;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class WebNotificationDataProvider implements IDataProvider<WebNotification> {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private WebNotificationDao webNotificationDao;
|
||||
|
||||
private User user;
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public WebNotificationDataProvider(User user) {
|
||||
InjectorHolder.getInjector().inject(this);
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int)
|
||||
*/
|
||||
@Override
|
||||
public Iterator<? extends WebNotification> iterator(int first, int count) {
|
||||
return webNotificationDao.getWebNotifications(user, first, count).iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.wicket.markup.repeater.data.IDataProvider#size()
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
// TODO Auto-generated method stub
|
||||
return webNotificationDao.getCountOfWebNotifications(user);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.wicket.markup.repeater.data.IDataProvider#model(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public IModel<WebNotification> model(WebNotification object) {
|
||||
// TODO Auto-generated method stub
|
||||
return new DomainObjectDetachableModel<WebNotification>(webNotificationDao, object);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user