added info box with target numbers and current numbers to supervisor project idea start page
This commit is contained in:
parent
d3d44f403e
commit
aa25711278
src/main/java/se/su/dsv/scipro
@ -250,4 +250,9 @@ public class SupervisorIdeaServiceImpl extends AbstractQueryService<SupervisorId
|
||||
return supervisorIdeaRepo.count(byStatus(status));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countIdeas(IdeaStatus status, Employee supervisor, ProjectClass pc) {
|
||||
return supervisorIdeaRepo.count(byStatus(status).and(bySupervisor(supervisor)).and(byLevel(pc)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,27 @@
|
||||
package se.su.dsv.scipro.springdata.serviceimpls;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.springdata.repos.SupervisorRepo;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.match.dataobject.Idea.IdeaStatus;
|
||||
import se.su.dsv.scipro.springdata.repos.SupervisorRepo;
|
||||
import se.su.dsv.scipro.springdata.services.ProjectClassService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorIdeaService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
@Service ( "supervisorService" )
|
||||
@Transactional ( readOnly = true )
|
||||
@ -22,7 +29,11 @@ public class SupervisorServiceImpl extends AbstractQueryService<Employee, Long>
|
||||
|
||||
@Resource
|
||||
private SupervisorRepo supervisorRepo;
|
||||
|
||||
@Resource
|
||||
private ProjectClassService projectClassService;
|
||||
@Resource
|
||||
private SupervisorIdeaService ideaService;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@ -116,4 +127,20 @@ public class SupervisorServiceImpl extends AbstractQueryService<Employee, Long>
|
||||
public Employee findByUser(User user) {
|
||||
return supervisorRepo.findByUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Availability> getAvailabilities(Employee supervisor) {
|
||||
List<Availability> list = new ArrayList<Availability>();
|
||||
for(ProjectClass pc : projectClassService.findAllActive())
|
||||
list.add(getAvailability(supervisor, pc));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Availability getAvailability(Employee supervisor, ProjectClass pc) {
|
||||
Integer projectLimit = supervisor.getCapabilities().getProjectLimit(pc);
|
||||
long activeProjectIdeas = ideaService.countIdeas(IdeaStatus.TAKEN, supervisor, pc);
|
||||
return new Availability(supervisor, activeProjectIdeas, projectLimit, pc);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public interface SupervisorIdeaService extends GenericService<SupervisorIdea, Lo
|
||||
List<SupervisorIdea> findIdeas(IdeaStatus status, Student author, boolean confirmed);
|
||||
|
||||
Long countByStatus(IdeaStatus status);
|
||||
Long countIdeas(IdeaStatus status, Employee supervisor, ProjectClass pc);
|
||||
|
||||
void saveSupervisorCreatedIdea(IModel<SupervisorIdea> model, Employee creator, SortedSet<Student> students);
|
||||
void deleteWaitingIdea(IModel<SupervisorIdea> model);
|
||||
|
@ -1,10 +1,12 @@
|
||||
package se.su.dsv.scipro.springdata.services;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
|
||||
/**
|
||||
* fred-fri
|
||||
* date: 2012 03 26
|
||||
@ -15,4 +17,7 @@ public interface SupervisorService extends GenericService<Employee,Long>, QueryS
|
||||
public List<Employee> findSupervisorBySQL(String keywordTypeName, String sortOrder);
|
||||
|
||||
public Employee findByUser(User user);
|
||||
|
||||
List<Availability> getAvailabilities(Employee supervisor);
|
||||
Availability getAvailability(Employee supervisor, ProjectClass pc);
|
||||
}
|
||||
|
@ -3,11 +3,8 @@
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div class="info-box rounded-box last">
|
||||
This info box should contain information about the current application period,
|
||||
the supervisors target numbers and the supervisors current number of supervisions
|
||||
</div>
|
||||
<div wicket:id="feedback"></div>
|
||||
<div wicket:id="feedback"></div>
|
||||
<div wicket:id="availabilityPanel" class="append-bottom"></div>
|
||||
<button wicket:id="ideaLink">Create new project idea</button>
|
||||
<div class="prepend-top" wicket:id="ideaPanel"></div>
|
||||
</wicket:extend>
|
||||
|
@ -7,6 +7,7 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.supervisor.panels.SupervisorAvailabilityPanel;
|
||||
import se.su.dsv.scipro.supervisor.panels.SupervisorProjectIdeaOverviewPanel;
|
||||
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN})
|
||||
@ -18,6 +19,7 @@ public class SupervisorProjectIdeaStartPage extends AbstractSupervisorProjectIde
|
||||
super(pp);
|
||||
add(feedbackPanel = new FeedbackPanel("feedback"));
|
||||
feedbackPanel.setOutputMarkupId(true);
|
||||
add(new SupervisorAvailabilityPanel("availabilityPanel", getUser()));
|
||||
add(new SupervisorProjectIdeaOverviewPanel("ideaPanel", getUser()));
|
||||
addSubmissionPageLink();
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div class="info-box rounded-box last">
|
||||
<p>Application period is open from xxxx-xx-xx to xxxx-xx-xx and the course start for the application period is xxxx-xx-xx</p>
|
||||
<p>
|
||||
According to the settings entered by admin, you should supervise <span wicket:id="targets"></span> projects.
|
||||
</p>
|
||||
You are currently supervising <span wicket:id="current"></span> projects.
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,40 @@
|
||||
package se.su.dsv.scipro.supervisor.panels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class SupervisorAvailabilityPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = -9010467449322120267L;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
public SupervisorAvailabilityPanel(String id, final User loggedInUser) {
|
||||
super(id);
|
||||
Employee supervisor = supervisorService.findByUser(loggedInUser);
|
||||
List<Availability> targets = supervisorService.getAvailabilities(supervisor);
|
||||
List<String> targetStrings = new ArrayList<String>();
|
||||
List<String> takenStrings = new ArrayList<String>();
|
||||
for(Availability a : targets) {
|
||||
targetStrings.add(a.getNumCapable() + " " + a.getProjectClass().getName().toLowerCase());
|
||||
takenStrings.add(a.getNumMatched() + " " + a.getProjectClass().getName().toLowerCase());
|
||||
}
|
||||
add(new Label("targets", Joiner.on(", ").join(targetStrings)));
|
||||
add(new Label("current", Joiner.on(", ").join(takenStrings)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user