Merge branch 'develop' of ssh://git.dsv.su.se/git/scipro/scipro into develop
* 'develop' of ssh://git.dsv.su.se/git/scipro/scipro: Done with upcomingEventPanel events now order properly Refactored some XML-related stuff to make it more reusable daily commit Removed checkbox for activating latest reviewers links since further work is needed on which reviews the students should have access to. added support for inactivating/activating Latest Reviewers panel in General System Settings and Peer Administration weekend commit fixed an issue where a test behaved differently on windows and linux Added upcomingeventpanel Added support for activating/inactivating clickable links in Latest reviewers panel. Minor changes in Latest reviewers panel and in the general system settings that the panel concern. Added functionality to enable/disable Latest reviews-panel and to specify number of reviews to show. Added a new panel that show the latest reviews in the peer portal
This commit is contained in:
commit
117f82eb45
src
main
java/se/su/dsv/scipro
admin/pages
data
dao
dataobjects
peer
data/dao
panels
project
schedule/baseevent/panels
util/xml
resources/META-INF
webapp/WEB-INF
test/java/se/su/dsv/scipro
@ -56,7 +56,5 @@ public class AdminProjectPartnerPage extends AbstractAdminPage {
|
||||
|
||||
|
||||
}
|
||||
|
||||
//generalsystemsettings för att spara datum
|
||||
|
||||
}
|
||||
|
@ -14,9 +14,17 @@
|
||||
<td><input type="checkbox" wicket:id="peerRatingsEnabled" name="peerRatingsEnabled"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="peerDisplayNumberOfReviewsPerformed">Display users number of reviews performed on portal page</label></td>
|
||||
<td><label for="peerDisplayNumberOfReviewsPerformed">Display users number of reviews performed on portal page:</label></td>
|
||||
<td><input type="checkbox" wicket:id="peerDisplayNumberOfReviewsPerformed" name="peerDisplayNumberOfReviewsPerformed"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="peerDisplayLatestReviews">Display the latest submitted reviews on portal page:</label></td>
|
||||
<td><input type="checkbox" wicket:id="peerDisplayLatestReviews" name="peerDisplayLatestReviews"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="numberOfLatestReviewsDisplayed">Number of reviews to show in the "Latest reviewers" panel: </label></td>
|
||||
<td><input type="text" wicket:id="numberOfLatestReviewsDisplayed" name="numberOfLatestReviewsDisplayed" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<h5 class="peer-title">Settings for levels</h5>
|
||||
|
@ -59,17 +59,36 @@ public class AdminPeerSettingsPage extends AbstractAdminSettingsPage {
|
||||
|
||||
private class PeerRatingsSettingsForm extends Form<GeneralSystemSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TextField<Integer> numberOfLatestReviewsDisplayed;
|
||||
|
||||
public PeerRatingsSettingsForm(String id, IModel<GeneralSystemSettings> model) {
|
||||
super(id, model);
|
||||
|
||||
CheckBox peerRatingsEnabled = new CheckBox("peerRatingsEnabled");
|
||||
add(peerRatingsEnabled);
|
||||
CheckBox peerDisplayNumberOfReviewsPerformed = new CheckBox("peerDisplayNumberOfReviewsPerformed");
|
||||
add(peerDisplayNumberOfReviewsPerformed);
|
||||
add(peerDisplayNumberOfReviewsPerformed);
|
||||
CheckBox peerDisplayLatestReviews = new CheckBox("peerDisplayLatestReviews");
|
||||
add(peerDisplayLatestReviews);
|
||||
|
||||
numberOfLatestReviewsDisplayed =
|
||||
new TextField<Integer>("numberOfLatestReviewsDisplayed");
|
||||
numberOfLatestReviewsDisplayed.setRequired(true);
|
||||
add(numberOfLatestReviewsDisplayed);
|
||||
|
||||
// Checkbox for activating/inactiviting links to reviews in the Latest reviewers panel.
|
||||
//
|
||||
/*CheckBox publicReviewsActivated = new CheckBox("publicReviewsActivated");
|
||||
add(publicReviewsActivated);*/
|
||||
}
|
||||
@Override
|
||||
public void onSubmit(){
|
||||
setModelObject(generalSystemSettingsDao.save(getModelObject()));
|
||||
if (getModelObject().getNumberOfLatestReviewsDisplayed() == 0) {
|
||||
warn("Number of reviews to show has been changed to 1. If you don't want to show any reviews, please hide the panel.");
|
||||
getModelObject().setNumberOfLatestReviewsDisplayed(1);
|
||||
}
|
||||
setModelObject(generalSystemSettingsDao.save(getModelObject()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ public interface EventDao extends LazyDeleteDao<Event> {
|
||||
|
||||
public List<Event> getUpcomingEventsByUserAndProject(final User u, final Project p);
|
||||
|
||||
public List<Event> getUpcomingEventsByUserAndProject(final User u, final Project p, final Integer limit);
|
||||
|
||||
public Event getNextEvent(final User u, final Project p, final Event event);
|
||||
|
||||
public boolean hasHandInsInHandInActivity(final Event event);
|
||||
|
@ -64,6 +64,7 @@ public class EventDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Event> implement
|
||||
events.addAll(d.getEventsByUserAndProject(u, p, fromDate, toDate, limit));
|
||||
}
|
||||
Collections.sort(events);
|
||||
System.out.println(events);
|
||||
return events;
|
||||
}
|
||||
|
||||
@ -83,6 +84,10 @@ public class EventDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Event> implement
|
||||
return getEvents(u, p, new Date(), null, null);
|
||||
}
|
||||
|
||||
public List<Event> getUpcomingEventsByUserAndProject(final User u, final Project p, Integer limit){
|
||||
return getEvents(u, p, new Date(), null, limit);
|
||||
}
|
||||
|
||||
public Event getNextEvent(final User u, final Project p, final Event e) {
|
||||
List<Event> list = getEvents(u, p, e.getDueDate() , null, 1);
|
||||
if(list.size() == 0){
|
||||
|
@ -89,6 +89,7 @@ public class GroupEventDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<GroupEvent>
|
||||
if(toDate != null){
|
||||
geQuery.setParameter("toDate", toDate);
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
return geQuery.getResultList();
|
||||
@ -131,6 +132,7 @@ public class GroupEventDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<GroupEvent>
|
||||
if(toDate != null){
|
||||
query.setParameter("toDate", toDate);
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
return query.getResultList();
|
||||
|
@ -132,18 +132,19 @@ public abstract class Event extends LazyDeletableDomainObject
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
if (obj instanceof Event){
|
||||
|
||||
Event other = (Event) obj;
|
||||
|
||||
Event other = (Event) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,7 +154,7 @@ public abstract class Event extends LazyDeletableDomainObject
|
||||
|
||||
@Override
|
||||
public int compareTo(Event other) {
|
||||
int dcomp = (int) (dueDate.getTime() - other.dueDate.getTime());
|
||||
int dcomp = dueDate.compareTo(other.dueDate);
|
||||
if(dcomp == 0)
|
||||
return id.compareTo(other.id);
|
||||
else
|
||||
|
@ -51,6 +51,15 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
@Basic(optional=false)
|
||||
private boolean peerDisplayNumberOfReviewsPerformed = true;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean peerDisplayLatestReviews = true;
|
||||
|
||||
@Basic(optional=false)
|
||||
private int numberOfLatestReviewsDisplayed = 3;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean publicReviewsActivated = true;
|
||||
|
||||
public GeneralSystemSettings(){
|
||||
}
|
||||
/**
|
||||
@ -116,6 +125,24 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
public boolean isPeerDisplayNumberOfReviewsPerformed() {
|
||||
return peerDisplayNumberOfReviewsPerformed;
|
||||
}
|
||||
public void setPeerDisplayLatestReviews(boolean peerDisplayLatestReviews) {
|
||||
this.peerDisplayLatestReviews = peerDisplayLatestReviews;
|
||||
}
|
||||
public boolean isPeerDisplayLatestReviews() {
|
||||
return peerDisplayLatestReviews;
|
||||
}
|
||||
public int getNumberOfLatestReviewsDisplayed() {
|
||||
return numberOfLatestReviewsDisplayed;
|
||||
}
|
||||
public void setNumberOfLatestReviewsDisplayed(int numberOfLatestReviewsDisplayed) {
|
||||
this.numberOfLatestReviewsDisplayed = numberOfLatestReviewsDisplayed;
|
||||
}
|
||||
public boolean isPublicReviewsActivated() {
|
||||
return publicReviewsActivated;
|
||||
}
|
||||
public void setPublicReviewsActivated(boolean publicReviewsActivated) {
|
||||
this.publicReviewsActivated = publicReviewsActivated;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ public interface PeerReviewDao extends LazyDeleteDao<PeerReview> {
|
||||
public int countStudentsWithReviews(final long minimumNumberOfReviews, final Date since);
|
||||
|
||||
public int countStudentsWithReviews();
|
||||
|
||||
public int countSubmittedReviews();
|
||||
|
||||
public List<PeerReview> findReviewsSortedByDate(final int firstResult, final Integer limit);
|
||||
|
||||
/**
|
||||
* Find given peer reviews for a given project and student
|
||||
|
@ -385,4 +385,55 @@ public class PeerReviewDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<PeerReview>
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<PeerReview> findReviewsSortedByDate(final int firstResult, final Integer limit) {
|
||||
|
||||
return getJpaTemplate().execute(new JpaCallback<List<PeerReview>>() {
|
||||
public List<PeerReview> doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
|
||||
String q = "select pr " +
|
||||
"from PeerReview pr " +
|
||||
"where pr.submitted = true " +
|
||||
"and pr.deleted = false " +
|
||||
"and pr.aborted = false " +
|
||||
"order by pr.lastModified desc";
|
||||
|
||||
|
||||
TypedQuery<PeerReview> query = em.createQuery(q, PeerReview.class);
|
||||
|
||||
query.setMaxResults(limit != null ? limit : 3);
|
||||
query.setFirstResult(firstResult);
|
||||
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return new LinkedList<PeerReview>();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countSubmittedReviews() {
|
||||
return getJpaTemplate().execute(new JpaCallback<Integer>() {
|
||||
public Integer doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
|
||||
String q = "select count(pr) " +
|
||||
"from PeerReview pr " +
|
||||
"where pr.submitted = true " +
|
||||
"and pr.deleted = false " +
|
||||
"and pr.aborted = false";
|
||||
|
||||
TypedQuery<Long> query = em.createQuery(q, Long.class);
|
||||
|
||||
try {
|
||||
return query.getSingleResult().intValue();
|
||||
} catch (NoResultException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}); }
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div>
|
||||
<table>
|
||||
<tbody wicket:id="listView">
|
||||
<tr>
|
||||
<td wicket:id="reviewer"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#" wicket:id="reviewLink">Review date: <span wicket:id="reviewDate"></span></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<i><span wicket:id="noReviewersFoundMessage"></span></i>
|
||||
</div>
|
||||
<div>
|
||||
<a href="#" wicket:id="showMore">Show more...</a>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,135 @@
|
||||
package se.su.dsv.scipro.peer.panels;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.ComponentTag;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
|
||||
public class LatestReviewPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param model
|
||||
* the number of users to show by default - also defines how many
|
||||
* users to show when clicking showmore
|
||||
*/
|
||||
public LatestReviewPanel(String id, final Model<Integer> model, final boolean publicLinks) {
|
||||
super(id, model);
|
||||
|
||||
setOutputMarkupId(true);
|
||||
|
||||
final int totalCount = peerReviewDao.countSubmittedReviews();
|
||||
|
||||
final LoadableDetachableModel<List<PeerReview>> listModel = new LoadableDetachableModel<List<PeerReview>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected List<PeerReview> load() {
|
||||
return peerReviewDao.findReviewsSortedByDate(0, model.getObject());
|
||||
}
|
||||
};
|
||||
|
||||
final ListView<PeerReview> listView = new ListView<PeerReview>("listView", listModel) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<PeerReview> item) {
|
||||
PeerReview pr = item.getModelObject();
|
||||
item.add(pr.getReviewer().getUser().getDisplayComponent("reviewer"));
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
Label dateLabel = new Label("reviewDate", df.format(pr.getLastModified()));
|
||||
|
||||
if(publicLinks) {
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PeerReview.PP_PEER_REVIEW_ID, pr.getId());
|
||||
BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>("reviewLink", ProjectPeerReviewPage.class, pp);
|
||||
link.add(dateLabel);
|
||||
item.add(link);
|
||||
} else {
|
||||
LinkToSpanContainer ltsc = new LinkToSpanContainer("reviewLink");
|
||||
ltsc.add(dateLabel);
|
||||
item.add(ltsc);
|
||||
}
|
||||
add(item);
|
||||
}
|
||||
};
|
||||
|
||||
add(new Label("noReviewersFoundMessage", "No reviewers found") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return listView.size() == 0;
|
||||
}
|
||||
});
|
||||
|
||||
add(listView);
|
||||
|
||||
add(new AjaxLink<Void>("showMore") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
Integer i = model.getObject();
|
||||
i += model.getObject();
|
||||
model.setObject(i);
|
||||
target.addComponent(LatestReviewPanel.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return listView.size() < totalCount;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public LatestReviewPanel(String id) {
|
||||
this(id, new Model<Integer>(3), false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Change html markup from a href to span when links are disabled.
|
||||
* Used when publicly viewable peer reviews is activated/inactivated.
|
||||
*/
|
||||
class LinkToSpanContainer extends WebMarkupContainer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public LinkToSpanContainer(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onComponentTag(final ComponentTag tag) {
|
||||
tag.setName("span");
|
||||
tag.remove("href");
|
||||
|
||||
super.onComponentTag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -72,6 +72,12 @@
|
||||
</div>
|
||||
<!-- End left column -->
|
||||
<div class="span-6 last">
|
||||
<wicket:enclosure>
|
||||
<div class="rounded-box">
|
||||
<span class="box-title">Latest reviewers</span>
|
||||
<div wicket:id="latestReviewPanel" class="append-bottom"></div>
|
||||
</div>
|
||||
</wicket:enclosure>
|
||||
<wicket:enclosure>
|
||||
<div class="rounded-box">
|
||||
<span class="box-title">Most frequent reviewers</span>
|
||||
@ -86,7 +92,6 @@
|
||||
<div>
|
||||
<i><span class="small right">Last 12 months</span></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
@ -216,7 +216,10 @@ public class PeerPortalPanel extends Panel {
|
||||
|
||||
GeneralSystemSettings gsettings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
final String mostFrequentPanel = "mostFrequentPanel";
|
||||
final String latestReviewPanel ="latestReviewPanel";
|
||||
final String bestRatedContainer = "bestRatedContainer";
|
||||
int displayedReviews = gsettings.getNumberOfLatestReviewsDisplayed();
|
||||
|
||||
|
||||
if(gsettings.isPeerDisplayNumberOfReviewsPerformed()){
|
||||
add(new MostFrequentReviewersPanel(mostFrequentPanel));
|
||||
@ -228,6 +231,18 @@ public class PeerPortalPanel extends Panel {
|
||||
} else {
|
||||
add(new InvisiblePanel(bestRatedContainer));
|
||||
}
|
||||
if(gsettings.isPeerDisplayLatestReviews()) {
|
||||
// Checkbox on the AdminPeerSettingsPage is not visible since it's
|
||||
// not decided what kind of info that should be public for students.
|
||||
if (gsettings.isPublicReviewsActivated()) {
|
||||
add(new LatestReviewPanel(latestReviewPanel, new Model<Integer>(displayedReviews), true));
|
||||
} else {
|
||||
add(new LatestReviewPanel(latestReviewPanel, new Model<Integer>(displayedReviews), false));
|
||||
}
|
||||
} else {
|
||||
add(new InvisiblePanel(latestReviewPanel));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,9 @@
|
||||
<h5 class="peer-title">Final seminar for this project</h5>
|
||||
<div wicket:id="projectSeminarPanel"></div>
|
||||
</div>
|
||||
<div class="span-10 last">
|
||||
<div wicket:id="upcomingEventPanel"></div>
|
||||
</div>
|
||||
<!-- <div class="span-10 last">-->
|
||||
<!-- <h5 class="peer-title">Oppositions & Active participations</h5>-->
|
||||
<!-- <div wicket:id="oppositionStatsPanel"></div>-->
|
||||
|
@ -12,6 +12,7 @@ import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.panels.StudentPeerInfoRequestsPanel;
|
||||
import se.su.dsv.scipro.project.panels.ProjectWallPanel;
|
||||
import se.su.dsv.scipro.project.panels.StateOfMindPanel;
|
||||
import se.su.dsv.scipro.project.panels.UpcomingEventPanel;
|
||||
import se.su.dsv.scipro.schedule.panels.ProjectProgressPanel;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@ -34,6 +35,7 @@ public class ProjectStartPage extends ProjectPage {
|
||||
add(new FeedbackPanel("feedback"));
|
||||
add(new ProjectFinalSeminarContainerPanel("projectSeminarPanel", activeProject));
|
||||
//add(new StudentOppositionStatsPanel("oppositionStatsPanel", activeProject));
|
||||
add(new UpcomingEventPanel("upcomingEventPanel", activeProject, 3));
|
||||
leftColumn.add(new StudentPeerInfoRequestsPanel("peerRequests", null, activeProject){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -45,7 +47,9 @@ public class ProjectStartPage extends ProjectPage {
|
||||
ProjectProgressPanel progressPanel = new ProjectProgressPanel("progress", activeProject);
|
||||
leftColumn.add(progressPanel.getHelpIcon("progressHelp"));
|
||||
leftColumn.add(progressPanel);
|
||||
//leftColumn.add(new UpcomingEventPanel("upcomingEventPanel", activeProject));
|
||||
leftColumn.add(new ProjectWallPanel("projectWallPanel", activeProject));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div class="span-10 last">
|
||||
<h5 class="peer-title">Upcoming events</h5>
|
||||
<div wicket:id="eventListContainer" class="span-10 last">
|
||||
<div class="span-10 last"></div>
|
||||
<div class="span-10 last" wicket:id="events">
|
||||
<div wicket:id="eventPanel"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div wicket:id="dialog">
|
||||
<div wicket:id="dialogContainer">
|
||||
<div wicket:id="containerContent">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,174 @@
|
||||
package se.su.dsv.scipro.project.panels;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.Page;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.core.effects.EffectSpeed;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Event;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.project.pages.ProjectEventPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectScheduleGeneratorPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectSchedulePlannerPage;
|
||||
import se.su.dsv.scipro.schedule.baseevent.panels.EventSchedulePanel;
|
||||
import se.su.dsv.scipro.util.WiQueryCoreEffectsHelper;
|
||||
|
||||
public class UpcomingEventPanel extends Panel{
|
||||
|
||||
/**
|
||||
* @author Fredrik Norberg - fnorbe@dsv.su.se
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4481663857329726445L;
|
||||
|
||||
@SpringBean
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@SpringBean
|
||||
private EventDao eventDao;
|
||||
|
||||
private Project project;
|
||||
private User user;
|
||||
private ListView<Event> eventList;
|
||||
private IModel<List<Event>> listModel;
|
||||
private WebMarkupContainer eventListContainer;
|
||||
private int amountToShow;
|
||||
private WebMarkupContainer dialogContainer;
|
||||
private Dialog dialog;
|
||||
private Model<String> dialogTitle = new Model<String>("");
|
||||
|
||||
public UpcomingEventPanel(String id, final Project p, final int amountToShow){
|
||||
super(id);
|
||||
this.project = projectDao.reLoad(p);
|
||||
this.user = SciProSession.get().getUser();
|
||||
this.amountToShow = amountToShow;
|
||||
|
||||
dialogContainer = new WebMarkupContainer("dialogContainer");
|
||||
dialogContainer.setOutputMarkupId(true);
|
||||
dialogContainer.setVersioned(false);
|
||||
dialogContainer.add(new EmptyPanel("containerContent"));
|
||||
dialog = new Dialog("dialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
dialog.add(dialogContainer);
|
||||
dialog.setWidth(600);
|
||||
dialog.setHeight(450);
|
||||
dialog.setTitle(dialogTitle);
|
||||
add(dialog);
|
||||
|
||||
listModel = new LoadableDetachableModel<List<Event>>(){
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4397997418096384845L;
|
||||
|
||||
@Override
|
||||
protected List<Event> load() {
|
||||
List<Event> list = eventDao.getEventsByUserAndProject(user, project,
|
||||
new Date(), null, null);
|
||||
if(amountToShow < list.size()){ //use this to limit the events shown
|
||||
list = list.subList(0, amountToShow);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
eventList = new ListView<Event>("events", listModel){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Event> item) {
|
||||
final Event e = item.getModelObject();
|
||||
item.add(new EventSchedulePanel("eventPanel", e, project, false){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void replaceAndOpenDialog(AjaxRequestTarget target,
|
||||
Panel replacePanel) {
|
||||
dialogContainer.replace(replacePanel);
|
||||
target.addComponent(dialogContainer);
|
||||
dialog.open(target);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshListView(AjaxRequestTarget target) {
|
||||
target.addComponent(WiQueryCoreEffectsHelper.fadeIn(eventListContainer, EffectSpeed.FAST));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeDialogAndRefreshListView(AjaxRequestTarget target) {
|
||||
target.addComponent(WiQueryCoreEffectsHelper.fadeIn(eventListContainer, EffectSpeed.FAST));
|
||||
dialog.close(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventDetailsClick() {
|
||||
PageParameters pp = getEventPageParameters();
|
||||
pp.add(Event.PP_EVENT_ID, String.valueOf(e.getId()));
|
||||
setResponsePage(getEventPageClass(), pp);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
add(item);
|
||||
}
|
||||
};
|
||||
|
||||
/*@Override
|
||||
protected void populateItem(ListItem<Event> item) {
|
||||
final Event e = item.getModelObject();
|
||||
item.add(new Label("title", e.getTitle()));
|
||||
item.add(new Label("date", e.getDueDate().toString()));
|
||||
}
|
||||
|
||||
};*/
|
||||
|
||||
eventListContainer = new WebMarkupContainer("eventListContainer");
|
||||
eventListContainer.setOutputMarkupId(true);
|
||||
eventListContainer.add(eventList);
|
||||
add(eventListContainer);
|
||||
}
|
||||
|
||||
|
||||
public Class<? extends Page> getGeneratorPageClass() {
|
||||
return ProjectScheduleGeneratorPage.class;
|
||||
}
|
||||
|
||||
public Class<? extends Page> getEventPageClass() {
|
||||
return ProjectEventPage.class;
|
||||
}
|
||||
|
||||
public PageParameters getSchedulePageParameters(){
|
||||
return new PageParameters();
|
||||
}
|
||||
public PageParameters getGeneratorPageParameters(){
|
||||
return new PageParameters();
|
||||
}
|
||||
public PageParameters getEventPageParameters(){
|
||||
return new PageParameters();
|
||||
}
|
||||
|
||||
}
|
@ -165,8 +165,10 @@ public abstract class EventSchedulePanel extends Panel {
|
||||
statusIcon = ImageIcon.ICON_EVENT_ALERT;
|
||||
} else {
|
||||
//The event must be upcoming
|
||||
statusMsgModel.setObject("Event upcoming");
|
||||
statusIcon = ImageIcon.ICON_EVENT_UPCOMING;
|
||||
if(event.getDueDate().getTime() > new Date().getTime()){
|
||||
statusMsgModel.setObject("Event upcoming");
|
||||
statusIcon = ImageIcon.ICON_EVENT_UPCOMING;
|
||||
}
|
||||
}
|
||||
|
||||
add(new IconPanel("statusIcon", statusIcon){
|
||||
|
@ -0,0 +1,106 @@
|
||||
package se.su.dsv.scipro.util.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
|
||||
/**
|
||||
* Utility class for providing configurable namespace contexts, satisfies specification defined in the NamespaceContext interface.
|
||||
* The default namespace-prefixes (DEFAULT_NS_PREFIX, XML_NS_PREFIX and XMLNS_ATTRIBUTE) are automatically mapped to defaults and are not configurable from clients.
|
||||
* Typical usage:
|
||||
* <code>
|
||||
* MutableNamespaceContext mnc = new MutableNamespaceContext();
|
||||
* mnc.setMapping("somePrefix", "someNamespaceURI");
|
||||
* XPath xp = .....
|
||||
* xp.setNamespaceContext(mnc);
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
public final class MutableNamespaceContext implements NamespaceContext {
|
||||
private final Map<String,String> nsMap = new HashMap<String,String>();
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public MutableNamespaceContext(){
|
||||
setupDefaults();
|
||||
}
|
||||
/**
|
||||
* Attempts to resolve the given prefix into a namespaceURI.
|
||||
* @return The namespace URI or XMLConstants.NULL_NS_URI if no mapping is found.
|
||||
* @throws IllegalStateException if the given prefix is null.
|
||||
*/
|
||||
@Override
|
||||
public String getNamespaceURI(String prefix){
|
||||
if(prefix == null)
|
||||
throw new IllegalStateException("A null prefix not allowed");
|
||||
if(!nsMap.containsKey(prefix))
|
||||
return XMLConstants.NULL_NS_URI;
|
||||
else
|
||||
return nsMap.get(prefix);
|
||||
}
|
||||
/**
|
||||
* Resolves all registered prefixes for the given URI.
|
||||
* @param uri
|
||||
* @return An iterator of all registered prefixes for the given URI, the empty iterator if none are found.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Iterator<String> getPrefixes(String URI) {
|
||||
if(URI == null)
|
||||
throw new IllegalStateException("A null URI not allowed");
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(Map.Entry<String, String> entry : nsMap.entrySet()){
|
||||
if(entry.getValue().equals(URI))
|
||||
list.add(entry.getKey());
|
||||
}
|
||||
return Collections.unmodifiableList(list).iterator();
|
||||
}
|
||||
/**
|
||||
* Resolves one prefix for the given URI.
|
||||
* @param uri
|
||||
* @return The registered prefix
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix(String URI) {
|
||||
if(URI == null)
|
||||
throw new IllegalStateException("A null URI not allowed");
|
||||
final Iterator<String> itr = getPrefixes(URI);
|
||||
if(itr.hasNext())
|
||||
return itr.next();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Sets a prefix to URI mapping.
|
||||
* Overwrites existing mappings if existing, does not allow setting any of the default name space prefix mappings or mapping alternative prefixes for the default name space URI's.
|
||||
* @param prefix
|
||||
* @param URI
|
||||
* @throws IllegalStateException if either argument is null.
|
||||
*/
|
||||
public void setMapping(final String prefix, final String URI){
|
||||
if(prefix==null || URI==null)
|
||||
throw new IllegalStateException("Null prefix or URI not allowed");
|
||||
if(!prefix.equals(XMLConstants.DEFAULT_NS_PREFIX) && !prefix.equals(XMLConstants.XML_NS_PREFIX) && !prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)
|
||||
&& !URI.equals(XMLConstants.XML_NS_URI) && !URI.equals(XMLConstants.XML_NS_URI) && !URI.equals(XMLConstants.NULL_NS_URI))
|
||||
nsMap.put(prefix, URI);
|
||||
}
|
||||
/**
|
||||
* Clear user defined mappings.
|
||||
*/
|
||||
public void clearMappings(){
|
||||
nsMap.clear();
|
||||
setupDefaults();
|
||||
}
|
||||
private void setupDefaults(){
|
||||
nsMap.put(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
|
||||
nsMap.put(XMLConstants.XMLNS_ATTRIBUTE, XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
|
||||
nsMap.put(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI);
|
||||
}
|
||||
}
|
@ -88,8 +88,8 @@
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
|
||||
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/scipro"></property>
|
||||
<property name="hibernate.connection.username" value="scipro"></property>
|
||||
<property name="hibernate.connection.password" value="pighleef"></property>
|
||||
<property name="hibernate.connection.username" value="root"></property>
|
||||
<property name="hibernate.connection.password" value="juju"></property>
|
||||
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"></property>
|
||||
<property name="hibernate.c3p0.min_size" value="3"></property>
|
||||
<property name="hibernate.c3p0.max_size" value="6"></property>
|
||||
|
@ -64,8 +64,8 @@
|
||||
<!-- Use deployment for production, development for development -->
|
||||
<context-param>
|
||||
<param-name>configuration</param-name>
|
||||
<!-- <param-value>development</param-value>-->
|
||||
<param-value>deployment</param-value>
|
||||
<param-value>development</param-value>
|
||||
<!--<param-value>deployment</param-value>-->
|
||||
</context-param>
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@ import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import se.su.dsv.scipro.util.xml.MutableNamespaceContext;
|
||||
|
||||
/**
|
||||
* Assert that deploy configuration is upheld before build can be completed.
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
@ -107,21 +109,21 @@ public class TestDeployConfiguration {
|
||||
public void testExternalAuthCfg() throws XPathExpressionException, IOException{
|
||||
InputSource applicationContextXml = getInputSource(applicationContextPath);
|
||||
XPath xPath = getApplicationContextXPath();
|
||||
Assert.assertEquals("true", xPath.evaluate("/defaultNS:beans/defaultNS:bean[@id='applicationSettings']/defaultNS:property[@name='acceptExternalAuthentication']/@value", applicationContextXml));
|
||||
Assert.assertEquals("true", xPath.evaluate("/beanNS:beans/beanNS:bean[@id='applicationSettings']/beanNS:property[@name='acceptExternalAuthentication']/@value", applicationContextXml));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteUserLookupCfg() throws XPathExpressionException, IOException{
|
||||
InputSource applicationContextXml = getInputSource(applicationContextPath);
|
||||
XPath xPath = getApplicationContextXPath();
|
||||
Assert.assertEquals("true", xPath.evaluate("/defaultNS:beans/defaultNS:bean[@id='applicationSettings']/defaultNS:property[@name='enableRemoteUserLookup']/@value", applicationContextXml));
|
||||
Assert.assertEquals("true", xPath.evaluate("/beanNS:beans/beanNS:bean[@id='applicationSettings']/beanNS:property[@name='enableRemoteUserLookup']/@value", applicationContextXml));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteUserRemoteUserLookupUrlCfg() throws XPathExpressionException, IOException{
|
||||
InputSource applicationContextXml = getInputSource(applicationContextPath);
|
||||
XPath xPath = getApplicationContextXPath();
|
||||
Assert.assertEquals("https://thesis.dsv.su.se/match/json", xPath.evaluate("/defaultNS:beans/defaultNS:bean[@id='applicationSettings']/defaultNS:property[@name='remoteLookupUrl']/@value", applicationContextXml));
|
||||
Assert.assertEquals("https://thesis.dsv.su.se/match/json", xPath.evaluate("/beanNS:beans/beanNS:bean[@id='applicationSettings']/beanNS:property[@name='remoteLookupUrl']/@value", applicationContextXml));
|
||||
}
|
||||
|
||||
private InputSource getInputSource(String filePath) throws IOException{
|
||||
@ -142,28 +144,9 @@ public class TestDeployConfiguration {
|
||||
}
|
||||
private XPath getApplicationContextXPath(){
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
xPath.setNamespaceContext(new NamespaceContext(){
|
||||
@Override
|
||||
public String getNamespaceURI(String prefix){
|
||||
if(prefix.equals("defaultNS"))
|
||||
return "http://www.springframework.org/schema/beans";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public Iterator<String> getPrefixes(String val) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(getPrefix(val));
|
||||
return list.iterator();
|
||||
}
|
||||
@Override
|
||||
public String getPrefix(String uri) {
|
||||
if(uri.equals("http://www.springframework.org/schema/beans"))
|
||||
return "defaultNS";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
});
|
||||
MutableNamespaceContext mnc = new MutableNamespaceContext();
|
||||
mnc.setMapping("beanNS","http://www.springframework.org/schema/beans");
|
||||
xPath.setNamespaceContext(mnc);
|
||||
return xPath;
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class BaseWicketTest {
|
||||
|
||||
@Mock EntityManagerFactoryInfo entityManagerFactory = Mockito.mock(LocalEntityManagerFactoryBean.class);
|
||||
|
||||
@Before
|
||||
//@Before
|
||||
public void setup() {
|
||||
/*
|
||||
* Setup a new mock applicationContext
|
||||
|
@ -59,6 +59,8 @@ public class TestWicketPages extends BaseWicketTest {
|
||||
@Test
|
||||
public void testStartPage() throws Exception {
|
||||
|
||||
|
||||
this.setLoggedIn(false);
|
||||
tester.startPage(HomePage.class);
|
||||
tester.assertRenderedPage(LoginPage.class);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user