fixed conflicts

This commit is contained in:
Fredrik Friis 2012-03-28 12:09:28 +09:00
commit f07d362242
18 changed files with 363 additions and 25 deletions

55
pom.xml

@ -19,6 +19,11 @@
<url>http://wiquery.googlecode.com/svn/repo/</url>
<layout>default</layout>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://repo.springsource.org/libs-milestone</url>
</repository>
</repositories>
<dependencies>
<!-- WICKET DEPENDENCIES -->
@ -115,7 +120,11 @@
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${org.springframework.data.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
@ -123,6 +132,31 @@
<scope>runtime</scope>
</dependency>
<!--QueryDSL-->
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
<exclusions>
<exclusion>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<groupId>org.hibernate.javax.persistence</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>
<!-- JPA -->
<!-- Hibernate impl -->
<dependency>
@ -361,6 +395,23 @@
</configuration>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
<!--
&lt;!&ndash; Used for deploying directly from Maven/Eclipse &ndash;&gt;
<plugin>
@ -412,6 +463,8 @@
<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>
<org.springframework.data.version>1.0.3.RELEASE</org.springframework.data.version>
<querydsl.version>2.3.3</querydsl.version>
</properties>
<profiles>

@ -1,3 +1,4 @@
package se.su.dsv.scipro.admin.pages;
import java.util.ArrayList;

@ -29,7 +29,8 @@ public abstract class AbstractAdminStatisticsPage extends AbstractAdminPage {
protected List<MenuItem> getItemList() {
final List<MenuItem> items = new ArrayList<MenuItem>();
items.add(new MenuItem("Supervisor keywords", AdminSupervisorKeywordsPage.class));
items.add(new MenuItem("Application periods", AdminProjectIdeaStatisticPage.class));
items.add(new MenuItem("Application periods", AdminApplicationPeriodStatisticPage.class));
items.add(new MenuItem("Project idea", AdminProjectIdeaStatisticsPage.class));
return items;
}

@ -0,0 +1,17 @@
package se.su.dsv.scipro.admin.pages;
import org.apache.wicket.PageParameters;
import se.su.dsv.scipro.admin.panels.AdminApplicationPeriodStatisticPanel;
import se.su.dsv.scipro.security.auth.Authorization;
import se.su.dsv.scipro.security.auth.roles.Roles;
@Authorization(authorizedRoles={Roles.ADMIN})
public class AdminApplicationPeriodStatisticPage extends AbstractAdminStatisticsPage {
public AdminApplicationPeriodStatisticPage(PageParameters pp) {
super(pp);
add(new AdminApplicationPeriodStatisticPanel("projectIdeaStatisticPanel"));
}
}

@ -1,19 +0,0 @@
package se.su.dsv.scipro.admin.pages;
import org.apache.wicket.PageParameters;
import se.su.dsv.scipro.admin.pages.AbstractAdminStatisticsPage;
import se.su.dsv.scipro.admin.panels.AdminProjectIdeaStatisticPanel;
import se.su.dsv.scipro.admin.panels.match.AdminSupervisorKeywordPanel;
import se.su.dsv.scipro.security.auth.Authorization;
import se.su.dsv.scipro.security.auth.roles.Roles;
@Authorization(authorizedRoles={Roles.ADMIN})
public class AdminProjectIdeaStatisticPage extends AbstractAdminStatisticsPage {
public AdminProjectIdeaStatisticPage(PageParameters pp) {
super(pp);
add(new AdminProjectIdeaStatisticPanel("projectIdeaStatisticPanel"));
}
}

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<body>
<wicket:extend>
<div wicket:id="projectIdeaStatisticsPanel"></div>
</wicket:extend>
</body>
</html>

@ -0,0 +1,19 @@
package se.su.dsv.scipro.admin.pages;
import org.apache.wicket.PageParameters;
import se.su.dsv.scipro.admin.panels.ProjectIdeaStatisticsPanel;
import se.su.dsv.scipro.security.auth.Authorization;
import se.su.dsv.scipro.security.auth.roles.Roles;
/**
* @author: fred-fri
* date: 2012 03 26
*/
@Authorization(authorizedRoles={Roles.ADMIN})
public class AdminProjectIdeaStatisticsPage extends AbstractAdminStatisticsPage {
public AdminProjectIdeaStatisticsPage(PageParameters pp) {
super(pp);
add(new ProjectIdeaStatisticsPanel("projectIdeaStatisticsPanel"));
// add(new AdminApplicationPeriodStatisticPanel("projectIdeaStatisticPanel"));
}
}

@ -14,7 +14,7 @@ import se.su.dsv.scipro.match.dataprovider.ProjectIdeaStatisticDataProvider;
import java.util.List;
public class AdminProjectIdeaStatisticPanel extends Panel {
public class AdminApplicationPeriodStatisticPanel extends Panel {
private static final long serialVersionUID = 1L;
@ -28,7 +28,7 @@ public class AdminProjectIdeaStatisticPanel extends Panel {
private PagingNavigator nav;
public AdminProjectIdeaStatisticPanel(String str) {
public AdminApplicationPeriodStatisticPanel(String str) {
super(str);
setup();
setupDataview();

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<body>
<wicket:panel>
<div>
<table class="rounded-corner">
<thead>
<tr>
<th class="rounded-left-top">Status</th>
<th>Total</th>
<th>Bachelor</th>
<th class="rounded-right-top">Master</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" class="rounded-foot">&nbsp;</td>
</tr>
</tfoot>
<tbody>
<tr wicket:id="listview">
<td wicket:id="statusNameLabel"></td>
<td wicket:id="statusCountLabel"></td>
<td wicket:id="bachelorCountLabel"></td>
<td wicket:id="masterCountLabel"></td>
</tr>
</tbody>
</table>
</div>
<!--<div wicket:id="listview">-->
<!--<div><span wicket:id="statusNameLabel"></span> <span wicket:id="statusCountLabel"></span></div>-->
<!--</div>-->
<!--<div wicket:id="container">-->
<!--<table class="rounded-corner">-->
<!--<thead>-->
<!--<tr>-->
<!--<th class="rounded-left-top">Application period</th><th>End date</th><th>Number of students</th><th>Number of project ideas</th>-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody>-->
<!--<tr wicket:id="periodList">-->
<!--&lt;!&ndash; <td><span wicket:id="name"></span></</td> &ndash;&gt;-->
<!--<td wicket:id="applicationPeriodName"></td>-->
<!--<td wicket:id="applicationPeriodEndDate"></td>-->
<!--<td wicket:id="numberOfStudents"></td>-->
<!--<td wicket:id="numberOfPIs"></td>-->
<!--</tr>-->
<!--</tbody>-->
<!--<tfoot>-->
<!--<tr>-->
<!--<td colspan="6" class="rounded-foot">&nbsp;</td>-->
<!--</tr>-->
<!--</tfoot>-->
<!--</table>-->
<!--</div>-->
<!--<div wicket:id="nav"></div>-->
</wicket:panel>
</body>
</html>

@ -0,0 +1,81 @@
package se.su.dsv.scipro.admin.panels;
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.Panel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
import se.su.dsv.scipro.match.dataobject.Match;
import se.su.dsv.scipro.springdata.repos.ProjectClassRepo;
import se.su.dsv.scipro.springdata.repos.ProjectIdeaRepo;
import se.su.dsv.scipro.springdata.services.ProjectIdeaService;
import java.util.ArrayList;
import static se.su.dsv.scipro.match.dataobject.Match.Status;
/**
* @author: fred-fri
* date: 2012 03 26
*/
public class ProjectIdeaStatisticsPanel extends Panel {
private static final long serialVersionUID = -8964934681195275340L;
@SpringBean
private ProjectIdeaRepo projectIdeaRepo;
@SpringBean
private ProjectIdeaService projectIdeaService;
@SpringBean
private ProjectClassRepo projectClassRepo;
public ProjectIdeaStatisticsPanel(String id) {
super(id);
ArrayList<Status> valueArray = new ArrayList<Status>();
for (Status s : Status.values()) {
valueArray.add(s);
}
final ProjectClass bachelor = projectClassRepo.findByName(ProjectClass.BACHELOR);
final ProjectClass master = projectClassRepo.findByName(ProjectClass.MASTER);
ListView listview = new ListView("listview", valueArray) {
protected void populateItem(ListItem item) {
Status s = (Status) item.getModelObject();
if (s.equals(Match.Status.CONFIRMED)){
item.add(new Label("statusNameLabel", item.getModelObject() + " (accepted by supervisor)"));
}
else if (s.equals(Match.Status.PUBLISHED)){
item.add(new Label("statusNameLabel", item.getModelObject() + " (suggested to supervisor)"));
}
else if (s.equals(Match.Status.INACTIVE)){
item.add(new Label("statusNameLabel", item.getModelObject() + " (e.g. cancelled)"));
}
else if (s.equals(Match.Status.REFUSED)){
item.add(new Label("statusNameLabel", item.getModelObject() + " (poorly written, sent back to author(s) for rewriting)"));
}
else if (s.equals(Match.Status.REJECTED)){
item.add(new Label("statusNameLabel", item.getModelObject() + " (e.g. declined by supervisor)"));
}
else if (s.equals(Match.Status.UNMATCHED)){
item.add(new Label("statusNameLabel", item.getModelObject() + " (waiting to be matched)"));
}
else if (s.equals(Match.Status.PENDING)){
item.add(new Label("statusNameLabel", item.getModelObject() + " (this status is almost never used)"));
}
item.add(new Label("statusCountLabel", String.valueOf(projectIdeaService.countProjectIdeaByMatchStatus(s))));
item.add(new Label("bachelorCountLabel", String.valueOf(projectIdeaService.countProjectIdeaByMatchStatusAndProjectClass(s, bachelor))));
item.add(new Label("masterCountLabel", String.valueOf(projectIdeaService.countProjectIdeaByMatchStatusAndProjectClass(s, master))));
}
};
add(listview);
}
}

@ -0,0 +1,17 @@
package se.su.dsv.scipro.springdata.repos;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.transaction.annotation.Transactional;
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
/**
* @author: fred-fri
* date: 2012 03 26
*/
@Transactional(readOnly = true)
public interface ProjectClassRepo extends JpaRepository<ProjectClass, Long>, QueryDslPredicateExecutor<ProjectClass> {
ProjectClass findByName(String name);
}

@ -0,0 +1,18 @@
package se.su.dsv.scipro.springdata.repos;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.transaction.annotation.Transactional;
import se.su.dsv.scipro.match.dataobject.ProjectIdea;
/**
* @author: fred-fri
* date: 2012 03 23
*/
@Transactional(readOnly = true)
public interface ProjectIdeaRepo extends JpaRepository<ProjectIdea, Long>, QueryDslPredicateExecutor<ProjectIdea> {
//nothing here yet
}

@ -0,0 +1,47 @@
package se.su.dsv.scipro.springdata.serviceimpls;
import com.mysema.query.types.expr.BooleanExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
import se.su.dsv.scipro.match.dataobject.Match;
import se.su.dsv.scipro.match.dataobject.QProjectIdea;
import se.su.dsv.scipro.springdata.repos.ProjectIdeaRepo;
import se.su.dsv.scipro.springdata.services.ProjectIdeaService;
/**
* @author: fred-fri
* date: 2012 03 26
*/
@Repository("projectIdeaService")
@Transactional(readOnly = true)
public class ProjectIdeaServiceImpl implements ProjectIdeaService {
@Qualifier("projectIdeaRepo")
@Autowired
private ProjectIdeaRepo projectIdeaRepo;
public ProjectIdeaServiceImpl(){
System.out.println("BLA BLA");
}
@Override
public Long countProjectIdeaByMatchStatus(Match.Status status) {
QProjectIdea qProjectIdea = QProjectIdea.projectIdea;
BooleanExpression isMatchStatus = qProjectIdea.match.status.eq(status);
return projectIdeaRepo.count(isMatchStatus);
}
@Override
public Long countProjectIdeaByMatchStatusAndProjectClass(Match.Status status, ProjectClass projectClass) {
QProjectIdea qProjectIdea = QProjectIdea.projectIdea;
BooleanExpression isMatchStatus = qProjectIdea.match.status.eq(status);
BooleanExpression isProjectClass = qProjectIdea.projectClass.eq(projectClass);
return projectIdeaRepo.count(isMatchStatus.and(isProjectClass));
}
}

@ -0,0 +1,16 @@
package se.su.dsv.scipro.springdata.services;
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
import se.su.dsv.scipro.match.dataobject.Match;
/**
* @author: fred-fri
* date: 2012 03 26
*/
public interface ProjectIdeaService {
public Long countProjectIdeaByMatchStatus(Match.Status status);
public Long countProjectIdeaByMatchStatusAndProjectClass(Match.Status status, ProjectClass projectClass);
}

@ -1,13 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
default-autowire="byType">
<jpa:repositories base-package="se.su.dsv.scipro.springdata" />
<!-- Sets up spring autowire configuration based on annotations -->
<context:annotation-config/>
<context:component-scan base-package="se.su.dsv.scipro"/>

@ -1,9 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
default-autowire="byName" default-lazy-init="true">
<jpa:repositories base-package="se.su.dsv.scipro.springdata" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitName" value="testPersistenceUnit"/>