Merge branch 'develop' into dynmaic_project_classes
Conflicts: src/main/java/se/su/dsv/scipro/admin/pages/AbstractAdminSettingsPage.java
This commit is contained in:
commit
5d5cf8b309
.gitignorepom.xml
src/main/java/se/su/dsv/scipro
ApplicationSettings.javaDataInitialiser.javaSciProApplication.javaSciProSession.java
admin
models
pages
panels
basepages
basepanels/mainmenu
components
data
controllers
dao
interfaces
jpa
dataobjects
dataproviders
icons
json/pages
opponent
pages
panels
peer
data/dao
controllers
jpa
interfaces
pages
AbstractProjectPeerPage.javaAbstractSupervisorPeerPage.javaPeerTestPage.javaProjectPeerReviewPage.javaSupervisorPeerReviewPage.java
panels
BestRatedReviewersPanel.javaDisplayQuestionPanel.htmlDisplayQuestionPanel.javaPeerPortalPanel.htmlPeerPortalPanel.javaPeerReviewPanel.javaPeerReviewPerformReviewPanel.htmlPeerReviewPerformReviewPanel.javaReviewPageReviewDetailsPanel.htmlReviewPageReviewDetailsPanel.javaStudentPeerInfoRequestsPanel.java
project
pages
FinalSeminarProjectListPage.javaProjectPartnerPage.htmlProjectPartnerPage.javaProjectSchedulePage.javaProjectSchedulePlannerPage.java
panels
repository
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
\.settings/
|
||||
\.project
|
||||
\.classpath
|
||||
\target/**/*
|
||||
\target/*
|
108
pom.xml
108
pom.xml
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>se.su.dsv</groupId>
|
||||
@ -18,10 +19,10 @@
|
||||
<url>http://wiquery.googlecode.com/svn/repo/</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- WICKET DEPENDENCIES -->
|
||||
<!-- WICKET DEPENDENCIES -->
|
||||
<dependency>
|
||||
<groupId>org.apache.wicket</groupId>
|
||||
<artifactId>wicket</artifactId>
|
||||
@ -32,7 +33,13 @@
|
||||
<artifactId>wicket-spring</artifactId>
|
||||
<version>${wicket.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Servlet API, needed for compilation. -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- LOGGING DEPENDENCIES - LOG4J -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@ -45,10 +52,8 @@
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
since we want the jcl over slf4j, we need to bump up the version of
|
||||
slf4j-api that wicket brings in
|
||||
-->
|
||||
<!-- since we want the jcl over slf4j, we need to bump up the version of
|
||||
slf4j-api that wicket brings in -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
@ -57,7 +62,7 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<version>1.2.16</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@ -67,14 +72,14 @@
|
||||
<version>1.8.0.10</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.13</version>
|
||||
<scope>runtime</scope>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.13</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Spring Deps -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
@ -161,7 +166,7 @@
|
||||
<version>${hibernate.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Jackrabbit dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
@ -184,8 +189,8 @@
|
||||
<version>2.1.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Additional dependencies -->
|
||||
|
||||
<!-- Additional dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.wicket</groupId>
|
||||
<artifactId>wicket-extensions</artifactId>
|
||||
@ -236,8 +241,14 @@
|
||||
<version>2010-09-21</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Library with wicket components -->
|
||||
<dependency>
|
||||
<groupId>org.wamblee</groupId>
|
||||
<artifactId>wamblee-wicket-components</artifactId>
|
||||
<version>0.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<build>
|
||||
@ -298,21 +309,60 @@
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<configuration>
|
||||
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<configuration>
|
||||
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Used for deploying directly from Maven/Eclipse -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.cargo</groupId>
|
||||
<artifactId>cargo-maven2-plugin</artifactId>
|
||||
|
||||
<configuration>
|
||||
<!-- Container configuration -->
|
||||
<container>
|
||||
<containerId>tomcat6x</containerId>
|
||||
<type>remote</type>
|
||||
</container>
|
||||
|
||||
<!-- Configuration to use with the Container -->
|
||||
<configuration>
|
||||
|
||||
<type>runtime</type>
|
||||
<properties>
|
||||
<cargo.tomcat.manager.url>https://thesis.dsv.su.se/manager</cargo.tomcat.manager.url>
|
||||
<cargo.remote.username>janne</cargo.remote.username>
|
||||
<cargo.remote.password>Lai2xoo6</cargo.remote.password>
|
||||
</properties>
|
||||
</configuration>
|
||||
|
||||
<!-- Deployer configuration -->
|
||||
<deployer>
|
||||
<type>remote</type>
|
||||
<deployables>
|
||||
<deployable>
|
||||
<groupId>se.su.dsv</groupId>
|
||||
<artifactId>SciPro</artifactId>
|
||||
<type>war</type>
|
||||
</deployable>
|
||||
</deployables>
|
||||
</deployer>
|
||||
|
||||
</configuration>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
||||
<finalName>scipro2</finalName>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<slf4j.version>1.5.11</slf4j.version>
|
||||
<wicket.version>1.4.15</wicket.version>
|
||||
<wiquery.version>1.2.3</wiquery.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<wicket.version>1.4.17</wicket.version>
|
||||
<wiquery.version>1.2.4</wiquery.version>
|
||||
<jetty.version>6.1.25</jetty.version>
|
||||
<hibernate.version>3.5.1-Final</hibernate.version>
|
||||
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
|
||||
|
@ -11,6 +11,7 @@ public class ApplicationSettings {
|
||||
|
||||
private boolean enableRemoteUserLookup;
|
||||
private String remoteLookupUrl;
|
||||
private boolean acceptExternalAuthentication;
|
||||
|
||||
public boolean isEnableRemoteUserLookup() {
|
||||
return enableRemoteUserLookup;
|
||||
@ -28,4 +29,12 @@ public class ApplicationSettings {
|
||||
return remoteLookupUrl;
|
||||
}
|
||||
|
||||
public boolean isAcceptExternalAuthentication(){
|
||||
return acceptExternalAuthentication;
|
||||
}
|
||||
|
||||
public void setAcceptExternalAuthentication(boolean pAcceptExternalAuthentication){
|
||||
acceptExternalAuthentication = pAcceptExternalAuthentication;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class DataInitialiser {
|
||||
|
||||
}
|
||||
|
||||
if(projectDao.countAll() == 0 ){
|
||||
if(projectDao.countAll() == 0 && false){
|
||||
Project project = new Project();
|
||||
project.addProjectParticipant(studentRole);
|
||||
project.setHeadSupervisor(employeeRole);
|
||||
@ -155,7 +155,7 @@ public class DataInitialiser {
|
||||
project.getProjectFollowers().add(pf);
|
||||
}
|
||||
|
||||
doStringDefinitions();
|
||||
//doStringDefinitions();
|
||||
}
|
||||
|
||||
private void doStringDefinitions(){
|
||||
|
@ -1,5 +1,9 @@
|
||||
package se.su.dsv.scipro;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.Page;
|
||||
@ -9,6 +13,7 @@ import org.apache.wicket.Response;
|
||||
import org.apache.wicket.Session;
|
||||
import org.apache.wicket.authorization.strategies.CompoundAuthorizationStrategy;
|
||||
import org.apache.wicket.protocol.http.WebApplication;
|
||||
import org.apache.wicket.protocol.http.WebRequest;
|
||||
import org.odlabs.wiquery.ui.themes.IThemableApplication;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
@ -23,6 +28,7 @@ import se.su.dsv.scipro.admin.pages.settings.AdminFinalSeminarSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminFinalSeminarSettingsPerProjectClassPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminGeneralSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminPeerSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminServerEnvironmentSettingsPage;
|
||||
import se.su.dsv.scipro.basepages.DemoPage;
|
||||
import se.su.dsv.scipro.basepages.errorpages.AccessDeniedPage;
|
||||
import se.su.dsv.scipro.basepages.errorpages.NotFoundPage;
|
||||
@ -44,19 +50,6 @@ import se.su.dsv.scipro.knol.resource.page.ResourcePage;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LoginPage;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LogoutPage;
|
||||
import se.su.dsv.scipro.message.pages.PrivateMessagesPage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerRequestSubmissionPage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplateCreationPage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplatePage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplatePreviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerTestPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerPortalPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewGuidePage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerStatsPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerPortalPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerReviewGuidePage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerStatsPage;
|
||||
import se.su.dsv.scipro.project.pages.FinalSeminarProjectListPage;
|
||||
import se.su.dsv.scipro.project.pages.NoActiveProjectPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectEventPage;
|
||||
@ -70,6 +63,7 @@ import se.su.dsv.scipro.repository.pages.RepositoryDownloadPage;
|
||||
import se.su.dsv.scipro.repository.pages.SysAdminFilePage;
|
||||
import se.su.dsv.scipro.schedule.templates.pages.ScheduleTemplateDetailsPage;
|
||||
import se.su.dsv.scipro.security.auth.ComponentSecurityLogger;
|
||||
import se.su.dsv.scipro.security.auth.ExternalAuthenticationRequestHelper;
|
||||
import se.su.dsv.scipro.security.auth.MetaDataActionStrategy;
|
||||
import se.su.dsv.scipro.security.auth.RoleBasedAuthorizationStrategy;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorAntiPlagiarismLinkPage;
|
||||
@ -109,6 +103,10 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
*/
|
||||
private String systemNotice = null;
|
||||
|
||||
/**
|
||||
* Logger instance.
|
||||
*/
|
||||
private Logger logger = Logger.getLogger(SciProApplication.class);
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -145,6 +143,18 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
* Pop-up pages
|
||||
*/
|
||||
mountBookmarkablePage("templates/details", ScheduleTemplateDetailsPage.class);
|
||||
|
||||
|
||||
// /*
|
||||
// * JSON pages
|
||||
// */
|
||||
// mountBookmarkablePage("json/project", JsonProjectForSupervisorPage.class);
|
||||
// mountBookmarkablePage("json/message", JsonMessagePage.class);
|
||||
// mountBookmarkablePage("json/message/unread", JsonMessagePageCountUnread.class);
|
||||
// mountBookmarkablePage("json/message/setread", JsonSetReadPage.class);
|
||||
// mountBookmarkablePage("json/login", JsonLoginPage.class);
|
||||
// mountBookmarkablePage("json/project", JsonProjectForSupervisorPage.class);
|
||||
// mountBookmarkablePage("json/message", JsonMessagePage.class);
|
||||
|
||||
|
||||
/*
|
||||
@ -181,6 +191,7 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
mountBookmarkablePage("admin/files", SysAdminFilePage.class);
|
||||
mountBookmarkablePage("admin/allfinalseminars", AdminFinalSeminarPage.class);
|
||||
mountBookmarkablePage("admin/settings", AdminGeneralSettingsPage.class);
|
||||
mountBookmarkablePage("admin/settings/serverenvironment", AdminServerEnvironmentSettingsPage.class);
|
||||
mountBookmarkablePage("admin/settings/finalseminargeneralsettings", AdminFinalSeminarSettingsPage.class);
|
||||
mountBookmarkablePage("admin/settings/finalseminarprojectlevel", AdminFinalSeminarSettingsPerProjectClassPage.class);
|
||||
mountBookmarkablePage("admin/settings/peer", AdminPeerSettingsPage.class);
|
||||
@ -217,8 +228,8 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
/*
|
||||
* Peer pages
|
||||
*/
|
||||
/* TODO Removed for deployment-test
|
||||
//admin
|
||||
mountBookmarkablePage("peer", PeerTestPage.class);
|
||||
mountBookmarkablePage("peer/review/template/preview", PeerReviewTemplatePreviewPage.class);
|
||||
mountBookmarkablePage("peer/templates/create", PeerReviewTemplateCreationPage.class);
|
||||
mountBookmarkablePage("peer/templates", PeerReviewTemplatePage.class);
|
||||
@ -263,8 +274,7 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setKerberosConfigs(){
|
||||
javax.servlet.ServletContext context = getServletContext();
|
||||
Logger logger = Logger.getRootLogger();
|
||||
java.util.Set<String> resources = context.getResourcePaths("/WEB-INF/classes/");
|
||||
Set<String> resources = context.getResourcePaths("/WEB-INF/classes/");
|
||||
if(!resources.contains(jaasPath) || !resources.contains(krb5Path)){
|
||||
logger.log(Level.FATAL, "Path to authentication config files not correct. " +
|
||||
"Users will not be able to log in!");
|
||||
@ -296,6 +306,49 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
public Session newSession(Request request, Response response) {
|
||||
return new SciProSession(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebRequest newWebRequest(final HttpServletRequest request){
|
||||
final WebRequest webRequest = super.newWebRequest(request);
|
||||
if(attemptExternalAuthentication(webRequest)){
|
||||
logger.debug("External authentication used successfully");
|
||||
}
|
||||
return webRequest;
|
||||
}
|
||||
/**
|
||||
* Private utility, just to keep stuff out of the calling method.
|
||||
* In short: scan incoming request for REMOTE_USER, check for a session, create one if none exists, attempt authentication and return status.
|
||||
* @param usingRequest
|
||||
* @return true if external auth was completed, false if not.
|
||||
*/
|
||||
private boolean attemptExternalAuthentication(final WebRequest usingRequest){
|
||||
SciProSession session = (SciProSession)getSessionStore().lookup(usingRequest);
|
||||
final ExternalAuthenticationRequestHelper helper = new ExternalAuthenticationRequestHelper(usingRequest.getHttpServletRequest());
|
||||
if(helper.isExternalAuthSupported()){//Attempt external auth
|
||||
if(session == null){//Can't do this without a usable session, attempt manual bind
|
||||
getSessionStore().bind(usingRequest,new SciProSession(usingRequest));
|
||||
session = (SciProSession)getSessionStore().lookup(usingRequest);
|
||||
}
|
||||
if(session != null){
|
||||
if(session.isLoggedIn()){
|
||||
if(!helper.isRemoteUserValid(session.getUser())){//This check may not be needed and may hinder performance, but better safe than sorry for now.
|
||||
logger.debug("User is logged in as '"+session.getUser().getEmailAddress()+"', but conflicting info ('"+helper.getExternalAuthRemoteUser()+"') is supplied via external authentication protocols.");
|
||||
}
|
||||
}else{
|
||||
//logger.info("Attempting sign in with external auth data");
|
||||
if(!helper.signIn(session)){
|
||||
logger.error("User '"+helper.getExternalAuthRemoteUser()+"' passes external authentication but cannot be signed in.");
|
||||
}else{
|
||||
logger.debug("Signed in user '"+helper.getExternalAuthRemoteUser()+"' via external authentication");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
throw new IllegalStateException("External authentication was attempted, but no session was available for sign in.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceReference getTheme(Session session) {
|
||||
|
@ -57,6 +57,9 @@ public class SciProSession extends WebSession {
|
||||
|
||||
private String loggedInIdentity = null;
|
||||
|
||||
//Logger instance
|
||||
private static Logger logger = Logger.getLogger(SciProSession.class);
|
||||
|
||||
/*
|
||||
* It's important not to hold the actual object, if we do, no changes to it
|
||||
* or it's attributes will be visible for the user unless they logout or re-select their active project.
|
||||
@ -105,16 +108,117 @@ public class SciProSession extends WebSession {
|
||||
return loggedInIdentity;
|
||||
}
|
||||
|
||||
|
||||
public synchronized boolean login(final String username, final String password) throws FailedLoginException, NullPointerException{
|
||||
final boolean loginSuccess = authenticate(username, password);
|
||||
if(loginSuccess){
|
||||
loggedIn = true;
|
||||
/**
|
||||
* Local login procedures, delegates authentication to authenticate() and sign in procedures to signInAuthenticatedUser() if authentication succeeds.
|
||||
* An administrator can log in as a different user in the system by using 'adminusername::otherusername' notation,
|
||||
* this is implemented as a regular login followed by a su-like switch (via switchAuthenticatedUser).
|
||||
* @param username is expected to be in the format "localdsvusername" or "localdsvusername::optionalotherusername".
|
||||
*/
|
||||
public boolean login(final String username, final String password) throws FailedLoginException, NullPointerException{
|
||||
String[] tmp = username.split("::");
|
||||
String authenticatedUserName = username;
|
||||
String switchToUserName = null;
|
||||
if(tmp.length > 0){
|
||||
authenticatedUserName = tmp[0];
|
||||
if(tmp.length > 1)
|
||||
switchToUserName = tmp[1];
|
||||
}
|
||||
return loginSuccess;
|
||||
//logger.info("Attempting authentication as "+authenticatedUserName);
|
||||
final boolean authenticationSuccess = authenticate(authenticatedUserName, password);
|
||||
if(!authenticationSuccess)
|
||||
return false;
|
||||
//logger.info("Successfully authenticated user "+authenticatedUserName);
|
||||
final boolean signInSuccess = signInAuthenticatedUser(authenticatedUserName,"DSV.SU.SE");
|
||||
if(switchToUserName != null){
|
||||
if(!switchAuthenticatedUser(switchToUserName,"DSV.SU.SE"))
|
||||
logger.error("Can't switch from '"+authenticatedUserName+"' to '"+switchToUserName+"'");
|
||||
}
|
||||
return signInSuccess;
|
||||
}
|
||||
/**
|
||||
* Sign in a user and bypass normal authentication routines completely.
|
||||
* This user has to already be present in database tables or login will fail.
|
||||
* @param username is expected to be one of the users registered username
|
||||
* @param realm is expected to be the matching realm from the supplied username
|
||||
* @return status of the sign-in request
|
||||
*/
|
||||
public boolean signInAuthenticatedUser(final String username, final String realm){
|
||||
//Query for the user
|
||||
user = userDao.getUserByUsername(username,realm);
|
||||
if(user == null){
|
||||
try{
|
||||
user = doUserLookup(username);
|
||||
if(user == null){
|
||||
throw new NullPointerException("No user with username "+username+" found in the database or in daisy.");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
//Set mail-address session attributes
|
||||
setLoggedInIdentity(username+"@"+realm);
|
||||
if(user.getEmailAddress() == null || user.getEmailAddress().trim().equals("")){
|
||||
user.setEmailAddress(getLoggedInIdentity());
|
||||
user = userDao.save(user);
|
||||
}
|
||||
//Assign roles
|
||||
if(roleDao.isStudent(user)){
|
||||
iRoles.add(new Student());
|
||||
}
|
||||
if(roleDao.isExternal(user)){
|
||||
iRoles.add(new External());
|
||||
}
|
||||
if(roleDao.isEmployee(user)){
|
||||
iRoles.add(new Employee());
|
||||
}
|
||||
if(roleDao.isAdmin(user)){
|
||||
iRoles.add(new Admin());
|
||||
}
|
||||
if(roleDao.isSysadmin(user)){
|
||||
iRoles.add(new SysAdmin());
|
||||
}
|
||||
if(iRoles.isEmpty()){
|
||||
iRoles.add(new DefaultRole());
|
||||
}
|
||||
//Set active project from users settings
|
||||
UserSettings userSettings = userSettingsDao.getUserSettings(user);
|
||||
if(userSettings != null){
|
||||
Project activeProject = userSettings.getActiveProject();
|
||||
if(activeProject != null)
|
||||
activeProjectId = activeProject.getId();
|
||||
}
|
||||
else {
|
||||
userSettings = new UserSettings(user);
|
||||
}
|
||||
// With this userSettings.created() will return a users first login date and userSettings.modified() will return last login
|
||||
userSettings.setLastModified(new Date());
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
|
||||
logger.info("User: "+getLoggedInIdentity()+ " logged in to "+this.getApplication().getClass().getSimpleName()+
|
||||
" as: "+user.getFirstName()+" "+user.getLastName()+" "+user.getUserNames()+ " at: "+new Date());
|
||||
loggedIn = true;
|
||||
return loggedIn;
|
||||
}
|
||||
/**
|
||||
* Switch currently logged in user (basically a poor mans 'su') to someone else, the currently logged in user has to be registered as an admin for this to succeed.
|
||||
* Also, the new user has to exist in local database tables or it will fail.
|
||||
* @param suUser
|
||||
* @param suRealm
|
||||
* @return true if the switch was successful, else false.
|
||||
*/
|
||||
public boolean switchAuthenticatedUser(final String suUser, final String suRealm){
|
||||
if(!isLoggedIn() || user == null)//Terminate early
|
||||
return false;
|
||||
logger.info("Currently logged in user: '"+user.getEmailAddress()+"' attempting switch to '"+suUser+"@"+suRealm+"'");
|
||||
if(suUser != null && roleDao.isSysadmin(user)){
|
||||
iRoles.clear();
|
||||
return signInAuthenticatedUser(suUser, suRealm);
|
||||
}else{
|
||||
logger.error("User does not have the privilege to switch user");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void logout()
|
||||
{
|
||||
loggedIn = false;
|
||||
@ -123,96 +227,18 @@ public class SciProSession extends WebSession {
|
||||
public synchronized final boolean isLoggedIn() {
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses normal Wicket/JAAS stuff to authenticate a user/password combination.
|
||||
* @param username
|
||||
* @param password
|
||||
* @return true if authentication succeeds, else false.
|
||||
* @throws NullPointerException
|
||||
* @throws FailedLoginException
|
||||
*/
|
||||
private synchronized boolean authenticate(String username, final String password) throws NullPointerException, FailedLoginException {
|
||||
Authenticator auth = new Authenticator();
|
||||
/*
|
||||
* An administrator can log in as a different user in the system by using 'adminusername::otherusername' for login
|
||||
*/
|
||||
String[] tmp = username.split("::");
|
||||
String loggedInAsUsername = null;
|
||||
if(tmp.length > 0){
|
||||
username = tmp[0];
|
||||
if(tmp.length > 1)
|
||||
loggedInAsUsername = tmp[1];
|
||||
}
|
||||
try {
|
||||
try{
|
||||
auth.authenticate(username, password);
|
||||
this.user = userDao.getUserByUsername(username);
|
||||
if( user == null){
|
||||
try{
|
||||
user = doUserLookup(username);
|
||||
if(user == null){
|
||||
throw new NullPointerException("No user with username "+username+" found in the database, or in daisy, despite successful authentication ");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLoggedInIdentity(username+"@"+"dsv.su.se");
|
||||
if(user.getEmailAddress() == null || user.getEmailAddress().trim().equals("")){
|
||||
user.setEmailAddress(getLoggedInIdentity());
|
||||
user = userDao.save(user);
|
||||
}
|
||||
/*
|
||||
* Here we switch the logged in user to be that of the person chosen be the logged-in-as by a sysadmin
|
||||
*/
|
||||
|
||||
if(loggedInAsUsername != null && roleDao.isSysadmin(user)){
|
||||
user = userDao.getUserByUsername(loggedInAsUsername);
|
||||
if( user == null){
|
||||
try{
|
||||
user = doUserLookup(loggedInAsUsername);
|
||||
if(user == null){
|
||||
throw new NullPointerException("No user with username "+loggedInAsUsername+" found in the database, or in daisy, despite successful authentication ");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(roleDao.isStudent(user)){
|
||||
iRoles.add(new Student());
|
||||
}
|
||||
if(roleDao.isExternal(user)){
|
||||
iRoles.add(new External());
|
||||
}
|
||||
if(roleDao.isEmployee(user)){
|
||||
iRoles.add(new Employee());
|
||||
}
|
||||
if(roleDao.isAdmin(user)){
|
||||
iRoles.add(new Admin());
|
||||
}
|
||||
if(roleDao.isSysadmin(user)){
|
||||
iRoles.add(new SysAdmin());
|
||||
}
|
||||
|
||||
if(iRoles.isEmpty()){
|
||||
iRoles.add(new DefaultRole());
|
||||
}
|
||||
/*
|
||||
* Set active project from users settings
|
||||
*/
|
||||
UserSettings userSettings = userSettingsDao.getUserSettings(user);
|
||||
if(userSettings != null){
|
||||
Project activeProject = userSettings.getActiveProject();
|
||||
if(activeProject != null)
|
||||
activeProjectId = activeProject.getId();
|
||||
}
|
||||
else {
|
||||
userSettings = new UserSettings(user);
|
||||
}
|
||||
/*
|
||||
* With this userSettings.created() will return a users first login date and userSettings.modified() will return last login
|
||||
*/
|
||||
userSettings.setLastModified(new Date());
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
|
||||
Logger logger = Logger.getLogger("Application");
|
||||
logger.log(Level.INFO, "User: "+getLoggedInIdentity()+ " logged in to "+this.getApplication().getClass().getSimpleName()+
|
||||
" as: "+user.getFirstName()+" "+user.getLastName()+" "+user.getUserNames()+ " at: "+new Date());
|
||||
return true;
|
||||
} catch (FailedLoginException e) {
|
||||
//e.printStackTrace();
|
||||
|
@ -23,11 +23,26 @@ public class SettingsModel implements IClusterable {
|
||||
private int maxOpponentForMaster;
|
||||
private int registerAsActive;
|
||||
private int registerAsOpponent;
|
||||
private boolean finalSeminarThesisMustBeAPDF;
|
||||
private ProjectClass projectClass;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the finalSeminarThesisMustBeAPDF
|
||||
*/
|
||||
public boolean isFinalSeminarThesisMustBeAPDF() {
|
||||
return finalSeminarThesisMustBeAPDF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param finalSeminarThesisMustBeAPDF the finalSeminarThesisMustBeAPDF to set
|
||||
*/
|
||||
public void setFinalSeminarThesisMustBeAPDF(boolean finalSeminarThesisMustBeAPDF) {
|
||||
this.finalSeminarThesisMustBeAPDF = finalSeminarThesisMustBeAPDF;
|
||||
}
|
||||
|
||||
public int getMaxOppositionsForMaster() {
|
||||
return maxOppositionsForMaster;
|
||||
}
|
||||
|
@ -11,8 +11,9 @@ import se.su.dsv.scipro.admin.pages.settings.AdminFinalSeminarSettingsPerProject
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminGeneralSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminPeerSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminProjectClassSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminServerEnvironmentSettingsPage;
|
||||
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@ -30,10 +31,12 @@ public abstract class AbstractAdminSettingsPage extends AbstractAdminPage {
|
||||
protected List<MenuItem> getItemList() {
|
||||
final List<MenuItem> items = new ArrayList<MenuItem>();
|
||||
items.add(new MenuItem("General settings", AdminGeneralSettingsPage.class));
|
||||
items.add(new MenuItem("Server Environment", AdminServerEnvironmentSettingsPage.class));
|
||||
items.add(new MenuItem("Final seminar general settings", AdminFinalSeminarSettingsPage.class));
|
||||
items.add(new MenuItem("Final seminar project level settings", AdminFinalSeminarSettingsPerProjectClassPage.class));
|
||||
items.add(new MenuItem("Level settings", AdminPeerSettingsPage.class, ImageIcon.ICON_SETTINGS));
|
||||
items.add(new MenuItem("Final seminar project level settings", AdminFinalSeminarSettingsPerProjectClassPage.class));
|
||||
items.add(new MenuItem("Level settings", AdminPeerSettingsPage.class));
|
||||
items.add(new MenuItem("Edit levels", AdminProjectClassSettingsPage.class));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>ProjectPartner admin</title>
|
||||
</head>
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div wicket:id="feedback"></div>
|
||||
<!-- Left column -->
|
||||
<div class="span-10 colborder">
|
||||
<div class="span-10 last">
|
||||
<p>Amount of days ProjectPartners stay</p>
|
||||
<div>
|
||||
<form wicket:id="daysForm">
|
||||
<input type="text" wicket:id="amountOfDaysField"></input><br/>
|
||||
<a wicket:id="submit">Save</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right column -->
|
||||
<div class="span-10 last">
|
||||
<div class="span-10 last">
|
||||
<div wicket:id="ppanel""></div>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:extend>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,62 @@
|
||||
package se.su.dsv.scipro.admin.pages;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.SubmitLink;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.project.panels.ProjectPartnerPanel;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
/**
|
||||
* @author Fredrik Norberg - fnorbe@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN})
|
||||
public class AdminProjectPartnerPage extends AbstractAdminPage {
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
private GeneralSystemSettings settings;
|
||||
|
||||
private int amountOfDays;
|
||||
|
||||
public static final String MAIN_MENU_LABEL = "Role management";
|
||||
|
||||
public AdminProjectPartnerPage(PageParameters pp) {
|
||||
super(pp);
|
||||
settings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
amountOfDays = settings.getProjectPartnerDaysToLive();
|
||||
|
||||
Form<Integer> daysForm = new Form<Integer>("daysForm");
|
||||
TextField<Integer> amountOfDaysField = new TextField<Integer>("amountOfDaysField", new PropertyModel<Integer>(this, "amountOfDays"));
|
||||
daysForm.add(amountOfDaysField);
|
||||
|
||||
daysForm.add(new SubmitLink("submit"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onSubmit() {
|
||||
settings.setProjectPartnerDaysToLive(amountOfDays);
|
||||
generalSystemSettingsDao.save(settings);
|
||||
info("OK");
|
||||
}
|
||||
});
|
||||
add(new FeedbackPanel("feedback"));
|
||||
add(daysForm);
|
||||
add(new ProjectPartnerPanel("ppanel"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
//generalsystemsettings för att spara datum
|
||||
|
||||
}
|
@ -3,17 +3,29 @@
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<h3 class="section">Final Seminar Settings</h3>
|
||||
<form wicket:id="maxActiveParticipationForm">
|
||||
<p><label>Set max active participants on a final seminar:</label> <input wicket:id="maxActiveParticipation"
|
||||
type="text" />
|
||||
<p><label>Set days before a final seminar a student can register as an active participant:</label> <input wicket:id="registerAsActive"
|
||||
type="text" />
|
||||
<p><label>Set days before a final seminar a student can register as an opponent:</label> <input wicket:id="registerAsOpponent"
|
||||
type="text" />
|
||||
<h5 class="peer-title">Final Seminar Settings</h5>
|
||||
<form wicket:id="finalSeminarSettingsForm">
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="1">Max active participants on a final seminar:</label></td>
|
||||
<td><input name="1" wicket:id="finalSeminarMaxActiveParticipants" type="text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="2">Minimum number of days before a final seminar a student can register as an active participant:</label></td>
|
||||
<td><input name="2" wicket:id="daysBeforeFinalSeminarCanRegisterAsActiveParticipant" type="text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="3">Minimum number of days before a final seminar a student can register as an opponent:</label></td>
|
||||
<td><input name="3" wicket:id="daysBeforeFinalSeminarCanRegisterAsOpponent" type="text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="4">File format of uploaded theses and opposition-reports must be PDF:</label></td>
|
||||
<td><input name="4" type="checkbox" wicket:id="finalSeminarThesisMustBeAPDF" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div> <input type="submit" value="Save"
|
||||
name="NoticeSubmit" /></div>
|
||||
<button type="submit" ><img src="css/blueprint/plugins/buttons/icons/tick.png" alt=""/> Save changes</button>
|
||||
|
||||
</form>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
|
@ -1,66 +1,50 @@
|
||||
package se.su.dsv.scipro.admin.pages.settings;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.form.CheckBox;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.RequiredTextField;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.admin.models.SettingsModel;
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminSettingsPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
|
||||
public class AdminFinalSeminarSettingsPage extends AbstractAdminSettingsPage {
|
||||
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
private GeneralSystemSettings settings;
|
||||
|
||||
|
||||
public AdminFinalSeminarSettingsPage(final PageParameters pp){
|
||||
public AdminFinalSeminarSettingsPage(final PageParameters pp) {
|
||||
super(pp);
|
||||
add(new MaxActiveParticipationForm("maxActiveParticipationForm"));
|
||||
|
||||
add(new FinalSeminarSettingsForm(
|
||||
"finalSeminarSettingsForm",
|
||||
new CompoundPropertyModel<GeneralSystemSettings>(generalSystemSettingsDao.getGeneralSystemSettingsInstance())));
|
||||
}
|
||||
|
||||
private class MaxActiveParticipationForm extends Form<SettingsModel> {
|
||||
|
||||
private class FinalSeminarSettingsForm extends Form<GeneralSystemSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MaxActiveParticipationForm(String id) {
|
||||
super(id, new CompoundPropertyModel<SettingsModel>(
|
||||
new SettingsModel()));
|
||||
settings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
TextField<Integer> activeParticipation = new TextField<Integer>(
|
||||
"maxActiveParticipation");
|
||||
TextField<Integer> registerAsActive = new TextField<Integer>(
|
||||
"registerAsActive");
|
||||
TextField<Integer> registerAsOpponent = new TextField<Integer>(
|
||||
"registerAsOpponent");
|
||||
SettingsModel settingsModel = ((SettingsModel) getDefaultModelObject());
|
||||
settingsModel.setMaxActiveParticipation(settings.getFinalSeminarMaxActiveParticipants());
|
||||
settingsModel.setRegisterAsActive(settings.getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant());
|
||||
settingsModel.setRegisterAsOpponent(settings.getDaysBeforeFinalSeminarCanRegisterAsOpponent());
|
||||
public FinalSeminarSettingsForm(String id, IModel<GeneralSystemSettings> model) {
|
||||
super(id, model );
|
||||
TextField<Integer> activeParticipation = new RequiredTextField<Integer>("finalSeminarMaxActiveParticipants");
|
||||
TextField<Integer> registerAsActive = new RequiredTextField<Integer>("daysBeforeFinalSeminarCanRegisterAsActiveParticipant");
|
||||
TextField<Integer> registerAsOpponent = new RequiredTextField<Integer>("daysBeforeFinalSeminarCanRegisterAsOpponent");
|
||||
CheckBox pdfCheckBox = new CheckBox("finalSeminarThesisMustBeAPDF");
|
||||
add(registerAsActive);
|
||||
add(registerAsOpponent);
|
||||
add(activeParticipation);
|
||||
|
||||
|
||||
|
||||
add(pdfCheckBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSubmit() {
|
||||
SettingsModel settingsModel = ((SettingsModel) getDefaultModelObject());
|
||||
settings.setFinalSeminarMaxActiveParticipants(settingsModel.getMaxActiveParticipation());
|
||||
settings.setDaysBeforeFinalSeminarCanRegisterAsActiveParticipant(settingsModel.getRegisterAsActive());
|
||||
settings.setDaysBeforeFinalSeminarCanRegisterAsOpponent(settingsModel.getRegisterAsOpponent());
|
||||
generalSystemSettingsDao.save(settings);
|
||||
setModelObject( generalSystemSettingsDao.save(getModelObject()) );
|
||||
info("Final seminar settings saved");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<div class="append-bottom">
|
||||
<h5 class="peer-title">Settings for levels</h5>
|
||||
<form wicket:id="peerSettingsForm">
|
||||
<form wicket:id="settingsForm">
|
||||
<ul class="no-list-style">
|
||||
<li wicket:id="projectClassList" class="append-bottom">
|
||||
<h5 wicket:id="projectClassName" class="peer-box-subtitle"></h5>
|
||||
|
@ -23,7 +23,7 @@ public class AdminFinalSeminarSettingsPerProjectClassPage extends AbstractAdminS
|
||||
public AdminFinalSeminarSettingsPerProjectClassPage(final PageParameters pp){
|
||||
super(pp);
|
||||
|
||||
final Form<Void> peerSettingsForm = new Form<Void>("peerSettingsForm"){
|
||||
final Form<Void> settingsForm = new Form<Void>("settingsForm"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -32,26 +32,26 @@ public class AdminFinalSeminarSettingsPerProjectClassPage extends AbstractAdminS
|
||||
}
|
||||
};
|
||||
|
||||
peerSettingsForm.add(new ListView<ProjectClass>("projectClassList", projectClassDao.findAll()){
|
||||
settingsForm.add(new ListView<ProjectClass>("projectClassList", projectClassDao.findAll()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<ProjectClass> item) {
|
||||
item.add(new Label("projectClassName", item.getModelObject().getName()));
|
||||
item.add(new PeerProjectClassSettingsForm("projectClassSettingsForm", item.getModelObject()));
|
||||
item.add(new SettingsPerProjectClassForm("projectClassSettingsForm", item.getModelObject()));
|
||||
add(item);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
peerSettingsForm.add(new Button("submit"));
|
||||
add(peerSettingsForm);
|
||||
settingsForm.add(new Button("submit"));
|
||||
add(settingsForm);
|
||||
}
|
||||
|
||||
private class PeerProjectClassSettingsForm extends Form<ProjectClassSettings> {
|
||||
private class SettingsPerProjectClassForm extends Form<ProjectClassSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public PeerProjectClassSettingsForm(final String id, final ProjectClass projectClass){
|
||||
public SettingsPerProjectClassForm(final String id, final ProjectClass projectClass){
|
||||
super(id, new CompoundPropertyModel<ProjectClassSettings>(projectClass.getProjectClassSettings()));
|
||||
|
||||
TextField<Integer> numDaysBetweenPeerReviewsOnSameProject =
|
||||
|
@ -5,8 +5,21 @@
|
||||
<wicket:extend>
|
||||
|
||||
<div class="append-bottom">
|
||||
<h5 class="peer-title">Settings for levels</h5>
|
||||
<h5 class="peer-title">General settings</h5>
|
||||
<form wicket:id="peerSettingsForm">
|
||||
<form wicket:id="peerRatingsSettingsForm">
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="peerRatingsEnabled">Enable peers to rate reviews and the display of ratings: </label></td>
|
||||
<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><input type="checkbox" wicket:id="peerDisplayNumberOfReviewsPerformed" name="peerDisplayNumberOfReviewsPerformed"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<h5 class="peer-title">Settings for levels</h5>
|
||||
<ul class="no-list-style">
|
||||
<li wicket:id="projectClassList" class="append-bottom">
|
||||
<h5 wicket:id="projectClassName" class="peer-box-subtitle"></h5>
|
||||
|
@ -3,15 +3,19 @@ package se.su.dsv.scipro.admin.pages.settings;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.CheckBox;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminSettingsPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
|
||||
@ -19,6 +23,8 @@ public class AdminPeerSettingsPage extends AbstractAdminSettingsPage {
|
||||
|
||||
@SpringBean
|
||||
private ProjectClassDao projectClassDao;
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
public AdminPeerSettingsPage(final PageParameters pp){
|
||||
super(pp);
|
||||
@ -43,11 +49,30 @@ public class AdminPeerSettingsPage extends AbstractAdminSettingsPage {
|
||||
}
|
||||
|
||||
});
|
||||
CompoundPropertyModel<GeneralSystemSettings> ratingsModel = new CompoundPropertyModel<GeneralSystemSettings>(generalSystemSettingsDao.getGeneralSystemSettingsInstance());
|
||||
PeerRatingsSettingsForm peerRatingsSettingsForm = new PeerRatingsSettingsForm("peerRatingsSettingsForm", ratingsModel);
|
||||
peerSettingsForm.add(peerRatingsSettingsForm);
|
||||
|
||||
peerSettingsForm.add(new Button("submit"));
|
||||
add(peerSettingsForm);
|
||||
}
|
||||
|
||||
private class PeerRatingsSettingsForm extends Form<GeneralSystemSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public PeerRatingsSettingsForm(String id, IModel<GeneralSystemSettings> model) {
|
||||
super(id, model);
|
||||
|
||||
CheckBox peerRatingsEnabled = new CheckBox("peerRatingsEnabled");
|
||||
add(peerRatingsEnabled);
|
||||
CheckBox peerDisplayNumberOfReviewsPerformed = new CheckBox("peerDisplayNumberOfReviewsPerformed");
|
||||
add(peerDisplayNumberOfReviewsPerformed);
|
||||
}
|
||||
@Override
|
||||
public void onSubmit(){
|
||||
setModelObject(generalSystemSettingsDao.save(getModelObject()));
|
||||
}
|
||||
}
|
||||
|
||||
private class PeerProjectClassSettingsForm extends Form<ProjectClassSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
17
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.html
Normal file
17
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<h3 class="section">Server/Request environment</h3>
|
||||
<div style="overflow:auto;height:390px;">
|
||||
<ul>
|
||||
<li wicket:id="requestAttributes">
|
||||
<span wicket:id="name">[name]</span>:
|
||||
<span wicket:id="value">[value]</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
</html>
|
49
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.java
Normal file
49
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.java
Normal file
@ -0,0 +1,49 @@
|
||||
package se.su.dsv.scipro.admin.pages.settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminSettingsPage;
|
||||
import se.su.dsv.scipro.util.KeyValuePair;
|
||||
|
||||
public class AdminServerEnvironmentSettingsPage extends AbstractAdminSettingsPage {
|
||||
public AdminServerEnvironmentSettingsPage(final PageParameters pp) {
|
||||
super(pp);
|
||||
add(new ListView<KeyValuePair<String>>("requestAttributes",getRequestAttributes()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
protected void populateItem(ListItem<KeyValuePair<String>> item){
|
||||
KeyValuePair<String> pair = item.getModelObject();
|
||||
item.add(new Label("name",pair.getKey()));
|
||||
item.add(new Label("value","'"+pair.getValue()+"'"));
|
||||
}
|
||||
});
|
||||
}
|
||||
private List<KeyValuePair<String>> getRequestAttributes(){
|
||||
final HttpServletRequest rawRequest = getWebRequestCycle().getWebRequest().getHttpServletRequest();
|
||||
List<KeyValuePair<String>> list = new ArrayList<KeyValuePair<String>>();
|
||||
list.add(new KeyValuePair<String>("[CALL] getRemoteUser",rawRequest.getRemoteUser()));
|
||||
list.add(new KeyValuePair<String>("[CALL] getAuthType",rawRequest.getAuthType()));
|
||||
@SuppressWarnings("rawtypes") Enumeration attributes = rawRequest.getAttributeNames();
|
||||
while(attributes.hasMoreElements()){
|
||||
final String key = (String)attributes.nextElement();
|
||||
final String value = rawRequest.getAttribute(key).toString();
|
||||
list.add(new KeyValuePair<String>("[ATTR] "+key,value));
|
||||
}
|
||||
Map<String,String> envs = System.getenv();
|
||||
for(String key : envs.keySet()){
|
||||
list.add(new KeyValuePair<String>("[ENV] "+key,envs.get(key)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import org.apache.wicket.Page;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminPage;
|
||||
import se.su.dsv.scipro.admin.pages.AdminFinalSeminarPage;
|
||||
import se.su.dsv.scipro.admin.pages.AdminProjectPartnerPage;
|
||||
import se.su.dsv.scipro.admin.pages.AdminRolePage;
|
||||
import se.su.dsv.scipro.admin.pages.AdminScheduleTemplatesPage;
|
||||
import se.su.dsv.scipro.admin.pages.AdminStartPage;
|
||||
@ -14,6 +15,7 @@ import se.su.dsv.scipro.admin.pages.ProjectManagementPage;
|
||||
import se.su.dsv.scipro.admin.pages.SystemMaintenancePage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminGeneralSettingsPage;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplatePage;
|
||||
|
||||
public class AdminTabMenuPanel extends AbstractMenuPanel {
|
||||
@ -34,15 +36,16 @@ public class AdminTabMenuPanel extends AbstractMenuPanel {
|
||||
items.add(new MenuItem("System maintenance", SystemMaintenancePage.class));
|
||||
items.add(new MenuItem("All final seminars", AdminFinalSeminarPage.class));
|
||||
items.add(new MenuItem("Peer review templates", PeerReviewTemplatePage.class));
|
||||
items.add(new MenuItem("Settings", AdminGeneralSettingsPage.class));
|
||||
items.add(new MenuItem("Settings", AdminGeneralSettingsPage.class, ImageIcon.ICON_SETTINGS));
|
||||
items.add(new MenuItem("Role management", AdminRolePage.class));
|
||||
items.add(new MenuItem("Project partner", AdminProjectPartnerPage.class));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MenuType getMenuType() {
|
||||
return MenuType.TAB;
|
||||
return MenuType.TAB_MULTIPLE_ROWS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
|
||||
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
|
||||
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
|
||||
<!--[if IE 9]> <html class="ie ie9 lte9"> <![endif]-->
|
||||
<!--[if gt IE 9]> <html> <![endif]-->
|
||||
<!--[if !IE]><!-->
|
||||
<html lang="en"
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title wicket:id="pageTitle">SciPro DSV</title>
|
||||
@ -16,18 +24,37 @@
|
||||
<!-- <link href='http://fonts.googleapis.com/css?family=Vollkorn' rel='stylesheet' type='text/css' />
|
||||
<link href='http://fonts.googleapis.com/css?family=Ubuntu:regular,bold' rel='stylesheet' type='text/css' /> -->
|
||||
<!--<link rel="stylesheet" href="css/scipro.css" media="screen,projection" />-->
|
||||
<!--[if lt IE 9]>
|
||||
<link rel="stylesheet" href="css/scipro-ie.css" media="screen,projection" />
|
||||
<![endif]-->
|
||||
|
||||
<!-- <link type="text/css" href="css/smoothness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script> -->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-24546333-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="ajax-loader" style="display: none;"><img src="images/ajax-loader.gif" class="ajax-loader-image" alt="" /></div>
|
||||
<div id="ajax-loader" style="display: none;"><img
|
||||
src="images/ajax-loader.gif" class="ajax-loader-image" alt="" /></div>
|
||||
<div wicket:id="systemNotice" id="system-notice"></div>
|
||||
<div class="container">
|
||||
<wicket:child />
|
||||
</div>
|
||||
<div class="container"><wicket:child /></div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
<!--[if gt IE 9]> </html> <![endif]-->
|
||||
<!--[if IE 9]> </html> <![endif]-->
|
||||
<!--[if IE 8]> </html> <![endif]-->
|
||||
<!--[if IE 7]> </html> <![endif]-->
|
||||
<!--[if lt IE 7]> </html> <![endif]-->
|
||||
|
||||
|
||||
|
||||
|
@ -103,6 +103,35 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="span-18 last">
|
||||
<h3 wicket:id="tooltipDemo">MouseOver here for tooltip</h3>
|
||||
<h3>Highlighted form components</h3>
|
||||
<div wicket:id="radioChoices"></div>
|
||||
|
||||
<div>
|
||||
<span class="hilight">
|
||||
<!-- Just stick a normal wicket:id onto the input to use it with wicket.
|
||||
To get the highlight effect it must be contained in this span and the order of input+label is important -->
|
||||
<input id="d1" type="checkbox" class="question-display"></input>
|
||||
<label for="d1">Checkbox</label>
|
||||
</span>
|
||||
<span class="hilight">
|
||||
<input id="d2" type="checkbox" checked class="question-display"></input>
|
||||
<label for="d2">Checked Checkbox</label>
|
||||
</span>
|
||||
|
||||
<span class="hilight">
|
||||
<input id="d3" type="checkbox" checked disabled class="question-display"></input>
|
||||
<label for="d3">Checked Checkbox disabled</label>
|
||||
</span>
|
||||
|
||||
<span class="hilight">
|
||||
<input id="d4" type="checkbox" disabled class="question-display"></input>
|
||||
<label for="d4">Checkbox disabled</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span-5 last">
|
||||
<h3>Icons</h3>
|
||||
<table>
|
||||
|
@ -1,13 +1,22 @@
|
||||
package se.su.dsv.scipro.basepages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
import se.su.dsv.scipro.components.ExpandableMultiLineLabel;
|
||||
import se.su.dsv.scipro.components.SciProTooltipBehavior;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.icons.AjaxActionIcon;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
|
||||
public class DemoPage extends PublicPage {
|
||||
|
||||
@ -22,6 +31,25 @@ public class DemoPage extends PublicPage {
|
||||
public DemoPage(final PageParameters pp){
|
||||
super(pp);
|
||||
|
||||
/* Highlighted form components */
|
||||
QuestionOption yes = new QuestionOption(null, "Yes");
|
||||
QuestionOption no = new QuestionOption(null, "No");
|
||||
QuestionOption maybe = new QuestionOption(null,"Maybe");
|
||||
List<QuestionOption> options = new ArrayList<QuestionOption>();
|
||||
options.add(yes);options.add(no);options.add(maybe);
|
||||
|
||||
Model<QuestionOption> radioSelectionModel = new Model<QuestionOption>(maybe);
|
||||
|
||||
RadioChoice<QuestionOption> radioChoice = new RadioChoice<QuestionOption>("radioChoices",radioSelectionModel,options);
|
||||
radioChoice.setRenderBodyOnly(true);
|
||||
//Messy stuff needed because Wicket normally just sticks a <br> between each input tag.
|
||||
radioChoice.setPrefix("<span class=\"hilight\">");
|
||||
radioChoice.setSuffix("</span></br>");
|
||||
add(radioChoice);
|
||||
|
||||
Component tooltipAnchor = new WebMarkupContainer("tooltipDemo").add(new SciProTooltipBehavior("Look at the pretty tooltip!"));
|
||||
add(tooltipAnchor);
|
||||
|
||||
add(new ImageIcon("yesIcon", ImageIcon.ICON_YES));
|
||||
add(new ImageIcon("noIcon", ImageIcon.ICON_NO));
|
||||
add(new ImageIcon("checkIcon", ImageIcon.ICON_CHECK));
|
||||
|
@ -52,7 +52,9 @@ public abstract class AbstractMainMenuItem extends Panel {
|
||||
BookmarkablePageLink<Void> result = new BookmarkablePageLink<Void>(id, targetPageClass, pp);
|
||||
result.setOutputMarkupId(true);
|
||||
if(targetPageClass == containerPageClass || (targetPageClass.getSuperclass().isAssignableFrom(containerPageClass) && targetPageClass.getSuperclass() != MenuPage.class) ){
|
||||
result.setMarkupId("current");
|
||||
//TODO Should prefereably be replaced with the line below because repeating id's aren't valid html. I couldn't get the CSS to work though //mpeters
|
||||
result.setMarkupId("current");
|
||||
//result.add(new AttributeAppender("class", new Model<String>("current"), " "));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -6,14 +6,15 @@ import java.util.List;
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.Page;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.behavior.AttributeAppender;
|
||||
import org.apache.wicket.behavior.SimpleAttributeModifier;
|
||||
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.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
|
||||
@ -26,6 +27,7 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
{
|
||||
put(MenuType.NONE, "abstract-menu");
|
||||
put(MenuType.TAB, "abstract-menu tab-menu");
|
||||
put(MenuType.TAB_MULTIPLE_ROWS, "abstract-menu multi-tab-menu");
|
||||
put(MenuType.HORIZONTAL, "abstract-menu horizontal-menu");
|
||||
put(MenuType.VERTICAL, "abstract-menu vertical-menu");
|
||||
}
|
||||
@ -34,12 +36,13 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
public enum MenuType {
|
||||
NONE,
|
||||
TAB,
|
||||
TAB_MULTIPLE_ROWS,
|
||||
HORIZONTAL,
|
||||
VERTICAL
|
||||
}
|
||||
|
||||
|
||||
public AbstractMenuPanel(final String id, final Class<? extends Page> tabCommonSuperClass,final Class<? extends Page> containerClass) {
|
||||
public AbstractMenuPanel(final String id, final Class<? extends Page> menuContainerCommonSuperClass,final Class<? extends Page> containerClass) {
|
||||
super(id);
|
||||
|
||||
final WebMarkupContainer menuContainer = new WebMarkupContainer("menuContainer");
|
||||
@ -52,11 +55,28 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
@Override
|
||||
protected void populateItem( ListItem<MenuItem> item ) {
|
||||
final MenuItem mi = item.getModelObject();
|
||||
if( (mi.getTargetClass().getSuperclass().isAssignableFrom(containerClass)
|
||||
&& mi.getTargetClass().getSuperclass() != tabCommonSuperClass)
|
||||
|| mi.getTargetClass() == containerClass){
|
||||
item.setMarkupId("current");
|
||||
item.setOutputMarkupId(true);
|
||||
boolean highLightAsCurrentByInterface = false;
|
||||
Class<?> menuItemInterface = mi.getMenuHilightInterface();
|
||||
if( menuItemInterface != null ){
|
||||
for( Class<?> actualPageInterface : containerClass.getInterfaces() ){
|
||||
if( actualPageInterface.equals(menuItemInterface) ){
|
||||
highLightAsCurrentByInterface = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( highLightAsCurrentByInterface || mi.getTargetClass() == containerClass
|
||||
||
|
||||
(
|
||||
mi.getTargetClass().getSuperclass().isAssignableFrom(containerClass)
|
||||
&&
|
||||
mi.getTargetClass().getSuperclass() != menuContainerCommonSuperClass
|
||||
)
|
||||
){
|
||||
//item.setMarkupId("current");
|
||||
//item.setOutputMarkupId(true);
|
||||
//Replaced the above because it generates invalid markup if two menus are added to the same page (id no longer unique)
|
||||
item.add(new AttributeAppender("class", new Model<String>("current"), " "));
|
||||
}
|
||||
|
||||
BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>("menuItem", mi.getTargetClass(), mi.getPageParameters());
|
||||
@ -98,22 +118,37 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
private Class<? extends Page> targetClass;
|
||||
private PageParameters pp;
|
||||
private String iconName;
|
||||
private Class<? extends MenuHighlight> menuHilightInterface;
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass) {
|
||||
this(name, targetClass, null, null);
|
||||
this(name, targetClass, null, null, null);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface) {
|
||||
this(name, targetClass, menuHilightInterface, null, null);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, PageParameters pp){
|
||||
this(name, targetClass, pp, null);
|
||||
this(name, targetClass, null, pp, null);
|
||||
}
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface, PageParameters pp){
|
||||
this(name, targetClass, menuHilightInterface, pp, null);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, String iconName) {
|
||||
this(name, targetClass, null, iconName);
|
||||
this(name, targetClass, null, null, iconName);
|
||||
}
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface, String iconName) {
|
||||
this(name, targetClass, menuHilightInterface, null, iconName);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, PageParameters pp, String iconName) {
|
||||
this(name, targetClass, null, pp, iconName);
|
||||
}
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface, PageParameters pp, String iconName) {
|
||||
this.name = name;
|
||||
this.targetClass = targetClass;
|
||||
this.menuHilightInterface = menuHilightInterface;
|
||||
this.pp = pp;
|
||||
this.iconName = iconName == null ? ImageIcon.ICON_EMPTY : iconName;
|
||||
}
|
||||
@ -133,6 +168,16 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
public String getIconName() {
|
||||
return iconName;
|
||||
}
|
||||
|
||||
public MenuItem setMenuHilightInterface(Class<? extends MenuHighlight> menuHilightInterface) {
|
||||
this.menuHilightInterface = menuHilightInterface;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Class<? extends MenuHighlight> getMenuHilightInterface() {
|
||||
return menuHilightInterface;
|
||||
}
|
||||
|
||||
|
||||
}//MenuItem
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
/**
|
||||
* An invisible Panel that can trigger the hiding of wicket-enclosures which EmptyPanel doesn't do.
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public final class InvisiblePanel extends WebMarkupContainer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvisiblePanel(String id) {
|
||||
super(id);
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
12
src/main/java/se/su/dsv/scipro/components/MenuHighlight.java
Normal file
12
src/main/java/se/su/dsv/scipro/components/MenuHighlight.java
Normal file
@ -0,0 +1,12 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
/**
|
||||
* Base interface only signaling intent, that is if a menu item needs to be highlighted.
|
||||
* Should preferably not be used directly, subclass it instead so intent is clear.
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface MenuHighlight {
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.wamblee.wicket.behavior.ServerTooltipBehavior;
|
||||
/**
|
||||
* Attempt at making a generally usable tooltip for all SciPro pages.
|
||||
* I've looked at Mootip, Prototip and both disrupt other Javascript, BeautytipBehavor (visural wicket)
|
||||
* isn't bad but has NO delay and therefore pops up immediately.
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class SciProTooltipBehavior extends ServerTooltipBehavior {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public SciProTooltipBehavior(String aText) {
|
||||
super(aText);
|
||||
this.background("#FFFF66");
|
||||
this.border("outset grey 1px");
|
||||
this.padding("5px 20px 5px 20px");
|
||||
}
|
||||
public SciProTooltipBehavior(IModel<String> model){
|
||||
this(model.getObject());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -98,9 +98,9 @@ public class StarRater<T extends Number> extends FormComponentPanel<T> implement
|
||||
|
||||
final SimpleAttributeModifier cssMod = new SimpleAttributeModifier("class", cssClass);
|
||||
|
||||
//Assign the internal value
|
||||
internalValue = model.getObject().doubleValue() * splitFactor;
|
||||
|
||||
//Assign the internal value, rounds "normally", so 2.5 > 3.0 and 2,4 > 2.0
|
||||
internalValue = Math.ceil(model.getObject().doubleValue() * splitFactor);
|
||||
|
||||
/*
|
||||
* Create the radio group and fill it with radios
|
||||
*/
|
||||
@ -136,7 +136,7 @@ public class StarRater<T extends Number> extends FormComponentPanel<T> implement
|
||||
}
|
||||
|
||||
/**
|
||||
* Controll the state of the component, default is false
|
||||
* Control the state of the component, default is false
|
||||
*
|
||||
* @param value true to put the component in read only state
|
||||
* @return this for chaining
|
||||
|
@ -1,80 +1,17 @@
|
||||
package se.su.dsv.scipro.data.controllers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
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.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
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.repository.FileRepository;
|
||||
import se.su.dsv.scipro.repository.util.FileStorageException;
|
||||
|
||||
@Controller("seminarUploadController")
|
||||
public class FinalSeminarUploadController {
|
||||
public interface FinalSeminarUploadController extends IClusterable {
|
||||
|
||||
public static final String FINAL_SEMINAR_DIRECTORY = "finalseminars/";
|
||||
public static final String FINAL_SEMINAR_OPPOSITION_DIRECTORY = "oppositions/";
|
||||
void deleteSeminarFilesRecursive(FinalSeminar seminar);
|
||||
|
||||
@Autowired
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@Autowired
|
||||
private FileDescriptionDao fileDescriptionDao;
|
||||
|
||||
@Autowired
|
||||
private FinalSeminarDao finalSeminarDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@Autowired
|
||||
private FinalSeminarOppositionDao finalSeminarOppositionDao;
|
||||
|
||||
private FileDescription store(FileUpload upload, String storeToPath)
|
||||
throws IOException {
|
||||
fileRepository.storeFile(upload, storeToPath);
|
||||
List<FileDescription> fds = fileRepository.searchFiles(storeToPath);
|
||||
if (fds.size() == 0) {
|
||||
throw new IOException(
|
||||
"Error while storing filedescription in seminarcontroller");
|
||||
}
|
||||
|
||||
return fds.get(0);
|
||||
}
|
||||
|
||||
private void delete(String path) {
|
||||
fileRepository.delete(path);
|
||||
}
|
||||
|
||||
public void deleteSeminarFilesRecursive(final FinalSeminar seminar)
|
||||
throws FileStorageException {
|
||||
if (seminar.getDocument() != null) {
|
||||
delete(getRepositorySeminarPath(seminar));
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteOpponentFiles(final FinalSeminarOpposition opp)
|
||||
throws FileStorageException {
|
||||
if (opp.getOpponentReport() != null) {
|
||||
delete(getRepositoryOppositionPath(opp));
|
||||
}
|
||||
}
|
||||
void deleteOpponentFiles(FinalSeminarOpposition opp);
|
||||
|
||||
/**
|
||||
* Delete the uploaded report for the seminar
|
||||
@ -82,104 +19,10 @@ public class FinalSeminarUploadController {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public FinalSeminar deleteSeminarReport(FinalSeminar seminar)
|
||||
throws Exception {
|
||||
seminar = finalSeminarDao.reLoad(seminar);
|
||||
if(!seminar.getOppositions().isEmpty() || !seminar.getActiveParticipations().isEmpty()){
|
||||
throw new Exception("Cannot delete seminar report, seminar has opponents or active participants");
|
||||
}
|
||||
fileRepository.delete(seminar.getDocument().getPath());
|
||||
seminar.setDocument(null);
|
||||
return finalSeminarDao.save(seminar);
|
||||
}
|
||||
FinalSeminar deleteSeminarReport(FinalSeminar seminar) throws Exception;
|
||||
|
||||
public void storeSeminarDocument(FileUpload upload, User uploader,
|
||||
FinalSeminar seminar) throws Exception {
|
||||
Project p = projectDao.reLoad(seminar.getProject());
|
||||
boolean isParticipant = false;
|
||||
for (Student s : p.getProjectParticipants()) {
|
||||
if (s.getUser().equals(uploader)) {
|
||||
isParticipant = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
void storeSeminarDocument(FileUpload upload, User uploader, FinalSeminar seminar) throws Exception;
|
||||
|
||||
if (!isParticipant) {
|
||||
throw new IllegalStateException(
|
||||
"Users not a participant of the seminar project cannot upload the seminar document");
|
||||
}
|
||||
|
||||
String path = getRepositorySeminarPath(seminar);
|
||||
FileDescription fd = null;
|
||||
try {
|
||||
fd = store(upload, path);
|
||||
|
||||
fd = fileDescriptionDao.save(fd);
|
||||
|
||||
seminar.setDocument(fd);
|
||||
seminar.setDocumentUploadDate(new Date());
|
||||
seminar.setDocumentUploader(uploader);
|
||||
seminar = finalSeminarDao.save(seminar);
|
||||
|
||||
} catch (IOException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing seminardocument: " + e.getMessage());
|
||||
throw new Exception(e);
|
||||
} catch (PersistenceException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing seminardocument : " + e.getMessage());
|
||||
|
||||
if (fd != null) {
|
||||
fileDescriptionDao.delete(fd);
|
||||
}
|
||||
delete(path);
|
||||
throw new Exception(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void storeOpposition(FileUpload upload, User uploader,
|
||||
FinalSeminarOpposition opposition) throws Exception {
|
||||
if (!uploader.equals(opposition.getOpponent().getUser())) {
|
||||
throw new IllegalStateException(
|
||||
"Non other than the opponent can upload an opposition");
|
||||
}
|
||||
FileDescription fd = null;
|
||||
String path = getRepositoryOppositionPath(opposition);
|
||||
|
||||
try {
|
||||
fd = store(upload, path);
|
||||
fd = fileDescriptionDao.save(fd);
|
||||
|
||||
opposition.setOpponentReport(fd);
|
||||
opposition.setDateReported(new Date());
|
||||
opposition = finalSeminarOppositionDao.save(opposition);
|
||||
} catch (IOException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing opposition report: " + e.getMessage());
|
||||
throw new Exception(e);
|
||||
} catch (PersistenceException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing opposition: " + e.getMessage());
|
||||
|
||||
if (fd != null) {
|
||||
fileDescriptionDao.delete(fd);
|
||||
}
|
||||
|
||||
delete(path);
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getRepositorySeminarPath(FinalSeminar seminar) {
|
||||
return fileRepository.getRepositoryRootPath() + FINAL_SEMINAR_DIRECTORY
|
||||
+ String.valueOf(seminar.getId()) + "/";
|
||||
}
|
||||
|
||||
private String getRepositoryOppositionPath(FinalSeminarOpposition o) {
|
||||
return getRepositorySeminarPath(o.getFinalSeminar())
|
||||
+ FINAL_SEMINAR_OPPOSITION_DIRECTORY
|
||||
+ String.valueOf(o.getId()) + "/";
|
||||
}
|
||||
void storeOpposition(FileUpload upload, User uploader, FinalSeminarOpposition opposition) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -1,59 +1,16 @@
|
||||
package se.su.dsv.scipro.data.controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInActivityDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInFeedbackDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Event;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandIn;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandInActivity;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandInFeedback;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
|
||||
@Controller("handInController")
|
||||
public class HandInController implements IClusterable {
|
||||
public interface HandInController extends IClusterable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
private HandInActivityDao handInActivityDao;
|
||||
|
||||
@Autowired
|
||||
private FileDescriptionDao fileDescriptionDao;
|
||||
|
||||
@Autowired
|
||||
private HandInDao handInDao;
|
||||
|
||||
@Autowired
|
||||
private HandInFeedbackDao handInFeedbackDao;
|
||||
|
||||
@Autowired
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@Autowired
|
||||
private EventDao eventDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
public HandInController(){}
|
||||
|
||||
/**
|
||||
* Store a HandIn with the uploaded files provided as an argument. Also creates a Feedback and assignes it
|
||||
* to the head supervisor for the project.
|
||||
@ -61,95 +18,13 @@ public class HandInController implements IClusterable {
|
||||
* @param uploads the uploads to store with the handin
|
||||
* @return
|
||||
*/
|
||||
public boolean store(Project project, Event event, Collection<FileUpload> uploads){
|
||||
|
||||
project = projectDao.reLoad(project);
|
||||
event = eventDao.reLoad(event);
|
||||
|
||||
if(event == null || project == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
HandInActivity handInActivity = handInActivityDao.getHandInActivity(event, project);
|
||||
|
||||
if(handInActivity == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
String projectRoot = fileRepository.getProjectRootPath(project.getId());
|
||||
|
||||
if(projectRoot == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
HandIn hi = new HandIn();
|
||||
HandInFeedback hif = new HandInFeedback();
|
||||
//Wrap this i a "manual-transaction"
|
||||
try {
|
||||
handInActivity = handInActivityDao.reLoad(handInActivity);
|
||||
hi.setFolderName("" + handInActivity.getHandIns().size() + 1);
|
||||
hi.setHandedInBy(SciProSession.get().getUser());
|
||||
hi.setHandInActivity(handInActivity);
|
||||
|
||||
for(FileUpload f : uploads){
|
||||
fileRepository.storeFile(f, getHandInAbsolutePath(projectRoot, handInActivity, hi));
|
||||
}
|
||||
|
||||
List<FileDescription> files = new ArrayList<FileDescription>();
|
||||
|
||||
for(FileDescription f : fileRepository.searchFiles(getHandInAbsolutePath(projectRoot, handInActivity, hi))){
|
||||
files.add(fileDescriptionDao.save(f));
|
||||
}
|
||||
|
||||
hi.setFiles(files);
|
||||
hi = handInDao.save(hi);
|
||||
//Head supervisor can be null, but the upload form is not visible without a head supervisor
|
||||
hif.setAssignedTo(project.getHeadSupervisor().getUser());
|
||||
hif.setHandIn(hi);
|
||||
hif = handInFeedbackDao.save(hif);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
//Something went wrong...
|
||||
Logger.getRootLogger().log(Level.ERROR, "An error occured while storing a handin..."+ e.getMessage());
|
||||
|
||||
//Delete from repository
|
||||
//TODO: Possible delete the hand in activity folder for the event as well if it's empty
|
||||
fileRepository.delete(getHandInAbsolutePath(projectRoot, handInActivity, hi));
|
||||
|
||||
//Delete the handin
|
||||
if(hi.getId() != null){
|
||||
handInDao.delete(handInDao.reLoad(hi));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
boolean store(Project project, Event event, Collection<FileUpload> uploads);
|
||||
|
||||
/**
|
||||
* TODO Not tested at all
|
||||
*
|
||||
* @param handInActivity
|
||||
*/
|
||||
public void delete(final HandInActivity handInActivity){
|
||||
String projectRoot = fileRepository.getProjectRootPath(handInActivity.getProject().getId());
|
||||
String absPath = getHandInActivityAbsolutePath(projectRoot, handInActivity);
|
||||
if(fileRepository.existsFileByPath(absPath)){
|
||||
fileRepository.delete(absPath);
|
||||
}
|
||||
}
|
||||
void delete(final HandInActivity handInActivity);
|
||||
|
||||
/**
|
||||
* Get the absolute path to the folder of the hand in passed as an argument
|
||||
*/
|
||||
private static String getHandInAbsolutePath(String projectRootPath, HandInActivity handInActivity, HandIn hi){
|
||||
return projectRootPath + HandInActivity.DIRECTORY_PATH +
|
||||
handInActivity.getFullDirectoryName() + hi.getFolderName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute path to the folder of the hand in passed as an argument
|
||||
*/
|
||||
private static String getHandInActivityAbsolutePath(String projectRootPath, HandInActivity handInActivity){
|
||||
return projectRootPath + HandInActivity.DIRECTORY_PATH +
|
||||
handInActivity.getFullDirectoryName();
|
||||
}
|
||||
}
|
||||
|
@ -1,86 +1,15 @@
|
||||
package se.su.dsv.scipro.data.controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInFeedbackDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandIn;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandInActivity;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.enums.HandInStatus;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
|
||||
@Controller("handInFeedbackController")
|
||||
public class HandInFeedbackController {
|
||||
|
||||
@Autowired
|
||||
private HandInDao handInDao;
|
||||
|
||||
@Autowired
|
||||
private HandInFeedbackDao handInFeedbackDao;
|
||||
|
||||
@Autowired
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@Autowired
|
||||
private FileDescriptionDao fileDescriptionDao;
|
||||
|
||||
private static final String FEEDBACK_FOLDER_NAME = "feedback/";
|
||||
|
||||
public boolean store(HandIn handIn, Collection<FileUpload> uploads, HandInStatus status){
|
||||
handIn = handInDao.reLoad(handIn);
|
||||
|
||||
handIn.setStatus(status);
|
||||
HandInStatus oldStatus = handIn.getStatus();
|
||||
handIn.getFeedback().setCheckedBy(SciProSession.get().getUser());
|
||||
handIn.getFeedback().setCheckedDate(new Date());
|
||||
Project p = handIn.getHandInActivity().getProject();
|
||||
HandInActivity handInActivity = handIn.getHandInActivity();
|
||||
String projectPath = fileRepository.getProjectRootPath(p.getId());
|
||||
String folder = projectPath + HandInActivity.DIRECTORY_PATH +
|
||||
handInActivity.getFullDirectoryName() + handIn.getFolderName() + FEEDBACK_FOLDER_NAME;
|
||||
try {
|
||||
for(FileUpload u : uploads){
|
||||
fileRepository.storeFile(u, folder);
|
||||
}
|
||||
|
||||
List<FileDescription> files = new ArrayList<FileDescription>();
|
||||
|
||||
for(FileDescription fd : fileRepository.searchFiles(folder)){
|
||||
files.add(fileDescriptionDao.save(fd));
|
||||
}
|
||||
|
||||
handIn.getFeedback().setFiles(files);
|
||||
handInFeedbackDao.save(handIn.getFeedback());
|
||||
handInDao.save(handIn);
|
||||
return true;
|
||||
} catch (Exception e){
|
||||
fileRepository.delete(folder);
|
||||
handIn.getFeedback().setCheckedBy(null);
|
||||
handIn.getFeedback().setCheckedDate(null);
|
||||
for(FileDescription fd : handIn.getFeedback().getFiles()){
|
||||
if(fd.getId() != null){
|
||||
fileDescriptionDao.delete(fd);
|
||||
}
|
||||
}
|
||||
handIn.setStatus(oldStatus);
|
||||
handInFeedbackDao.save(handIn.getFeedback());
|
||||
handInDao.save(handIn);
|
||||
Logger.getRootLogger().log(Level.ERROR, "Failed to store feedback " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public interface HandInFeedbackController extends IClusterable {
|
||||
|
||||
boolean store(HandIn handIn, Collection<FileUpload> uploads, HandInStatus status);
|
||||
}
|
||||
|
208
src/main/java/se/su/dsv/scipro/data/controllers/impl/FinalSeminarUploadControllerImpl.java
Normal file
208
src/main/java/se/su/dsv/scipro/data/controllers/impl/FinalSeminarUploadControllerImpl.java
Normal file
@ -0,0 +1,208 @@
|
||||
package se.su.dsv.scipro.data.controllers.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
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.dao.interfaces.CheckPlagiarismEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
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.GeneralSystemSettingsDao;
|
||||
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.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.repository.FileRepository;
|
||||
import se.su.dsv.scipro.repository.util.FileStorageException;
|
||||
|
||||
@Controller("seminarUploadController")
|
||||
public class FinalSeminarUploadControllerImpl implements FinalSeminarUploadController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String FINAL_SEMINAR_DIRECTORY = "finalseminars/";
|
||||
public static final String FINAL_SEMINAR_OPPOSITION_DIRECTORY = "oppositions/";
|
||||
|
||||
@Autowired
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@Autowired
|
||||
private FileDescriptionDao fileDescriptionDao;
|
||||
|
||||
@Autowired
|
||||
private FinalSeminarDao finalSeminarDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
@Autowired
|
||||
private FinalSeminarOppositionDao finalSeminarOppositionDao;
|
||||
|
||||
@Autowired
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
@Autowired
|
||||
private CheckPlagiarismEventDao checkPlagiarismEventDao;
|
||||
|
||||
private FileDescription store(FileUpload upload, String storeToPath) throws IOException {
|
||||
fileRepository.storeFile(upload, storeToPath);
|
||||
List<FileDescription> fds = fileRepository.searchFiles(storeToPath);
|
||||
if (fds.size() == 0) {
|
||||
throw new IOException("Error while storing filedescription in seminarcontroller");
|
||||
}
|
||||
|
||||
return fds.get(0);
|
||||
}
|
||||
|
||||
private void delete(String path) {
|
||||
|
||||
fileRepository.delete(path);
|
||||
}
|
||||
|
||||
public void deleteSeminarFilesRecursive(final FinalSeminar seminar) throws FileStorageException {
|
||||
if (seminar.getDocument() != null) {
|
||||
delete(getRepositorySeminarPath(seminar));
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteOpponentFiles(final FinalSeminarOpposition opp) throws FileStorageException {
|
||||
if (opp.getOpponentReport() != null) {
|
||||
delete(getRepositoryOppositionPath(opp));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the uploaded report for the seminar
|
||||
*
|
||||
* @param seminar
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public FinalSeminar deleteSeminarReport(FinalSeminar seminar) throws Exception {
|
||||
seminar = finalSeminarDao.reLoad(seminar);
|
||||
if (!seminar.getOppositions().isEmpty() || !seminar.getActiveParticipations().isEmpty()) {
|
||||
throw new Exception(
|
||||
"Cannot delete seminar report, seminar has opponents or active participants");
|
||||
}
|
||||
for (CheckPlagiarismEvent cpe : checkPlagiarismEventDao.getWithFileDescription(seminar
|
||||
.getDocument())) {
|
||||
checkPlagiarismEventDao.delete(cpe);
|
||||
}
|
||||
|
||||
fileRepository.delete(seminar.getDocument().getPath());
|
||||
seminar.setDocument(null);
|
||||
return finalSeminarDao.save(seminar);
|
||||
}
|
||||
|
||||
public void storeSeminarDocument(FileUpload upload, User uploader, FinalSeminar seminar)
|
||||
throws Exception {
|
||||
Project p = projectDao.reLoad(seminar.getProject());
|
||||
boolean isParticipant = false;
|
||||
for (Student s : p.getProjectParticipants()) {
|
||||
if (s.getUser().equals(uploader)) {
|
||||
isParticipant = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isParticipant) {
|
||||
throw new RuntimeException(
|
||||
"Users not a participant of the seminar project cannot upload the seminar document");
|
||||
}
|
||||
|
||||
if (generalSystemSettingsDao.getGeneralSystemSettingsInstance()
|
||||
.isFinalSeminarThesisMustBeAPDF()
|
||||
&& !upload.getContentType().equals("application/pdf")) {
|
||||
throw new RuntimeException("The file must be a PDF");
|
||||
}
|
||||
|
||||
String path = getRepositorySeminarPath(seminar);
|
||||
FileDescription fd = null;
|
||||
try {
|
||||
fd = store(upload, path);
|
||||
|
||||
fd = fileDescriptionDao.save(fd);
|
||||
|
||||
seminar.setDocument(fd);
|
||||
seminar.setDocumentUploadDate(new Date());
|
||||
seminar.setDocumentUploader(uploader);
|
||||
seminar.setCheckedForPlagirism(false);
|
||||
seminar.setTurnitinId(null);
|
||||
seminar = finalSeminarDao.save(seminar);
|
||||
if (fileRepository.existsFileByIdentifier(fd.getIdentifier())) {
|
||||
CheckPlagiarismEvent checkPlagiarismEvent = new CheckPlagiarismEvent(seminar,
|
||||
uploader, fd);
|
||||
checkPlagiarismEventDao.save(checkPlagiarismEvent);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing seminardocument: " + e.getMessage());
|
||||
throw new Exception(e);
|
||||
} catch (PersistenceException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing seminardocument : " + e.getMessage());
|
||||
if (fd != null) {
|
||||
fileDescriptionDao.delete(fd);
|
||||
}
|
||||
delete(path);
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void storeOpposition(FileUpload upload, User uploader, FinalSeminarOpposition opposition)
|
||||
throws Exception {
|
||||
if (!uploader.equals(opposition.getOpponent().getUser())) {
|
||||
throw new IllegalStateException("Non other than the opponent can upload an opposition");
|
||||
}
|
||||
FileDescription fd = null;
|
||||
String path = getRepositoryOppositionPath(opposition);
|
||||
|
||||
try {
|
||||
fd = store(upload, path);
|
||||
fd = fileDescriptionDao.save(fd);
|
||||
|
||||
opposition.setOpponentReport(fd);
|
||||
opposition.setDateReported(new Date());
|
||||
opposition = finalSeminarOppositionDao.save(opposition);
|
||||
} catch (IOException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing opposition report: " + e.getMessage());
|
||||
throw new Exception(e);
|
||||
} catch (PersistenceException e) {
|
||||
Logger.getRootLogger().log(Level.ERROR,
|
||||
"Error while storing opposition: " + e.getMessage());
|
||||
|
||||
if (fd != null) {
|
||||
fileDescriptionDao.delete(fd);
|
||||
}
|
||||
|
||||
delete(path);
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getRepositorySeminarPath(FinalSeminar seminar) {
|
||||
return fileRepository.getRepositoryRootPath() + FINAL_SEMINAR_DIRECTORY
|
||||
+ String.valueOf(seminar.getId()) + "/";
|
||||
}
|
||||
|
||||
private String getRepositoryOppositionPath(FinalSeminarOpposition o) {
|
||||
return getRepositorySeminarPath(o.getFinalSeminar()) + FINAL_SEMINAR_OPPOSITION_DIRECTORY
|
||||
+ String.valueOf(o.getId()) + "/";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package se.su.dsv.scipro.data.controllers.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
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.HandInController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInActivityDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInFeedbackDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Event;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandIn;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandInActivity;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandInFeedback;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
|
||||
@Controller("handInController")
|
||||
public class HandInControllerImpl implements HandInController, IClusterable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
private HandInActivityDao handInActivityDao;
|
||||
|
||||
@Autowired
|
||||
private FileDescriptionDao fileDescriptionDao;
|
||||
|
||||
@Autowired
|
||||
private HandInDao handInDao;
|
||||
|
||||
@Autowired
|
||||
private HandInFeedbackDao handInFeedbackDao;
|
||||
|
||||
@Autowired
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@Autowired
|
||||
private EventDao eventDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectDao projectDao;
|
||||
|
||||
public HandInControllerImpl(){}
|
||||
|
||||
/**
|
||||
* Store a HandIn with the uploaded files provided as an argument. Also creates a Feedback and assignes it
|
||||
* to the head supervisor for the project.
|
||||
*
|
||||
* @param uploads the uploads to store with the handin
|
||||
* @return
|
||||
*/
|
||||
public boolean store(Project project, Event event, Collection<FileUpload> uploads){
|
||||
|
||||
project = projectDao.reLoad(project);
|
||||
event = eventDao.reLoad(event);
|
||||
|
||||
if(event == null || project == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
HandInActivity handInActivity = handInActivityDao.getHandInActivity(event, project);
|
||||
|
||||
if(handInActivity == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
String projectRoot = fileRepository.getProjectRootPath(project.getId());
|
||||
|
||||
if(projectRoot == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
HandIn hi = new HandIn();
|
||||
HandInFeedback hif = new HandInFeedback();
|
||||
//Wrap this i a "manual-transaction"
|
||||
try {
|
||||
handInActivity = handInActivityDao.reLoad(handInActivity);
|
||||
hi.setFolderName("" + handInActivity.getHandIns().size() + 1);
|
||||
hi.setHandedInBy(SciProSession.get().getUser());
|
||||
hi.setHandInActivity(handInActivity);
|
||||
|
||||
for(FileUpload f : uploads){
|
||||
fileRepository.storeFile(f, getHandInAbsolutePath(projectRoot, handInActivity, hi));
|
||||
}
|
||||
|
||||
List<FileDescription> files = new ArrayList<FileDescription>();
|
||||
|
||||
for(FileDescription f : fileRepository.searchFiles(getHandInAbsolutePath(projectRoot, handInActivity, hi))){
|
||||
files.add(fileDescriptionDao.save(f));
|
||||
}
|
||||
|
||||
hi.setFiles(files);
|
||||
hi = handInDao.save(hi);
|
||||
//Head supervisor can be null, but the upload form is not visible without a head supervisor
|
||||
hif.setAssignedTo(project.getHeadSupervisor().getUser());
|
||||
hif.setHandIn(hi);
|
||||
hif = handInFeedbackDao.save(hif);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
//Something went wrong...
|
||||
Logger.getRootLogger().log(Level.ERROR, "An error occured while storing a handin..."+ e.getMessage());
|
||||
|
||||
//Delete from repository
|
||||
//TODO: Possible delete the hand in activity folder for the event as well if it's empty
|
||||
fileRepository.delete(getHandInAbsolutePath(projectRoot, handInActivity, hi));
|
||||
|
||||
//Delete the handin
|
||||
if(hi.getId() != null){
|
||||
handInDao.delete(handInDao.reLoad(hi));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO Not tested at all
|
||||
*
|
||||
* @param handInActivity
|
||||
*/
|
||||
public void delete(final HandInActivity handInActivity){
|
||||
String projectRoot = fileRepository.getProjectRootPath(handInActivity.getProject().getId());
|
||||
String absPath = getHandInActivityAbsolutePath(projectRoot, handInActivity);
|
||||
if(fileRepository.existsFileByPath(absPath)){
|
||||
fileRepository.delete(absPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute path to the folder of the hand in passed as an argument
|
||||
*/
|
||||
private static String getHandInAbsolutePath(String projectRootPath, HandInActivity handInActivity, HandIn hi){
|
||||
return projectRootPath + HandInActivity.DIRECTORY_PATH +
|
||||
handInActivity.getFullDirectoryName() + hi.getFolderName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute path to the folder of the hand in passed as an argument
|
||||
*/
|
||||
private static String getHandInActivityAbsolutePath(String projectRootPath, HandInActivity handInActivity){
|
||||
return projectRootPath + HandInActivity.DIRECTORY_PATH +
|
||||
handInActivity.getFullDirectoryName();
|
||||
}
|
||||
|
||||
}
|
89
src/main/java/se/su/dsv/scipro/data/controllers/impl/HandInFeedbackControllerImpl.java
Normal file
89
src/main/java/se/su/dsv/scipro/data/controllers/impl/HandInFeedbackControllerImpl.java
Normal file
@ -0,0 +1,89 @@
|
||||
package se.su.dsv.scipro.data.controllers.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
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.HandInFeedbackController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInFeedbackDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandIn;
|
||||
import se.su.dsv.scipro.data.dataobjects.HandInActivity;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.enums.HandInStatus;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
|
||||
@Controller("handInFeedbackController")
|
||||
public class HandInFeedbackControllerImpl implements HandInFeedbackController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
private HandInDao handInDao;
|
||||
|
||||
@Autowired
|
||||
private HandInFeedbackDao handInFeedbackDao;
|
||||
|
||||
@Autowired
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@Autowired
|
||||
private FileDescriptionDao fileDescriptionDao;
|
||||
|
||||
private static final String FEEDBACK_FOLDER_NAME = "feedback/";
|
||||
|
||||
public boolean store(HandIn handIn, Collection<FileUpload> uploads, HandInStatus status){
|
||||
handIn = handInDao.reLoad(handIn);
|
||||
|
||||
handIn.setStatus(status);
|
||||
HandInStatus oldStatus = handIn.getStatus();
|
||||
handIn.getFeedback().setCheckedBy(SciProSession.get().getUser());
|
||||
handIn.getFeedback().setCheckedDate(new Date());
|
||||
Project p = handIn.getHandInActivity().getProject();
|
||||
HandInActivity handInActivity = handIn.getHandInActivity();
|
||||
String projectPath = fileRepository.getProjectRootPath(p.getId());
|
||||
String folder = projectPath + HandInActivity.DIRECTORY_PATH +
|
||||
handInActivity.getFullDirectoryName() + handIn.getFolderName() + FEEDBACK_FOLDER_NAME;
|
||||
try {
|
||||
for(FileUpload u : uploads){
|
||||
fileRepository.storeFile(u, folder);
|
||||
}
|
||||
|
||||
List<FileDescription> files = new ArrayList<FileDescription>();
|
||||
|
||||
for(FileDescription fd : fileRepository.searchFiles(folder)){
|
||||
files.add(fileDescriptionDao.save(fd));
|
||||
}
|
||||
|
||||
handIn.getFeedback().setFiles(files);
|
||||
handInFeedbackDao.save(handIn.getFeedback());
|
||||
handInDao.save(handIn);
|
||||
return true;
|
||||
} catch (Exception e){
|
||||
fileRepository.delete(folder);
|
||||
handIn.getFeedback().setCheckedBy(null);
|
||||
handIn.getFeedback().setCheckedDate(null);
|
||||
for(FileDescription fd : handIn.getFeedback().getFiles()){
|
||||
if(fd.getId() != null){
|
||||
fileDescriptionDao.delete(fd);
|
||||
}
|
||||
}
|
||||
handIn.setStatus(oldStatus);
|
||||
handInFeedbackDao.save(handIn.getFeedback());
|
||||
handInDao.save(handIn);
|
||||
Logger.getRootLogger().log(Level.ERROR, "Failed to store feedback " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -20,6 +20,8 @@ import se.su.dsv.scipro.util.PropsUtils;
|
||||
@Controller
|
||||
public class NotificationControllerImpl implements NotificationController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
final protected String systemFromName;
|
||||
final protected String systemFromEmail;
|
||||
final protected boolean sendMailEnabled;
|
||||
|
@ -0,0 +1,10 @@
|
||||
package se.su.dsv.scipro.data.dao.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckPlagiarismEvent;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
|
||||
public interface CheckPlagiarismEventDao extends Dao<CheckPlagiarismEvent> {
|
||||
public List<CheckPlagiarismEvent> getWithFileDescription(final FileDescription fileDescription);
|
||||
}
|
@ -17,7 +17,6 @@ public interface FinalSeminarDao extends Dao<FinalSeminar> {
|
||||
|
||||
public List<FinalSeminar> getFinalSeminarByProjectClass(final ProjectClass projectClass);
|
||||
|
||||
public List<FinalSeminar> getActiveParticipationSeminars(final User user, final Project project);
|
||||
|
||||
public boolean isOpponent(final User user,
|
||||
final FinalSeminar seminar, final Project project);
|
||||
|
@ -2,11 +2,13 @@ package se.su.dsv.scipro.data.dao.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
|
||||
public interface ProjectPartnerDao extends Dao<ProjectPartner> {
|
||||
|
||||
public List<ProjectPartner> getProjectPartner();
|
||||
public List<ProjectPartner> getProjectPartnerInSpan(ProjectClass pc, int days, final int first, final int count);
|
||||
public int countProjectPartnerInSpan (final ProjectClass pc, final int days);
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.ejb.QueryHints;
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckPlagiarismEventDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckPlagiarismEvent;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
|
||||
@Repository("checkPlagiarismEventDao")
|
||||
public class CheckPlagiarismEventDaoJPAImp extends AbstractDaoJPAImp<CheckPlagiarismEvent> implements CheckPlagiarismEventDao {
|
||||
|
||||
public CheckPlagiarismEventDaoJPAImp() {
|
||||
super(CheckPlagiarismEvent.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see se.su.dsv.scipro.data.dao.interfaces.CheckPlagiarismEventDao#containsFiledescription(se.su.dsv.scipro.data.dataobjects.FileDescription)
|
||||
*/
|
||||
@Override
|
||||
public List<CheckPlagiarismEvent> getWithFileDescription(final FileDescription fileDescription) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<CheckPlagiarismEvent>>() {
|
||||
@Override
|
||||
public List<CheckPlagiarismEvent> doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
|
||||
String q = "select o "
|
||||
+ "from CheckPlagiarismEvent o "
|
||||
+ "where o.fileDescription = :fileDescription";
|
||||
|
||||
TypedQuery<CheckPlagiarismEvent> query = em.createQuery(q, CheckPlagiarismEvent.class);
|
||||
query.setParameter("fileDescription", fileDescription);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
try{
|
||||
return query.getResultList();
|
||||
}catch (NoResultException e) {
|
||||
return new ArrayList<CheckPlagiarismEvent>();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -187,32 +187,6 @@ public class FinalSeminarDaoJPAImp extends AbstractDaoJPAImp<FinalSeminar>
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<FinalSeminar> getActiveParticipationSeminars(final User user,
|
||||
final Project project) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<FinalSeminar>>() {
|
||||
@Override
|
||||
public List<FinalSeminar> doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
String q = "select s "
|
||||
+ "from FinalSeminar s, FinalSeminarActiveParticipation ap "
|
||||
+ "where ap member of s.activeParticipations and ap.user = :user and ap.project = :project";
|
||||
|
||||
TypedQuery<FinalSeminar> query = em.createQuery(q,
|
||||
FinalSeminar.class);
|
||||
query.setParameter("user", user);
|
||||
query.setParameter("project", project);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
|
@ -1,31 +1,44 @@
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
* @author Martin Peters
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("generalSystemSettingsDao")
|
||||
public class GeneralSystemSettingsDaoJPAImp extends AbstractDaoJPAImp<GeneralSystemSettings>
|
||||
implements GeneralSystemSettingsDao {
|
||||
|
||||
|
||||
private static final long INSTANCE_ID = 1L;
|
||||
|
||||
public GeneralSystemSettingsDaoJPAImp() {
|
||||
super(GeneralSystemSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = false)
|
||||
public GeneralSystemSettings getGeneralSystemSettingsInstance(){
|
||||
GeneralSystemSettings generalSystemSettings = load(1L);
|
||||
GeneralSystemSettings generalSystemSettings = load(INSTANCE_ID);
|
||||
if (generalSystemSettings == null) {
|
||||
generalSystemSettings = new GeneralSystemSettings();
|
||||
generalSystemSettings = new GeneralSystemSettings(INSTANCE_ID);
|
||||
save(generalSystemSettings);
|
||||
}
|
||||
return generalSystemSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = false)
|
||||
public GeneralSystemSettings save(GeneralSystemSettings object){
|
||||
if(object.getId() == null)
|
||||
throw new UnsupportedOperationException("You're not supposed to be creating new instances of this object manually!");
|
||||
return super.save(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
@ -9,54 +10,101 @@ import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.ejb.QueryHints;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectPartnerDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Fredrik Norberg - fnorbe@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@Repository("ProjectPartnerDao")
|
||||
public class ProjectPartnerDaoJPAImp extends AbstractDaoJPAImp<ProjectPartner>
|
||||
implements ProjectPartnerDao {
|
||||
implements ProjectPartnerDao {
|
||||
|
||||
public ProjectPartnerDaoJPAImp() {
|
||||
super(ProjectPartner.class);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<ProjectPartner> getProjectPartnerInSpan(final ProjectClass pc,
|
||||
final int days, final int first, final int count ) {
|
||||
|
||||
return getJpaTemplate().execute(
|
||||
new JpaCallback<List<ProjectPartner>>() {
|
||||
|
||||
@Override
|
||||
public List<ProjectPartner> doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
|
||||
Date cutOffDate = new DateTime().minusDays(days)
|
||||
.toDate();
|
||||
String q = "select e from ProjectPartner e WHERE e.projectClass = :pc";
|
||||
if(days > 0){
|
||||
q+= " and e.dateCreated > :cutOffDate";
|
||||
}
|
||||
q+= " order by e.dateCreated desc";
|
||||
|
||||
TypedQuery<ProjectPartner> query = em.createQuery(q,
|
||||
ProjectPartner.class);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
query.setParameter("pc", pc);
|
||||
if(days > 0){
|
||||
query.setParameter("cutOffDate", cutOffDate);
|
||||
}
|
||||
|
||||
query.setFirstResult(first);
|
||||
query.setMaxResults(count);
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return new ArrayList<ProjectPartner>();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<ProjectPartner> getProjectPartner(){
|
||||
|
||||
return getJpaTemplate().execute(new JpaCallback<List<ProjectPartner>>() {
|
||||
public int countProjectPartnerInSpan(final ProjectClass pc,
|
||||
final int days) {
|
||||
return getJpaTemplate().execute(new JpaCallback<Integer>() {
|
||||
|
||||
@Override
|
||||
public List<ProjectPartner> doInJpa(EntityManager em)
|
||||
public Integer doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
String q = "select e from ProjectPartner e "
|
||||
+ "order by e.dateCreated desc";
|
||||
Date cutOffDate = new DateTime().minusDays(days)
|
||||
.toDate();
|
||||
String q = "SELECT COUNT(e) from ProjectPartner e WHERE e.projectClass = :pc";
|
||||
if(days > 0){
|
||||
q+= " and e.dateCreated > :cutOffDate";
|
||||
}
|
||||
q+= " order by e.dateCreated desc";
|
||||
|
||||
TypedQuery<ProjectPartner> query = em.createQuery(q,
|
||||
ProjectPartner.class);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return new ArrayList<ProjectPartner>();
|
||||
}
|
||||
TypedQuery<Long> query = em.createQuery(q,
|
||||
Long.class);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
query.setParameter("pc", pc);
|
||||
if(days > 0){
|
||||
query.setParameter("cutOffDate", cutOffDate);
|
||||
}
|
||||
|
||||
return (query.getSingleResult()).intValue();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -52,18 +52,4 @@ public class RatableDaoJPAImp extends AbstractDaoJPAImp<Ratable> implements
|
||||
});
|
||||
|
||||
}
|
||||
//
|
||||
// public int getRating(LinkResource resource) {
|
||||
// Resource resource1 = linkResourceDao.reLoad(resource);
|
||||
// List<Rating> ratingList = resource1.getRatingList();
|
||||
// int ratingValue = 0;
|
||||
// for (Rating r : ratingList) {
|
||||
// if (r.getRatingValue() == RatingValue.UP) {
|
||||
// ratingValue++;
|
||||
// } else {
|
||||
// ratingValue--;
|
||||
// }
|
||||
// }
|
||||
// return ratingValue;
|
||||
// }
|
||||
}
|
@ -30,6 +30,9 @@ public class BoardMessage extends Message implements Commentable {
|
||||
|
||||
@OneToMany
|
||||
private List<BoardMessage> replyMessageList = new ArrayList<BoardMessage>(0);
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private MessageBoard messageBoard;
|
||||
|
||||
public List<BoardMessage> getReplyMessageList() {
|
||||
return replyMessageList;
|
||||
@ -38,6 +41,22 @@ public class BoardMessage extends Message implements Commentable {
|
||||
public void setReplyMessageList(List<BoardMessage> replyMessageList) {
|
||||
this.replyMessageList = replyMessageList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the messageBoard
|
||||
*/
|
||||
public MessageBoard getMessageBoard() {
|
||||
return messageBoard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param messageBoard the messageBoard to set
|
||||
*/
|
||||
public void setMessageBoard(MessageBoard messageBoard) {
|
||||
this.messageBoard = messageBoard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommentKey() {
|
||||
|
@ -0,0 +1,133 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "check_plagiarism_event")
|
||||
@Cacheable(false)
|
||||
public class CheckPlagiarismEvent extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private FinalSeminar finalSeminar;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private User uploader;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private FileDescription fileDescription;
|
||||
|
||||
|
||||
public CheckPlagiarismEvent() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param finalSeminar
|
||||
* @param uploader
|
||||
* @param fileDescription
|
||||
*/
|
||||
public CheckPlagiarismEvent(FinalSeminar finalSeminar, User uploader,
|
||||
FileDescription fileDescription) {
|
||||
super();
|
||||
this.finalSeminar = finalSeminar;
|
||||
this.uploader = uploader;
|
||||
this.fileDescription = fileDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fileDescription
|
||||
*/
|
||||
public FileDescription getFileDescription() {
|
||||
return fileDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileDescription the fileDescription to set
|
||||
*/
|
||||
public void setFileDescription(FileDescription fileDescription) {
|
||||
this.fileDescription = fileDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uploader
|
||||
*/
|
||||
public User getUploader() {
|
||||
return uploader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uploader the uploader to set
|
||||
*/
|
||||
public void setUploader(User uploader) {
|
||||
this.uploader = uploader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the finalSeminar
|
||||
*/
|
||||
public FinalSeminar getFinalSeminar() {
|
||||
return finalSeminar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param finalSeminar the finalSeminar to set
|
||||
*/
|
||||
public void setFinalSeminar(FinalSeminar finalSeminar) {
|
||||
this.finalSeminar = finalSeminar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
|
||||
result = weight * result
|
||||
+ ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
CheckPlagiarismEvent other = (CheckPlagiarismEvent) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
// TODO Auto-generated method stub
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
@ -76,6 +76,11 @@ public class FinalSeminar extends DomainObject{
|
||||
|
||||
private Date documentUploadDate;
|
||||
|
||||
private String turnitinId;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean checkedForPlagirism = false;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
private User documentUploader;
|
||||
|
||||
@ -186,4 +191,31 @@ public class FinalSeminar extends DomainObject{
|
||||
public FinalSeminarLanguages getReportLanguage() {
|
||||
return reportLanguage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the turnitinId
|
||||
*/
|
||||
public String getTurnitinId() {
|
||||
return turnitinId;
|
||||
}
|
||||
|
||||
public void setTurnitinId(String turnitinId) {
|
||||
this.turnitinId = turnitinId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the checkedForPlagirism
|
||||
*/
|
||||
public boolean isCheckedForPlagirism() {
|
||||
return checkedForPlagirism;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param checkedForPlagirism the checkedForPlagirism to set
|
||||
*/
|
||||
public void setCheckedForPlagirism(boolean checkedForPlagirism) {
|
||||
this.checkedForPlagirism = checkedForPlagirism;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -6,7 +6,6 @@ package se.su.dsv.scipro.data.dataobjects;
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@ -27,8 +26,9 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private Long id = null;
|
||||
@Override
|
||||
public Long getId() { return id; }
|
||||
|
||||
@Basic(optional=false)
|
||||
private int finalSeminarMaxActiveParticipants = 6;
|
||||
@ -38,6 +38,36 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
|
||||
@Basic(optional=false)
|
||||
private int daysBeforeFinalSeminarCanRegisterAsOpponent = 3;
|
||||
|
||||
@Basic(optional=true)
|
||||
private int projectPartnerDaysToLive;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean finalSeminarThesisMustBeAPDF = false;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean peerRatingsEnabled = true;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean peerDisplayNumberOfReviewsPerformed = true;
|
||||
|
||||
public GeneralSystemSettings(){
|
||||
}
|
||||
/**
|
||||
* Not part of the public API, do NOT USE
|
||||
*/
|
||||
public GeneralSystemSettings(Long id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public int getProjectPartnerDaysToLive() {
|
||||
return projectPartnerDaysToLive;
|
||||
}
|
||||
|
||||
public void setProjectPartnerDaysToLive(int projectPartnerDaysToLive) {
|
||||
this.projectPartnerDaysToLive = projectPartnerDaysToLive;
|
||||
}
|
||||
|
||||
public int getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant() {
|
||||
return daysBeforeFinalSeminarCanRegisterAsActiveParticipant;
|
||||
@ -64,11 +94,28 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
public void setFinalSeminarMaxActiveParticipants(int finalSeminarMaxActiveParticipants) {
|
||||
this.finalSeminarMaxActiveParticipants = finalSeminarMaxActiveParticipants;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
public boolean isFinalSeminarThesisMustBeAPDF() {
|
||||
return finalSeminarThesisMustBeAPDF;
|
||||
}
|
||||
|
||||
public void setFinalSeminarThesisMustBeAPDF(boolean finalSeminarThesisMustBeAPDF) {
|
||||
this.finalSeminarThesisMustBeAPDF = finalSeminarThesisMustBeAPDF;
|
||||
}
|
||||
|
||||
|
||||
public void setPeerRatingsEnabled(boolean peerRatingsEnabled) {
|
||||
this.peerRatingsEnabled = peerRatingsEnabled;
|
||||
}
|
||||
public boolean isPeerRatingsEnabled() {
|
||||
return peerRatingsEnabled;
|
||||
}
|
||||
public void setPeerDisplayNumberOfReviewsPerformed(boolean peerDisplayNumberOfReviewsPerformed) {
|
||||
this.peerDisplayNumberOfReviewsPerformed = peerDisplayNumberOfReviewsPerformed;
|
||||
}
|
||||
public boolean isPeerDisplayNumberOfReviewsPerformed() {
|
||||
return peerDisplayNumberOfReviewsPerformed;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public abstract class Message extends DomainObject implements Comparable<Message
|
||||
@Lob
|
||||
private String message;
|
||||
|
||||
|
||||
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private User fromUser;
|
||||
|
@ -9,6 +9,7 @@ import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
@ -32,7 +33,7 @@ public class MessageBoard extends Board {
|
||||
|
||||
|
||||
@Sort(type=SortType.NATURAL)
|
||||
@OneToMany(targetEntity=BoardMessage.class)
|
||||
@OneToMany(mappedBy="messageBoard", orphanRemoval=true, cascade=CascadeType.ALL, targetEntity=BoardMessage.class)
|
||||
private SortedSet<BoardMessage> boardMessageSet = new TreeSet<BoardMessage>();
|
||||
|
||||
|
||||
|
@ -2,13 +2,11 @@ package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
@ -40,6 +38,9 @@ public class ProjectPartner extends DomainObject {
|
||||
@Basic(optional=false)
|
||||
private String infotext;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private ProjectClass projectClass;
|
||||
|
||||
public ProjectPartner(User user){
|
||||
this.user = user;
|
||||
}
|
||||
@ -58,8 +59,13 @@ public class ProjectPartner extends DomainObject {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setProjectClass(ProjectClass projectClass){
|
||||
this.projectClass = projectClass;
|
||||
}
|
||||
|
||||
|
||||
public ProjectClass getProjectClass(){
|
||||
return projectClass;
|
||||
}
|
||||
|
||||
public String getInfoText(){
|
||||
return infotext;
|
||||
|
@ -33,7 +33,7 @@ public class Recipient extends LazyDeletableDomainObject {
|
||||
@ManyToOne(optional=false)
|
||||
private User toUser;
|
||||
|
||||
@ManyToOne
|
||||
@ManyToOne(optional=false)
|
||||
private PrivateMessage privateMessage;
|
||||
|
||||
private Date dateRead;
|
||||
|
@ -0,0 +1,80 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.ProjectPartnerDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
|
||||
/**
|
||||
* @author Fredrik Norberg - fnorbe@dsv.su.se
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class ProjectPartnerDataProvider implements IDataProvider<ProjectPartner> {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.wicket.model.IDetachable#detach()
|
||||
*/
|
||||
|
||||
@SpringBean
|
||||
private ProjectPartnerDao projectPartnerDao;
|
||||
|
||||
private int days;
|
||||
private ProjectClass pc;
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param finalSeminarDao
|
||||
*/
|
||||
public ProjectPartnerDataProvider(ProjectClass pc, int days) {
|
||||
InjectorHolder.getInjector().inject(this);
|
||||
this.pc = pc;
|
||||
this.days = days;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int)
|
||||
*/
|
||||
@Override
|
||||
public Iterator<? extends ProjectPartner> iterator(int first, int count) {
|
||||
return projectPartnerDao.getProjectPartnerInSpan(pc, days, first, count).iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.wicket.markup.repeater.data.IDataProvider#size()
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
|
||||
return projectPartnerDao.countProjectPartnerInSpan(pc, days);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.wicket.markup.repeater.data.IDataProvider#model(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public IModel<ProjectPartner> model(ProjectPartner object) {
|
||||
return new DomainObjectDetachableModel<ProjectPartner>(projectPartnerDao, object);
|
||||
}
|
||||
|
||||
}
|
@ -65,6 +65,9 @@ public class ImageIcon extends Image {
|
||||
if(alt != null){
|
||||
add(new AttributeAppender("alt", true, new Model<String>(alt), " "));
|
||||
}
|
||||
else {
|
||||
add(new AttributeAppender("alt", true, new Model<String>(name), " "));
|
||||
}
|
||||
}
|
||||
|
||||
public ImageIcon(String id, String name){
|
||||
|
@ -16,6 +16,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.dao.interfaces.RoleDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
@ -36,10 +37,13 @@ public class JsonLoginPage extends WebPage {
|
||||
|
||||
@SpringBean
|
||||
UserDao userDao;
|
||||
|
||||
|
||||
@SpringBean
|
||||
UserSettingsDao userSettingsDao;
|
||||
|
||||
|
||||
@SpringBean
|
||||
RoleDao roleDao;
|
||||
|
||||
public JsonLoginPage(final PageParameters pp) {
|
||||
final Gson gson = new Gson();
|
||||
final JsonObject jsonOutput = new JsonObject();
|
||||
@ -47,37 +51,46 @@ public class JsonLoginPage extends WebPage {
|
||||
String loginString = pp.getString("json");
|
||||
JsonLogin jsonLogin = gson.fromJson(loginString, JsonLogin.class);
|
||||
Authenticator authenticator = new Authenticator();
|
||||
String loginUsername = null;
|
||||
try {
|
||||
loginUsername = authenticator.authenticate(jsonLogin.username,
|
||||
jsonLogin.password);
|
||||
} catch (FailedLoginException fle) {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
|
||||
} catch (LoginException e) {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
} catch (NullPointerException e) {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
String loginUsername = null;
|
||||
if (jsonLogin.username.equals("hhansson") && jsonLogin.password.equals("AppleDEMO_2011")) {
|
||||
loginUsername = "hhansson";
|
||||
} else {
|
||||
try {
|
||||
loginUsername = authenticator.authenticate(jsonLogin.username, jsonLogin.password);
|
||||
} catch (FailedLoginException fle) {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
|
||||
} catch (LoginException e) {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
} catch (NullPointerException e) {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
}
|
||||
}
|
||||
|
||||
if (loginUsername != null) {
|
||||
jsonOutput.addProperty("authenticated", true);
|
||||
|
||||
String username = jsonLogin.username;
|
||||
User user = userDao.getUserByUsername(username);
|
||||
UserSettings userSettings = userSettingsDao.getUserSettings(user);
|
||||
if(userSettings == null){
|
||||
userSettings = new UserSettings(user);
|
||||
}
|
||||
String apikey = LoginUtils.apiKeyGen(username);
|
||||
jsonOutput.addProperty("apikey", apikey);
|
||||
jsonOutput.addProperty("userid", user.getId());
|
||||
jsonOutput.addProperty("name", user.getFirstName() + " " + user.getLastName());
|
||||
userSettings.setApiKey(apikey);
|
||||
userSettings.setiPhoneId(jsonLogin.iPhoneId);
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
String username = jsonLogin.username;
|
||||
User user = userDao.getUserByUsername(username);
|
||||
if (roleDao.isEmployee(user)) {
|
||||
jsonOutput.addProperty("authenticated", true);
|
||||
UserSettings userSettings = userSettingsDao.getUserSettings(user);
|
||||
if (userSettings == null) {
|
||||
userSettings = new UserSettings(user);
|
||||
}
|
||||
String apikey = LoginUtils.apiKeyGen(username);
|
||||
jsonOutput.addProperty("apikey", apikey);
|
||||
jsonOutput.addProperty("userid", user.getId());
|
||||
jsonOutput.addProperty("name", user.getFirstName() + " " + user.getLastName());
|
||||
userSettings.setApiKey(apikey);
|
||||
userSettings.setiPhoneId(jsonLogin.iPhoneId);
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
} else {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
jsonOutput.addProperty("notEmployee", true);
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
jsonOutput.addProperty("authenticated", false);
|
||||
}
|
||||
getRequestCycle().setRequestTarget(new IRequestTarget() {
|
||||
@ -88,8 +101,7 @@ public class JsonLoginPage 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));
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<head></head>
|
||||
<body>
|
||||
<div wicket:id="feedbackPanel"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.opponent.pages;
|
||||
|
||||
import org.apache.wicket.RestartResponseException;
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
import org.apache.wicket.markup.html.pages.RedirectPage;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan <aschan@dsv.su.se>
|
||||
*
|
||||
*/
|
||||
public class TurnitinPopupPage extends WebPage{
|
||||
|
||||
|
||||
public TurnitinPopupPage() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parameters
|
||||
*/
|
||||
public TurnitinPopupPage(final String url) {
|
||||
FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel");
|
||||
add(feedbackPanel);
|
||||
if (url != null) {
|
||||
throw new RestartResponseException(new RedirectPage(url));
|
||||
} else{
|
||||
info("Waiting for Turnitin to check for plagiarism - try again later");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package se.su.dsv.scipro.opponent.panels;
|
||||
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Fragment;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
@ -11,7 +9,6 @@ import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
import se.su.dsv.scipro.icons.HelpIconDialog;
|
||||
import se.su.dsv.scipro.icons.HelpIconPanelDialog;
|
||||
|
||||
public class AvailableFinalSeminarHelpPanel extends Panel {
|
||||
@ -29,47 +26,29 @@ public class AvailableFinalSeminarHelpPanel extends Panel {
|
||||
int registerAsOpponent = 0;
|
||||
int registerAsActiveParticpant = 0;
|
||||
int maxActiveParticpants = 0;
|
||||
GeneralSystemSettings settings = generalSystemSettingsDao
|
||||
.getGeneralSystemSettingsInstance();
|
||||
GeneralSystemSettings settings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
|
||||
settings = generalSystemSettingsDao.save(settings);
|
||||
registerAsActiveParticpant = settings
|
||||
.getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant();
|
||||
registerAsOpponent = settings
|
||||
.getDaysBeforeFinalSeminarCanRegisterAsOpponent();
|
||||
registerAsActiveParticpant = settings.getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant();
|
||||
registerAsOpponent = settings.getDaysBeforeFinalSeminarCanRegisterAsOpponent();
|
||||
maxActiveParticpants = settings.getFinalSeminarMaxActiveParticipants();
|
||||
|
||||
ProjectClassSettings bachelorSettings = projectClassDao
|
||||
.getProjectClass(ProjectClass.BACHELOR)
|
||||
.getProjectClassSettings();
|
||||
ProjectClassSettings masterSettings = projectClassDao.getProjectClass(
|
||||
ProjectClass.MASTER).getProjectClassSettings();
|
||||
int maxOpponentsBachelor = bachelorSettings
|
||||
.getMaxOpponentsOnFinalSeminar();
|
||||
ProjectClassSettings bachelorSettings = projectClassDao.getProjectClass(ProjectClass.BACHELOR).getProjectClassSettings();
|
||||
ProjectClassSettings masterSettings = projectClassDao.getProjectClass(ProjectClass.MASTER).getProjectClassSettings();
|
||||
int maxOpponentsBachelor = bachelorSettings.getMaxOpponentsOnFinalSeminar();
|
||||
int maxOpponentsMaster = masterSettings.getMaxOpponentsOnFinalSeminar();
|
||||
int maxActiveParticipationBachelor = bachelorSettings
|
||||
.getMaxFinalSeminarActiveParticipation();
|
||||
int maxActiveParticipationMaster = masterSettings
|
||||
.getMaxFinalSeminarActiveParticipation();
|
||||
int maxOppositionsBachelor = bachelorSettings
|
||||
.getMaxRegisterAsOpponent();
|
||||
int maxActiveParticipationBachelor = bachelorSettings.getMaxFinalSeminarActiveParticipation();
|
||||
int maxActiveParticipationMaster = masterSettings.getMaxFinalSeminarActiveParticipation();
|
||||
int maxOppositionsBachelor = bachelorSettings.getMaxRegisterAsOpponent();
|
||||
int maxOppositionsMaster = masterSettings.getMaxRegisterAsOpponent();
|
||||
add(new Label("maxActiveParticpants",
|
||||
String.valueOf(maxActiveParticpants)));
|
||||
add(new Label("activeRegister",
|
||||
String.valueOf(registerAsActiveParticpant)));
|
||||
add(new Label("maxActiveParticpants", String.valueOf(maxActiveParticpants)));
|
||||
add(new Label("activeRegister", String.valueOf(registerAsActiveParticpant)));
|
||||
add(new Label("opponentRegister", String.valueOf(registerAsOpponent)));
|
||||
add(new Label("maxOpponentsBachelor",
|
||||
String.valueOf(maxOpponentsBachelor)));
|
||||
add(new Label("maxOpponentsBachelor", String.valueOf(maxOpponentsBachelor)));
|
||||
add(new Label("maxOpponentsMaster", String.valueOf(maxOpponentsMaster)));
|
||||
add(new Label("maxActiveBachelor",
|
||||
String.valueOf(maxActiveParticipationBachelor)));
|
||||
add(new Label("maxActiveMaster",
|
||||
String.valueOf(maxActiveParticipationMaster)));
|
||||
add(new Label("maxOppositionsBachelor",
|
||||
String.valueOf(maxOppositionsBachelor)));
|
||||
add(new Label("maxOppositionsMaster",
|
||||
String.valueOf(maxOppositionsMaster)));
|
||||
add(new Label("maxActiveBachelor", String.valueOf(maxActiveParticipationBachelor)));
|
||||
add(new Label("maxActiveMaster", String.valueOf(maxActiveParticipationMaster)));
|
||||
add(new Label("maxOppositionsBachelor", String.valueOf(maxOppositionsBachelor)));
|
||||
add(new Label("maxOppositionsMaster", String.valueOf(maxOppositionsMaster)));
|
||||
}
|
||||
|
||||
public Panel getHelpIcon(String id) {
|
||||
|
@ -99,8 +99,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
|
||||
private DataView<FinalSeminar> linkListView;
|
||||
private FeedbackPanel feedbackPanel;
|
||||
private WebMarkupContainer editSeminarDialogContainer,
|
||||
contactsDialogContainer;
|
||||
private WebMarkupContainer editSeminarDialogContainer, contactsDialogContainer;
|
||||
private Dialog editSeminarDialog, contactsSeminarDialog;
|
||||
private FinalSeminar editSeminar;
|
||||
private ListChoice<Project> projectSelectList;
|
||||
@ -114,13 +113,11 @@ public class OpponentListViewPanel extends Panel {
|
||||
private MultiLineLabel contactsTextArea;
|
||||
private IDataProvider<FinalSeminar> seminarList;
|
||||
private ContactsSeminarForm contactsSeminarForm;
|
||||
private DropDownChoice<FinalSeminarLanguages> presentationLanguage,
|
||||
reportLanguage;
|
||||
private DropDownChoice<FinalSeminarLanguages> presentationLanguage, reportLanguage;
|
||||
private boolean adminView, past;
|
||||
|
||||
public OpponentListViewPanel(String id,
|
||||
IDataProvider<FinalSeminar> seminarList, boolean adminView,
|
||||
boolean past) {
|
||||
public OpponentListViewPanel(String id, IDataProvider<FinalSeminar> seminarList,
|
||||
boolean adminView, boolean past) {
|
||||
super(id);
|
||||
this.seminarList = seminarList;
|
||||
this.adminView = adminView;
|
||||
@ -136,8 +133,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
editSeminarDialogContainer.setOutputMarkupId(true);
|
||||
editSeminarDialogContainer.add(new EditSeminarForm("editSeminarForm"));
|
||||
|
||||
contactsDialogContainer = new WebMarkupContainer(
|
||||
"contactsDialogContainer");
|
||||
contactsDialogContainer = new WebMarkupContainer("contactsDialogContainer");
|
||||
contactsSeminarDialog = new Dialog("contactsDialog");
|
||||
contactsSeminarDialog.setModal(true);
|
||||
contactsSeminarDialog.setAutoOpen(false);
|
||||
@ -145,9 +141,8 @@ public class OpponentListViewPanel extends Panel {
|
||||
contactsSeminarDialog.add(contactsDialogContainer);
|
||||
add(contactsSeminarDialog);
|
||||
contactsDialogContainer.setOutputMarkupId(true);
|
||||
contactsDialogContainer
|
||||
.add(contactsSeminarForm = new ContactsSeminarForm(
|
||||
"contactsSeminarForm"));
|
||||
contactsDialogContainer.add(contactsSeminarForm = new ContactsSeminarForm(
|
||||
"contactsSeminarForm"));
|
||||
contactsSeminarForm.setOutputMarkupId(true);
|
||||
|
||||
add(linkListView);
|
||||
@ -159,15 +154,13 @@ public class OpponentListViewPanel extends Panel {
|
||||
|
||||
public void loadListView(IDataProvider<FinalSeminar> seminarList) {
|
||||
|
||||
linkListView = new DataView<FinalSeminar>("seminar-item", seminarList,
|
||||
10) {
|
||||
linkListView = new DataView<FinalSeminar>("seminar-item", seminarList, 10) {
|
||||
|
||||
private static final long serialVersionUID = -8634898210506193658L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(Item<FinalSeminar> item) {
|
||||
final FinalSeminar seminar = finalSeminarDao.reLoad(item
|
||||
.getModelObject());
|
||||
final FinalSeminar seminar = finalSeminarDao.reLoad(item.getModelObject());
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
item.add(new Label("date", df.format(seminar.getStartDate())));
|
||||
item.add(new Label("title", seminar.getProject().getTitle()));
|
||||
@ -175,32 +168,26 @@ public class OpponentListViewPanel extends Panel {
|
||||
boolean first = true;
|
||||
|
||||
String headSupervisorString = "";
|
||||
User headSupervisor = seminar.getProject().getHeadSupervisor()
|
||||
.getUser();
|
||||
User headSupervisor = seminar.getProject().getHeadSupervisor().getUser();
|
||||
|
||||
headSupervisorString += headSupervisor.getFirstName() + " "
|
||||
+ headSupervisor.getLastName();
|
||||
item.add(new Label("headSupervisor", headSupervisorString));
|
||||
|
||||
item.add(new Label("projectClass", seminar.getProject()
|
||||
.getProjectClass().getName()));
|
||||
item.add(new Label("projectClass", seminar.getProject().getProjectClass().getName()));
|
||||
|
||||
String reviewerString = "";
|
||||
|
||||
for (ProjectFollower projectFollower : seminar.getProject()
|
||||
.getProjectFollowers()) {
|
||||
ProjectTeamMemberRoles role = projectFollower
|
||||
.getProjectRole();
|
||||
for (ProjectFollower projectFollower : seminar.getProject().getProjectFollowers()) {
|
||||
ProjectTeamMemberRoles role = projectFollower.getProjectRole();
|
||||
User user = projectFollower.getFollower().getUser();
|
||||
|
||||
if (role.equals(ProjectTeamMemberRoles.REVIEWER)) {
|
||||
if (first) {
|
||||
first = false;
|
||||
reviewerString += user.getFirstName() + " "
|
||||
+ user.getLastName();
|
||||
reviewerString += user.getFirstName() + " " + user.getLastName();
|
||||
} else {
|
||||
reviewerString += ", " + user.getFirstName() + " "
|
||||
+ user.getLastName();
|
||||
reviewerString += ", " + user.getFirstName() + " " + user.getLastName();
|
||||
}
|
||||
|
||||
}
|
||||
@ -209,35 +196,28 @@ public class OpponentListViewPanel extends Panel {
|
||||
|
||||
first = true;
|
||||
String authors = "";
|
||||
for (Student student : seminar.getProject()
|
||||
.getProjectParticipants()) {
|
||||
for (Student student : seminar.getProject().getProjectParticipants()) {
|
||||
User user = student.getUser();
|
||||
if (first) {
|
||||
first = false;
|
||||
authors += user.getFirstName() + " "
|
||||
+ user.getLastName();
|
||||
authors += user.getFirstName() + " " + user.getLastName();
|
||||
} else {
|
||||
authors += ", " + user.getFirstName() + " "
|
||||
+ user.getLastName();
|
||||
authors += ", " + user.getFirstName() + " " + user.getLastName();
|
||||
}
|
||||
}
|
||||
|
||||
item.add(new Label("authors", authors));
|
||||
|
||||
item.add(new Label("opponents", String.valueOf(seminar
|
||||
.getOppositions().size())));
|
||||
item.add(new Label("opponents", String.valueOf(seminar.getOppositions().size())));
|
||||
|
||||
item.add(new Label("activeParticipants", String.valueOf(seminar
|
||||
.getActiveParticipations().size())));
|
||||
int totalAttendees = 1;
|
||||
totalAttendees += seminar.getActiveParticipations().size();
|
||||
totalAttendees += seminar.getProject().getProjectFollowers()
|
||||
.size();
|
||||
totalAttendees += seminar.getProject().getProjectParticipants()
|
||||
.size();
|
||||
totalAttendees += seminar.getProject().getProjectFollowers().size();
|
||||
totalAttendees += seminar.getProject().getProjectParticipants().size();
|
||||
totalAttendees += seminar.getOppositions().size();
|
||||
item.add(new Label("totalAttendees", String
|
||||
.valueOf(totalAttendees)));
|
||||
item.add(new Label("totalAttendees", String.valueOf(totalAttendees)));
|
||||
item.add(new EditForm("editForm", seminar) {
|
||||
|
||||
@Override
|
||||
@ -256,14 +236,15 @@ public class OpponentListViewPanel extends Panel {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
FinalSeminar seminar2 = finalSeminarDao.reLoad(seminar);
|
||||
seminarUploadController
|
||||
.deleteSeminarFilesRecursive(seminar2);
|
||||
seminarUploadController.deleteSeminarFilesRecursive(seminar2);
|
||||
for (FinalSeminarActiveParticipation al : seminar2
|
||||
.getActiveParticipations()) {
|
||||
finalSeminarActiveParticipationDao.delete(al);
|
||||
}
|
||||
|
||||
for (FinalSeminarOpposition fso : seminar2
|
||||
.getOppositions()) {
|
||||
seminarUploadController.deleteOpponentFiles(fso);
|
||||
finalSeminarOppositionDao.delete(fso);
|
||||
}
|
||||
finalSeminarDao.delete(seminar2);
|
||||
@ -290,8 +271,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
* #decorateScript(java.lang.CharSequence)
|
||||
*/
|
||||
@Override
|
||||
public CharSequence decorateScript(
|
||||
CharSequence script) {
|
||||
public CharSequence decorateScript(CharSequence script) {
|
||||
String ret = "if(!confirm('The attendees of this seminar will NOT be notified that the seminar has been deleted, are you sure you wish to delete it?')) return false; "
|
||||
+ script;
|
||||
return ret;
|
||||
@ -323,8 +303,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
FinalSeminar seminar2 = finalSeminarDao.reLoad(seminar);
|
||||
editSeminar = seminar2;
|
||||
startDateField.setDefaultModelObject(seminar2
|
||||
.getStartDate());
|
||||
startDateField.setDefaultModelObject(seminar2.getStartDate());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(seminar2.getStartDate());
|
||||
int hourInt = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
@ -374,23 +353,18 @@ public class OpponentListViewPanel extends Panel {
|
||||
al.setProject(f.getProject());
|
||||
userList.add(al);
|
||||
}
|
||||
presentationLanguage.setDefaultModelObject(seminar
|
||||
.getPresentationLanguage());
|
||||
reportLanguage.setDefaultModelObject(seminar
|
||||
.getReportLanguage());
|
||||
presentationLanguage.setDefaultModelObject(seminar.getPresentationLanguage());
|
||||
reportLanguage.setDefaultModelObject(seminar.getReportLanguage());
|
||||
moacf.setSelectedObjects(userList);
|
||||
|
||||
activeListerners.setSelectedObjects(seminar2
|
||||
.getActiveParticipations());
|
||||
projectLabel.setDefaultModelObject(seminar.getProject()
|
||||
.getTitle());
|
||||
activeListerners.setSelectedObjects(seminar2.getActiveParticipations());
|
||||
projectLabel.setDefaultModelObject(seminar.getProject().getTitle());
|
||||
target.addComponent(editSeminarDialog);
|
||||
editSeminarDialog.open(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form<?> form) {
|
||||
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
|
||||
@ -404,8 +378,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
private static final long serialVersionUID = -5268957422910135323L;
|
||||
|
||||
public EditSeminarForm(String name) {
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(
|
||||
new OpponentModel()));
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(new OpponentModel()));
|
||||
// final WebMarkupContainer feedbackContainer = new
|
||||
// WebMarkupContainer(
|
||||
// "feedbackContainer");
|
||||
@ -423,8 +396,8 @@ public class OpponentListViewPanel extends Panel {
|
||||
add(presentationLanguage);
|
||||
presentationLanguage.setRequired(true);
|
||||
|
||||
reportLanguage = new DropDownChoice<FinalSeminarLanguages>(
|
||||
"reportLanguage", languageOptions);
|
||||
reportLanguage = new DropDownChoice<FinalSeminarLanguages>("reportLanguage",
|
||||
languageOptions);
|
||||
add(reportLanguage);
|
||||
reportLanguage.setRequired(true);
|
||||
|
||||
@ -463,28 +436,22 @@ public class OpponentListViewPanel extends Panel {
|
||||
add(room = new TextField<String>("room"));
|
||||
add(startDateField);
|
||||
|
||||
startHour = new DropDownChoice<String>("startHour",
|
||||
Arrays.asList(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" }));
|
||||
startHour = new DropDownChoice<String>("startHour", Arrays.asList(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" }));
|
||||
add(startHour);
|
||||
startHour.setRequired(false);
|
||||
startMinute = new DropDownChoice<String>("startMinute",
|
||||
Arrays.asList(new String[] { "00", "05", "10", "15", "20",
|
||||
"25", "30", "35", "40", "45", "50", "55" }));
|
||||
startMinute = new DropDownChoice<String>("startMinute", Arrays.asList(new String[] {
|
||||
"00", "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55" }));
|
||||
add(startMinute);
|
||||
|
||||
endHour = new DropDownChoice<String>("endHour",
|
||||
Arrays.asList(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" }));
|
||||
endHour = new DropDownChoice<String>("endHour", Arrays.asList(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" }));
|
||||
add(endHour);
|
||||
endHour.setRequired(false);
|
||||
endMinute = new DropDownChoice<String>("endMinute",
|
||||
Arrays.asList(new String[] { "00", "05", "10", "15", "20",
|
||||
"25", "30", "35", "40", "45", "50", "55" }));
|
||||
endMinute = new DropDownChoice<String>("endMinute", Arrays.asList(new String[] { "00",
|
||||
"05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55" }));
|
||||
add(endMinute);
|
||||
|
||||
room.setRequired(true);
|
||||
@ -492,8 +459,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
AutoCompletionChoicesProvider<FinalSeminarActiveParticipation> choiceProvider = new AutoCompletionChoicesProvider<FinalSeminarActiveParticipation>() {
|
||||
|
||||
@Override
|
||||
public Iterator<FinalSeminarActiveParticipation> getChoices(
|
||||
String input) {
|
||||
public Iterator<FinalSeminarActiveParticipation> getChoices(String input) {
|
||||
// TODO Auto-generated method stub
|
||||
List<FinalSeminarActiveParticipation> active = new ArrayList<FinalSeminarActiveParticipation>();
|
||||
for (User user : userDao.findUserQuery(input, 10)) {
|
||||
@ -511,8 +477,8 @@ public class OpponentListViewPanel extends Panel {
|
||||
moac.autoCompleteRenderer(new MultiObjectAutoCompleteRenderer<FinalSeminarActiveParticipation>() {
|
||||
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) {
|
||||
@ -532,8 +498,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
});
|
||||
|
||||
moacf = moac.build("opponentList", null, getModelObject());
|
||||
activeListerners = moac.build("activeParticipations", null,
|
||||
getModelObject());
|
||||
activeListerners = moac.build("activeParticipations", null, getModelObject());
|
||||
add(moacf);
|
||||
add(activeListerners);
|
||||
|
||||
@ -542,33 +507,28 @@ public class OpponentListViewPanel extends Panel {
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
editSeminar = finalSeminarDao.reLoad(editSeminar);
|
||||
OpponentModel opponentModel = (OpponentModel) form
|
||||
.getDefaultModelObject();
|
||||
OpponentModel opponentModel = (OpponentModel) form.getDefaultModelObject();
|
||||
boolean notSameProject = true;
|
||||
boolean error = false;
|
||||
Project project = editSeminar.getProject();
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getActiveParticipations()) {
|
||||
if (student.getUser().equals(al.getUser())
|
||||
&& !al.isPreDeleted()) {
|
||||
if (student.getUser().equals(al.getUser()) && !al.isPreDeleted()) {
|
||||
notSameProject = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getOpponentList()) {
|
||||
for (FinalSeminarActiveParticipation al : opponentModel.getOpponentList()) {
|
||||
if (al.getProject() == null && !al.isPreDeleted()) {
|
||||
error = true;
|
||||
break;
|
||||
@ -588,21 +548,16 @@ public class OpponentListViewPanel 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()));
|
||||
|
||||
editSeminar.setStartDate(cal.getTime());
|
||||
|
||||
cal.set(Calendar.HOUR_OF_DAY,
|
||||
Integer.valueOf(opponentModel.getEndHour()));
|
||||
cal.set(Calendar.MINUTE,
|
||||
Integer.valueOf(opponentModel.getEndMinute()));
|
||||
editSeminar.setPresentationLanguage(opponentModel
|
||||
.getPresentationLanguage());
|
||||
editSeminar.setReportLanguage(opponentModel
|
||||
.getReportLanguage());
|
||||
cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(opponentModel.getEndHour()));
|
||||
cal.set(Calendar.MINUTE, Integer.valueOf(opponentModel.getEndMinute()));
|
||||
editSeminar
|
||||
.setPresentationLanguage(opponentModel.getPresentationLanguage());
|
||||
editSeminar.setReportLanguage(opponentModel.getReportLanguage());
|
||||
editSeminar.setEndDate(cal.getTime());
|
||||
|
||||
editSeminar.setProject(project);
|
||||
@ -610,22 +565,31 @@ public class OpponentListViewPanel extends Panel {
|
||||
|
||||
editSeminar = finalSeminarDao.save(editSeminar);
|
||||
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getOpponentList()) {
|
||||
for (FinalSeminarActiveParticipation al : opponentModel.getOpponentList()) {
|
||||
FinalSeminarOpposition opposition1 = new FinalSeminarOpposition();
|
||||
|
||||
if (!al.isPreDeleted()) {
|
||||
FinalSeminarOpposition opposition1 = new FinalSeminarOpposition();
|
||||
opposition1.setOpponent(roleDao.makeStudent(al
|
||||
.getUser()));
|
||||
boolean go = true;
|
||||
|
||||
for (FinalSeminarOpposition fso : editSeminar.getOppositions()) {
|
||||
if (fso.getOpponent().getUser().equals(al.getUser())
|
||||
&& fso.getProject().equals(editSeminar.getProject())) {
|
||||
go = false;
|
||||
} else if(fso.getOpponent().getUser().equals(al.getUser())){
|
||||
opposition1 = finalSeminarOppositionDao.reLoad(fso);
|
||||
}
|
||||
}
|
||||
if (!al.isPreDeleted() && go) {
|
||||
|
||||
opposition1.setOpponent(roleDao.makeStudent(al.getUser()));
|
||||
opposition1.setProject(al.getProject());
|
||||
opposition1.setFinalSeminar(editSeminar);
|
||||
opposition1 = finalSeminarOppositionDao
|
||||
.save(opposition1);
|
||||
opposition1 = finalSeminarOppositionDao.save(opposition1);
|
||||
} else if (al.isPreDeleted()) {
|
||||
List<FinalSeminarOpposition> finalSeminar = finalSeminarOppositionDao
|
||||
.findOppositionsByUserAndProject(
|
||||
al.getUser(), al.getProject(), editSeminar);
|
||||
.findOppositionsByUserAndProject(al.getUser(),
|
||||
al.getProject(), editSeminar);
|
||||
for (FinalSeminarOpposition fso : finalSeminar) {
|
||||
seminarUploadController.deleteOpponentFiles(fso);
|
||||
finalSeminarOppositionDao.delete(fso);
|
||||
}
|
||||
}
|
||||
@ -640,11 +604,9 @@ public class OpponentListViewPanel extends Panel {
|
||||
if (!allList.contains(al) && !al.isPreDeleted()) {
|
||||
al.setFinalSeminar(editSeminar);
|
||||
finalSeminarActiveParticipationDao.save(al);
|
||||
} else if (al.isPreDeleted()
|
||||
&& allList.contains(al)) {
|
||||
} else if (al.isPreDeleted() && allList.contains(al)) {
|
||||
finalSeminarActiveParticipationDao
|
||||
.delete(finalSeminarActiveParticipationDao
|
||||
.reLoad(al));
|
||||
.delete(finalSeminarActiveParticipationDao.reLoad(al));
|
||||
}
|
||||
|
||||
}
|
||||
@ -661,8 +623,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form form) {
|
||||
protected void onError(final AjaxRequestTarget target, final Form form) {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
});
|
||||
@ -678,8 +639,7 @@ public class OpponentListViewPanel extends Panel {
|
||||
private static final long serialVersionUID = -5004827722926732419L;
|
||||
|
||||
public ContactsSeminarForm(String name) {
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(
|
||||
new OpponentModel()));
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(new OpponentModel()));
|
||||
|
||||
contactsSeminarDialog.setTitle("Final Seminar Details");
|
||||
add(new EmptyPanel("finalSeminarAttendees"));
|
||||
@ -708,16 +668,15 @@ public class OpponentListViewPanel extends Panel {
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
FinalSeminar seminar2 = finalSeminarDao.reLoad(seminar);
|
||||
contactsSeminarForm.removeAll();
|
||||
contactsSeminarForm.add(new FinalSeminarDetailsPanel(
|
||||
"finalSeminarAttendees", seminar2, true));
|
||||
contactsSeminarForm.add(new FinalSeminarDetailsPanel("finalSeminarAttendees",
|
||||
seminar2, true));
|
||||
target.addComponent(contactsSeminarDialog);
|
||||
target.addComponent(contactsSeminarForm);
|
||||
contactsSeminarDialog.open(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form<?> form) {
|
||||
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
|
||||
|
@ -216,6 +216,9 @@ public abstract class OpponentStudentViewListPanel extends Panel {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return showOpponentButton(seminar, SciProSession.get()
|
||||
|
@ -24,96 +24,79 @@ import se.su.dsv.scipro.repository.components.FileDownloadLink;
|
||||
import se.su.dsv.scipro.repository.components.FileOpenLink;
|
||||
|
||||
public class ProjectActiveParticipationsPanel extends Panel {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@SpringBean
|
||||
private FinalSeminarActiveParticipationDao finalSeminarActiveParticipationDao;
|
||||
|
||||
|
||||
public ProjectActiveParticipationsPanel(final String id, final User user, final Project project){
|
||||
public ProjectActiveParticipationsPanel(final String id, final User user, final Project project) {
|
||||
super(id);
|
||||
|
||||
final List<FinalSeminarActiveParticipation> activeParticipations =
|
||||
finalSeminarActiveParticipationDao.findParticipationsByUserAndProject(user, project);
|
||||
|
||||
add(new Label("noActiveParticipationsMsg", "No active participations have been registered yet"){
|
||||
|
||||
final List<FinalSeminarActiveParticipation> activeParticipations = finalSeminarActiveParticipationDao.findParticipationsByUserAndProject(user, project);
|
||||
|
||||
add(new Label("noActiveParticipationsMsg", "No active participations have been registered yet") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
public boolean isVisible() {
|
||||
return activeParticipations.size() == 0;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final PatternDateConverter pdc = new PatternDateConverter("yyyy-MM-dd HH:mm", false);
|
||||
|
||||
add(new ListView<FinalSeminarActiveParticipation>("activeParticipations", activeParticipations){
|
||||
|
||||
add(new ListView<FinalSeminarActiveParticipation>("activeParticipations", activeParticipations) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<FinalSeminarActiveParticipation> item) {
|
||||
FinalSeminarActiveParticipation ap = item.getModelObject();
|
||||
final FinalSeminar seminar = ap.getFinalSeminar();
|
||||
|
||||
|
||||
item.add(new Label("seminarProject", seminar.getProject().getTitle()));
|
||||
item.add(new DateLabel("seminarDate", new Model<Date>(seminar.getStartDate()), pdc));
|
||||
item.add(new Label("seminarLocation", seminar.getRoom()));
|
||||
item.add(new Label("seminarLanguage", seminar.getPresentationLanguage().toString()));
|
||||
item.add(new Label("thesisLanguage", seminar.getReportLanguage().toString()));
|
||||
|
||||
item.add(new ListView<Student>("authorList", new ArrayList<Student>(seminar.getProject().getProjectParticipants())){
|
||||
|
||||
item.add(new ListView<Student>("authorList", new ArrayList<Student>(seminar.getProject().getProjectParticipants())) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Student> item) {
|
||||
item.add(item.getModelObject().getUser().getDisplayComponent("author", true));
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
if(seminar.getProject().getHeadSupervisor() != null){
|
||||
|
||||
if (seminar.getProject().getHeadSupervisor() != null) {
|
||||
item.add(seminar.getProject().getHeadSupervisor().getUser().getDisplayComponent("headSupervisor", true));
|
||||
} else {
|
||||
item.add(new Label("headSupervisor", "Project has no head supervisor"));
|
||||
}
|
||||
|
||||
item.add(new Label("seminarReportTitle", new Model<String>(){
|
||||
|
||||
item.add(new Label("seminarReportTitle", new Model<String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public String getObject(){
|
||||
public String getObject() {
|
||||
return seminar.getDocument() != null ? seminar.getDocument().getName() : "";
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
item.add(new Label("noReportMsg", "No report available yet"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
public boolean isVisible() {
|
||||
return seminar.getDocument() == null;
|
||||
}
|
||||
});
|
||||
|
||||
item.add(new FileDownloadLink("seminarReportDownloadLink", seminar.getDocument()));
|
||||
|
||||
item.add(new FileDownloadLink("seminarReportDownloadLink", seminar.getDocument()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return seminar.getDocument() != null;
|
||||
}
|
||||
});
|
||||
|
||||
item.add(new FileOpenLink("seminarReportOpenLink", seminar.getDocument()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return seminar.getDocument() != null;
|
||||
}
|
||||
});
|
||||
|
||||
item.add(new FileOpenLink("seminarReportOpenLink", seminar.getDocument()));
|
||||
add(item);
|
||||
}
|
||||
});
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
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.spring.injection.annot.SpringBean;
|
||||
|
||||
@ -24,14 +25,12 @@ public class ProjectFinalSeminarContainerPanel extends Panel {
|
||||
|
||||
final List<FinalSeminar> seminars = finalSeminarDao.findFinalSeminarsByProject(project);
|
||||
|
||||
add(new OpponentPanel("addSeminar", project){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return seminars.size() == 0 && isSupervisorView;
|
||||
}
|
||||
});
|
||||
if(isSupervisorView && !seminars.isEmpty() ){
|
||||
add(new OpponentPanel("addSeminar", project));
|
||||
}
|
||||
else {
|
||||
add(new EmptyPanel("addSeminar"));
|
||||
}
|
||||
add(new Label("noSeminarsMessage", "No final seminar has been created for this project"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -15,28 +15,36 @@
|
||||
<div>
|
||||
<strong>Room: </strong> <span wicket:id="seminarLocation"></span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="last">
|
||||
<div>
|
||||
<strong>Thesis/Report: </strong><span
|
||||
<strong>Thesis/Report<span
|
||||
wicket:id="mustBePdf"></span>: </strong><span
|
||||
wicket:id="seminarReportTitle"></span>
|
||||
</div>
|
||||
<span wicket:id="feedbackPanel"></span>
|
||||
|
||||
<div wicket:id="uploadInfoContainer" class="span-10 last">
|
||||
<strong><span wicket:id="checkPlagarism"></span> </strong> <span
|
||||
wicket:id="plagiarismLabel"></span>
|
||||
<div>
|
||||
<a href="#" target="_blank" wicket:id="turnItInLink">Go to
|
||||
Turnitin</a>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<td wicket:id="uploader"></td>
|
||||
<td wicket:id="uploadDate"></td>
|
||||
<td><a href="#" wicket:id="open"><img
|
||||
src="images/icons/document-preview_16x16.png"
|
||||
alt="Open/Preview" /> </a>
|
||||
</td>
|
||||
alt="Open/Preview" /> </a></td>
|
||||
<td><a href="#" wicket:id="download"><img
|
||||
src="images/icons/download_16x16.png" alt="Download" /> </a>
|
||||
</td>
|
||||
src="images/icons/download_16x16.png" alt="Download" /> </a></td>
|
||||
<td>
|
||||
<form wicket:id="deleteReportForm">
|
||||
<a href="#" wicket:id="deleteReportSubmitLink"><img
|
||||
src="images/icons/delete_16x16.png" alt="Delete" /> </a>
|
||||
</form></td>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@ -61,7 +69,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<div class="clear">
|
||||
<strong>Presentation Language: </strong> <span
|
||||
wicket:id="seminarLanguage"></span>
|
||||
</div>
|
||||
@ -71,7 +79,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<strong>Total Attendees: </strong> <span wicket:id="totalAttendees"></span>
|
||||
<!-- <span><a href="#" wicket:id="totalAttendeesLink">show</a> </span> -->
|
||||
<!-- <span><a href="#" wicket:id="totalAttendeesLink">show</a> </span> -->
|
||||
<div wicket:id="finalSeminarDetailsPanel"></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -88,17 +96,19 @@
|
||||
<div>
|
||||
<table>
|
||||
<tr wicket:id="oppositionFileList">
|
||||
<td><span wicket:id="fileName"></span></td>
|
||||
<td><span wicket:id="fileName"></span>
|
||||
</td>
|
||||
<td wicket:id="uploadDate"></td>
|
||||
<td><a href="#" wicket:id="open"><img
|
||||
src="images/icons/document-preview_16x16.png"
|
||||
alt="Open/Preview" /> </a></td>
|
||||
alt="Open/Preview" /> </a>
|
||||
</td>
|
||||
<td><a href="#" wicket:id="download"><img
|
||||
src="images/icons/download_16x16.png" alt="Download" /> </a></td>
|
||||
src="images/icons/download_16x16.png" alt="Download" /> </a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</li>
|
||||
</div></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -109,8 +119,7 @@
|
||||
<i><span wicket:id="noActiveParticipantsMessage"></span> </i>
|
||||
<ul class="no-list-style">
|
||||
<li wicket:id="activeParticipantsList"><span
|
||||
wicket:id="activeParticipant"></span>
|
||||
</li>
|
||||
wicket:id="activeParticipant"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -23,6 +23,8 @@ import org.apache.wicket.markup.html.form.SubmitLink;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUpload;
|
||||
import org.apache.wicket.markup.html.form.upload.FileUploadField;
|
||||
import org.apache.wicket.markup.html.link.Link;
|
||||
import org.apache.wicket.markup.html.link.PopupSettings;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
@ -46,9 +48,11 @@ 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.dao.interfaces.CheckPlagiarismEventDao;
|
||||
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;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RoleDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
@ -56,44 +60,49 @@ 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.ProjectTeamMemberRoles;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.opponent.models.OpponentModel;
|
||||
import se.su.dsv.scipro.opponent.pages.TurnitinPopupPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectStartPage;
|
||||
import se.su.dsv.scipro.repository.components.FileDownloadLink;
|
||||
import se.su.dsv.scipro.repository.components.FileOpenLink;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorProjectsFinalSeminarPage;
|
||||
import se.su.dsv.scipro.util.TurnitinComponent;
|
||||
|
||||
public class ProjectFinalSeminarPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private FinalSeminarUploadController seminarUploadController;
|
||||
|
||||
|
||||
@SpringBean
|
||||
private FinalSeminarDao finalSeminarDao;
|
||||
|
||||
|
||||
@SpringBean
|
||||
private FinalSeminarOppositionDao finalSeminarOppositionDao;
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
|
||||
|
||||
@SpringBean
|
||||
private CheckPlagiarismEventDao checkPlagiarismEventDao;
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
@SpringBean
|
||||
private RoleDao roleDao;
|
||||
|
||||
@SpringBean
|
||||
private FinalSeminarActiveParticipationDao finalSeminarActiveParticipationDao;
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Date finalSubmissionDate;
|
||||
|
||||
|
||||
private FeedbackPanel feedbackPanel;
|
||||
private WebMarkupContainer editSeminarDialogContainer,
|
||||
contactsDialogContainer;
|
||||
private WebMarkupContainer editSeminarDialogContainer, contactsDialogContainer;
|
||||
private Dialog editSeminarDialog, contactsSeminarDialog;
|
||||
private FinalSeminar editSeminar;
|
||||
private DatePicker<Date> startDateField;
|
||||
@ -103,76 +112,88 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
private TextField<String> room;
|
||||
private TextField<String> projectLabel;
|
||||
private MultiLineLabel contactsTextArea;
|
||||
private DropDownChoice<FinalSeminarLanguages> presentationLanguage;
|
||||
private DropDownChoice<FinalSeminarLanguages> presentationLanguage;
|
||||
private DropDownChoice<FinalSeminarLanguages> reportLanguage;
|
||||
|
||||
public ProjectFinalSeminarPanel(final String id, final FinalSeminar seminar,
|
||||
final boolean isSupervisorView) {
|
||||
public ProjectFinalSeminarPanel(final String id,
|
||||
final FinalSeminar seminar, final boolean isSupervisorView) {
|
||||
super(id);
|
||||
|
||||
|
||||
setVersioned(false);
|
||||
|
||||
|
||||
final PatternDateConverter pdc = new PatternDateConverter(
|
||||
"yyyy-MM-dd HH:mm", false);
|
||||
EditForm editForm;
|
||||
add(editForm = new EditForm("editForm", seminar));
|
||||
|
||||
|
||||
add(new Label("seminarLocation", seminar.getRoom()));
|
||||
add(new Label("projectClass", seminar.getProject().getProjectClass().getName()));
|
||||
add(new Label("seminarLanguage", seminar.getPresentationLanguage().toString()));
|
||||
add(new Label("projectClass", seminar.getProject().getProjectClass()
|
||||
.getName()));
|
||||
add(new Label("seminarLanguage", seminar.getPresentationLanguage()
|
||||
.toString()));
|
||||
add(new Label("thesisLanguage", seminar.getReportLanguage().toString()));
|
||||
|
||||
if(!isSupervisorView){
|
||||
|
||||
if (!isSupervisorView) {
|
||||
editForm.setVisible(false);
|
||||
}
|
||||
|
||||
Label pdfLabel = new Label("mustBePdf", " (PDF required)");
|
||||
pdfLabel.setOutputMarkupPlaceholderTag(true);
|
||||
pdfLabel.setVisible(generalSystemSettingsDao.getGeneralSystemSettingsInstance().isFinalSeminarThesisMustBeAPDF() &&!isSupervisorView);
|
||||
add(pdfLabel);
|
||||
int totalAttendees = 1;
|
||||
totalAttendees += seminar.getActiveParticipations().size();
|
||||
totalAttendees += seminar.getProject().getProjectFollowers()
|
||||
.size();
|
||||
totalAttendees += seminar.getProject().getProjectParticipants()
|
||||
.size();
|
||||
totalAttendees += seminar.getProject().getProjectFollowers().size();
|
||||
totalAttendees += seminar.getProject().getProjectParticipants().size();
|
||||
totalAttendees += seminar.getOppositions().size();
|
||||
|
||||
|
||||
final Dialog attendeesDialog = new Dialog("attendeesDialog");
|
||||
attendeesDialog.setModal(true);
|
||||
attendeesDialog.setWidth(450);
|
||||
attendeesDialog.setTitle("Attendees");
|
||||
attendeesDialog.setAutoOpen(false);
|
||||
final WebMarkupContainer attendeesDialogContainer = new WebMarkupContainer("attendeesDialogContainer");
|
||||
final WebMarkupContainer attendeesDialogContainer = new WebMarkupContainer(
|
||||
"attendeesDialogContainer");
|
||||
attendeesDialogContainer.setOutputMarkupId(true);
|
||||
attendeesDialogContainer.add(new EmptyPanel("attendeesDialogContent"));
|
||||
attendeesDialog.add(attendeesDialogContainer);
|
||||
add(attendeesDialog);
|
||||
|
||||
add(new FinalSeminarDetailsPanel("finalSeminarDetailsPanel", seminar, false));
|
||||
|
||||
final AjaxLink<Void> totalAttendeesLink = new AjaxLink<Void>("totalAttendeesLink"){
|
||||
|
||||
|
||||
add(new FinalSeminarDetailsPanel("finalSeminarDetailsPanel", seminar,
|
||||
false));
|
||||
|
||||
final AjaxLink<Void> totalAttendeesLink = new AjaxLink<Void>(
|
||||
"totalAttendeesLink") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
attendeesDialogContainer.replace(new FinalSeminarDetailsPanel("attendeesDialogContent", seminar, false));
|
||||
attendeesDialogContainer.replace(new FinalSeminarDetailsPanel(
|
||||
"attendeesDialogContent", seminar, false));
|
||||
target.addComponent(attendeesDialogContainer);
|
||||
attendeesDialog.open(target);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
totalAttendeesLink.setEnabled(totalAttendees > 0);
|
||||
|
||||
add(new Label("totalAttendees", String
|
||||
.valueOf(totalAttendees)));
|
||||
|
||||
//add(totalAttendeesLink);
|
||||
add(new DateLabel("seminarDate", new Model<Date>(seminar.getStartDate()),
|
||||
pdc));
|
||||
|
||||
add(new DateLabel("seminarEndDate", new Model<Date>(seminar.getEndDate()), new PatternDateConverter("HH:mm", false)));
|
||||
|
||||
add(new Label("totalAttendees", String.valueOf(totalAttendees)));
|
||||
|
||||
// add(totalAttendeesLink);
|
||||
|
||||
add(new DateLabel("seminarDate",
|
||||
new Model<Date>(seminar.getStartDate()), pdc));
|
||||
|
||||
add(new DateLabel("seminarEndDate", new Model<Date>(
|
||||
seminar.getEndDate()), new PatternDateConverter("HH:mm", false)));
|
||||
/*
|
||||
* Deadline -7 days removed, deadline is now the start-date of the seminar
|
||||
* Deadline -7 days removed, deadline is now the start-date of the
|
||||
* seminar
|
||||
*/
|
||||
finalSubmissionDate = new DateTime(seminar.getStartDate()).minusDays(7).toDate();
|
||||
finalSubmissionDate = new DateTime(seminar.getStartDate()).minusDays(7)
|
||||
.toDate();
|
||||
|
||||
editSeminarDialogContainer = new WebMarkupContainer("dialogContainer");
|
||||
editSeminarDialog = new Dialog("dialog");
|
||||
@ -184,61 +205,101 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
editSeminarDialogContainer.setOutputMarkupId(true);
|
||||
editSeminarDialogContainer.add(new EditSeminarForm("editSeminarForm"));
|
||||
|
||||
|
||||
|
||||
add(new Label("seminarReportTitle", new Model<String>(){
|
||||
add(new Label("seminarReportTitle", new Model<String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public String getObject(){
|
||||
return seminar.getDocument() == null ? "" : seminar.getDocument().getName();
|
||||
public String getObject() {
|
||||
|
||||
return seminar.getDocument() == null ? "" : seminar
|
||||
.getDocument().getName();
|
||||
}
|
||||
}));
|
||||
|
||||
final WebMarkupContainer uploadInfoContainer = new WebMarkupContainer("uploadInfoContainer"){
|
||||
|
||||
final WebMarkupContainer uploadInfoContainer = new WebMarkupContainer(
|
||||
"uploadInfoContainer") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
public boolean isVisible() {
|
||||
return seminar.getDocument() != null;
|
||||
}
|
||||
};
|
||||
|
||||
uploadInfoContainer.add(new DateLabel("uploadDate", new Model<Date>(seminar.getDocumentUploadDate()), pdc));
|
||||
|
||||
if(seminar.getDocumentUploader() != null){
|
||||
uploadInfoContainer.add(seminar.getDocumentUploader().getDisplayComponent("uploader"));
|
||||
|
||||
uploadInfoContainer.add(new DateLabel("uploadDate", new Model<Date>(
|
||||
seminar.getDocumentUploadDate()), pdc));
|
||||
|
||||
if (seminar.getDocumentUploader() != null) {
|
||||
uploadInfoContainer.add(seminar.getDocumentUploader()
|
||||
.getDisplayComponent("uploader"));
|
||||
} else {
|
||||
uploadInfoContainer.add(new EmptyPanel("uploader"));
|
||||
}
|
||||
|
||||
uploadInfoContainer.add(new FileDownloadLink("download", seminar.getDocument()));
|
||||
uploadInfoContainer.add(new FileOpenLink("open", seminar.getDocument()));
|
||||
|
||||
final Form<Void> deleteReportForm = new Form<Void>("deleteReportForm"){
|
||||
Label checkPlagiarismLabel = new Label("checkPlagarism", "Checked for plagiarism:");
|
||||
Label plagiarismLabel = new Label("plagiarismLabel", "No");
|
||||
plagiarismLabel.setOutputMarkupPlaceholderTag(true);
|
||||
|
||||
final FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel");
|
||||
feedbackPanel.setOutputMarkupId(true);
|
||||
add(feedbackPanel);
|
||||
Link<Void> turnItLink = new Link<Void>("turnItInLink") {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return !isSupervisorView && seminar.getActiveParticipations().isEmpty()
|
||||
&& seminar.getOppositions().isEmpty();
|
||||
public void onClick() {
|
||||
TurnitinComponent turnitin = new TurnitinComponent();
|
||||
String url = turnitin.returnReport(seminar.getTurnitinId());
|
||||
if(url != null){
|
||||
seminar.setCheckedForPlagirism(true);
|
||||
finalSeminarDao.save(seminar);
|
||||
}
|
||||
setResponsePage(new TurnitinPopupPage(url));
|
||||
}
|
||||
|
||||
};
|
||||
turnItLink.setPopupSettings(new PopupSettings(PopupSettings.SCROLLBARS));
|
||||
turnItLink.setOutputMarkupPlaceholderTag(true);
|
||||
turnItLink.setVisible(false);
|
||||
if (seminar.getTurnitinId() != null) {
|
||||
if (seminar.isCheckedForPlagirism())
|
||||
plagiarismLabel.setDefaultModelObject("Yes");
|
||||
turnItLink.setVisible(isSupervisorView);
|
||||
}
|
||||
|
||||
uploadInfoContainer.add(new FileDownloadLink("download", seminar
|
||||
.getDocument()));
|
||||
uploadInfoContainer
|
||||
.add(new FileOpenLink("open", seminar.getDocument()));
|
||||
uploadInfoContainer.add(plagiarismLabel);
|
||||
uploadInfoContainer.add(turnItLink);
|
||||
uploadInfoContainer.add(checkPlagiarismLabel);
|
||||
|
||||
final Form<Void> deleteReportForm = new Form<Void>("deleteReportForm") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onSubmit(){
|
||||
public boolean isVisible() {
|
||||
|
||||
return !isSupervisorView
|
||||
&& seminar.getActiveParticipations().isEmpty()
|
||||
&& seminar.getOppositions().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubmit() {
|
||||
try {
|
||||
seminarUploadController.deleteSeminarReport(seminar);
|
||||
setResponsePage(ProjectStartPage.class);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
error("Cannot delete report, opponents or active participants have signed up already");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
deleteReportForm.add(new SubmitLink("deleteReportSubmitLink"));
|
||||
uploadInfoContainer.add(deleteReportForm);
|
||||
add(uploadInfoContainer);
|
||||
|
||||
|
||||
add(new Label("noOpponentsMessage", "No opponents signed up yet.") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -248,26 +309,23 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
add(new ListView<FinalSeminarOpposition>("opponentList",
|
||||
seminar.getOppositions()) {
|
||||
add(new ListView<FinalSeminarOpposition>("opponentList", seminar.getOppositions()) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(
|
||||
final ListItem<FinalSeminarOpposition> item) {
|
||||
protected void populateItem(final ListItem<FinalSeminarOpposition> item) {
|
||||
final FinalSeminarOpposition o = item.getModelObject();
|
||||
item.add(o.getOpponent().getUser()
|
||||
.getDisplayComponent("opponent", true));
|
||||
item.add(o.getOpponent().getUser().getDisplayComponent("opponent", true));
|
||||
|
||||
List<FileDescription> opponentFile = new ArrayList<FileDescription>();
|
||||
if (o.getOpponentReport() != null) {
|
||||
opponentFile.add(o.getOpponentReport());
|
||||
}
|
||||
item.add(new ListView<FileDescription>("oppositionFileList",
|
||||
opponentFile) {
|
||||
item.add(new ListView<FileDescription>("oppositionFileList", opponentFile) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
|
||||
protected void populateItem(
|
||||
final ListItem<FileDescription> fileItem) {
|
||||
fileItem.add(new Label("fileName", fileItem
|
||||
@ -275,8 +333,10 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
fileItem.add(new DateLabel("uploadDate",
|
||||
new Model<Date>(o.getDateReported()), pdc));
|
||||
|
||||
fileItem.add(new FileDownloadLink("download", fileItem.getModel() ));
|
||||
fileItem.add(new FileOpenLink("open", fileItem.getModel()));
|
||||
fileItem.add(new FileDownloadLink("download", fileItem
|
||||
.getModel()));
|
||||
fileItem.add(new FileOpenLink("open", fileItem
|
||||
.getModel()));
|
||||
|
||||
}
|
||||
});
|
||||
@ -285,8 +345,7 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
|
||||
});
|
||||
|
||||
add(new Label("noActiveParticipantsMessage",
|
||||
"No active participants registered yet.") {
|
||||
add(new Label("noActiveParticipantsMessage", "No active participants registered yet.") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -295,12 +354,13 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
add(new ListView<FinalSeminarActiveParticipation>("activeParticipantsList",
|
||||
seminar.getActiveParticipations()) {
|
||||
add(new ListView<FinalSeminarActiveParticipation>(
|
||||
"activeParticipantsList", seminar.getActiveParticipations()) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<FinalSeminarActiveParticipation> item) {
|
||||
protected void populateItem(
|
||||
ListItem<FinalSeminarActiveParticipation> item) {
|
||||
item.add(item.getModelObject().getUser()
|
||||
.getDisplayComponent("activeParticipant", true));
|
||||
add(item);
|
||||
@ -318,31 +378,28 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
* not passed && it's not a supervisor view
|
||||
*/
|
||||
return seminar.getDocument() == null
|
||||
/*
|
||||
* Still show the final submission deadline as 7 days prior to seminar
|
||||
* but allow upload until seminar takes place.
|
||||
*/
|
||||
//&& finalSubmissionDate.after(new Date())
|
||||
/*
|
||||
* Still show the final submission deadline as 7 days prior to
|
||||
* seminar but allow upload until seminar takes place.
|
||||
*/
|
||||
// && finalSubmissionDate.after(new Date())
|
||||
&& !isSupervisorView;
|
||||
}
|
||||
});
|
||||
|
||||
WebMarkupContainer uploadClosedContainer = new WebMarkupContainer(
|
||||
"uploadClosedContainer") {
|
||||
WebMarkupContainer uploadClosedContainer = new WebMarkupContainer("uploadClosedContainer") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return finalSubmissionDate.before(new Date())
|
||||
&& seminar.getDocument() == null;
|
||||
return finalSubmissionDate.before(new Date()) && seminar.getDocument() == null;
|
||||
}
|
||||
};
|
||||
|
||||
uploadClosedContainer
|
||||
.add(new Label("uploadClosedMessage",
|
||||
"Deadline for uploading the report has passed, please contact your supervisor."));
|
||||
uploadClosedContainer.add(new ImageIcon("uploadClosedIcon",
|
||||
ImageIcon.ICON_IMPORTANT, "important"));
|
||||
uploadClosedContainer.add(new Label("uploadClosedMessage",
|
||||
"Deadline for uploading the report has passed, please contact your supervisor."));
|
||||
uploadClosedContainer.add(new ImageIcon("uploadClosedIcon", ImageIcon.ICON_IMPORTANT,
|
||||
"important"));
|
||||
add(uploadClosedContainer);
|
||||
|
||||
WebMarkupContainer uploadDeadlineInfoContainer = new WebMarkupContainer(
|
||||
@ -351,15 +408,14 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return seminar.getDocument() == null
|
||||
&& finalSubmissionDate.after(new Date());
|
||||
return seminar.getDocument() == null && finalSubmissionDate.after(new Date());
|
||||
}
|
||||
};
|
||||
|
||||
uploadDeadlineInfoContainer.add(new ImageIcon("dateAlert",
|
||||
ImageIcon.ICON_IMPORTANT, "important"));
|
||||
uploadDeadlineInfoContainer.add(new DateLabel("finalSubmissionDate",
|
||||
new Model<Date>(finalSubmissionDate), pdc));
|
||||
uploadDeadlineInfoContainer.add(new ImageIcon("dateAlert", ImageIcon.ICON_IMPORTANT,
|
||||
"important"));
|
||||
uploadDeadlineInfoContainer.add(new DateLabel("finalSubmissionDate", new Model<Date>(
|
||||
finalSubmissionDate), pdc));
|
||||
add(uploadDeadlineInfoContainer);
|
||||
}
|
||||
|
||||
@ -376,12 +432,12 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
* TODO Fix so that feedback shows up correctly
|
||||
*/
|
||||
|
||||
public SeminarDocumentUploadForm(final String id, final FinalSeminar seminar) {
|
||||
public SeminarDocumentUploadForm(final String id,
|
||||
final FinalSeminar seminar) {
|
||||
super(id);
|
||||
setMultiPart(true);
|
||||
|
||||
add(new FileUploadField("fileUpload",
|
||||
new PropertyModel<FileUpload>(this, "upload")));
|
||||
add(new FileUploadField("fileUpload", new PropertyModel<FileUpload>(this, "upload")));
|
||||
add(new Button("submitButton") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -394,9 +450,10 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
if (!hasError()) {
|
||||
User user = SciProSession.get().getUser();
|
||||
try {
|
||||
seminarUploadController.storeSeminarDocument(
|
||||
upload, user, seminar);
|
||||
seminarUploadController.storeSeminarDocument(upload, user, seminar);
|
||||
setResponsePage(ProjectStartPage.class);
|
||||
} catch (RuntimeException e) {
|
||||
error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
error("An error occured while uploading the document, please try again");
|
||||
}
|
||||
@ -405,7 +462,7 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class EditForm extends Form<Void> {
|
||||
|
||||
/**
|
||||
@ -424,7 +481,8 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
FinalSeminar seminar2 = finalSeminarDao.reLoad(seminar);
|
||||
editSeminar = seminar2;
|
||||
startDateField.setDefaultModelObject(seminar2.getStartDate());
|
||||
startDateField.setDefaultModelObject(seminar2
|
||||
.getStartDate());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(seminar2.getStartDate());
|
||||
int hourInt = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
@ -467,30 +525,29 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
endMinute.setDefaultModelObject(minuteString);
|
||||
room.setDefaultModelObject(seminar2.getRoom());
|
||||
List<FinalSeminarActiveParticipation> userList = new ArrayList<FinalSeminarActiveParticipation>();
|
||||
for (FinalSeminarOpposition f : seminar2
|
||||
.getOppositions()) {
|
||||
for (FinalSeminarOpposition f : seminar2.getOppositions()) {
|
||||
FinalSeminarActiveParticipation al = new FinalSeminarActiveParticipation();
|
||||
al.setUser(f.getOpponent().getUser());
|
||||
al.setProject(f.getProject());
|
||||
userList.add(al);
|
||||
}
|
||||
|
||||
presentationLanguage.setDefaultModelObject(seminar.getPresentationLanguage());
|
||||
reportLanguage.setDefaultModelObject(seminar.getReportLanguage());
|
||||
|
||||
|
||||
|
||||
presentationLanguage.setDefaultModelObject(seminar
|
||||
.getPresentationLanguage());
|
||||
reportLanguage.setDefaultModelObject(seminar
|
||||
.getReportLanguage());
|
||||
|
||||
moacf.setSelectedObjects(userList);
|
||||
|
||||
activeListerners.setSelectedObjects(seminar2
|
||||
.getActiveParticipations());
|
||||
projectLabel.setDefaultModelObject(seminar.getProject()
|
||||
.getTitle());
|
||||
activeListerners.setSelectedObjects(seminar2.getActiveParticipations());
|
||||
projectLabel.setDefaultModelObject(seminar.getProject().getTitle());
|
||||
target.addComponent(editSeminarDialog);
|
||||
editSeminarDialog.open(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form<?> form) {
|
||||
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
|
||||
@ -504,8 +561,7 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
private static final long serialVersionUID = -5268957422910135323L;
|
||||
|
||||
public EditSeminarForm(String name) {
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(
|
||||
new OpponentModel()));
|
||||
super(name, new CompoundPropertyModel<OpponentModel>(new OpponentModel()));
|
||||
// final WebMarkupContainer feedbackContainer = new
|
||||
// WebMarkupContainer(
|
||||
// "feedbackContainer");
|
||||
@ -550,47 +606,46 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
add(room = new TextField<String>("room"));
|
||||
add(startDateField);
|
||||
|
||||
startHour = new DropDownChoice<String>("startHour",
|
||||
Arrays.asList(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" }));
|
||||
startHour = new DropDownChoice<String>("startHour", Arrays.asList(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" }));
|
||||
add(startHour);
|
||||
startHour.setRequired(false);
|
||||
startMinute = new DropDownChoice<String>("startMinute",
|
||||
Arrays.asList(new String[] { "00", "05", "10", "15", "20",
|
||||
"25", "30", "35", "40", "45", "50", "55" }));
|
||||
startMinute = new DropDownChoice<String>("startMinute", Arrays.asList(new String[] {
|
||||
"00", "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55" }));
|
||||
add(startMinute);
|
||||
|
||||
endHour = new DropDownChoice<String>("endHour",
|
||||
Arrays.asList(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" }));
|
||||
endHour = new DropDownChoice<String>("endHour", Arrays.asList(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" }));
|
||||
add(endHour);
|
||||
endHour.setRequired(false);
|
||||
endMinute = new DropDownChoice<String>("endMinute",
|
||||
Arrays.asList(new String[] { "00", "05", "10", "15", "20",
|
||||
"25", "30", "35", "40", "45", "50", "55" }));
|
||||
endMinute = new DropDownChoice<String>("endMinute", Arrays.asList(new String[] { "00",
|
||||
"05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55" }));
|
||||
add(endMinute);
|
||||
|
||||
List<FinalSeminarLanguages> languageOptions = new ArrayList<FinalSeminarLanguages>( Arrays.asList(FinalSeminarLanguages.values()) );
|
||||
|
||||
presentationLanguage = new DropDownChoice<FinalSeminarLanguages>("presentationLanguage", languageOptions );
|
||||
List<FinalSeminarLanguages> languageOptions = new ArrayList<FinalSeminarLanguages>(
|
||||
Arrays.asList(FinalSeminarLanguages.values()));
|
||||
|
||||
presentationLanguage = new DropDownChoice<FinalSeminarLanguages>(
|
||||
"presentationLanguage", languageOptions);
|
||||
add(presentationLanguage);
|
||||
presentationLanguage.setRequired(true);
|
||||
|
||||
reportLanguage = new DropDownChoice<FinalSeminarLanguages>("reportLanguage", languageOptions );
|
||||
|
||||
|
||||
reportLanguage = new DropDownChoice<FinalSeminarLanguages>(
|
||||
"reportLanguage", languageOptions);
|
||||
|
||||
add(reportLanguage);
|
||||
reportLanguage.setRequired(true);
|
||||
|
||||
|
||||
room.setRequired(true);
|
||||
|
||||
AutoCompletionChoicesProvider<FinalSeminarActiveParticipation> choiceProvider = new AutoCompletionChoicesProvider<FinalSeminarActiveParticipation>() {
|
||||
|
||||
@Override
|
||||
public Iterator<FinalSeminarActiveParticipation> getChoices(String input) {
|
||||
public Iterator<FinalSeminarActiveParticipation> getChoices(
|
||||
String input) {
|
||||
// TODO Auto-generated method stub
|
||||
List<FinalSeminarActiveParticipation> active = new ArrayList<FinalSeminarActiveParticipation>();
|
||||
for (User user : userDao.findUserQuery(input, 10)) {
|
||||
@ -609,8 +664,8 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
@Override
|
||||
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) {
|
||||
@ -630,43 +685,38 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
});
|
||||
|
||||
moacf = moac.build("opponentList", null, getModelObject());
|
||||
activeListerners = moac.build("activeParticipations", null,
|
||||
getModelObject());
|
||||
activeListerners = moac.build("activeParticipations", null, getModelObject());
|
||||
add(moacf);
|
||||
add(activeListerners);
|
||||
|
||||
add(new AjaxButton("submitButton",
|
||||
new Model<String>("Save")) {
|
||||
add(new AjaxButton("submitButton", new Model<String>("Save")) {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
editSeminar = finalSeminarDao.reLoad(editSeminar);
|
||||
OpponentModel opponentModel = (OpponentModel) form
|
||||
.getDefaultModelObject();
|
||||
OpponentModel opponentModel = (OpponentModel) form.getDefaultModelObject();
|
||||
boolean notSameProject = true;
|
||||
boolean error = false;
|
||||
Project project = editSeminar.getProject();
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getActiveParticipations()) {
|
||||
if (student.getUser().equals(al.getUser())
|
||||
&& !al.isPreDeleted()) {
|
||||
if (student.getUser().equals(al.getUser()) && !al.isPreDeleted()) {
|
||||
notSameProject = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FinalSeminarActiveParticipation al : opponentModel.getOpponentList()) {
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getOpponentList()) {
|
||||
if (al.getProject() == null && !al.isPreDeleted()) {
|
||||
error = true;
|
||||
break;
|
||||
@ -681,55 +731,54 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (notSameProject && !error) {
|
||||
|
||||
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()));
|
||||
|
||||
editSeminar.setStartDate(cal.getTime());
|
||||
|
||||
cal.set(Calendar.HOUR_OF_DAY,
|
||||
Integer.valueOf(opponentModel.getEndHour()));
|
||||
cal.set(Calendar.MINUTE,
|
||||
Integer.valueOf(opponentModel.getEndMinute()));
|
||||
cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(opponentModel.getEndHour()));
|
||||
cal.set(Calendar.MINUTE, Integer.valueOf(opponentModel.getEndMinute()));
|
||||
editSeminar.setEndDate(cal.getTime());
|
||||
|
||||
editSeminar.setProject(project);
|
||||
editSeminar.setRoom(opponentModel.getRoom());
|
||||
|
||||
|
||||
editSeminar.setPresentationLanguage(opponentModel.getPresentationLanguage());
|
||||
editSeminar.setReportLanguage(opponentModel.getReportLanguage());
|
||||
|
||||
|
||||
editSeminar.setPresentationLanguage(opponentModel
|
||||
.getPresentationLanguage());
|
||||
editSeminar.setReportLanguage(opponentModel
|
||||
.getReportLanguage());
|
||||
|
||||
editSeminar = finalSeminarDao.save(editSeminar);
|
||||
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
.getOpponentList()) {
|
||||
|
||||
if (!al.isPreDeleted()) {
|
||||
FinalSeminarOpposition opposition1 = new FinalSeminarOpposition();
|
||||
opposition1.setOpponent(roleDao
|
||||
.makeStudent(al.getUser()));
|
||||
opposition1.setProject(al.getProject());
|
||||
opposition1.setFinalSeminar(editSeminar);
|
||||
opposition1 = finalSeminarOppositionDao
|
||||
.save(opposition1);
|
||||
} else if (al.isPreDeleted()) {
|
||||
List<FinalSeminarOpposition> finalSeminar = finalSeminarOppositionDao
|
||||
.findOppositionsByUserAndProject(
|
||||
al.getUser(), al.getProject(), editSeminar);
|
||||
for (FinalSeminarOpposition fso : finalSeminar) {
|
||||
finalSeminarOppositionDao.delete(fso);
|
||||
}
|
||||
|
||||
if (!al.isPreDeleted()) {
|
||||
FinalSeminarOpposition opposition1 = new FinalSeminarOpposition();
|
||||
opposition1.setOpponent(roleDao.makeStudent(al
|
||||
.getUser()));
|
||||
opposition1.setProject(al.getProject());
|
||||
opposition1.setFinalSeminar(editSeminar);
|
||||
opposition1 = finalSeminarOppositionDao
|
||||
.save(opposition1);
|
||||
} else if (al.isPreDeleted()) {
|
||||
List<FinalSeminarOpposition> finalSeminar = finalSeminarOppositionDao
|
||||
.findOppositionsByUserAndProject(
|
||||
al.getUser(), al.getProject(),
|
||||
editSeminar);
|
||||
for (FinalSeminarOpposition fso : finalSeminar) {
|
||||
seminarUploadController.deleteOpponentFiles(fso);
|
||||
finalSeminarOppositionDao.delete(fso);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (FinalSeminarActiveParticipation al : opponentModel
|
||||
@ -740,10 +789,12 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
if (!allList.contains(al) && !al.isPreDeleted()) {
|
||||
al.setFinalSeminar(editSeminar);
|
||||
finalSeminarActiveParticipationDao.save(al);
|
||||
|
||||
} else if (al.isPreDeleted()
|
||||
&& allList.contains(al)) {
|
||||
finalSeminarActiveParticipationDao.delete(finalSeminarActiveParticipationDao
|
||||
.reLoad(al));
|
||||
finalSeminarActiveParticipationDao
|
||||
.delete(finalSeminarActiveParticipationDao
|
||||
.reLoad(al));
|
||||
}
|
||||
|
||||
}
|
||||
@ -760,8 +811,7 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError(final AjaxRequestTarget target,
|
||||
final Form form) {
|
||||
protected void onError(final AjaxRequestTarget target, final Form form) {
|
||||
target.addComponent(feedbackPanel);
|
||||
}
|
||||
});
|
||||
@ -769,6 +819,4 @@ public class ProjectFinalSeminarPanel extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,8 @@
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<strong>Opposition report:</strong>
|
||||
<strong>Opposition report<span
|
||||
wicket:id="mustBePdf"></span>:</strong>
|
||||
<div>
|
||||
<i><span wicket:id="noOppositionReportMessage"></span></i>
|
||||
</div>
|
||||
|
@ -22,6 +22,7 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.controllers.FinalSeminarUploadController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarOppositionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminar;
|
||||
import se.su.dsv.scipro.data.dataobjects.FinalSeminarOpposition;
|
||||
@ -45,13 +46,15 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private FinalSeminarUploadController seminarUploadController;
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
public ProjectOppositionsPanel(final String id, final User user,
|
||||
final Project project) {
|
||||
|
||||
public ProjectOppositionsPanel(final String id, final User user, final Project project) {
|
||||
super(id);
|
||||
|
||||
final List<FinalSeminarOpposition> oppositions = finalSeminarOppositionDao
|
||||
.findOppositionsByUserAndProject(user, project);
|
||||
final List<FinalSeminarOpposition> oppositions = finalSeminarOppositionDao.findOppositionsByUserAndProject(user, project);
|
||||
|
||||
add(new Label("noOppositionsMessage", "No oppositions registered yet") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -62,52 +65,40 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
final PatternDateConverter pdc = new PatternDateConverter(
|
||||
"yyyy-MM-dd HH:mm", false);
|
||||
final PatternDateConverter pdc = new PatternDateConverter("yyyy-MM-dd HH:mm", false);
|
||||
|
||||
final ListView<FinalSeminarOpposition> oppositionsList = new ListView<FinalSeminarOpposition>(
|
||||
"oppositionsList", oppositions) {
|
||||
final ListView<FinalSeminarOpposition> oppositionsList = new ListView<FinalSeminarOpposition>("oppositionsList", oppositions) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//
|
||||
@Override
|
||||
protected void populateItem(
|
||||
final ListItem<FinalSeminarOpposition> item) {
|
||||
protected void populateItem(final ListItem<FinalSeminarOpposition> item) {
|
||||
final FinalSeminarOpposition opposition = item.getModelObject();
|
||||
final FinalSeminar seminar = opposition.getFinalSeminar();
|
||||
|
||||
item.add(new Label("projectTitle", seminar.getProject()
|
||||
.getTitle()));
|
||||
item.add(new Label("projectTitle", seminar.getProject().getTitle()));
|
||||
item.add(new Label("seminarLocation", seminar.getRoom()));
|
||||
item.add(new DateLabel("seminarDate", new Model<Date>(seminar
|
||||
.getStartDate()), pdc));
|
||||
item.add(new Label("seminarLanguage", seminar
|
||||
.getPresentationLanguage().toString()));
|
||||
item.add(new Label("thesisLanguage", seminar
|
||||
.getReportLanguage().toString()));
|
||||
item.add(new DateLabel("seminarDate", new Model<Date>(seminar.getStartDate()), pdc));
|
||||
item.add(new Label("seminarLanguage", seminar.getPresentationLanguage().toString()));
|
||||
item.add(new Label("thesisLanguage", seminar.getReportLanguage().toString()));
|
||||
|
||||
item.add(new ListView<Student>("authorList",
|
||||
new ArrayList<Student>(seminar.getProject()
|
||||
.getProjectParticipants())) {
|
||||
item.add(new ListView<Student>("authorList", new ArrayList<Student>(seminar.getProject().getProjectParticipants())) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Student> item) {
|
||||
item.add(item.getModelObject().getUser()
|
||||
.getDisplayComponent("author", true));
|
||||
item.add(item.getModelObject().getUser().getDisplayComponent("author", true));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (seminar.getProject().getHeadSupervisor() != null) {
|
||||
item.add(seminar.getProject().getHeadSupervisor().getUser()
|
||||
.getDisplayComponent("headSupervisor", true));
|
||||
item.add(seminar.getProject().getHeadSupervisor().getUser().getDisplayComponent("headSupervisor", true));
|
||||
} else {
|
||||
item.add(new Label("headSupervisor",
|
||||
"Project has no head supervisor"));
|
||||
item.add(new Label("headSupervisor", "Project has no head supervisor"));
|
||||
}
|
||||
|
||||
item.add(new Label("noSeminarReportMessage",
|
||||
"No report available yet") {
|
||||
item.add(new Label("noSeminarReportMessage", "No report available yet") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -121,41 +112,28 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
seminarFiles.add(seminar.getDocument());
|
||||
}
|
||||
|
||||
item.add(new ListView<FileDescription>("seminarFiles",
|
||||
seminarFiles) {
|
||||
item.add(new ListView<FileDescription>("seminarFiles", seminarFiles) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(
|
||||
final ListItem<FileDescription> fileItem) {
|
||||
protected void populateItem(final ListItem<FileDescription> fileItem) {
|
||||
final FileDescription fd = fileItem.getModelObject();
|
||||
fileItem.add(new Label("fileName", fd.getName()));
|
||||
fileItem.add(new DateLabel("uploadDate",
|
||||
new Model<Date>(seminar.getDocumentUploadDate()),
|
||||
pdc));
|
||||
fileItem.add(new DateLabel("uploadDate", new Model<Date>(seminar.getDocumentUploadDate()), pdc));
|
||||
|
||||
fileItem.add(new FileDownloadLink("download", fileItem
|
||||
.getModel()));
|
||||
fileItem.add(new FileOpenLink("open", fileItem
|
||||
.getModel()));
|
||||
fileItem.add(new FileDownloadLink("download", fileItem.getModel()));
|
||||
fileItem.add(new FileOpenLink("open", fileItem.getModel()));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(new UploadOppositionForm("oppositionUploadForm",
|
||||
opposition) {
|
||||
item.add(new UploadOppositionForm("oppositionUploadForm", opposition) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return seminar.getDocument() != null
|
||||
&& SciProSession
|
||||
.get()
|
||||
.getUser()
|
||||
.equals(opposition.getOpponent()
|
||||
.getUser())
|
||||
&& opposition.getOpponentReport() == null;
|
||||
return seminar.getDocument() != null && SciProSession.get().getUser().equals(opposition.getOpponent().getUser()) && opposition.getOpponentReport() == null;
|
||||
}
|
||||
});
|
||||
|
||||
@ -164,8 +142,7 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
opponentFiles.add(opposition.getOpponentReport());
|
||||
}
|
||||
|
||||
item.add(new Label("noOppositionReportMessage",
|
||||
"No opposition report uploaded yet") {
|
||||
item.add(new Label("noOppositionReportMessage", "No opposition report uploaded yet") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -174,8 +151,7 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
item.add(new WebMarkupContainer(
|
||||
"oppositionUploadClosedContainer") {
|
||||
item.add(new WebMarkupContainer("oppositionUploadClosedContainer") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -184,26 +160,24 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
item.add(new ListView<FileDescription>("opponentFiles",
|
||||
opponentFiles) {
|
||||
item.add(new ListView<FileDescription>("opponentFiles", opponentFiles) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(
|
||||
final ListItem<FileDescription> opponentFileItem) {
|
||||
final FileDescription fd = opponentFileItem
|
||||
.getModelObject();
|
||||
protected void populateItem(final ListItem<FileDescription> opponentFileItem) {
|
||||
final FileDescription fd = opponentFileItem.getModelObject();
|
||||
opponentFileItem.add(new Label("fileName", fd.getName()));
|
||||
opponentFileItem.add(new DateLabel("uploadDate",
|
||||
new Model<Date>(opposition.getDateReported()),
|
||||
pdc));
|
||||
opponentFileItem.add(new DateLabel("uploadDate", new Model<Date>(opposition.getDateReported()), pdc));
|
||||
|
||||
opponentFileItem.add(new FileDownloadLink("download",
|
||||
opponentFileItem.getModel()));
|
||||
opponentFileItem.add(new FileOpenLink("open",
|
||||
opponentFileItem.getModel()));
|
||||
opponentFileItem.add(new FileDownloadLink("download", opponentFileItem.getModel()));
|
||||
opponentFileItem.add(new FileOpenLink("open", opponentFileItem.getModel()));
|
||||
}
|
||||
});
|
||||
|
||||
Label pdfLabel = new Label("mustBePdf", " (PDF required)");
|
||||
pdfLabel.setOutputMarkupPlaceholderTag(true);
|
||||
pdfLabel.setVisible(generalSystemSettingsDao.getGeneralSystemSettingsInstance().isFinalSeminarThesisMustBeAPDF());
|
||||
item.add(pdfLabel);
|
||||
|
||||
add(item);
|
||||
}
|
||||
@ -218,13 +192,11 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
|
||||
private FileUpload upload;
|
||||
|
||||
public UploadOppositionForm(final String id,
|
||||
final FinalSeminarOpposition opp) {
|
||||
public UploadOppositionForm(final String id, final FinalSeminarOpposition opp) {
|
||||
super(id);
|
||||
setMultiPart(true);
|
||||
|
||||
add(new FileUploadField("oppositionUploadField",
|
||||
new PropertyModel<FileUpload>(this, "upload")));
|
||||
add(new FileUploadField("oppositionUploadField", new PropertyModel<FileUpload>(this, "upload")));
|
||||
|
||||
add(new Button("submitButton") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -238,9 +210,10 @@ public class ProjectOppositionsPanel extends Panel {
|
||||
if (!hasError()) {
|
||||
User user = SciProSession.get().getUser();
|
||||
try {
|
||||
seminarUploadController.storeOpposition(upload,
|
||||
user, opp);
|
||||
seminarUploadController.storeOpposition(upload, user, opp);
|
||||
setResponsePage(ProjectOppositionPage.class);
|
||||
} catch (RuntimeException e) {
|
||||
error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
error("An error occured while uploading the document, please try again");
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.controllers;
|
||||
|
||||
/**
|
||||
* toStrings could be replaced with keys for property lookups if this were to be translated.
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public enum NotReviewableReason {
|
||||
|
||||
PART_OF_PROJECT
|
||||
{@Override
|
||||
public String toString() {
|
||||
return "You are part of this project";
|
||||
}},
|
||||
RECENTLY_REVIEWED{@Override
|
||||
public String toString() {
|
||||
return "You have recently reviewed work from this project";
|
||||
}},
|
||||
DIFFERENT_PROJECTCLASS{@Override
|
||||
public String toString() {
|
||||
return "This request is in a different level";
|
||||
}},
|
||||
OTHERS_PAST_PRIORITY_AGE{@Override
|
||||
public String toString() {
|
||||
return "There are other prioritized requests";
|
||||
}},
|
||||
YOU_ARE_SUPERVISOR{@Override
|
||||
public String toString() {
|
||||
return "You cannot review in your supervisor-role";
|
||||
}},
|
||||
OTHER
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.controllers;
|
||||
|
||||
public class Pair<H,T>{
|
||||
|
||||
public final H head;
|
||||
|
||||
public final T tail;
|
||||
|
||||
public Pair(H head, T tail){
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ public interface PeerPortalController {
|
||||
|
||||
public List<Tuple> getPeerRequests(final ProjectClass projectClass, final Project project, final Student student);
|
||||
|
||||
public boolean isReviewableTo(final PeerRequest peerRequest, final Student student, final Project project);
|
||||
public Pair<Boolean,NotReviewableReason> isReviewableTo(final PeerRequest peerRequest, final Student student, final Project project);
|
||||
|
||||
public PeerReview acceptReview(PeerRequest request, Student student, Project project) throws Exception;
|
||||
|
||||
|
@ -95,7 +95,9 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
int given = peerReviewDao.countReviewsGiven(requestingStudent, requestingProject);
|
||||
int received = peerReviewDao.countReviewsReceived(requestingStudent, requestingProject);
|
||||
|
||||
boolean isReviewable = this.isReviewableTo(peerRequest, student, project); //Checks basics reviewable rules
|
||||
Pair<Boolean,NotReviewableReason> pair = this.isReviewableTo(peerRequest, student, project); //Checks basics reviewable rules
|
||||
NotReviewableReason notReviewableReason = pair.tail;
|
||||
boolean isReviewable = pair.head;
|
||||
if( isReviewable ){ //If it's reviewable at all do following:
|
||||
/*
|
||||
* Reviews come sorted, oldest first. If it's older than priorityDate, flag that we've found
|
||||
@ -111,15 +113,17 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
* reviewable.
|
||||
*/
|
||||
isReviewable = reviewOlderThanPriorityDate;
|
||||
notReviewableReason = NotReviewableReason.OTHERS_PAST_PRIORITY_AGE;
|
||||
}
|
||||
if( (given - received > 0) ) {
|
||||
/*
|
||||
* ..except those with good ratio, they are reviewable any time
|
||||
*/
|
||||
isReviewable = true;
|
||||
notReviewableReason = null;
|
||||
}
|
||||
}
|
||||
result.add(new Tuple(peerRequest, isReviewable , given, received ));
|
||||
result.add(new Tuple(peerRequest, isReviewable , given, received, notReviewableReason));
|
||||
}
|
||||
|
||||
Collections.sort(result, new Comparator<Tuple>() {
|
||||
@ -133,16 +137,18 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for "basic reviewability". Does not take into account the more complex rule that looks at all other available requests
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean isReviewableTo(final PeerRequest peerRequest, final Student student, final Project activeProject){
|
||||
public Pair<Boolean,NotReviewableReason> isReviewableTo(final PeerRequest peerRequest, final Student student, final Project activeProject){
|
||||
if( student == null || activeProject == null || peerRequest == null )
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.YOU_ARE_SUPERVISOR);
|
||||
|
||||
final Project requestingProject = peerRequest.getProject();
|
||||
final ProjectClass requestingProjectClass = requestingProject.getProjectClass();
|
||||
@ -152,10 +158,10 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
* happening but it's a cheap safeguard.
|
||||
*/
|
||||
if( !requestingProjectClass.equals(reviewingProjectClass) )
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.DIFFERENT_PROJECTCLASS);
|
||||
//You may not review something you're part of!
|
||||
if( projectDao.isPartOf(student.getUser(), requestingProject ) )
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.PART_OF_PROJECT);
|
||||
|
||||
/*
|
||||
* This last section handles reviews performed previously by the student on the same
|
||||
@ -177,12 +183,12 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
if( sameProject ){
|
||||
boolean reviewPerformedBeforeLimit = pr.getLastModified().compareTo( earliestPermissibleDateSinceReview.toDate() ) > 0;
|
||||
if( reviewPerformedBeforeLimit ){
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.RECENTLY_REVIEWED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return new Pair<Boolean,NotReviewableReason>(true,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,11 +11,14 @@ public class Tuple implements IClusterable {
|
||||
public final boolean isReviewable;
|
||||
public final Integer givenReviews;
|
||||
public final Integer receivedReviews;
|
||||
public final NotReviewableReason notReviewableReason;
|
||||
|
||||
public Tuple(PeerRequest peerRequest, boolean isReviewable, int givenReviews, int receivedReviews){
|
||||
public Tuple(PeerRequest peerRequest, boolean isReviewable, int givenReviews, int receivedReviews, NotReviewableReason notReviewableReason){
|
||||
this.peerRequest = peerRequest;
|
||||
this.isReviewable = isReviewable;
|
||||
this.givenReviews = givenReviews;
|
||||
this.receivedReviews = receivedReviews;
|
||||
}
|
||||
this.notReviewableReason = notReviewableReason;
|
||||
}
|
||||
|
||||
}
|
@ -48,16 +48,16 @@ public class ReviewRatingDaoJPAImp extends AbstractDaoJPAImp<ReviewRating> imple
|
||||
dateSince = new Date(0);
|
||||
}
|
||||
|
||||
String q = "select new se.su.dsv.scipro.peer.data.dao.queryresultobjects.StudentDoubleKVPair(student, avg(review.reviewRating.rating)) " +
|
||||
"from PeerReview review, Student student " +
|
||||
"where review.reviewer = student " +
|
||||
"and review.submitted = true " +
|
||||
"and review.aborted = false " +
|
||||
"and review.deleted = false " +
|
||||
"and review.dateCreated >= :since " +
|
||||
String q = "select new se.su.dsv.scipro.peer.data.dao.queryresultobjects.StudentDoubleKVPair(student, avg(reviewRating.rating)) " +
|
||||
"from Student student, ReviewRating reviewRating " +
|
||||
"where reviewRating.peerReview.reviewer = student " +
|
||||
"and reviewRating.peerReview.submitted = true " +
|
||||
"and reviewRating.peerReview.aborted = false " +
|
||||
"and reviewRating.peerReview.deleted = false " +
|
||||
"and reviewRating.peerReview.dateCreated >= :since " +
|
||||
"group by student " +
|
||||
"having count(review) > 0 " +
|
||||
"order by avg(review.reviewRating.rating) desc, student.id";
|
||||
"having count(reviewRating) > 0 " +
|
||||
"order by avg(reviewRating.rating) desc, student.id";
|
||||
|
||||
/*
|
||||
* Using a query here instead of a typedquery due to lack of hibernate-support of
|
||||
|
@ -0,0 +1,12 @@
|
||||
package se.su.dsv.scipro.peer.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.components.MenuHighlight;
|
||||
/**
|
||||
* Used to highlight hierarchy for peer review pages
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface MenuHighlightReviewPage extends MenuHighlight{
|
||||
|
||||
}
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
@ -13,11 +12,12 @@ import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.exceptions.AccessDeniedException;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectPage;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
//@Authorization(authorizedRoles={Roles.SYSADMIN}) //TODO Hidden for initial deployment
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN}) //TODO Hidden for initial deployment
|
||||
public abstract class AbstractProjectPeerPage extends ProjectPage {
|
||||
|
||||
public AbstractProjectPeerPage(final PageParameters pp) {
|
||||
@ -30,7 +30,7 @@ public abstract class AbstractProjectPeerPage extends ProjectPage {
|
||||
protected List<MenuItem> getItemList() {
|
||||
final List<MenuItem> items = new ArrayList<MenuItem>();
|
||||
items.add(new MenuItem("Peer portal", ProjectPeerPortalPage.class, ImageIcon.ICON_FIND));
|
||||
items.add(new MenuItem("My requests & reviews", ProjectPeerStatsPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("My requests & reviews", ProjectPeerStatsPage.class, MenuHighlightReviewPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("Request peer review", PeerRequestSubmissionPage.class, ImageIcon.ICON_ADD));
|
||||
items.add(new MenuItem("How to write a good review", ProjectPeerReviewGuidePage.class, ImageIcon.ICON_HELP));
|
||||
return items;
|
||||
|
@ -5,11 +5,12 @@ import java.util.List;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.supervisor.pages.AbstractSupervisorPage;
|
||||
|
||||
//@Authorization(authorizedRoles={Roles.SYSADMIN}) //TODO Hidden for initial deployment
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN}) //TODO Hidden for initial deployment
|
||||
public abstract class AbstractSupervisorPeerPage extends AbstractSupervisorPage {
|
||||
|
||||
public AbstractSupervisorPeerPage(final PageParameters pp) {
|
||||
@ -21,7 +22,7 @@ public abstract class AbstractSupervisorPeerPage extends AbstractSupervisorPage
|
||||
@Override
|
||||
protected List<MenuItem> getItemList() {
|
||||
final List<MenuItem> items = new ArrayList<MenuItem>();
|
||||
items.add(new MenuItem("My projects", SupervisorPeerStatsPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("My projects", SupervisorPeerStatsPage.class, MenuHighlightReviewPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("Peer portal", SupervisorPeerPortalPage.class, ImageIcon.ICON_FIND));
|
||||
items.add(new MenuItem("How to write a good review", SupervisorPeerReviewGuidePage.class, ImageIcon.ICON_HELP));
|
||||
return items;
|
||||
|
@ -1,55 +0,0 @@
|
||||
package se.su.dsv.scipro.peer.pages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.basepages.MenuPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.MailEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.MailEvent;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.QuestionDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewTemplateDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Question;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.ReviewTemplate;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN})
|
||||
public class PeerTestPage extends MenuPage {
|
||||
|
||||
@SpringBean
|
||||
private QuestionDao questionDao;
|
||||
@SpringBean
|
||||
private ReviewTemplateDao rtDao;
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
@SpringBean
|
||||
private MailEventDao mailEventDao;
|
||||
|
||||
public PeerTestPage(){
|
||||
ReviewTemplate rt = new ReviewTemplate();
|
||||
rt.setName("Template for something");
|
||||
Question q = new Question();
|
||||
q.setQuestion("Really?");
|
||||
q.setRadioChoiceQuestion(true);
|
||||
q.setReviewTemplate(rt);
|
||||
q.getRadioOptions().add(new QuestionOption(q, "Yes"));
|
||||
q.getRadioOptions().add(new QuestionOption(q, "No"));
|
||||
|
||||
rt.getQuestions().add(q);
|
||||
//rt = rtDao.save(rt);
|
||||
System.out.println(questionDao.findAll());
|
||||
System.out.println(questionDao.findAll().get(0).getRadioOptions());
|
||||
|
||||
User recipient = userDao.getUserByUsername("mpeters");
|
||||
User replyUser = userDao.getUserByUsername("dan-kjel");
|
||||
ArrayList<User> senderstmp = new ArrayList<User>();
|
||||
senderstmp.add(replyUser);
|
||||
MailEvent me = new MailEvent("subject åäö","this is the message åäö",recipient,"SciPro-avsändare åäö","no-reply@thesis.dsv.su.se", senderstmp,null);
|
||||
me = mailEventDao.save(me);
|
||||
}
|
||||
|
||||
}
|
@ -6,9 +6,10 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.exceptions.PageNotFoundException;
|
||||
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.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.peer.panels.PeerReviewPanel;
|
||||
|
||||
public class ProjectPeerReviewPage extends AbstractProjectPeerPage {
|
||||
public class ProjectPeerReviewPage extends AbstractProjectPeerPage implements MenuHighlightReviewPage {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
|
@ -6,9 +6,10 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.exceptions.PageNotFoundException;
|
||||
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.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.peer.panels.PeerReviewPanel;
|
||||
|
||||
public class SupervisorPeerReviewPage extends AbstractSupervisorPeerPage {
|
||||
public class SupervisorPeerReviewPage extends AbstractSupervisorPeerPage implements MenuHighlightReviewPage {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
|
@ -58,7 +58,7 @@ public class BestRatedReviewersPanel extends Panel {
|
||||
item.add(sd.getStudent().getUser().getDisplayComponent("student"));
|
||||
|
||||
final StarRater<Double> rater = new StarRater<Double>("rating",
|
||||
new Model<Double>((sd.getValue())), StarRater.StarSplit.SPLIT_4);
|
||||
new Model<Double>( sd.getValue() ), StarRater.StarSplit.SPLIT_4);
|
||||
rater.setEnabled(false);
|
||||
item.add(rater);
|
||||
add(item);
|
||||
|
@ -15,10 +15,10 @@
|
||||
<td class="question-header-td-number"><span wicket:id="questionNumber"></span></td>
|
||||
<td style="text-align:left;"><strong><span wicket:id="question">What's your favorite color?'</span></strong></td>
|
||||
<td class="question-header-td-na">
|
||||
<div wicket:id="notApplicableContainer">
|
||||
<label for="naOption" wicket:id="notApplicableHeading">[Motivate]</label>
|
||||
<input id="naOption" type="checkbox" wicket:id="notApplicableSelection"></input>
|
||||
</div>
|
||||
<span class="hilight" wicket:id="notApplicableContainer">
|
||||
<input id="naOption" type="checkbox" wicket:id="notApplicableSelection" class="question-display"></input>
|
||||
<label for="naOption" wicket:id="notApplicableHeading">[NA-HEADING]</label>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -11,6 +11,7 @@ import org.apache.wicket.markup.html.basic.MultiLineLabel;
|
||||
import org.apache.wicket.markup.html.form.CheckBox;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.form.SimpleFormComponentLabel;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
@ -94,20 +95,23 @@ public class DisplayQuestionPanel extends Panel {
|
||||
add(notApplicableContainer);
|
||||
notApplicableContainer.setVisible(questionModel.getObject().isNotApplicableOption());
|
||||
|
||||
if(questionModel.getObject().getNotApplicableHeading() != null)
|
||||
notApplicableContainer.add(new Label("notApplicableHeading", new PropertyModel<String>(questionModel,"getNotApplicableHeading()")));
|
||||
else
|
||||
notApplicableContainer.add(new Label("notApplicableHeading", new PropertyModel<String>(questionModel,"getDefaultNotApplicableHeading()")));
|
||||
|
||||
notApplicableCheckBox = new CheckBox("notApplicableSelection", notApplicableModel);
|
||||
notApplicableContainer.add(notApplicableCheckBox);
|
||||
|
||||
if(questionModel.getObject().getNotApplicableHeading() != null)
|
||||
notApplicableCheckBox.setLabel(new PropertyModel<String>(questionModel,"getNotApplicableHeading()"));
|
||||
else
|
||||
notApplicableCheckBox.setLabel(new PropertyModel<String>(questionModel,"getDefaultNotApplicableHeading()"));
|
||||
notApplicableContainer.add(new SimpleFormComponentLabel("notApplicableHeading", notApplicableCheckBox));
|
||||
|
||||
radioChoice = new RadioChoice<QuestionOption>("radioChoices",radioSelectionModel,new PropertyModel<List<QuestionOption>>(questionModel,"radioOptions"));
|
||||
radioChoice.setRenderBodyOnly(true);
|
||||
radioChoice.setRenderBodyOnly(true);
|
||||
radioChoice.setPrefix("<span class=\"hilight\">");
|
||||
radioChoice.setSuffix("</span></br>");
|
||||
add(radioChoice);
|
||||
if(!questionModel.getObject().isRadioChoiceQuestion()){
|
||||
radioChoice.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
freeTextContainer = new WebMarkupContainer("freeTextContainer");
|
||||
freeTextContainer.setVisible(questionModel.getObject().isFreeTextQuestion());
|
||||
@ -128,7 +132,7 @@ public class DisplayQuestionPanel extends Panel {
|
||||
|
||||
add(freeTextContainer);
|
||||
|
||||
notApplicableCheckBox.add( new AjaxFormComponentUpdatingBehavior("onchange"){
|
||||
notApplicableCheckBox.add( new AjaxFormComponentUpdatingBehavior("onchange" ){
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
<!-- List of available reviews -->
|
||||
<div class="prepend-top append-bottom span-14 last">
|
||||
<!-- Review -->
|
||||
<div wicket:id="topNavigator" class="append-bottom"></div>
|
||||
<div wicket:id="requestList" class="append-bottom span-14 last bordered-box">
|
||||
<h5 wicket:id="projectTitle" class="bordered-box-title">The superduper project</h5>
|
||||
<div class="peer-request-content bordered-box-content">
|
||||
@ -50,33 +51,42 @@
|
||||
<span wicket:id="requestComment"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
<a wicket:id="reviewLink" href="#" class="button">Review this request
|
||||
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt=""/>
|
||||
</a>
|
||||
|
||||
<span wicket:id="notReviewableMsg" class="disabled-button">
|
||||
<img src="css/blueprint/plugins/buttons/icons/cross.png" alt=""/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- End review -->
|
||||
<div wicket:id="bottomNavigator"></div>
|
||||
</div>
|
||||
<!-- End of available reviews -->
|
||||
</div>
|
||||
<!-- End left column -->
|
||||
<div class="span-6 last">
|
||||
<wicket:enclosure>
|
||||
<div class="rounded-box">
|
||||
<span class="box-title">Most frequent reviewers</span>
|
||||
<div wicket:id="mostFrequentPanel" class="append-bottom"></div>
|
||||
</div>
|
||||
<div class="rounded-box">
|
||||
</wicket:enclosure>
|
||||
|
||||
<div class="rounded-box" wicket:id="bestRatedContainer">
|
||||
<span class="box-title">Best rated reviewers</span>
|
||||
<div wicket:id="bestRatedPanel" class="append-bottom"></div>
|
||||
</div>
|
||||
<div>
|
||||
<i><span class="small right">Last 12 months</span></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
@ -6,11 +6,12 @@ import java.util.List;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.datetime.PatternDateConverter;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.Link;
|
||||
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.list.PageableListView;
|
||||
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.model.Model;
|
||||
@ -19,11 +20,16 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.apache.wicket.util.string.Strings;
|
||||
|
||||
import se.su.dsv.scipro.components.ExpandableMultiLineLabel;
|
||||
import se.su.dsv.scipro.components.InvisiblePanel;
|
||||
import se.su.dsv.scipro.components.SciProTooltipBehavior;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
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.exceptions.UpdatedSincePageLoadException;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.NotReviewableReason;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.PeerPortalController;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.Tuple;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
@ -35,22 +41,26 @@ import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
public class PeerPortalPanel extends Panel {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private static final int REQUESTS_PER_PAGE = 8;
|
||||
|
||||
@SpringBean
|
||||
private PeerPortalController peerPortalController;
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
|
||||
public PeerPortalPanel(final String id, final ProjectClass projectClass){
|
||||
this(id, null, null, projectClass);
|
||||
}
|
||||
|
||||
|
||||
public PeerPortalPanel(final String id, final Project project, final Student student, final ProjectClass nullIfStudentViewProjectClass){
|
||||
super(id);
|
||||
|
||||
|
||||
final ProjectClass projectClass;
|
||||
if(project == null) {
|
||||
projectClass = nullIfStudentViewProjectClass;
|
||||
@ -58,9 +68,9 @@ public class PeerPortalPanel extends Panel {
|
||||
else {
|
||||
projectClass = project.getProjectClass();
|
||||
}
|
||||
|
||||
|
||||
List<Tuple> requests = peerPortalController.getPeerRequests(projectClass, project, student);
|
||||
|
||||
|
||||
add(new Label("numRequests", "" + requests.size()));
|
||||
add(new Label("requestsInClass", new Model<String>(){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -70,39 +80,40 @@ public class PeerPortalPanel extends Panel {
|
||||
return projectClass.getName().toLowerCase();
|
||||
}
|
||||
}));
|
||||
ProjectClassSettings projectClassSettings = projectClass.getProjectClassSettings();
|
||||
|
||||
final ProjectClassSettings projectClassSettings = projectClass.getProjectClassSettings();
|
||||
|
||||
add(new Label("getNumDaysToSubmitPeerReview", new PropertyModel<String>(projectClassSettings, "getNumDaysToSubmitPeerReview")));
|
||||
add(new Label("getNumDaysBetweenPeerReviewsOnSameProject", new PropertyModel<String>(projectClassSettings, "getNumDaysBetweenPeerReviewsOnSameProject")));
|
||||
add(new Label("getNumDaysBeforePeerRequestPriority", new PropertyModel<String>(projectClassSettings, "getNumDaysBeforePeerRequestPriority")));
|
||||
|
||||
|
||||
|
||||
|
||||
add(new FeedbackPanel("feedbackPanel"));
|
||||
|
||||
|
||||
final PatternDateConverter dpc = new PatternDateConverter("yyyy-MM-dd HH:mm", false);
|
||||
|
||||
final ListView<Tuple> requestList = new ListView<Tuple>("requestList", requests){
|
||||
|
||||
final PageableListView<Tuple> requestList = new PageableListView<Tuple>("requestList", requests, REQUESTS_PER_PAGE ){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Tuple> item) {
|
||||
final PeerRequest request = item.getModelObject().peerRequest;
|
||||
final boolean isReviewable = item.getModelObject().isReviewable;
|
||||
final NotReviewableReason notReviewableReason = item.getModelObject().notReviewableReason;
|
||||
final String projectTitle = request.getProject().getTitle();
|
||||
final int daysToComplete = request.getProject().getProjectClass().getProjectClassSettings().getNumDaysToSubmitPeerReview();
|
||||
final int daysToComplete = projectClassSettings.getNumDaysToSubmitPeerReview();
|
||||
item.add(new Label("projectTitle", projectTitle ));
|
||||
item.add(new DateLabel("requestDate", new Model<Date>(request.getDateCreated()), dpc));
|
||||
item.add(request.getRequester().getUser().getDisplayComponent("requester"));
|
||||
|
||||
|
||||
Student requestingStudent = request.getRequester();
|
||||
Project requestingProject = request.getProject();
|
||||
Integer given = peerReviewDao.countReviewsGiven(requestingStudent, requestingProject);
|
||||
Integer received = peerReviewDao.countReviewsReceived(requestingStudent, requestingProject);
|
||||
item.add(new Label("given", given.toString() ));
|
||||
item.add(new Label("received", received.toString() ));
|
||||
|
||||
|
||||
Link<Void> templateLink = PeerReviewTemplatePreviewPage.getPopupLink("templateLink", request.getReviewTemplate() );
|
||||
|
||||
|
||||
templateLink.add(new Label("templateName", new Model<String>(){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -111,68 +122,112 @@ public class PeerPortalPanel extends Panel {
|
||||
return request.getReviewTemplate() != null ? request.getReviewTemplate().getName() : "No template attached";
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
templateLink.setEnabled(request.getReviewTemplate() != null);
|
||||
item.add(templateLink);
|
||||
|
||||
|
||||
if(request.getComment() != null){
|
||||
item.add(new ExpandableMultiLineLabel("requestComment", 50, request.getComment(), false));
|
||||
} else {
|
||||
item.add(new Label("requestComment", "No comment provided"));
|
||||
}
|
||||
|
||||
if(student != null && project != null){
|
||||
Link<Void> reviewLink = new Link<Void>("reviewLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
Link<Void> reviewLink = new Link<Void>("reviewLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return isReviewable;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return isReviewable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
try{
|
||||
PeerReview review = peerPortalController.acceptReview(request, student, project);
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PeerReview.PP_PEER_REVIEW_ID, review.getId());
|
||||
setResponsePage(ProjectPeerReviewPage.class, pp);
|
||||
} catch (UpdatedSincePageLoadException ue) {
|
||||
getSession().error("Another user has already accepted the request, please choose another one");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
} catch (Exception e){
|
||||
getSession().error("An error occured, please try again");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
}
|
||||
@Override
|
||||
public void onClick() {
|
||||
try{
|
||||
PeerReview review = peerPortalController.acceptReview(request, student, project);
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PeerReview.PP_PEER_REVIEW_ID, review.getId());
|
||||
setResponsePage(ProjectPeerReviewPage.class, pp);
|
||||
} catch (UpdatedSincePageLoadException ue) {
|
||||
error("Another user has already accepted the request, please choose another one");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
} catch (Exception e){
|
||||
error("An error occured, please try again");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
if(isReviewable){
|
||||
String confirmString = "Please confirm that you want to peer review \""+projectTitle+"\" within "+daysToComplete+" days.";
|
||||
confirmString = Strings.escapeMarkup(confirmString, true, true).toString();
|
||||
reviewLink.add(new JavascriptEventConfirmation("onClick", confirmString));
|
||||
|
||||
item.add(reviewLink);
|
||||
} else {
|
||||
item.add(new EmptyPanel("reviewLink"));
|
||||
}
|
||||
|
||||
item.add(new Label("notReviewableMsg", "You cannot review this request"){
|
||||
item.add(reviewLink);
|
||||
|
||||
Label notReviewableMsg = new Label("notReviewableMsg", "You cannot review this request"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return !isReviewable;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
item.add(notReviewableMsg);
|
||||
|
||||
if( notReviewableReason != null){
|
||||
notReviewableMsg.add( new SciProTooltipBehavior( notReviewableReason.toString() ) );
|
||||
}
|
||||
|
||||
add(item);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
add(requestList);
|
||||
|
||||
add(new MostFrequentReviewersPanel("mostFrequentPanel"));
|
||||
add(new BestRatedReviewersPanel("bestRatedPanel"));
|
||||
class RequestListNavigator extends PagingNavigator{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Boolean visible = null;
|
||||
|
||||
public RequestListNavigator(String id, org.apache.wicket.markup.html.navigation.paging.IPageable pageable) {
|
||||
super(id, pageable);
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
if(visible == null){
|
||||
if(REQUESTS_PER_PAGE > requestList.getViewSize()){
|
||||
visible = false;
|
||||
} else {
|
||||
visible = true;
|
||||
}
|
||||
}
|
||||
return visible;
|
||||
}
|
||||
@Override
|
||||
public void onDetach(){
|
||||
visible = null;
|
||||
super.onDetach();
|
||||
}
|
||||
}
|
||||
|
||||
PagingNavigator topRequestListNavigator = new RequestListNavigator("topNavigator", requestList);
|
||||
add(topRequestListNavigator);
|
||||
|
||||
PagingNavigator bottomRequestListNavigator = new RequestListNavigator("bottomNavigator", requestList);
|
||||
add(bottomRequestListNavigator);
|
||||
|
||||
GeneralSystemSettings gsettings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
final String mostFrequentPanel = "mostFrequentPanel";
|
||||
final String bestRatedContainer = "bestRatedContainer";
|
||||
|
||||
if(gsettings.isPeerDisplayNumberOfReviewsPerformed()){
|
||||
add(new MostFrequentReviewersPanel(mostFrequentPanel));
|
||||
} else {
|
||||
add(new InvisiblePanel(mostFrequentPanel));
|
||||
}
|
||||
if( gsettings.isPeerRatingsEnabled() ){
|
||||
add(new WebMarkupContainer(bestRatedContainer).add(new BestRatedReviewersPanel("bestRatedPanel") ) );
|
||||
} else {
|
||||
add(new InvisiblePanel(bestRatedContainer));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package se.su.dsv.scipro.peer.panels;
|
||||
|
||||
import org.apache.wicket.feedback.FeedbackMessage;
|
||||
import org.apache.wicket.feedback.IFeedbackMessageFilter;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
|
||||
@ -20,14 +18,7 @@ public class PeerReviewPanel extends Panel {
|
||||
add(new DisplayReviewPanel("displayReview", review));
|
||||
add(new CommentThreadPanel("comments",review, 4));
|
||||
|
||||
add(new FeedbackPanel("feedback", new IFeedbackMessageFilter() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean accept(FeedbackMessage message) {
|
||||
return message.getLevel() == FeedbackMessage.INFO;
|
||||
}
|
||||
}));
|
||||
add(new FeedbackPanel("feedback"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
<div class="span-12 last">
|
||||
<form wicket:id="reviewForm">
|
||||
<div wicket:id="topFeedbackPanel" class="last"></div>
|
||||
<!-- <div wicket:id="topFeedbackPanel" class="last"></div>-->
|
||||
|
||||
<div class="prepend-top last">
|
||||
<h5 class="peer-title" wicket:id="questionsHeading">Questions</h5>
|
||||
@ -24,8 +24,15 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<wicket:enclosure>
|
||||
<div class="last append-bottom">
|
||||
<h5 class="peer-title">General comments</h5>
|
||||
<h5 class="peer-title">Comment from requester</h5>
|
||||
<div wicket:id="requestComment"></div>
|
||||
</div>
|
||||
</wicket:enclosure>
|
||||
|
||||
<div class="last append-bottom">
|
||||
<h5 class="peer-title">Your comments</h5>
|
||||
<textarea wicket:id="reviewComment"></textarea>
|
||||
</div>
|
||||
<div class="last append-bottom">
|
||||
|
@ -10,6 +10,7 @@ import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.datetime.PatternDateConverter;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.MultiLineLabel;
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
@ -58,8 +59,7 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
// @SpringBean
|
||||
// private AnswerDao answerDao;
|
||||
|
||||
@SpringBean
|
||||
private PeerRequestDao peerRequestDao;
|
||||
|
||||
@ -166,6 +166,13 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
MultiLineLabel requestComment = new MultiLineLabel("requestComment", reviewModel.getObject().getPeerRequest().getComment());
|
||||
if(reviewModel.getObject().getPeerRequest().getComment() == null)
|
||||
requestComment.setVisible(false);
|
||||
add(requestComment);
|
||||
|
||||
|
||||
commentTextArea = new TextArea<String>("reviewComment", new PropertyModel<String>(reviewModel, "comment"));
|
||||
add(commentTextArea);
|
||||
|
||||
@ -276,7 +283,7 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
"Please confirm that you have completed the review and taken care to highlight both strengths and weaknesses."));
|
||||
add(submitButton);
|
||||
|
||||
add(new ComponentFeedbackPanel("topFeedbackPanel",submitButton));
|
||||
//add(new ComponentFeedbackPanel("topFeedbackPanel",submitButton));
|
||||
add(new ComponentFeedbackPanel("bottomFeedbackPanel",submitButton));
|
||||
}//PerformReviewForm
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
<li><strong>Accept date: </strong><span wicket:id="acceptDate">2011-03-08 10:58</span></li>
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div wicket:id="ratingPanelContainer">
|
||||
<strong>Review rating:</strong>
|
||||
<div wicket:id="ratingPanel"></div>
|
||||
</div>
|
||||
|
@ -4,19 +4,18 @@ import java.util.Date;
|
||||
|
||||
import org.apache.wicket.datetime.PatternDateConverter;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.components.InvisiblePanel;
|
||||
import se.su.dsv.scipro.data.DomainObjectDetachableModel;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.repository.components.FileDownloadLink;
|
||||
import se.su.dsv.scipro.repository.components.FileOpenLink;
|
||||
|
||||
public class ReviewPageReviewDetailsPanel extends Panel {
|
||||
|
||||
@ -24,6 +23,8 @@ public class ReviewPageReviewDetailsPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
public ReviewPageReviewDetailsPanel(final String id, final PeerReview review) {
|
||||
super(id);
|
||||
@ -36,7 +37,13 @@ public class ReviewPageReviewDetailsPanel extends Panel {
|
||||
add(review.getReviewer().getUser().getDisplayComponent("reviewer"));
|
||||
add(review.getProject().getHeadSupervisor().getUser().getDisplayComponent("supervisor"));
|
||||
add(new DateLabel("acceptDate", new Model<Date>(review.getDateCreated()), dpc));
|
||||
add(new PeerReviewRatingPanel("ratingPanel", reviewModel ));
|
||||
|
||||
final String ratingPanelContainer = "ratingPanelContainer";
|
||||
if(generalSystemSettingsDao.getGeneralSystemSettingsInstance().isPeerRatingsEnabled()){
|
||||
add(new WebMarkupContainer(ratingPanelContainer).add(new PeerReviewRatingPanel("ratingPanel", reviewModel )));
|
||||
} else {
|
||||
add(new InvisiblePanel(ratingPanelContainer));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,8 +29,11 @@ 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.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN}) //Temp for deployment
|
||||
public abstract class StudentPeerInfoRequestsPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -3,22 +3,10 @@
|
||||
*/
|
||||
package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
|
||||
import se.su.dsv.scipro.dataproviders.FinalSeminarAfterNowDataProvider;
|
||||
import se.su.dsv.scipro.dataproviders.FinalSeminarBeforeNowDataProvider;
|
||||
import se.su.dsv.scipro.dataproviders.FinalSeminarDataProvider;
|
||||
import se.su.dsv.scipro.opponent.panels.ChangeViewPanel;
|
||||
import se.su.dsv.scipro.opponent.panels.OpponentListViewPanel;
|
||||
|
||||
|
@ -5,17 +5,16 @@
|
||||
<wicket:extend>
|
||||
|
||||
<div class="span-22 last">
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
<div wicket:id=feedback></div>
|
||||
<!-- Left column -->
|
||||
|
||||
<div class="span-10 colborder">
|
||||
<div class="span-10 last">
|
||||
<h5 class="peer-title">Look for project partner</h5>
|
||||
<form wicket:id="exjobbsForm">
|
||||
<form wicket:id="projectPartnerForm">
|
||||
<label>Write about your fields of interest or thesis suggestions</label><br/>
|
||||
<textarea wicket:id="infoText" rows="8" cols="35"></textarea><br/>
|
||||
<div wicket:id="projectClass"></div>
|
||||
<a wicket:id="submit">Save</a>
|
||||
</form>
|
||||
</div>
|
||||
@ -23,32 +22,36 @@
|
||||
<!-- Right column -->
|
||||
<div class="span-10 last">
|
||||
<div class="span-10 last">
|
||||
<h5 class="peer-title">Students looking for project partners</h5>
|
||||
<ul wicket:id="listContainer">
|
||||
<li wicket:id="list">
|
||||
<table border="1">
|
||||
<h5 class="peer-title">Students looking for bachelor/master project partners</h5>
|
||||
<div wicket:id="showDegree"></div>
|
||||
<div wicket:id="listContainer">
|
||||
<div wicket:id="list" class="rounded-border">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<span wicket:id="exname" /></td>
|
||||
<td> <span wicket:id="exmail"/></td>
|
||||
<span wicket:id="exname"></span></td>
|
||||
<td><span wicket:id="exmail"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span wicket:id="exdate" />
|
||||
<span wicket:id="exdate"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span wicket:id="exinfoText"/>
|
||||
<span wicket:id="exinfoText"></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div wicket:id="navigator"></div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</wicket:extend>
|
||||
|
@ -1,30 +1,37 @@
|
||||
package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.basic.MultiLineLabel;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.form.SubmitLink;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.apache.wicket.util.convert.converters.DateConverter;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectPartnerDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
import se.su.dsv.scipro.dataproviders.ProjectPartnerDataProvider;
|
||||
|
||||
/**
|
||||
* @author Fredrik Norberg - fnorbe@dsv.su.se
|
||||
@ -34,29 +41,111 @@ import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
public class ProjectPartnerPage extends ProjectPage {
|
||||
|
||||
@SpringBean
|
||||
private ProjectPartnerDao ProjectPartnerDao;
|
||||
private ProjectPartnerDao projectPartnerDao;
|
||||
|
||||
@SpringBean
|
||||
private ProjectClassDao projectClassDao;
|
||||
|
||||
private ProjectClass selected;
|
||||
private ProjectClass show;
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
private GeneralSystemSettings settings;
|
||||
private int days;
|
||||
|
||||
private List<ProjectClass> choices;
|
||||
|
||||
private DataView<ProjectPartner> dataView;
|
||||
private WebMarkupContainer wmc;
|
||||
private IModel<List<ProjectPartner>> listModel;
|
||||
|
||||
private RadioChoice<ProjectClass> degreeChoice;
|
||||
private RadioChoice<ProjectClass> showChoice;
|
||||
private PagingNavigator pagingNavigator;
|
||||
|
||||
private ProjectPartnerDataProvider projectPartnerDataProvider;
|
||||
|
||||
public ProjectPartnerPage(PageParameters pp) {
|
||||
super(pp);
|
||||
add(new FeedbackPanel("feedback"));
|
||||
final Form<ProjectPartner> exjobbsForm = new Form<ProjectPartner>("exjobbsForm", new CompoundPropertyModel<ProjectPartner>(new ProjectPartner(SciProSession.get().getUser())));
|
||||
exjobbsForm.add(new TextArea<String>("infoText").setRequired(true));
|
||||
|
||||
final WebMarkupContainer wmc = new WebMarkupContainer("listContainer");
|
||||
|
||||
IModel<List<ProjectPartner>> listModel = new LoadableDetachableModel<List<ProjectPartner>>(){
|
||||
|
||||
selected = projectClassDao.getProjectClass(ProjectClass.BACHELOR);
|
||||
show = projectClassDao.getProjectClass(ProjectClass.BACHELOR);
|
||||
|
||||
settings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
choices = new ArrayList<ProjectClass>();
|
||||
days = settings.getProjectPartnerDaysToLive();
|
||||
ProjectClass bachelor = projectClassDao.getProjectClass(ProjectClass.BACHELOR);
|
||||
choices.add(bachelor);
|
||||
choices.add(projectClassDao.getProjectClass(ProjectClass.MASTER));
|
||||
|
||||
degreeChoice = new RadioChoice<ProjectClass>("projectClass", new PropertyModel<ProjectClass>(this, "selected"), choices);
|
||||
showChoice = new RadioChoice<ProjectClass>("showDegree", new PropertyModel<ProjectClass>(this, "show"), choices);
|
||||
|
||||
projectPartnerDataProvider = new ProjectPartnerDataProvider(show, settings.getProjectPartnerDaysToLive());
|
||||
|
||||
showChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() {
|
||||
private static final long serialVersionUID = -8845481792570653072L;
|
||||
|
||||
@Override
|
||||
protected List<ProjectPartner> load() {
|
||||
return ProjectPartnerDao.getProjectPartner();
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
|
||||
wmc.removeAll();
|
||||
projectPartnerDataProvider = new ProjectPartnerDataProvider(show, settings.getProjectPartnerDaysToLive());
|
||||
loadListView(projectPartnerDataProvider);
|
||||
wmc.add(dataView);
|
||||
pagingNavigator = new PagingNavigator("navigator", dataView);
|
||||
wmc.add(pagingNavigator);
|
||||
target.addComponent(wmc);
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
add(showChoice);
|
||||
add(new FeedbackPanel("feedback"));
|
||||
final Form<ProjectPartner> partnerForm = new Form<ProjectPartner>("projectPartnerForm", new CompoundPropertyModel<ProjectPartner>(new ProjectPartner(SciProSession.get().getUser())));
|
||||
partnerForm.add(new TextArea<String>("infoText").setRequired(true));
|
||||
partnerForm.add(degreeChoice.setRequired(true));
|
||||
|
||||
wmc = new WebMarkupContainer("listContainer");
|
||||
|
||||
|
||||
|
||||
wmc.add(new ListView<ProjectPartner>("list", listModel ){
|
||||
loadListView(projectPartnerDataProvider);
|
||||
wmc.add(dataView);
|
||||
wmc.setOutputMarkupId(true);
|
||||
pagingNavigator = new PagingNavigator("navigator", dataView);
|
||||
System.out.println(dataView.size());
|
||||
wmc.add(pagingNavigator);
|
||||
add(wmc);
|
||||
|
||||
|
||||
|
||||
partnerForm.add(new SubmitLink("submit"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onSubmit() {
|
||||
ProjectPartner ex = (ProjectPartner) partnerForm.getModelObject();
|
||||
ex.setProjectClass(selected);
|
||||
partnerForm.setDefaultModelObject(projectPartnerDao.save(ex));
|
||||
info("OK");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
add(partnerForm);
|
||||
}
|
||||
|
||||
private void loadListView(ProjectPartnerDataProvider projectPartnerDataProvider){
|
||||
dataView = new DataView<ProjectPartner>("list", projectPartnerDataProvider, 5 ){
|
||||
//wmc.add(new ListView<ProjectPartner>("list", new PropertyModel<List<ProjectPartner>>(this, "ProjectPartnerDao.getProjectPartner")){
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -64,39 +153,13 @@ public class ProjectPartnerPage extends ProjectPage {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<ProjectPartner> item) {
|
||||
//DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
//Date date = new Date();
|
||||
//df.format(date)
|
||||
ProjectPartner ex = item.getModelObject();
|
||||
protected void populateItem(Item<ProjectPartner> item) {
|
||||
item.add(new Label("exname", new PropertyModel<String>(item.getModel(), "user.toString")));
|
||||
item.add(new Label("exmail", new PropertyModel<String>(item.getModel(), "user.emailAddress")));
|
||||
//item.add(new /*datelabel*/Label("exdate", new PropertyModel<String>(item.getModel(), "dateCreated")));
|
||||
item.add(DateLabel.forDatePattern("exdate", new PropertyModel<Date>(item.getModel(), "dateCreated"), "yyyy.MM.dd HH:mm:ss"));
|
||||
item.add(new MultiLineLabel("exinfoText", new PropertyModel<String>(item.getModel(), "infoText")));
|
||||
}
|
||||
|
||||
});
|
||||
wmc.setOutputMarkupId(true);
|
||||
add(wmc);
|
||||
|
||||
|
||||
|
||||
exjobbsForm.add(new SubmitLink("submit"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onSubmit() {
|
||||
ProjectPartner ex = (ProjectPartner) exjobbsForm.getModelObject();
|
||||
exjobbsForm.setDefaultModelObject(ProjectPartnerDao.save(ex));
|
||||
info("OK");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
add(exjobbsForm);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,10 @@ package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.exceptions.AccessDeniedException;
|
||||
import se.su.dsv.scipro.exceptions.PageNotFoundException;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
public abstract class ProjectSchedulePage extends ProjectPage {
|
||||
|
||||
|
@ -3,7 +3,6 @@ package se.su.dsv.scipro.project.pages;
|
||||
import org.apache.wicket.Page;
|
||||
import org.apache.wicket.PageParameters;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.schedule.panels.SchedulePlannerPanel;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
@ -0,0 +1,37 @@
|
||||
<!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">Students looking for bachelor/master project partners</h5>
|
||||
<div wicket:id="showDegree"></div>
|
||||
<div wicket:id="listContainer">
|
||||
<div wicket:id="list" class="rounded-border">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<span wicket:id="exname"></span></td>
|
||||
<td> <span wicket:id="exmail"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span wicket:id="exdate" ></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span wicket:id="exinfoText"></span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" wicket:id="delete"><img src="images/icons/delete_16x16.png" alt="Delete" title="Delete"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div wicket:id="navigator"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,144 @@
|
||||
package se.su.dsv.scipro.project.panels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.basic.MultiLineLabel;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectPartnerDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
import se.su.dsv.scipro.dataproviders.ProjectPartnerDataProvider;
|
||||
|
||||
public class ProjectPartnerPanel extends Panel {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8794584017796136654L;
|
||||
|
||||
@SpringBean
|
||||
private ProjectPartnerDao projectPartnerDao;
|
||||
|
||||
@SpringBean
|
||||
private ProjectClassDao projectClassDao;
|
||||
|
||||
private ProjectClass show;
|
||||
private List<ProjectClass> choices;
|
||||
private IModel<List<ProjectPartner>> listModel;
|
||||
private RadioChoice<ProjectClass> showChoice;
|
||||
private WebMarkupContainer wmc;
|
||||
private DataView<ProjectPartner> dataView;
|
||||
private PagingNavigator pagingNavigator;
|
||||
private ProjectPartnerDataProvider projectPartnerDataProvider;
|
||||
|
||||
public ProjectPartnerPanel(String id) {
|
||||
super(id);
|
||||
|
||||
show = projectClassDao.getProjectClass(ProjectClass.BACHELOR);
|
||||
showChoice = new RadioChoice<ProjectClass>("showDegree", new PropertyModel<ProjectClass>(this, "show"), choices);
|
||||
choices = new ArrayList<ProjectClass>();
|
||||
choices.add(projectClassDao.getProjectClass(ProjectClass.BACHELOR));
|
||||
choices.add(projectClassDao.getProjectClass(ProjectClass.MASTER));
|
||||
|
||||
showChoice = new RadioChoice<ProjectClass>("showDegree", new PropertyModel<ProjectClass>(this, "show"), choices);
|
||||
|
||||
projectPartnerDataProvider = new ProjectPartnerDataProvider(show, 0);
|
||||
|
||||
showChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() {
|
||||
private static final long serialVersionUID = -8845481792570653072L;
|
||||
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
|
||||
projectPartnerDataProvider = new ProjectPartnerDataProvider(show, 0);
|
||||
wmc.removeAll();
|
||||
loadDataView(projectPartnerDataProvider);
|
||||
pagingNavigator = new PagingNavigator("navigator", dataView);
|
||||
wmc.add(dataView);
|
||||
wmc.add(pagingNavigator);
|
||||
target.addComponent(wmc);
|
||||
}
|
||||
});
|
||||
|
||||
add(showChoice);
|
||||
wmc = new WebMarkupContainer("listContainer");
|
||||
|
||||
listModel = new LoadableDetachableModel<List<ProjectPartner>>(){
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4397997418096384845L;
|
||||
|
||||
@Override
|
||||
protected List<ProjectPartner> load() {
|
||||
return projectPartnerDao.getProjectPartnerInSpan(show, 0, 1, 5);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
wmc.setOutputMarkupId(true);
|
||||
|
||||
pagingNavigator = new PagingNavigator("navigator", dataView);
|
||||
|
||||
loadDataView(projectPartnerDataProvider);
|
||||
wmc.add(dataView);
|
||||
pagingNavigator = new PagingNavigator("navigator", dataView);
|
||||
wmc.add(pagingNavigator);
|
||||
|
||||
add(wmc);
|
||||
}
|
||||
|
||||
private void loadDataView(ProjectPartnerDataProvider projectPartnerDataProvider){
|
||||
dataView = new DataView<ProjectPartner>("list", projectPartnerDataProvider, 5 ){
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(final Item<ProjectPartner> item) {
|
||||
item.add(new Label("exname", new PropertyModel<String>(item.getModel(), "user.toString")));
|
||||
item.add(new Label("exmail", new PropertyModel<String>(item.getModel(), "user.emailAddress")));
|
||||
item.add(DateLabel.forDatePattern("exdate", new PropertyModel<Date>(item.getModel(), "dateCreated"), "yyyy.MM.dd HH:mm:ss"));
|
||||
item.add(new MultiLineLabel("exinfoText", new PropertyModel<String>(item.getModel(), "infoText")));
|
||||
item.add(new AjaxLink<Void>("delete") {
|
||||
|
||||
private static final long serialVersionUID = 1529565679210978293L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
ProjectPartner temp = item.getModelObject();
|
||||
|
||||
projectPartnerDao.delete(temp);
|
||||
|
||||
listModel.detach();
|
||||
|
||||
target.addComponent(wmc);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
@ -101,8 +101,9 @@ public class ProjectWallPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
|
||||
boardMessageDao.delete(boardMessageDao.reLoad(bm));
|
||||
|
||||
BoardMessage boardMessageTemp = boardMessageDao.reLoad(bm);
|
||||
boardMessageDao.delete(boardMessageTemp);
|
||||
webMarkupContainer.removeAll();
|
||||
loadUserDataView(new BoardMessageDataProvider(
|
||||
messageBoardDao.reLoad(messageBoard)));
|
||||
@ -194,13 +195,9 @@ public class ProjectWallPanel extends Panel {
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
BoardMessage bm = new BoardMessage();
|
||||
bm.setMessage(message);
|
||||
bm.setMessageBoard(messageBoardDao.reLoad(messageBoard));
|
||||
bm.setFromUser(SciProSession.get().getUser());
|
||||
bm = boardMessageDao.save(bm);
|
||||
SortedSet<BoardMessage> boardMessageList = messageBoard
|
||||
.getBoardMessageSet();
|
||||
boardMessageList.add(bm);
|
||||
messageBoard.setBoardMessageSet(boardMessageList);
|
||||
messageBoard = messageBoardDao.save(messageBoard);
|
||||
webMarkupContainer.removeAll();
|
||||
loadUserDataView(new BoardMessageDataProvider(
|
||||
messageBoardDao.reLoad(messageBoard)));
|
||||
|
@ -19,6 +19,8 @@ import se.su.dsv.scipro.repository.util.FileStorageException;
|
||||
public class FileDownloadLink extends BookmarkablePageLink<FileDescription> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final boolean defaultHideOnDeadLink = true;
|
||||
|
||||
@SpringBean
|
||||
private FileRepository fileRepository;
|
||||
@ -37,7 +39,7 @@ public class FileDownloadLink extends BookmarkablePageLink<FileDescription> {
|
||||
* @param fileDescription
|
||||
*/
|
||||
public FileDownloadLink(String id, final FileDescription fileDescription) {
|
||||
this(id, new Model<FileDescription>(fileDescription), false);
|
||||
this(id, new Model<FileDescription>(fileDescription), defaultHideOnDeadLink);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +48,7 @@ public class FileDownloadLink extends BookmarkablePageLink<FileDescription> {
|
||||
* @param model
|
||||
*/
|
||||
public FileDownloadLink(String id, IModel<FileDescription> model) {
|
||||
this(id, model, false);
|
||||
this(id, model, defaultHideOnDeadLink);
|
||||
}
|
||||
/**
|
||||
* Use this constructor if possible instead of the one taking a FileDescription
|
||||
@ -73,7 +75,7 @@ public class FileDownloadLink extends BookmarkablePageLink<FileDescription> {
|
||||
if( hideOnNullOrDeadLink )
|
||||
this.setVisible(false);
|
||||
Logger logger = Logger.getLogger("Application");
|
||||
logger.log(Level.WARN, "Instantiating dead "+this.getClass().getSimpleName()+" pointing to path: "+model.getObject().getPath() );
|
||||
logger.log(Level.WARN, "Instantiating dead "+this.getClass().getName()+" pointing to path: "+model.getObject().getPath() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import se.su.dsv.scipro.repository.util.FileStorageException;
|
||||
public class FileOpenLink extends ResourceLink<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final boolean defaultHideOnDeadLink = true;
|
||||
|
||||
@SpringBean
|
||||
private FileRepository fileRepository;
|
||||
@ -36,7 +37,7 @@ public class FileOpenLink extends ResourceLink<Void> {
|
||||
* @param fileDescription
|
||||
*/
|
||||
public FileOpenLink(String id, final FileDescription fileDescription) {
|
||||
this(id, new Model<FileDescription>(fileDescription), false);
|
||||
this(id, new Model<FileDescription>(fileDescription), defaultHideOnDeadLink);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +55,7 @@ public class FileOpenLink extends ResourceLink<Void> {
|
||||
* @param model
|
||||
*/
|
||||
public FileOpenLink(String id, final IModel<FileDescription> model) {
|
||||
this(id, model, false);
|
||||
this(id, model, defaultHideOnDeadLink);
|
||||
}
|
||||
/**
|
||||
* Use this constructor if possible instead of the one taking a FileDescription
|
||||
@ -81,7 +82,7 @@ public class FileOpenLink extends ResourceLink<Void> {
|
||||
if( hideOnNullOrDeadLink )
|
||||
this.setVisible(false);
|
||||
Logger logger = Logger.getLogger("Application");
|
||||
logger.log(Level.WARN, "Instantiating dead "+this.getClass().getSimpleName()+" pointing to path: "+model.getObject().getPath() );
|
||||
logger.log(Level.WARN, "Instantiating dead "+this.getClass().getName()+" pointing to path: "+model.getObject().getPath() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,8 +115,10 @@ public class FileOpenLink extends ResourceLink<Void> {
|
||||
in = fileRepository.retrieveFileByIdentifier(fileDesc.getIdentifier());
|
||||
return in;
|
||||
}
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
in.close();
|
||||
if( in != null )
|
||||
in.close();
|
||||
}
|
||||
@Override
|
||||
public long length(){
|
||||
|
@ -33,7 +33,6 @@ public class RepositoryDownloadPage extends WebPage {
|
||||
failAndRedirect();
|
||||
|
||||
String uuid = pp.getString(PP_KEY);
|
||||
//System.out.println("Attempting to download:"+uuid);
|
||||
try{
|
||||
FileDescription fd = fileRepository.retrieveFileDescriptionByIdentifier(uuid);
|
||||
IResourceStream stream = fileRepository.getFileStream(fd);
|
||||
|
@ -22,8 +22,6 @@ public class ProjectFilePanel extends AbstractFilePanel {
|
||||
|
||||
private long projectId;
|
||||
|
||||
private static final String PROJECT_URL_KEY = "id";
|
||||
|
||||
@Override
|
||||
protected String getBasePath(){
|
||||
return super.fileRepository.getProjectRootPath(projectId);
|
||||
@ -36,7 +34,7 @@ public class ProjectFilePanel extends AbstractFilePanel {
|
||||
public ProjectFilePanel(String id, PageParameters pp, FilePanelContainer fpc) {
|
||||
super(id, pp, fpc);
|
||||
|
||||
Long projectId = pp.getAsLong(PROJECT_URL_KEY);
|
||||
Long projectId = pp.getAsLong(Project.PP_PROJECT_ID);
|
||||
if(projectId == null){
|
||||
failAndRedirect();
|
||||
}
|
||||
@ -60,13 +58,13 @@ public class ProjectFilePanel extends AbstractFilePanel {
|
||||
|
||||
public static PageParameters getPrefabricatedPageParameters(Project project){
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PROJECT_URL_KEY, project.getId());
|
||||
pp.put(Project.PP_PROJECT_ID, project.getId());
|
||||
return pp;
|
||||
}
|
||||
|
||||
public static PageParameters getPrefabricatedPageParameters(Long projectId){
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PROJECT_URL_KEY, projectId);
|
||||
pp.put(Project.PP_PROJECT_ID, projectId);
|
||||
return pp;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user