Merge branch 'target' into develop
This commit is contained in:
commit
88c53ac8d6
resources/db_update_scripts
src/main
java/se/su/dsv/scipro
data/dataobjects
match
resources/META-INF
@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS `Employee_countActiveFromDates` (
|
||||
`Employee_id` bigint(20) NOT NULL,
|
||||
`countActiveFromDates` datetime DEFAULT NULL,
|
||||
`countActiveFromDates_KEY` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`Employee_id`,`countActiveFromDates_KEY`),
|
||||
KEY `FK5183E457A4585B4A` (`countActiveFromDates_KEY`),
|
||||
KEY `FK5183E4575FCBC05F` (`Employee_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
ALTER TABLE `Employee_countActiveFromDates`
|
||||
ADD CONSTRAINT `FK5183E4575FCBC05F` FOREIGN KEY (`Employee_id`) REFERENCES `role` (`id`),
|
||||
ADD CONSTRAINT `FK5183E457A4585B4A` FOREIGN KEY (`countActiveFromDates_KEY`) REFERENCES `project_class` (`id`);
|
@ -1,12 +1,14 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Embeddable;
|
||||
@ -19,6 +21,7 @@ import javax.persistence.ManyToMany;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.dataproviders.SortableField;
|
||||
import se.su.dsv.scipro.match.dataobject.Keywords;
|
||||
|
||||
/**
|
||||
@ -30,8 +33,27 @@ import se.su.dsv.scipro.match.dataobject.Keywords;
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class Employee extends ProjectTeamMember {
|
||||
|
||||
@ElementCollection(fetch=FetchType.EAGER)
|
||||
private Map<ProjectClass, Date> countActiveFromDates =
|
||||
new HashMap<ProjectClass, Date>();
|
||||
|
||||
public Map<ProjectClass, Date> getCountActiveFromDates() {
|
||||
return countActiveFromDates;
|
||||
}
|
||||
|
||||
@Embedded
|
||||
public void setCountActiveFromDates(Map<ProjectClass, Date> countActiveFromDates) {
|
||||
this.countActiveFromDates = countActiveFromDates;
|
||||
}
|
||||
|
||||
public Date getCountFromDate(ProjectClass projectClass){
|
||||
return countActiveFromDates.get(projectClass);
|
||||
}
|
||||
|
||||
public void setCountFromDate(ProjectClass projectClass, Date date){
|
||||
countActiveFromDates.put(projectClass, date);
|
||||
}
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(name="languages", joinTable=@JoinTable(name="Employee_Language"))
|
||||
private Capabilities capabilities = new Capabilities();
|
||||
|
||||
|
@ -25,8 +25,12 @@ public interface SupervisorDao extends QueryableDao<Employee, SupervisorDaoParam
|
||||
Employee getOrCreate(User user);
|
||||
|
||||
List<Availability> getAvailability();
|
||||
|
||||
// List<Availability> getAvailability2();
|
||||
|
||||
Availability getAvailability(Employee supervisor, ProjectClass projectClass);
|
||||
|
||||
void setAvailability(Availability availability);
|
||||
|
||||
void resetCountFromDate(ProjectClass projectClass);
|
||||
}
|
||||
|
@ -51,7 +51,9 @@ public class ProjectIdeaDaoJPAImp extends AbstractDaoJPAImp<ProjectIdea>
|
||||
querySet.projectClasses(projectClasses);
|
||||
}
|
||||
return getJpaTemplate().execute(
|
||||
querySet.supervisor(supervisor).projectCreated(false).countCallback());
|
||||
// querySet.supervisor(supervisor).projectCreated(false).countCallback());
|
||||
// querySet.supervisor(supervisor).matchDateAfter(supervisor.getBachelorTargetCountFromDate()).countCallback());
|
||||
querySet.supervisor(supervisor).matchDateAfter(supervisor.getCountFromDate(projectClass)).countCallback());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -142,6 +144,16 @@ public class ProjectIdeaDaoJPAImp extends AbstractDaoJPAImp<ProjectIdea>
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuerySet matchDateAfter(Date matchDateAfter) {
|
||||
if (matchDateAfter != null) {
|
||||
getQuery().combine(
|
||||
new Query().join("_.match m").where(
|
||||
"m.dateCreated >= :matchDateAfter").parameter("matchDateAfter",
|
||||
matchDateAfter));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuerySet orderByMatchAge() {
|
||||
getQuery().combine(
|
||||
|
@ -2,7 +2,9 @@ package se.su.dsv.scipro.match.dao.jpa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
@ -16,6 +18,7 @@ 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.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractQuerySet;
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractSortableQuerySet;
|
||||
import se.su.dsv.scipro.data.dao.jpa.Query;
|
||||
@ -25,212 +28,241 @@ import se.su.dsv.scipro.data.dataobjects.Language;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ProjectIdeaDao;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.SupervisorDaoParams;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.SupervisorDao;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.SupervisorDaoParams;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.Match;
|
||||
|
||||
@Repository("supervisorDao")
|
||||
public class SupervisorDaoJPAImp extends
|
||||
QueryableDaoJPAImp<Employee, SupervisorDaoParams> implements
|
||||
SupervisorDao {
|
||||
QueryableDaoJPAImp<Employee, SupervisorDaoParams> implements
|
||||
SupervisorDao {
|
||||
|
||||
@Autowired
|
||||
private ProjectIdeaDao projectIdeaDao;
|
||||
|
||||
public SupervisorDaoJPAImp() {
|
||||
super(Employee.class);
|
||||
}
|
||||
@Autowired
|
||||
private ProjectIdeaDao projectIdeaDao;
|
||||
@Autowired
|
||||
private ProjectClassDao projectClassDao;
|
||||
|
||||
@Override
|
||||
public Employee getOrCreate(final User user) {
|
||||
Employee supervisor = getFrom(user);
|
||||
if (supervisor == null) {
|
||||
supervisor = new Employee();
|
||||
supervisor.setUser(user);
|
||||
supervisor = save(supervisor);
|
||||
}
|
||||
return supervisor;
|
||||
}
|
||||
public SupervisorDaoJPAImp() {
|
||||
super(Employee.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Employee getFrom(final User user) {
|
||||
return getJpaTemplate().execute(new JpaCallback<Employee>() {
|
||||
@Override
|
||||
public Employee getOrCreate(final User user) {
|
||||
Employee supervisor = getFrom(user);
|
||||
if (supervisor == null) {
|
||||
supervisor = new Employee();
|
||||
supervisor.setUser(user);
|
||||
supervisor = save(supervisor);
|
||||
}
|
||||
return supervisor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Employee doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
TypedQuery<Employee> query =
|
||||
em.createQuery(
|
||||
"select e FROM Employee e WHERE e.user = :user",
|
||||
Employee.class);
|
||||
query.setParameter("user", user);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
try {
|
||||
return query.getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public Employee getFrom(final User user) {
|
||||
return getJpaTemplate().execute(new JpaCallback<Employee>() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public Employee doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
TypedQuery<Employee> query =
|
||||
em.createQuery(
|
||||
"select e FROM Employee e WHERE e.user = :user",
|
||||
Employee.class);
|
||||
query.setParameter("user", user);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
try {
|
||||
return query.getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public List<Employee> getCapableSupervisors(
|
||||
final ProjectClass projectClass) {
|
||||
return getJpaTemplate().execute(
|
||||
new QuerySet().projectClass(projectClass).fetchCallback());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Employee> getCapableSupervisors(
|
||||
final ProjectClass projectClass, final Set<Language> languages) {
|
||||
return getJpaTemplate().execute(
|
||||
new QuerySet().projectClass(projectClass).languages(languages)
|
||||
.fetchCallback());
|
||||
}
|
||||
@Override
|
||||
public List<Employee> getCapableSupervisors(
|
||||
final ProjectClass projectClass) {
|
||||
return getJpaTemplate().execute(
|
||||
new QuerySet().projectClass(projectClass).fetchCallback());
|
||||
}
|
||||
|
||||
public List<Employee> getAutoCompleteCapableSupervisors(
|
||||
final ProjectClass projectClass, final Set<Language> languages,
|
||||
final String searchString, final int limit) {
|
||||
return getJpaTemplate().execute(
|
||||
new QuerySet().projectClass(projectClass).languages(languages)
|
||||
.nameLike(searchString).orderByUser().limit(limit)
|
||||
.fetchCallback());
|
||||
}
|
||||
public List<Employee> getCapableSupervisors(
|
||||
final ProjectClass projectClass, final Set<Language> languages) {
|
||||
return getJpaTemplate().execute(
|
||||
new QuerySet().projectClass(projectClass).languages(languages)
|
||||
.fetchCallback());
|
||||
}
|
||||
|
||||
protected AbstractQuerySet<Employee> createQuerySet(
|
||||
SupervisorDaoParams params) {
|
||||
return new QuerySet().languages(params.getLanguages())
|
||||
.projectClass(params.getProjectClass())
|
||||
.keywords(params.getKeywords())
|
||||
.nameLike(params.getNameLike());
|
||||
}
|
||||
public List<Employee> getAutoCompleteCapableSupervisors(
|
||||
final ProjectClass projectClass, final Set<Language> languages,
|
||||
final String searchString, final int limit) {
|
||||
return getJpaTemplate().execute(
|
||||
new QuerySet().projectClass(projectClass).languages(languages)
|
||||
.nameLike(searchString).orderByUser().limit(limit)
|
||||
.fetchCallback());
|
||||
}
|
||||
|
||||
private static class QuerySet extends AbstractSortableQuerySet<Employee> {
|
||||
public QuerySet() {
|
||||
super(Employee.class);
|
||||
}
|
||||
protected AbstractQuerySet<Employee> createQuerySet(
|
||||
SupervisorDaoParams params) {
|
||||
return new QuerySet().languages(params.getLanguages())
|
||||
.projectClass(params.getProjectClass())
|
||||
.keywords(params.getKeywords())
|
||||
.nameLike(params.getNameLike());
|
||||
}
|
||||
|
||||
public QuerySet keywords(Collection<Keyword> keywords) {
|
||||
if (keywords != null) {
|
||||
getQuery().combine(
|
||||
new Query().join("_.keywords.keywords k").where("k in (:keywords)").parameter(
|
||||
"keywords", keywords)).distinct();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private static class QuerySet extends AbstractSortableQuerySet<Employee> {
|
||||
public QuerySet() {
|
||||
super(Employee.class);
|
||||
}
|
||||
|
||||
public QuerySet orderByUser() {
|
||||
getQuery().combine(RoleDaoJPAImp.orderByUserQuery());
|
||||
return this;
|
||||
}
|
||||
public QuerySet keywords(Collection<Keyword> keywords) {
|
||||
if (keywords != null) {
|
||||
getQuery().combine(
|
||||
new Query().join("_.keywords.keywords k").where("k in (:keywords)").parameter(
|
||||
"keywords", keywords)).distinct();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuerySet nameLike(String name) {
|
||||
if (name != null) {
|
||||
getQuery().combine(
|
||||
new Query().combine(RoleDaoJPAImp
|
||||
.autoCompleteUserNameQuery(name)));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public QuerySet orderByUser() {
|
||||
getQuery().combine(RoleDaoJPAImp.orderByUserQuery());
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuerySet projectClass(ProjectClass projectClass) {
|
||||
if (projectClass != null) {
|
||||
getQuery().combine(
|
||||
new Query().join("_.capabilities.projectLimits pl").where(
|
||||
"index(pl) = :projectClass AND pl > 0").parameter(
|
||||
"projectClass", projectClass));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public QuerySet nameLike(String name) {
|
||||
if (name != null) {
|
||||
getQuery().combine(
|
||||
new Query().combine(RoleDaoJPAImp
|
||||
.autoCompleteUserNameQuery(name)));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public QuerySet languages(Collection<Language> languages) {
|
||||
if (languages != null) {
|
||||
getQuery().combine(
|
||||
new Query().join("_.capabilities.languages l").where(
|
||||
"l IN (:languages)").parameter("languages", languages)).distinct();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public QuerySet projectClass(ProjectClass projectClass) {
|
||||
if (projectClass != null) {
|
||||
getQuery().combine(
|
||||
new Query().join("_.capabilities.projectLimits pl").where(
|
||||
"index(pl) = :projectClass AND pl > 0").parameter(
|
||||
"projectClass", projectClass));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query initQuery() {
|
||||
return new Query().select("e").from("Employee e");
|
||||
}
|
||||
public QuerySet languages(Collection<Language> languages) {
|
||||
if (languages != null) {
|
||||
getQuery().combine(
|
||||
new Query().join("_.capabilities.languages l").where(
|
||||
"l IN (:languages)").parameter("languages", languages)).distinct();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public Query initQuery() {
|
||||
return new Query().select("e").from("Employee e");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Availability> getAvailability() {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<Availability>>() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Availability> doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
List<Availability> availabilities = matchedProjectIdeas(em);
|
||||
availabilities.addAll(unmatchedProjectIdeas(em));
|
||||
return availabilities;
|
||||
}
|
||||
/*
|
||||
* THIS IS THE OLD WAY OF GETTING AVAILABILITIES FOR MATCHING.
|
||||
* Ive changed it so that we now get availabilities for the algorithm
|
||||
* the same way as the GUI gets availabilities for individual supervisors.
|
||||
* by Friis
|
||||
*/
|
||||
// @Override
|
||||
// public List<Availability> getAvailability() {
|
||||
// return getJpaTemplate().execute(new JpaCallback<List<Availability>>() {
|
||||
//
|
||||
// @Override
|
||||
// public List<Availability> doInJpa(EntityManager em)
|
||||
// throws PersistenceException {
|
||||
// List<Availability> availabilities = matchedProjectIdeas(em);
|
||||
// availabilities.addAll(unmatchedProjectIdeas(em));
|
||||
// return availabilities;
|
||||
// }
|
||||
//
|
||||
// private List<Availability> matchedProjectIdeas(EntityManager em) {
|
||||
// javax.persistence.Query query =
|
||||
// em.createQuery("SELECT NEW se.su.dsv.scipro.match.dataobject.Availability"
|
||||
// + "(s, COUNT(m), pl, pi.projectClass) "
|
||||
// + "FROM Match m JOIN m.supervisor s JOIN m.projectIdea pi JOIN s.capabilities.projectLimits pl "
|
||||
// + "WHERE pi.match = m AND pi.projectClass = index(pl) AND m.status IN (:statuses) "
|
||||
// + "GROUP BY s, pi.projectClass, pl, index(pl)");
|
||||
//
|
||||
// query.setParameter("statuses", occupiedStatuses());
|
||||
// query.setHint(QueryHints.HINT_CACHEABLE, "false");
|
||||
// try {
|
||||
// return query.getResultList();
|
||||
// } catch (NoResultException e) {
|
||||
// return new ArrayList<Availability>();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private List<Match.Status> occupiedStatuses() {
|
||||
// List<Match.Status> statuses = new ArrayList<Match.Status>();
|
||||
// statuses.add(Match.Status.CONFIRMED);
|
||||
// statuses.add(Match.Status.PENDING);
|
||||
// statuses.add(Match.Status.PUBLISHED);
|
||||
// return statuses;
|
||||
// }
|
||||
//
|
||||
// private List<Availability> unmatchedProjectIdeas(EntityManager em) {
|
||||
// javax.persistence.Query query =
|
||||
// em.createQuery("SELECT NEW se.su.dsv.scipro.match.dataobject.Availability"
|
||||
// + "(s, 0L, pl, index(pl)) "
|
||||
// + "FROM Match m RIGHT JOIN m.supervisor s JOIN s.capabilities.projectLimits pl LEFT JOIN m.projectIdea pi "
|
||||
// + "WHERE m = NULL OR pi.projectClass != index(pl) OR (pi.projectClass = index(pl) AND m.status NOT IN (:statuses))");
|
||||
//
|
||||
// query.setParameter("statuses", occupiedStatuses());
|
||||
// query.setHint(QueryHints.HINT_CACHEABLE, "false");
|
||||
// try {
|
||||
// return query.getResultList();
|
||||
// } catch (NoResultException e) {
|
||||
// return new ArrayList<Availability>();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
|
||||
private List<Availability> matchedProjectIdeas(EntityManager em) {
|
||||
javax.persistence.Query query =
|
||||
em.createQuery("SELECT NEW se.su.dsv.scipro.match.dataobject.Availability"
|
||||
+ "(s, COUNT(m), pl, pi.projectClass) "
|
||||
+ "FROM Match m JOIN m.supervisor s JOIN m.projectIdea pi JOIN s.capabilities.projectLimits pl "
|
||||
+ "WHERE pi.match = m AND pi.projectClass = index(pl) AND m.status IN (:statuses) "
|
||||
+ "GROUP BY s, pi.projectClass, pl, index(pl)");
|
||||
@Override
|
||||
public Availability getAvailability(Employee supervisor, ProjectClass projectClass) {
|
||||
Integer projectLimit = supervisor.getCapabilities().getProjectLimit(projectClass);
|
||||
long activeProjectIdeas = projectIdeaDao.countActiveProjectIdeas(supervisor, projectClass);
|
||||
return new Availability(supervisor, activeProjectIdeas, projectLimit, projectClass);
|
||||
}
|
||||
|
||||
query.setParameter("statuses", occupiedStatuses());
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "false");
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return new ArrayList<Availability>();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Match.Status> occupiedStatuses() {
|
||||
List<Match.Status> statuses = new ArrayList<Match.Status>();
|
||||
statuses.add(Match.Status.CONFIRMED);
|
||||
statuses.add(Match.Status.PENDING);
|
||||
statuses.add(Match.Status.PUBLISHED);
|
||||
return statuses;
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void setAvailability(Availability availability) {
|
||||
availability.getSupervisor().getCapabilities().getProjectLimits().put(
|
||||
availability.getProjectClass(), availability.getNumCapable());
|
||||
save(availability.getSupervisor());
|
||||
}
|
||||
|
||||
private List<Availability> unmatchedProjectIdeas(EntityManager em) {
|
||||
javax.persistence.Query query =
|
||||
em.createQuery("SELECT NEW se.su.dsv.scipro.match.dataobject.Availability"
|
||||
+ "(s, 0L, pl, index(pl)) "
|
||||
+ "FROM Match m RIGHT JOIN m.supervisor s JOIN s.capabilities.projectLimits pl LEFT JOIN m.projectIdea pi "
|
||||
+ "WHERE m = NULL OR pi.projectClass != index(pl) OR (pi.projectClass = index(pl) AND m.status NOT IN (:statuses))");
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void resetCountFromDate(ProjectClass projectClass) {
|
||||
List<Employee> supervisors = getCapableSupervisors(projectClass);
|
||||
for (Employee e : supervisors){
|
||||
e.setCountFromDate(projectClass, new Date());
|
||||
}
|
||||
}
|
||||
|
||||
query.setParameter("statuses", occupiedStatuses());
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "false");
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return new ArrayList<Availability>();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Availability getAvailability(Employee supervisor, ProjectClass projectClass) {
|
||||
Integer projectLimit = supervisor.getCapabilities().getProjectLimit(projectClass);
|
||||
long activeProjectIdeas = projectIdeaDao.countActiveProjectIdeas(supervisor, projectClass);
|
||||
return new Availability(supervisor, activeProjectIdeas, projectLimit, projectClass);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly=false)
|
||||
public void setAvailability(Availability availability) {
|
||||
availability.getSupervisor().getCapabilities().getProjectLimits().put(
|
||||
availability.getProjectClass(), availability.getNumCapable());
|
||||
save(availability.getSupervisor());
|
||||
}
|
||||
@Override
|
||||
public List<Availability> getAvailability() {
|
||||
List<Availability> list = new ArrayList<Availability>();
|
||||
for (ProjectClass pc : projectClassDao.findAll()){
|
||||
for (Employee e : getCapableSupervisors(pc)){
|
||||
list.add(getAvailability(e, pc));
|
||||
System.out.println(e.getNameAsString() + " numcap " + getAvailability(e, pc).getNumCapable() + " nummatched" + getAvailability(e, pc).getNumMatched());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -11,17 +11,23 @@
|
||||
<input style="width:300px;" wicket:id="keywordField" type="text" />
|
||||
<div class="span-16 prepend-top append-bottom last">
|
||||
|
||||
<div class="span-6">
|
||||
<div class="span-5">
|
||||
<label for="unitPanel">Filter by unit:</label><br />
|
||||
<span wicket:id="unitPanel"></span>
|
||||
</div>
|
||||
<div class="span-10 last append-bottom">
|
||||
<div class="span-5">
|
||||
<label for="researchAreaPanel">Filter by research area:</label>
|
||||
<span wicket:id="researchAreaPanel"></span>
|
||||
</div>
|
||||
<div class="span-5 last append-bottom">
|
||||
<label>Filter</label>
|
||||
<div class="append-bottom"><input wicket:id="filterButton" type="submit" /></div>
|
||||
<label>DO NOT TOUCH unless you know what you're doing!</label>
|
||||
<div><button wicket:id="resetAllBachelorButton">Reset all supervisor Bachelor count numbers</button></div>
|
||||
<div><button wicket:id="resetAllMasterButton">Reset all supervisor Master count numbers</button></div>
|
||||
</div>
|
||||
<div><input wicket:id="filterButton" type="submit" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<div wicket:id="container">
|
||||
<div class="span-15 last">
|
||||
@ -32,8 +38,8 @@
|
||||
<th>Unit</th>
|
||||
<th>Target bachelor</th>
|
||||
<th>Target master</th>
|
||||
<th>Current bachelor</th>
|
||||
<th class="rounded-right-top">Current master</th>
|
||||
<th>Bachelors (counting since)</th>
|
||||
<th class="rounded-right-top">Masters (counting since)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
@ -49,8 +55,8 @@
|
||||
<td wicket:id="targetMaster"></td>-->
|
||||
<td><select wicket:id="targetBachelor"></select></td>
|
||||
<td><select wicket:id="targetMaster"></select></td>
|
||||
<td wicket:id="currentBachelor"></td>
|
||||
<td wicket:id="currentMaster"></td>
|
||||
<td><span wicket:id="currentBachelor"></span> (<span wicket:id="bachelorDate"></span>)</td>
|
||||
<td><span wicket:id="currentMaster"></span> (<span wicket:id="masterDate"></span>)</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
@ -23,7 +24,6 @@ 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.admin.panels.match.AdminEditProjectIdeaPanel;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.dataproviders.QueryableDataProvider;
|
||||
@ -34,6 +34,8 @@ import se.su.dsv.scipro.match.dao.interfaces.SupervisorDaoParams;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
import se.su.dsv.scipro.util.DateFormatter;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
public class AdminManageSupervisorPanel extends Panel {
|
||||
|
||||
@ -109,8 +111,22 @@ public class AdminManageSupervisorPanel extends Panel {
|
||||
item.add(new Label("unit", new Model<String>(unit)));
|
||||
item.add(createDropDown(new Model<Availability>(bachelorAvalibality), "numCapable", "targetBachelor"));
|
||||
item.add(createDropDown(new Model<Availability>(masterAvalibality), "numCapable", "targetMaster"));
|
||||
|
||||
item.add(new Label("currentBachelor", new Model<Integer>((bachelorAvalibality.getNumMatched().intValue()))));
|
||||
if(supervisor.getCountFromDate(projectClassDao.getProjectClass("BACHELOR"))!=null){
|
||||
item.add(new DateFormatter(DateFormatter.FORMAT.EXTENDED).createFormattedDateLabel("bachelorDate", supervisor.getCountFromDate(projectClassDao.getProjectClass("BACHELOR"))));
|
||||
}
|
||||
else {
|
||||
item.add(new Label("bachelorDate", "no date"));
|
||||
}
|
||||
|
||||
item.add(new Label("currentMaster", new Model<Integer>(masterAvalibality.getNumMatched().intValue())));
|
||||
if(supervisor.getCountFromDate(projectClassDao.getProjectClass("MASTER"))!=null){
|
||||
item.add(new DateFormatter(DateFormatter.FORMAT.EXTENDED).createFormattedDateLabel("masterDate", supervisor.getCountFromDate(projectClassDao.getProjectClass("MASTER"))));
|
||||
}
|
||||
else {
|
||||
item.add(new Label("masterDate", "no date"));
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
@ -219,6 +235,31 @@ public class AdminManageSupervisorPanel extends Panel {
|
||||
add(researchAreaPanel);
|
||||
|
||||
add(filterButton);
|
||||
|
||||
AjaxLink resetAllBachelor = new AjaxLink("resetAllBachelorButton"){
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
supervisorDao.resetCountFromDate(projectClassDao.getProjectClass("BACHELOR"));
|
||||
target.addComponent(container);
|
||||
}
|
||||
};
|
||||
|
||||
resetAllBachelor.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to reset all supervisors bachelor counts?"));
|
||||
|
||||
add(resetAllBachelor);
|
||||
|
||||
AjaxLink resetAllMaster = new AjaxLink("resetAllMasterButton"){
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
supervisorDao.resetCountFromDate(projectClassDao.getProjectClass("MASTER"));
|
||||
target.addComponent(container);
|
||||
}
|
||||
};
|
||||
|
||||
resetAllMaster.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to reset all supervisors master counts?"));
|
||||
|
||||
add(resetAllMaster);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
value="true" />
|
||||
<property name="hibernate.generate_statistics" value="false" />
|
||||
<!-- DEVELOPMENT VARIABLE, REMOVE FOR PRODUCTION USE -->
|
||||
<!-- <property name="hibernate.hbm2ddl.auto" value="update" /> -->
|
||||
<!-- <property name="hibernate.hbm2ddl.auto" value="update" /> -->
|
||||
<!-- production settings database -->
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
|
||||
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user