resolved some conflicts
This commit is contained in:
commit
444672ad83
resources/db_update_scripts
src
main/java/se/su/dsv/scipro
SciProApplication.java
admin
components/menuhighlighting
data/dataobjects
datatables
employee
target
match
dao
dataobject
panel
project/panels
springdata
repos
serviceimpls
ApplicationPeriodServiceImpl.javaNewIdeaServiceImpl.javaProjectServiceImpl.javaSupervisorServiceImpl.javaTargetServiceImpl.java
services
supervisor
pages
panels
user/facade
test/java/se/su/dsv/scipro
@ -0,0 +1,35 @@
|
||||
# <<<<<<< HEAD
|
||||
# =======
|
||||
ALTER TABLE `general_system_settings` ADD `thesisReviewsMandatory` tinyint(1) NOT NULL;
|
||||
|
||||
ALTER TABLE `forum_posts` ADD `attachment_id` bigint(20) DEFAULT NULL;
|
||||
ALTER TABLE `forum_posts` ADD CONSTRAINT `FKEDDC4F35CCABB192` FOREIGN KEY (`attachment_id`) REFERENCES `file_description` (`id`);
|
||||
|
||||
ALTER TABLE `general_system_settings` ADD `thesisCommentNoDaysAheadReminder` int(11) NOT NULL;
|
||||
|
||||
--
|
||||
-- Table structure for table `target`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `target` (
|
||||
`applicationPeriodId` bigint(20) NOT NULL,
|
||||
`employeeId` bigint(20) NOT NULL,
|
||||
`projectClassId` bigint(20) NOT NULL,
|
||||
`target` int(11) NOT NULL,
|
||||
PRIMARY KEY (`applicationPeriodId`,`employeeId`,`projectClassId`),
|
||||
KEY `FKCB7E71913353DC5C` (`employeeId`),
|
||||
KEY `FKCB7E7191A520201E` (`projectClassId`),
|
||||
KEY `FKCB7E7191790761A4` (`applicationPeriodId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Constraints for table `target`
|
||||
--
|
||||
ALTER TABLE `target`
|
||||
ADD CONSTRAINT `FKCB7E7191790761A4b` FOREIGN KEY (`applicationPeriodId`) REFERENCES `ApplicationPeriod` (`id`),
|
||||
ADD CONSTRAINT `FKCB7E71913353DC5Cb` FOREIGN KEY (`employeeId`) REFERENCES `role` (`id`),
|
||||
ADD CONSTRAINT `FKCB7E7191A520201Eb` FOREIGN KEY (`projectClassId`) REFERENCES `project_class` (`id`);
|
||||
|
||||
DROP TABLE Employee_countActiveFromDates;
|
||||
DROP TABLE Employee_projectLimits;
|
||||
# >>>>>>> develop2
|
@ -208,7 +208,6 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
mountBookmarkablePage("admin/match/ideapopup", AdminNewIdeaPopupPage.class);
|
||||
mountBookmarkablePage("admin/match/keywords", AdminKeywordPage.class);
|
||||
mountBookmarkablePage("admin/match/exemptions", AdminExemptionPage.class);
|
||||
mountBookmarkablePage("admin/match/supervisors", AdminSupervisorSettingsPage.class);
|
||||
mountBookmarkablePage("admin/match/applicationperiods", AdminManageMatchPeriodsPage.class);
|
||||
mountBookmarkablePage("admin/mail", AdminMailPage.class);
|
||||
mountBookmarkablePage("admin/statistics", AdminStatisticsPage.class);
|
||||
|
@ -6,6 +6,7 @@ import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import se.su.dsv.scipro.admin.pages.match.*;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
import se.su.dsv.scipro.components.menuhighlighting.MenuHighlightAdminApplicationPeriod;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@ -32,8 +33,7 @@ public abstract class AbstractAdminMatchPage extends AbstractAdminPage {
|
||||
items.add(new MenuItem("Ideas", AdminManageIdeaPage.class));
|
||||
items.add(new MenuItem("Keywords and research areas", AdminKeywordPage.class));
|
||||
items.add(new MenuItem("Student exemptions", AdminExemptionPage.class));
|
||||
items.add(new MenuItem("Supervisor settings", AdminSupervisorSettingsPage.class));
|
||||
items.add(new MenuItem("Application periods", AdminManageMatchPeriodsPage.class));
|
||||
items.add(new MenuItem("Application periods", AdminManageMatchPeriodsPage.class, MenuHighlightAdminApplicationPeriod.class));
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,15 @@
|
||||
package se.su.dsv.scipro.admin.pages.match;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.Session;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
@ -13,14 +18,22 @@ import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
import se.su.dsv.scipro.components.DialogPlus;
|
||||
//<<<<<<< HEAD
|
||||
import se.su.dsv.scipro.data.enums.DateStyle;
|
||||
//=======
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
//import se.su.dsv.scipro.admin.panels.AdminEditProject;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
//>>>>>>> develop2
|
||||
import se.su.dsv.scipro.datatables.ClickableIconColumn;
|
||||
import se.su.dsv.scipro.datatables.DateColumn;
|
||||
import se.su.dsv.scipro.datatables.GenericDataPanel;
|
||||
import se.su.dsv.scipro.datatables.LabelAndLinkColumn;
|
||||
import se.su.dsv.scipro.datatables.target.AddTargetLinkPanel;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
import se.su.dsv.scipro.match.panel.MatchPeriodEditPanel;
|
||||
import se.su.dsv.scipro.project.pages.ProjectViewCheckListPage;
|
||||
import se.su.dsv.scipro.springdata.services.ApplicationPeriodService;
|
||||
import se.su.dsv.scipro.springdata.services.GenericService;
|
||||
|
||||
@ -116,6 +129,13 @@ public class AdminApplicationPeriodsPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<ApplicationPeriod>(Model.of("Targets"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<ApplicationPeriod>> item, String s, IModel<ApplicationPeriod> iModel) {
|
||||
item.add(new AddTargetLinkPanel(s, iModel));
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<ApplicationPeriod>(Model.of("Exemptions")) {
|
||||
private static final long serialVersionUID = -537646326380180505L;
|
||||
|
||||
|
@ -2,8 +2,10 @@ package se.su.dsv.scipro.admin.pages.match;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminMatchPage;
|
||||
import se.su.dsv.scipro.components.menuhighlighting.MenuHighlightAdminApplicationPeriod;
|
||||
import se.su.dsv.scipro.components.menuhighlighting.MenuHighlightProjectIdeas;
|
||||
|
||||
public class AdminManageMatchPeriodsPage extends AbstractAdminMatchPage {
|
||||
public class AdminManageMatchPeriodsPage extends AbstractAdminMatchPage implements MenuHighlightAdminApplicationPeriod {
|
||||
public AdminManageMatchPeriodsPage(PageParameters pp) {
|
||||
super(pp);
|
||||
add(new AdminApplicationPeriodsPanel("dp"));
|
||||
|
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div>Editing targets for application period <span wicket:id="name"></span></div>
|
||||
<div>Start date: <span wicket:id="startDate"></span></div>
|
||||
<div>End date: <span wicket:id="endDate"></span></div>
|
||||
<div>Course start date: <span wicket:id="courseDate"></span></div>
|
||||
|
||||
<form wicket:id="form">
|
||||
<div class="span-24 prepend-top append-bottom">
|
||||
<div class="span-7" wicket:id="unitFilter"></div>
|
||||
<div class="span-10" wicket:id="areaFilter"></div>
|
||||
<div class="span-6"><label for="nameFilter">Filter by name:</label><br/><input wicket:id="nameFilter"/>
|
||||
</div>
|
||||
<!--<div class="span-1 last"><span wicket:id="help"></span></div>-->
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div wicket:id="dp"></div>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,357 @@
|
||||
package se.su.dsv.scipro.admin.pages.match;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminMatchPage;
|
||||
import se.su.dsv.scipro.admin.panels.match.AdminSupervisorSettingsInfoPanel;
|
||||
import se.su.dsv.scipro.components.menuhighlighting.MenuHighlightAdminApplicationPeriod;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.datatables.DateColumn;
|
||||
import se.su.dsv.scipro.datatables.GenericDataPanel;
|
||||
import se.su.dsv.scipro.datatables.target.EditTargetPanel;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
import se.su.dsv.scipro.match.panel.FilterFormAreaPanel;
|
||||
import se.su.dsv.scipro.match.panel.FilterFormUnitPanel;
|
||||
import se.su.dsv.scipro.reusable.EmployeeAutoComplete;
|
||||
//import se.su.dsv.scipro.reusable.SafeLongToIntService;
|
||||
import se.su.dsv.scipro.reusable.SciProUtilities;
|
||||
import se.su.dsv.scipro.springdata.services.*;
|
||||
import se.su.dsv.scipro.util.DateFormatter;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class AdminManageTargetsPage extends AbstractAdminMatchPage implements MenuHighlightAdminApplicationPeriod {
|
||||
|
||||
@SpringBean
|
||||
private SupervisorService employeeService;
|
||||
@SpringBean
|
||||
private ApplicationPeriodService applicationPeriodService;
|
||||
@SpringBean
|
||||
private ProjectClassService projectClassService;
|
||||
@SpringBean
|
||||
private NewIdeaService newIdeaService;
|
||||
|
||||
private GenericDataPanel<Employee> genericDataPanel;
|
||||
|
||||
private SupervisorService.FilterParams params;
|
||||
|
||||
public AdminManageTargetsPage(final PageParameters pp) {
|
||||
super(pp);
|
||||
|
||||
|
||||
final ProjectClass bachelor = projectClassService.getProjectClass(ProjectClass.BACHELOR);
|
||||
final ProjectClass master = projectClassService.getProjectClass(ProjectClass.MASTER);
|
||||
final ApplicationPeriod current = applicationPeriodService.findOne(pp.getAsLong("apid"));
|
||||
|
||||
add(new Label("name", current.getName()));
|
||||
add(new DateFormatter(DateFormatter.FORMAT.EXTENDED).createFormattedDateLabel("startDate", current.getStartDate()));
|
||||
add(new DateFormatter(DateFormatter.FORMAT.EXTENDED).createFormattedDateLabel("endDate", current.getEndDate()));
|
||||
add(new DateFormatter(DateFormatter.FORMAT.EXTENDED).createFormattedDateLabel("courseDate", current.getCourseStartDate()));
|
||||
|
||||
add(new FilterForm("form"));
|
||||
|
||||
add(genericDataPanel = new GenericDataPanel<Employee>("dp") {
|
||||
@Override
|
||||
public GenericService getService() {
|
||||
return employeeService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Employee> getIterator() {
|
||||
return employeeService.findAll(params, new PageRequest(getTable().getCurrentPage(), getTable().getRowsPerPage(), getSort())).iterator();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return SciProUtilities.safeLongToInt(employeeService.count(params));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSortString() {
|
||||
return "user.firstName";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addColumns() {
|
||||
|
||||
int total = 4;
|
||||
|
||||
total += current.getProjectClass().size();
|
||||
|
||||
final ApplicationPeriod firstPrevious = applicationPeriodService.getPrevious(current);
|
||||
ApplicationPeriod secondPrevious = null;
|
||||
|
||||
if (firstPrevious != null) {
|
||||
// total += firstPrevious.getProjectClass().size();
|
||||
|
||||
int add = firstPrevious.getProjectClass().size() * 2;
|
||||
total += add;
|
||||
|
||||
secondPrevious = applicationPeriodService.getPrevious(firstPrevious);
|
||||
}
|
||||
if (secondPrevious != null) {
|
||||
// total += secondPrevious.getProjectClass().size();
|
||||
|
||||
int add = secondPrevious.getProjectClass().size() * 2;
|
||||
total += add;
|
||||
}
|
||||
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("First name"), "user.firstName", "user.firstName"));
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("Last name"), "user.lastName", "user.lastName"));
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("Unit"), "unit", "unit.title"));
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("Research areas"), "researchAreas"));
|
||||
|
||||
if (current.getProjectClass().contains(bachelor)) {
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(current.getName() + " Bachelor matched"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new Label(s, Long.toString(newIdeaService.countMatched(current, model.getObject(), bachelor))));
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(current.getName() + " Bachelor target"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new EditTargetPanel(s, new Model<ApplicationPeriod>(current), model, new Model<ProjectClass>(bachelor)) {
|
||||
@Override
|
||||
public void update(AjaxRequestTarget ajaxTarget, Employee e) {
|
||||
info("Saved target for supervisor " + e.getNameAsString());
|
||||
ajaxTarget.addComponent(genericDataPanel.getWMC());
|
||||
ajaxTarget.addComponent(feedBackPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return current.getProjectClass().contains(bachelor);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (current.getProjectClass().contains(master)) {
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(current.getName() + " Master matched"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new Label(s, Long.toString(newIdeaService.countMatched(current, model.getObject(), master))));
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(current.getName() + " Master target"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new EditTargetPanel(s, new Model<ApplicationPeriod>(current), model, new Model<ProjectClass>(master)) {
|
||||
@Override
|
||||
public void update(AjaxRequestTarget ajaxTarget, Employee e) {
|
||||
info("Saved target for supervisor " + e.getNameAsString());
|
||||
ajaxTarget.addComponent(genericDataPanel.getWMC());
|
||||
ajaxTarget.addComponent(feedBackPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return current.getProjectClass().contains(master);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (firstPrevious != null) {
|
||||
|
||||
if (firstPrevious.getProjectClass().contains(bachelor)) {
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(firstPrevious.getName() + " Bachelor matched"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new Label(s, Long.toString(newIdeaService.countMatched(firstPrevious, model.getObject(), bachelor))));
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(firstPrevious.getName() + " Bachelor target"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new EditTargetPanel(s, new Model<ApplicationPeriod>(firstPrevious), model, new Model<ProjectClass>(bachelor)) {
|
||||
@Override
|
||||
public void update(AjaxRequestTarget ajaxTarget, Employee e) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (firstPrevious.getProjectClass().contains(master)) {
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(firstPrevious.getName() + " Master matched"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new Label(s, Long.toString(newIdeaService.countMatched(firstPrevious, model.getObject(), master))));
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(firstPrevious.getName() + " Master target"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new EditTargetPanel(s, new Model<ApplicationPeriod>(firstPrevious), model, new Model<ProjectClass>(master)) {
|
||||
@Override
|
||||
public void update(AjaxRequestTarget ajaxTarget, Employee e) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (secondPrevious != null) {
|
||||
|
||||
final ApplicationPeriod finalSecondPrevious = secondPrevious;
|
||||
|
||||
if (secondPrevious.getProjectClass().contains(bachelor)) {
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(finalSecondPrevious.getName() + " Bachelor matched"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new Label(s, Long.toString(newIdeaService.countMatched(finalSecondPrevious, model.getObject(), bachelor))));
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(finalSecondPrevious.getName() + " Bachelor target"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new EditTargetPanel(s, new Model<ApplicationPeriod>(finalSecondPrevious), model, new Model<ProjectClass>(bachelor)) {
|
||||
@Override
|
||||
public void update(AjaxRequestTarget ajaxTarget, Employee e) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (secondPrevious.getProjectClass().contains(master)) {
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(finalSecondPrevious.getName() + " Master matched"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new Label(s, Long.toString(newIdeaService.countMatched(finalSecondPrevious, model.getObject(), master))));
|
||||
}
|
||||
});
|
||||
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of(finalSecondPrevious.getName() + " Master target"), null) {
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String s, IModel<Employee> model) {
|
||||
item.add(new EditTargetPanel(s, new Model<ApplicationPeriod>(finalSecondPrevious), model, new Model<ProjectClass>(master)) {
|
||||
@Override
|
||||
public void update(AjaxRequestTarget ajaxTarget, Employee e) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private class FilterForm extends Form<Void> {
|
||||
|
||||
private static final long serialVersionUID = -6837178911713319977L;
|
||||
|
||||
public FilterForm(String id) {
|
||||
super(id);
|
||||
params = new SupervisorService.FilterParams();
|
||||
|
||||
// add(new AdminSupervisorSettingsInfoPanel("help"));
|
||||
|
||||
//FILTER BY UNIT
|
||||
final FilterFormUnitPanel unitFilter = new FilterFormUnitPanel("unitFilter", true) {
|
||||
private static final long serialVersionUID = -5395913265109372627L;
|
||||
|
||||
@Override
|
||||
public void ajaxUpdate(AjaxRequestTarget target) {
|
||||
if (getOption().equals("None")) {
|
||||
params.setUnit(null);
|
||||
params.setNoUnit(true);
|
||||
} else {
|
||||
params.setUnit(getUnit());
|
||||
params.setNoUnit(false);
|
||||
}
|
||||
target.addComponent(genericDataPanel.getWMC());
|
||||
}
|
||||
};
|
||||
params.setUnit(null);
|
||||
add(unitFilter);
|
||||
|
||||
//FILTER BY RESEARCH AREA (true to add none-option)
|
||||
final FilterFormAreaPanel areaFilter = new FilterFormAreaPanel("areaFilter", true) {
|
||||
private static final long serialVersionUID = -1751214432450157380L;
|
||||
|
||||
@Override
|
||||
public void ajaxUpdate(AjaxRequestTarget target) {
|
||||
if (getOption().equals("None")) {
|
||||
params.setResearchArea(null);
|
||||
params.setNoAreas(true);
|
||||
} else {
|
||||
params.setResearchArea(getArea());
|
||||
params.setNoAreas(false);
|
||||
}
|
||||
target.addComponent(genericDataPanel.getWMC());
|
||||
}
|
||||
};
|
||||
params.setResearchArea(null);
|
||||
add(areaFilter);
|
||||
|
||||
//FILTER BY SUPERVISOR
|
||||
add(new EmployeeAutoComplete("nameFilter") {
|
||||
private static final long serialVersionUID = 3754694873165687588L;
|
||||
|
||||
@Override
|
||||
protected void action(AjaxRequestTarget pTarget, Employee newSelection) {
|
||||
params.setSupervisor(newSelection);
|
||||
pTarget.addComponent(genericDataPanel.getWMC());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div wicket:id="supervisorPanel"></div>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
</html>
|
@ -1,18 +0,0 @@
|
||||
package se.su.dsv.scipro.admin.pages.match;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminMatchPage;
|
||||
import se.su.dsv.scipro.match.panel.AdminSupervisorSettingsPanel;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@Authorization(authorizedRoles = {Roles.ADMIN})
|
||||
public class AdminSupervisorSettingsPage extends AbstractAdminMatchPage {
|
||||
|
||||
public AdminSupervisorSettingsPage(PageParameters pp) {
|
||||
super(pp);
|
||||
add(new AdminSupervisorSettingsPanel("supervisorPanel", (FeedbackPanel)getFeedBackPanel()));
|
||||
}
|
||||
|
||||
}
|
@ -29,6 +29,7 @@ import se.su.dsv.scipro.project.panels.NewIdeaWatsonInfoPanel;
|
||||
import se.su.dsv.scipro.reusable.AddRemoveStudentsPanel;
|
||||
import se.su.dsv.scipro.springdata.services.NewIdeaService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
import se.su.dsv.scipro.springdata.services.TargetService;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorNewIdeaStartPage;
|
||||
import se.su.dsv.scipro.util.DateFormatter;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
@ -47,7 +48,8 @@ public abstract class AdminNewIdeaDetailsCrudPanel extends Panel {
|
||||
private NewIdeaService ideaService;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
@SpringBean
|
||||
private TargetService targetService;
|
||||
private AddRemoveStudentsPanel studentsPanel;
|
||||
|
||||
public AdminNewIdeaDetailsCrudPanel(String id, IModel<NewIdea> model, boolean isEditable) {
|
||||
@ -147,7 +149,9 @@ public abstract class AdminNewIdeaDetailsCrudPanel extends Panel {
|
||||
@Override
|
||||
public void onNewEmployeeSelection(AjaxRequestTarget target,
|
||||
Employee newSelection) {
|
||||
if(supervisorService.withinLimits(newSelection, idea.getProjectClass())) {
|
||||
|
||||
// if(supervisorService.withinLimits(newSelection, idea.getProjectClass())) {
|
||||
if (targetService.hasTargetsLeft(idea.getApplicationPeriod(), newSelection, idea.getProjectClass()) ){
|
||||
ideaService.changeSupervisor(idea, newSelection, SciProSession.get().getUser());
|
||||
info("Supervisor changed to: " + newSelection.getNameAsString());
|
||||
} else {
|
||||
@ -158,7 +162,7 @@ public abstract class AdminNewIdeaDetailsCrudPanel extends Panel {
|
||||
target.addComponent(container);
|
||||
updateTarget(target);
|
||||
}
|
||||
}.setEnabled(isEditable));
|
||||
}.setEnabled(isEditable && idea.getApplicationPeriod()!=null && idea.getProjectClass()!=null));
|
||||
|
||||
addUnmatchButton(container, idea, feedback, idea.getType().equals(Type.STUDENT)&&idea.getMatch().getStatus().equals(Status.MATCHED));
|
||||
|
||||
@ -195,7 +199,11 @@ public abstract class AdminNewIdeaDetailsCrudPanel extends Panel {
|
||||
//do nothing
|
||||
}
|
||||
});
|
||||
studentsPanel.setEnabled(isEditable);
|
||||
/**
|
||||
* If there is no application period, we cannot match the idea with new target system
|
||||
*/
|
||||
studentsPanel.setEnabled(isEditable && idea.getApplicationPeriod()!=null);
|
||||
|
||||
AjaxLink<Void> saveAuthors = new AjaxLink<Void>("saveAuthorButton"){
|
||||
private static final long serialVersionUID = -1112809450176868083L;
|
||||
|
||||
@ -217,7 +225,10 @@ public abstract class AdminNewIdeaDetailsCrudPanel extends Panel {
|
||||
}
|
||||
|
||||
};
|
||||
saveAuthors.setEnabled(isEditable);
|
||||
/**
|
||||
* If there is no application period, we cannot match the idea with new target system
|
||||
*/
|
||||
saveAuthors.setEnabled(isEditable && idea.getApplicationPeriod()!=null);
|
||||
container.add(saveAuthors);
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,8 @@ public class AdminNewIdeaOverviewPanel extends Panel {
|
||||
private ExcelExportService excelExportService;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
@SpringBean
|
||||
private TargetService targetService;
|
||||
|
||||
private GenericDataPanel<NewIdea> dataTable;
|
||||
private FilterParams params;
|
||||
@ -255,7 +257,8 @@ public class AdminNewIdeaOverviewPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public void onNewEmployeeSelection(AjaxRequestTarget target, Employee newSelection) {
|
||||
if (supervisorService.withinLimits(newSelection, idea.getProjectClass())) {
|
||||
// if (supervisorService.withinLimits(newSelection, idea.getProjectClass())) {
|
||||
if (targetService.hasTargetsLeft(idea.getApplicationPeriod(), newSelection, idea.getProjectClass()) ){
|
||||
ideaService.changeSupervisor(idea, newSelection, SciProSession.get().getUser());
|
||||
info("Supervisor changed to " + newSelection.getNameAsString() + " on idea '" + idea.getTitle() + "'");
|
||||
} else {
|
||||
@ -265,7 +268,7 @@ public class AdminNewIdeaOverviewPanel extends Panel {
|
||||
target.addComponent(feedback);
|
||||
target.addComponent(dataTable.getWMC());
|
||||
}
|
||||
}.setEnabled(idea.getProject() == null));
|
||||
}.setEnabled(idea.getProject() == null && idea.getApplicationPeriod()!=null && idea.getProjectClass()!=null));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ public class AdminNewIdeaPopupPanel extends Panel {
|
||||
private ExcelExportService excelExportService;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
@SpringBean
|
||||
private TargetService targetService;
|
||||
|
||||
private GenericDataPanel<NewIdea> dataTable;
|
||||
private FilterParams params;
|
||||
@ -248,7 +250,8 @@ public class AdminNewIdeaPopupPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public void onNewEmployeeSelection(AjaxRequestTarget target, Employee newSelection) {
|
||||
if(supervisorService.withinLimits(newSelection, idea.getProjectClass())) {
|
||||
// if(supervisorService.withinLimits(newSelection, idea.getProjectClass())) {
|
||||
if (targetService.hasTargetsLeft(idea.getApplicationPeriod(), newSelection, idea.getProjectClass()) ){
|
||||
ideaService.changeSupervisor(idea, newSelection, SciProSession.get().getUser());
|
||||
info("Supervisor changed to "+ newSelection.getNameAsString()+ " on idea '"+idea.getTitle()+"'");
|
||||
} else {
|
||||
@ -258,7 +261,7 @@ public class AdminNewIdeaPopupPanel extends Panel {
|
||||
target.addComponent(feedback);
|
||||
target.addComponent(dataTable.getWMC());
|
||||
}
|
||||
}.setEnabled(idea.getProject()==null));
|
||||
}.setEnabled(idea.getProject()==null && idea.getApplicationPeriod()!=null && idea.getProjectClass()!=null));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
4
src/main/java/se/su/dsv/scipro/components/menuhighlighting/MenuHighlightAdminApplicationPeriod.java
Normal file
4
src/main/java/se/su/dsv/scipro/components/menuhighlighting/MenuHighlightAdminApplicationPeriod.java
Normal file
@ -0,0 +1,4 @@
|
||||
package se.su.dsv.scipro.components.menuhighlighting;
|
||||
|
||||
public interface MenuHighlightAdminApplicationPeriod extends MenuHighlight {
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
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.*;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
@ -15,29 +24,32 @@ import java.util.*;
|
||||
@Cacheable(true)
|
||||
@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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ManyToMany
|
||||
@JoinTable(name="Employee_Language")
|
||||
private Set<Language> languages = new HashSet<Language>();
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(name="languages", joinTable=@JoinTable(name="Employee_Language"))
|
||||
public Set<Language> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
public void setLanguages(Set<Language> languages) {
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "targetId.employeeId", cascade=CascadeType.ALL, orphanRemoval=true)
|
||||
private Set<Target> targets = new HashSet<Target>();
|
||||
|
||||
public Set<Target> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(Set<Target> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
@Embedded
|
||||
// @AssociationOverride(name="languages", joinTable=@JoinTable(name="Employee_Language"))
|
||||
private Capabilities capabilities = new Capabilities();
|
||||
|
||||
@ManyToMany
|
||||
@ -73,17 +85,17 @@ public class Employee extends ProjectTeamMember {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Employee)) return false;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
Employee employee = (Employee) o;
|
||||
|
||||
if (capabilities != null ? !capabilities.equals(employee.capabilities) : employee.capabilities != null)
|
||||
return false;
|
||||
if (countActiveFromDates != null ? !countActiveFromDates.equals(employee.countActiveFromDates) : employee.countActiveFromDates != null)
|
||||
return false;
|
||||
if (languages != null ? !languages.equals(employee.languages) : employee.languages != null) return false;
|
||||
if (researchAreas != null ? !researchAreas.equals(employee.researchAreas) : employee.researchAreas != null)
|
||||
return false;
|
||||
if (targets != null ? !targets.equals(employee.targets) : employee.targets != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -91,7 +103,8 @@ public class Employee extends ProjectTeamMember {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (countActiveFromDates != null ? countActiveFromDates.hashCode() : 0);
|
||||
result = 31 * result + (languages != null ? languages.hashCode() : 0);
|
||||
result = 31 * result + (targets != null ? targets.hashCode() : 0);
|
||||
result = 31 * result + (capabilities != null ? capabilities.hashCode() : 0);
|
||||
result = 31 * result + (researchAreas != null ? researchAreas.hashCode() : 0);
|
||||
return result;
|
||||
@ -102,77 +115,33 @@ public class Employee extends ProjectTeamMember {
|
||||
public static class Capabilities implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3561755898522270150L;
|
||||
|
||||
@ElementCollection(fetch=FetchType.EAGER)
|
||||
private Map<ProjectClass, Integer> projectLimits =
|
||||
new HashMap<ProjectClass, Integer>();
|
||||
|
||||
@ManyToMany(fetch=FetchType.EAGER)
|
||||
private Set<Language> languages = new HashSet<Language>();
|
||||
|
||||
public Map<ProjectClass, Integer> getProjectLimits() {
|
||||
return projectLimits;
|
||||
}
|
||||
|
||||
public void setProjectLimits(Map<ProjectClass, Integer> projectLimits) {
|
||||
this.projectLimits = projectLimits;
|
||||
}
|
||||
|
||||
public void setMaxProjects(ProjectClass projectClass, int numProjects) {
|
||||
projectLimits.put(projectClass, numProjects);
|
||||
}
|
||||
|
||||
public int getProjectLimit(ProjectClass projectClass) {
|
||||
Integer projectLimit = getProjectLimits().get(projectClass);
|
||||
if (projectLimit != null) {
|
||||
return projectLimit;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Capabilities [projectLimits=" + projectLimits + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result =
|
||||
prime * result
|
||||
+ ((projectLimits == null) ? 0 : projectLimits.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Capabilities other = (Capabilities) obj;
|
||||
if (projectLimits == null) {
|
||||
if (other.projectLimits != null)
|
||||
return false;
|
||||
} else if (!projectLimits.equals(other.projectLimits))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public Set<Language> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
|
||||
public void setLanguages(Set<Language> languages) {
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Capabilities that = (Capabilities) o;
|
||||
|
||||
if (languages != null ? !languages.equals(that.languages) : that.languages != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return languages != null ? languages.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@ -39,8 +45,19 @@ public class ProjectClass extends LazyDeletableDomainObject implements Comparabl
|
||||
|
||||
@Lob
|
||||
private String description;
|
||||
|
||||
public ProjectClass() {}
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "targetId.projectClassId", cascade=CascadeType.ALL, orphanRemoval=true)
|
||||
private Set<Target> targets = new HashSet<Target>();
|
||||
|
||||
public Set<Target> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(Set<Target> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public ProjectClass() {}
|
||||
|
||||
public ProjectClass(String projectCode, String name, String description){
|
||||
this.code = projectCode;
|
||||
|
@ -1,8 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<input class="span-2" wicket:id="targetNumber" />
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -1,51 +0,0 @@
|
||||
package se.su.dsv.scipro.datatables.employee;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
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.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
/**
|
||||
*
|
||||
* Panel where supervisors target numbers is presented and changeable through a
|
||||
* free text input field with Ajax-behavior. No save button is needed.
|
||||
*
|
||||
*/
|
||||
public class EmployeeProjectLimitsInputPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = -2173132087809862546L;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
public EmployeeProjectLimitsInputPanel(String id, Availability availability, final WebMarkupContainer container, final FeedbackPanel feedback) {
|
||||
super(id);
|
||||
add(createInputField(Model.of(availability), "numCapable", "targetNumber", container, feedback));
|
||||
}
|
||||
|
||||
private TextField<Integer> createInputField(final IModel<Availability> model, String weightName, String id, final WebMarkupContainer container, final FeedbackPanel feedback) {
|
||||
final TextField<Integer> inputField = new TextField<Integer>(id, new PropertyModel<Integer>(model, weightName));
|
||||
inputField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
|
||||
private static final long serialVersionUID = 2215184263767569338L;
|
||||
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
supervisorService.setAvailability(model.getObject());
|
||||
info(model.getObject().getProjectClass().getName()+" target number saved for supervisor "+model.getObject().getSupervisor());
|
||||
target.addComponent(container);
|
||||
target.addComponent(feedback);
|
||||
|
||||
}
|
||||
});
|
||||
inputField.setOutputMarkupId(true);
|
||||
return inputField;
|
||||
}
|
||||
|
||||
}
|
9
src/main/java/se/su/dsv/scipro/datatables/target/AddTargetLinkPanel.html
Executable file
9
src/main/java/se/su/dsv/scipro/datatables/target/AddTargetLinkPanel.html
Executable file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div><span wicket:id="count"></span> <a wicket:id="add">Edit targets</a></div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,26 @@
|
||||
package se.su.dsv.scipro.datatables.target;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import se.su.dsv.scipro.admin.pages.match.AdminManageTargetsPage;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
|
||||
/**
|
||||
* @author: fred-fri@dsv.su.se
|
||||
* created: 2012-11-16 11:50
|
||||
*/
|
||||
public class AddTargetLinkPanel extends Panel {
|
||||
|
||||
public AddTargetLinkPanel(String id, IModel<ApplicationPeriod> model) {
|
||||
super(id, model);
|
||||
|
||||
add(new Label("count", Integer.toString(model.getObject().getTargets().size())));
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put("apid" ,model.getObject().getId());
|
||||
add(new BookmarkablePageLink<Void>("add", AdminManageTargetsPage.class, pp));
|
||||
|
||||
}
|
||||
}
|
10
src/main/java/se/su/dsv/scipro/datatables/target/EditTargetPanel.html
Executable file
10
src/main/java/se/su/dsv/scipro/datatables/target/EditTargetPanel.html
Executable file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<!--<div><span wicket:id="target"></span></div>-->
|
||||
<div><input class="span-2" wicket:id="input"/> </div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,61 @@
|
||||
package se.su.dsv.scipro.datatables.target;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
import se.su.dsv.scipro.springdata.services.ApplicationPeriodService;
|
||||
import se.su.dsv.scipro.springdata.services.ProjectClassService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
import se.su.dsv.scipro.springdata.services.TargetService;
|
||||
|
||||
/**
|
||||
* @author: fred-fri@dsv.su.se
|
||||
* created: 2012-11-16 12:10
|
||||
*/
|
||||
public abstract class EditTargetPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private TargetService targetService;
|
||||
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
@SpringBean
|
||||
private ApplicationPeriodService applicationPeriodService;
|
||||
@SpringBean
|
||||
private ProjectClassService projectClassService;
|
||||
|
||||
public abstract void update(AjaxRequestTarget ajaxTarget, Employee e);
|
||||
public abstract boolean isEditable();
|
||||
|
||||
public EditTargetPanel(String id, final IModel<ApplicationPeriod> apModel, final IModel<Employee> eModel, final IModel<ProjectClass> pcModel) {
|
||||
super(id);
|
||||
|
||||
// final Target target = supervisorService.getTarget(apModel.getObject(), eModel.getObject(), pcModel.getObject());
|
||||
final Target target = targetService.findOne(apModel.getObject(), eModel.getObject(), pcModel.getObject());
|
||||
|
||||
|
||||
final TextField<Integer> inputField = new TextField<Integer>("input", new PropertyModel<Integer>(target, "target"));
|
||||
|
||||
/**
|
||||
* Ajax method that notices changes and saves them
|
||||
*/
|
||||
inputField.add(new AjaxFormComponentUpdatingBehavior("onchange") {
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget ajaxTarget) {
|
||||
eModel.getObject().getTargets().add(target);
|
||||
eModel.setObject(supervisorService.save(eModel.getObject()));
|
||||
update(ajaxTarget, eModel.getObject());
|
||||
}
|
||||
});
|
||||
inputField.setEnabled(isEditable());
|
||||
add(inputField);
|
||||
}
|
||||
}
|
@ -4,6 +4,10 @@ import se.su.dsv.scipro.data.dao.interfaces.QueryableDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
//>>>>>>> develop2
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -12,4 +16,9 @@ public interface SupervisorDao extends QueryableDao<Employee, SupervisorDaoParam
|
||||
List<Employee> getCapableSupervisors(ProjectClass bachelor);
|
||||
List<Employee> getAutoCompleteCapableSupervisors(
|
||||
/*final ProjectClass projectClass, final Set<Language> languages,*/ final String searchString, int limit);
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
|
||||
// Employee getOrCreate(User user);
|
||||
//>>>>>>> develop2
|
||||
}
|
||||
|
@ -144,6 +144,9 @@ public class SupervisorDaoJPAImp extends QueryableDaoJPAImp<Employee, Supervisor
|
||||
public Query initQuery() {
|
||||
return new Query().select("e").from("Employee e");
|
||||
}
|
||||
|
||||
//<<<<<<< HEAD
|
||||
//
|
||||
//=======
|
||||
//>>>>>>> develop2
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,17 @@ public class ApplicationPeriod extends DomainObject {
|
||||
this.applicationPeriodExemptions = applicationPeriodExemptions;
|
||||
}
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "targetId.applicationPeriodId", cascade=CascadeType.ALL, orphanRemoval=true)
|
||||
private Set<Target> targets = new HashSet<Target>();
|
||||
|
||||
public Set<Target> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(Set<Target> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public ApplicationPeriod() {
|
||||
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
package se.su.dsv.scipro.match.dataobject;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A class that specifies how available a supervisor is(in terms of thesis supervision)
|
||||
*/
|
||||
public class Availability implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long numMatched;
|
||||
private final ProjectClass projectClass;
|
||||
private Integer numCapable;
|
||||
private final Employee supervisor;
|
||||
|
||||
public Availability(final Employee supervisor, final Long numMatched, final Integer numCapable, final ProjectClass projectClass) {
|
||||
this.supervisor = supervisor;
|
||||
this.numMatched = numMatched;
|
||||
this.numCapable = numCapable;
|
||||
this.projectClass = projectClass;
|
||||
}
|
||||
|
||||
public int getAvailability() {
|
||||
return numCapable - numMatched.intValue();
|
||||
}
|
||||
public boolean isAvailable() {
|
||||
return getAvailability() > 0;
|
||||
}
|
||||
public Employee getSupervisor() {
|
||||
return supervisor;
|
||||
}
|
||||
|
||||
public ProjectClass getProjectClass() {
|
||||
return projectClass;
|
||||
}
|
||||
|
||||
public Integer getNumCapable() {
|
||||
return numCapable;
|
||||
}
|
||||
|
||||
public void setNumCapable(Integer numCapable) {
|
||||
this.numCapable = numCapable;
|
||||
}
|
||||
|
||||
public Long getNumMatched() {
|
||||
return numMatched;
|
||||
}
|
||||
|
||||
public void setNumMatched(Long num) {
|
||||
numMatched = num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Availability [supervisorId=" + supervisor + ", numMatched="
|
||||
+ numMatched + ", projectClassId=" + projectClass
|
||||
+ ", numCapable=" + numCapable + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result =
|
||||
prime * result + ((numCapable == null) ? 0 : numCapable.hashCode());
|
||||
result =
|
||||
prime * result + ((numMatched == null) ? 0 : numMatched.hashCode());
|
||||
result =
|
||||
prime * result
|
||||
+ ((projectClass == null) ? 0 : projectClass.hashCode());
|
||||
result =
|
||||
prime * result
|
||||
+ ((supervisor == null) ? 0 : supervisor.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Availability other = (Availability) obj;
|
||||
if (numCapable == null) {
|
||||
if (other.numCapable != null)
|
||||
return false;
|
||||
} else if (!numCapable.equals(other.numCapable))
|
||||
return false;
|
||||
if (numMatched == null) {
|
||||
if (other.numMatched != null)
|
||||
return false;
|
||||
} else if (!numMatched.equals(other.numMatched))
|
||||
return false;
|
||||
if (projectClass == null) {
|
||||
if (other.projectClass != null)
|
||||
return false;
|
||||
} else if (!projectClass.equals(other.projectClass))
|
||||
return false;
|
||||
if (supervisor == null) {
|
||||
if (other.supervisor != null)
|
||||
return false;
|
||||
} else if (!supervisor.equals(other.supervisor))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
67
src/main/java/se/su/dsv/scipro/match/dataobject/Target.java
Normal file
67
src/main/java/se/su/dsv/scipro/match/dataobject/Target.java
Normal file
@ -0,0 +1,67 @@
|
||||
package se.su.dsv.scipro.match.dataobject;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: fred-fri@dsv.su.se
|
||||
* created: 2012-11-15 13:24
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name = "target")
|
||||
@AssociationOverrides({
|
||||
@AssociationOverride(name = "targetId.employeeId",
|
||||
joinColumns = @JoinColumn(name = "role_id")),
|
||||
@AssociationOverride(name = "targetId.applicationPeriodId",
|
||||
joinColumns = @JoinColumn(name = "ApplicationPeriod_id")),
|
||||
@AssociationOverride(name = "targetId.projectClassId",
|
||||
joinColumns = @JoinColumn(name = "project_class_id"))
|
||||
})
|
||||
public class Target implements Serializable {
|
||||
|
||||
@EmbeddedId
|
||||
private TargetId targetId;
|
||||
|
||||
private int target;
|
||||
|
||||
public TargetId getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public void setTargetId(TargetId targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
public int getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(int target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public Target() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Target)) return false;
|
||||
|
||||
Target target = (Target) o;
|
||||
|
||||
if (this.target != target.target) return false;
|
||||
if (targetId != null ? !targetId.equals(target.targetId) : target.targetId != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = targetId != null ? targetId.hashCode() : 0;
|
||||
result = 31 * result + target;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package se.su.dsv.scipro.match.dataobject;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.ManyToOne;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: fred-fri@dsv.su.se
|
||||
* created: 2012-11-14 17:37
|
||||
*/
|
||||
|
||||
@Embeddable
|
||||
public class TargetId implements Serializable {
|
||||
|
||||
@Basic
|
||||
private Long employeeId;
|
||||
|
||||
@Basic
|
||||
private Long applicationPeriodId;
|
||||
|
||||
@Basic
|
||||
private Long projectClassId;
|
||||
|
||||
public Long getEmployeeId() {
|
||||
return employeeId;
|
||||
}
|
||||
|
||||
public void setEmployeeId(Long employeeId) {
|
||||
this.employeeId = employeeId;
|
||||
}
|
||||
|
||||
public Long getApplicationPeriodId() {
|
||||
return applicationPeriodId;
|
||||
}
|
||||
|
||||
public void setApplicationPeriodId(Long applicationPeriodId) {
|
||||
this.applicationPeriodId = applicationPeriodId;
|
||||
}
|
||||
|
||||
public Long getProjectClassId() {
|
||||
return projectClassId;
|
||||
}
|
||||
|
||||
public void setProjectClassId(Long projectClassId) {
|
||||
this.projectClassId = projectClassId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof TargetId)) return false;
|
||||
|
||||
TargetId targetId = (TargetId) o;
|
||||
|
||||
if (applicationPeriodId != null ? !applicationPeriodId.equals(targetId.applicationPeriodId) : targetId.applicationPeriodId != null)
|
||||
return false;
|
||||
if (employeeId != null ? !employeeId.equals(targetId.employeeId) : targetId.employeeId != null) return false;
|
||||
if (projectClassId != null ? !projectClassId.equals(targetId.projectClassId) : targetId.projectClassId != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = employeeId != null ? employeeId.hashCode() : 0;
|
||||
result = 31 * result + (applicationPeriodId != null ? applicationPeriodId.hashCode() : 0);
|
||||
result = 31 * result + (projectClassId != null ? projectClassId.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id="container">
|
||||
<a wicket:id="openLink">Reset targets and count from dates</a>
|
||||
<br/>
|
||||
<br/>
|
||||
<div wicket:id="dntWMC" class="row-fluid">
|
||||
<div class="rounded-box span12">
|
||||
<div><a wicket:id="closeLink">Close</a></div>
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<button wicket:id="resetAllBachelorTargets">Reset all bachelor target numbers</button>
|
||||
<button wicket:id="resetAllMasterTargets">Reset all master target numbers</button>
|
||||
</div>
|
||||
<div class="span8">
|
||||
<div wicket:id="currentBachelorDate"></div>
|
||||
<div wicket:id="currentMasterDate"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form wicket:id="form">
|
||||
<div class="row-fluid">
|
||||
<div class="span4" wicket:id="unitFilter"></div>
|
||||
<div class="span4" wicket:id="areaFilter"></div>
|
||||
<div class="span3"><b>Filter by name:</b><br/><input wicket:id="nameFilter"/>
|
||||
</div>
|
||||
<div class="span1"><span wicket:id="help"></span></div>
|
||||
</div>
|
||||
</form>
|
||||
<div wicket:id="dp"></div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -1,336 +0,0 @@
|
||||
package se.su.dsv.scipro.match.panel;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import se.su.dsv.scipro.admin.pages.match.AdminSupervisorSettingsPage;
|
||||
import se.su.dsv.scipro.admin.panels.match.AdminSupervisorSettingsInfoPanel;
|
||||
import se.su.dsv.scipro.components.AjaxDateFieldPanel;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.datatables.GenericDataPanel;
|
||||
import se.su.dsv.scipro.datatables.employee.EmployeeProjectLimitsInputPanel;
|
||||
import se.su.dsv.scipro.io.ExcelExportService;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.reusable.EmployeeAutoComplete;
|
||||
import se.su.dsv.scipro.reusable.SciProUtilities;
|
||||
import se.su.dsv.scipro.springdata.services.GeneralSystemSettingsService;
|
||||
import se.su.dsv.scipro.springdata.services.GenericService;
|
||||
import se.su.dsv.scipro.springdata.services.ProjectClassService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
import se.su.dsv.scipro.util.DateFormatter;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class AdminSupervisorSettingsPanel extends Panel {
|
||||
private static final long serialVersionUID = 8338471684291958056L;
|
||||
@SpringBean
|
||||
private ProjectClassService projectClassService;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsService settingsService;
|
||||
@SpringBean
|
||||
private ExcelExportService excelExportService;
|
||||
|
||||
private GenericDataPanel<Employee> genericDataPanel;
|
||||
private SupervisorService.FilterParams params;
|
||||
private Availability bachelorAvailability;
|
||||
private Availability masterAvailability;
|
||||
|
||||
private WebMarkupContainer dntWMC;
|
||||
private AjaxLink openLink;
|
||||
private AjaxLink closeLink;
|
||||
|
||||
public AdminSupervisorSettingsPanel(String id, final FeedbackPanel feedback) {
|
||||
super(id);
|
||||
final ProjectClass bachelor = projectClassService.getProjectClass(ProjectClass.BACHELOR);
|
||||
final ProjectClass master = projectClassService.getProjectClass(ProjectClass.MASTER);
|
||||
final WebMarkupContainer container = new WebMarkupContainer("container");
|
||||
final GeneralSystemSettings settings = settingsService.getGeneralSystemSettingsInstance();
|
||||
final String bachelorCountDate = settings.getBachelorCountDate()!=null?new DateFormatter().createFormattedString(settings.getBachelorCountDate()):"no date";
|
||||
final String masterCountDate = settings.getMasterCountDate()!=null?new DateFormatter().createFormattedString(settings.getMasterCountDate()):"no date";
|
||||
|
||||
container.setOutputMarkupId(true);
|
||||
add(container);
|
||||
|
||||
|
||||
dntWMC = new WebMarkupContainer("dntWMC");
|
||||
dntWMC.setOutputMarkupId(true);
|
||||
dntWMC.setVisible(false);
|
||||
container.add(dntWMC);
|
||||
|
||||
addResetTargetButtons(container, bachelor, master, feedback);
|
||||
addResetCountNumbersByDate(container, bachelor, master, settings.getBachelorCountDate(), settings.getMasterCountDate());
|
||||
|
||||
openLink = new AjaxLink("openLink") {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
target.addComponent(dntWMC);
|
||||
target.addComponent(container);
|
||||
dntWMC.setVisible(true);
|
||||
openLink.setVisible(false);
|
||||
}
|
||||
};
|
||||
openLink.setOutputMarkupId(true);
|
||||
container.add(openLink);
|
||||
|
||||
|
||||
closeLink = new AjaxLink("closeLink") {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
target.addComponent(dntWMC);
|
||||
target.addComponent(container);
|
||||
dntWMC.setVisible(false);
|
||||
openLink.setVisible(true);
|
||||
}
|
||||
};
|
||||
closeLink.setOutputMarkupId(true);
|
||||
dntWMC.add(closeLink);
|
||||
|
||||
|
||||
container.add(new FilterForm("form"));
|
||||
container.add(genericDataPanel = new GenericDataPanel<Employee>("dp") {
|
||||
|
||||
private static final long serialVersionUID = -2698025613140440493L;
|
||||
|
||||
@Override
|
||||
public GenericService<Employee, Long> getService() {
|
||||
return supervisorService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Employee> getIterator() {
|
||||
return supervisorService.findAll(params, new PageRequest(getTable().getCurrentPage(), getTable().getRowsPerPage(), getSort())).iterator();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillExcelSheet(HSSFSheet sheet, List<Employee> list, int rowIndex) {
|
||||
for (int i=rowIndex; i+rowIndex<list.size(); i++) {
|
||||
HSSFRow row = sheet.createRow((short) i+1);
|
||||
Employee emp = list.get(i);
|
||||
Availability bachelorNumbers = supervisorService.getNewIdeaAvailability(emp, bachelor);
|
||||
Availability masterNumbers = supervisorService.getNewIdeaAvailability(emp, master);
|
||||
excelExportService.createCell(row, 0, emp.getUser().getFirstName(), sheet);
|
||||
excelExportService.createCell(row, 1, emp.getUser().getLastName(), sheet);
|
||||
excelExportService.createCell(row, 2, emp.getUnit()!=null?emp.getUnit().getTitle():"", sheet);
|
||||
excelExportService.createCell(row, 3, emp.getResearchAreas().toString(), sheet);
|
||||
excelExportService.createCell(row, 4, bachelorNumbers.getNumCapable()+"", sheet);
|
||||
excelExportService.createCell(row, 5, masterNumbers.getNumCapable()+"", sheet);
|
||||
excelExportService.createCell(row, 6, bachelorNumbers.getNumMatched()+"", sheet);
|
||||
excelExportService.createCell(row, 7, masterNumbers.getNumMatched()+"", sheet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getExcelHeaders() {
|
||||
return Arrays.asList(new String[]{"First name", "Last name", "Unit", "Research areas", "Target bachelor", "Target master",
|
||||
"Current bachelors (Since "+bachelorCountDate+")", "Current masters (Since "+masterCountDate+")"});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExcelTitle() {
|
||||
return "Supervisor target numbers";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Employee> getExcelIterator() {
|
||||
return supervisorService.findAll(params, new PageRequest(0, Integer.MAX_VALUE, getSort())).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize(){
|
||||
return SciProUtilities.safeLongToInt(supervisorService.count(params));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSortString() {
|
||||
return "user.firstName";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addColumns() {
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("First name"), "user.firstName", "user.firstName"));
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("Last name"), "user.lastName", "user.lastName"));
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("Unit"), "unit.title", "unit"));
|
||||
getColumns().add(new PropertyColumn<Employee>(Model.of("Research areas"), "researchAreas"));
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of("Target bachelor")) {
|
||||
private static final long serialVersionUID = 6865714578537238681L;
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String componentId, IModel<Employee> rowModel) {
|
||||
bachelorAvailability = supervisorService.getNewIdeaAvailability(rowModel.getObject(), bachelor);
|
||||
//bachelorAvailability = supervisorService.getAvailability(rowModel.getObject(), bachelor);
|
||||
item.add(new EmployeeProjectLimitsInputPanel(componentId, bachelorAvailability, container, feedback));
|
||||
}
|
||||
});
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of("Target master")) {
|
||||
private static final long serialVersionUID = -3462795850773285065L;
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String componentId, IModel<Employee> rowModel) {
|
||||
masterAvailability = supervisorService.getNewIdeaAvailability(rowModel.getObject(), master);
|
||||
//masterAvailability = supervisorService.getAvailability(rowModel.getObject(), master);
|
||||
item.add(new EmployeeProjectLimitsInputPanel(componentId, masterAvailability, container, feedback));
|
||||
}
|
||||
|
||||
});
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of("Current bachelors (Since "+bachelorCountDate+")")) {
|
||||
private static final long serialVersionUID = -112984729843654916L;
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String componentId, IModel<Employee> rowModel) {
|
||||
item.add(new Label(componentId, bachelorAvailability.getNumMatched()+""));
|
||||
}
|
||||
});
|
||||
getColumns().add(new AbstractColumn<Employee>(Model.of("Current masters (Since "+masterCountDate+")")) {
|
||||
private static final long serialVersionUID = -112984729843654916L;
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Employee>> item, String componentId, IModel<Employee> rowModel) {
|
||||
item.add(new Label(componentId, masterAvailability.getNumMatched()+""));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void addResetTargetButtons(final WebMarkupContainer container, final ProjectClass bachelor, final ProjectClass master, final FeedbackPanel feedback) {
|
||||
|
||||
AjaxLink<Void> resetAllBachelorTargets = new AjaxLink<Void>("resetAllBachelorTargets") {
|
||||
private static final long serialVersionUID = -7778030814119885418L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
supervisorService.resetAllTargetNumbers(bachelor);
|
||||
info("Reset of bachelor target numbers completed");
|
||||
target.addComponent(feedback);
|
||||
target.addComponent(container);
|
||||
}
|
||||
|
||||
};
|
||||
AjaxLink<Void> resetAllMasterTargets = new AjaxLink<Void>("resetAllMasterTargets") {
|
||||
private static final long serialVersionUID = 7985976497835986380L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
supervisorService.resetAllTargetNumbers(master);
|
||||
info("Reset of master target numbers completed");
|
||||
target.addComponent(container);
|
||||
target.addComponent(feedback);
|
||||
}
|
||||
|
||||
};
|
||||
resetAllBachelorTargets.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to reset all supervisors bachelor target numbers?"));
|
||||
resetAllMasterTargets.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to reset all supervisors master target numbers?"));
|
||||
dntWMC.add(resetAllBachelorTargets);
|
||||
dntWMC.add(resetAllMasterTargets);
|
||||
}
|
||||
|
||||
private void addResetCountNumbersByDate(final WebMarkupContainer container, final ProjectClass bachelor, final ProjectClass master, final Date bachelorDate, final Date masterDate) {
|
||||
|
||||
AjaxDateFieldPanel bachelorDateField = new AjaxDateFieldPanel("currentBachelorDate", bachelorDate, "Count current bachelors since: ", "Are you sure you want to change the count since date for the bachelor level?") {
|
||||
private static final long serialVersionUID = -4305117901093246596L;
|
||||
|
||||
@Override
|
||||
public void updateDate(AjaxRequestTarget target) {
|
||||
supervisorService.resetCountFromDate(bachelor, getDate());
|
||||
getSession().info("Current bachelors now counting since: " + new DateFormatter().createFormattedString(getDate()));
|
||||
setResponsePage(AdminSupervisorSettingsPage.class);
|
||||
}
|
||||
};
|
||||
AjaxDateFieldPanel masterDateField = new AjaxDateFieldPanel("currentMasterDate", masterDate, "Count current masters since: ", "Are you sure you want to change the count since date for the master level?") {
|
||||
private static final long serialVersionUID = 7596946266368385037L;
|
||||
|
||||
@Override
|
||||
public void updateDate(AjaxRequestTarget target) {
|
||||
supervisorService.resetCountFromDate(master, getDate());
|
||||
getSession().info("Current masters now counting since: " + new DateFormatter().createFormattedString(getDate()));
|
||||
setResponsePage(AdminSupervisorSettingsPage.class);
|
||||
}
|
||||
};
|
||||
dntWMC.add(bachelorDateField);
|
||||
dntWMC.add(masterDateField);
|
||||
}
|
||||
|
||||
private class FilterForm extends Form<Void> {
|
||||
|
||||
private static final long serialVersionUID = -6837178911713319977L;
|
||||
|
||||
public FilterForm(String id) {
|
||||
super(id);
|
||||
params = new SupervisorService.FilterParams();
|
||||
|
||||
add(new AdminSupervisorSettingsInfoPanel("help"));
|
||||
|
||||
//FILTER BY UNIT
|
||||
final FilterFormUnitPanel unitFilter = new FilterFormUnitPanel("unitFilter", true) {
|
||||
private static final long serialVersionUID = -5395913265109372627L;
|
||||
|
||||
@Override
|
||||
public void ajaxUpdate(AjaxRequestTarget target) {
|
||||
if(getOption().equals("None")){
|
||||
params.setUnit(null);
|
||||
params.setNoUnit(true);
|
||||
} else {
|
||||
params.setUnit(getUnit());
|
||||
params.setNoUnit(false);
|
||||
}
|
||||
target.addComponent(genericDataPanel.getWMC());
|
||||
}
|
||||
};
|
||||
params.setUnit(null);
|
||||
add(unitFilter);
|
||||
|
||||
//FILTER BY RESEARCH AREA (true to add none-option)
|
||||
final FilterFormAreaPanel areaFilter = new FilterFormAreaPanel("areaFilter", true) {
|
||||
private static final long serialVersionUID = -1751214432450157380L;
|
||||
|
||||
@Override
|
||||
public void ajaxUpdate(AjaxRequestTarget target) {
|
||||
if(getOption().equals("None")){
|
||||
params.setResearchArea(null);
|
||||
params.setNoAreas(true);
|
||||
}
|
||||
else {
|
||||
params.setResearchArea(getArea());
|
||||
params.setNoAreas(false);
|
||||
}
|
||||
target.addComponent(genericDataPanel.getWMC());
|
||||
}
|
||||
};
|
||||
params.setResearchArea(null);
|
||||
add(areaFilter);
|
||||
|
||||
//FILTER BY SUPERVISOR
|
||||
add(new EmployeeAutoComplete("nameFilter") {
|
||||
private static final long serialVersionUID = 3754694873165687588L;
|
||||
|
||||
@Override
|
||||
protected void action(AjaxRequestTarget pTarget, Employee newSelection) {
|
||||
params.setSupervisor(newSelection);
|
||||
pTarget.addComponent(genericDataPanel.getWMC());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,12 +12,21 @@
|
||||
<b>Start date:</b> <span wicket:id="startDate"></span>
|
||||
<b>End date:</b> <span wicket:id="endDate"></span>
|
||||
<b>Course start date:</b> <span wicket:id="courseStartDate"></span><br>
|
||||
<a wicket:id="selectSupervisorIdeas">Select from available ideas</a> <a wicket:id="createIdea">Create new idea</a> <a wicket:id="selectStudentIdeas">Select student ideas</a>
|
||||
|
||||
<div wicket:id="studentContainer">
|
||||
<a wicket:id="selectSupervisorIdeas">Select from available ideas</a> <a wicket:id="createIdea">Create new idea</a>
|
||||
</div>
|
||||
|
||||
<div wicket:id="supervisorContainer">
|
||||
<div><b>Targets:</b> <span wicket:id="bachelorTargets"></span> Bachelor, <span wicket:id="masterTargets"></span> Master <b>Currently matched:</b> <span wicket:id="bachelorCurrent"></span> Bachelor, <span wicket:id="masterCurrent"></span> Master</div>
|
||||
<a wicket:id="selectStudentIdeas">Select student ideas</a>
|
||||
|
||||
<!--<div wicket:id="noTargets">You either have no targets or no targets left for this application period</div>-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div wicket:id="emptyLabel"></div>
|
||||
<br/>
|
||||
|
||||
<div wicket:id="availability"></div>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
@ -2,6 +2,7 @@ package se.su.dsv.scipro.match.panel;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import org.apache.wicket.PageParameters;
|
||||
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;
|
||||
@ -10,17 +11,19 @@ import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.enums.DateStyle;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
import se.su.dsv.scipro.project.pages.ProjectNewAllSupervisorIdeasPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectNewIdeaSubmissionPage;
|
||||
import se.su.dsv.scipro.springdata.services.ApplicationPeriodService;
|
||||
import se.su.dsv.scipro.springdata.services.StudentService;
|
||||
import se.su.dsv.scipro.springdata.services.*;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorNewAllStudentIdeasPage;
|
||||
import se.su.dsv.scipro.supervisor.panels.SupervisorNewAvailabilityPanel;
|
||||
import se.su.dsv.scipro.util.DateFormatter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class NewApplicationPeriodInfoPanel extends Panel {
|
||||
@ -30,9 +33,20 @@ public class NewApplicationPeriodInfoPanel extends Panel {
|
||||
@SpringBean
|
||||
private ApplicationPeriodService periodService;
|
||||
@SpringBean
|
||||
private NewIdeaService newIdeaService;
|
||||
@SpringBean
|
||||
private StudentService studentService;
|
||||
private final boolean supervisorView;
|
||||
|
||||
@SpringBean
|
||||
private EmployeeService employeeService;
|
||||
@SpringBean
|
||||
private TargetService targetService;
|
||||
|
||||
@SpringBean
|
||||
private ProjectClassService projectClassService;
|
||||
|
||||
|
||||
public NewApplicationPeriodInfoPanel(String id, boolean supervisorView) {
|
||||
super(id);
|
||||
this.supervisorView = supervisorView;
|
||||
@ -43,10 +57,6 @@ public class NewApplicationPeriodInfoPanel extends Panel {
|
||||
else currentPeriods = periodService.getCurrentPeriods(new Date(), studentService.findByUser(SciProSession.get().getUser()));
|
||||
|
||||
addListOfPeriods(currentPeriods);
|
||||
if (supervisorView)
|
||||
addAvailabilityInfo();
|
||||
else
|
||||
add(new EmptyPanel(NewApplicationPeriodInfoPanel.AVAILABILITY));
|
||||
}
|
||||
|
||||
private void addListOfPeriods(final List<ApplicationPeriod> currentPeriods) {
|
||||
@ -65,8 +75,8 @@ public class NewApplicationPeriodInfoPanel extends Panel {
|
||||
addPeriodInfo(item);
|
||||
}
|
||||
|
||||
private void addPeriodInfo(ListItem<ApplicationPeriod> item) {
|
||||
ApplicationPeriod ap = item.getModelObject();
|
||||
private void addPeriodInfo(final ListItem<ApplicationPeriod> item) {
|
||||
final ApplicationPeriod ap = item.getModelObject();
|
||||
item.add(new Label(PROJECT_CLASS, Joiner.on(", ").join(ap.getProjectClass())));
|
||||
item.add(new Label(START_DATE, format(ap.getStartDate())));
|
||||
item.add(new Label(END_DATE, format(ap.getEndDate())));
|
||||
@ -75,29 +85,57 @@ public class NewApplicationPeriodInfoPanel extends Panel {
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put("apid", item.getModelObject().getId());
|
||||
|
||||
item.add(new BookmarkablePageLink<Void>(SELECT_SUPERVISOR, ProjectNewAllSupervisorIdeasPage.class, pp) {
|
||||
WebMarkupContainer studentContainer = new WebMarkupContainer(STUDENT_CONTAINER){
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisibilityAllowed(!supervisorView);
|
||||
setVisibilityAllowed(!supervisorView && !newIdeaService.authorParticipatingOnIdea(studentService.findByUser(SciProSession.get().getUser()), item.getModelObject()));
|
||||
}
|
||||
});
|
||||
};
|
||||
item.add(studentContainer);
|
||||
studentContainer.add(new BookmarkablePageLink<Void>(SELECT_SUPERVISOR, ProjectNewAllSupervisorIdeasPage.class, pp));
|
||||
studentContainer.add(new BookmarkablePageLink<Void>(CREATE, ProjectNewIdeaSubmissionPage.class, pp));
|
||||
|
||||
item.add(new BookmarkablePageLink<Void>(CREATE, ProjectNewIdeaSubmissionPage.class, pp){
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisibilityAllowed(!supervisorView);
|
||||
}
|
||||
});
|
||||
|
||||
item.add(new BookmarkablePageLink<Void>(SELECT_STUDENT, SupervisorNewAllStudentIdeasPage.class, pp){
|
||||
WebMarkupContainer supervisorContainer = new WebMarkupContainer(SUPERVISOR_CONTAINER){
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisibilityAllowed(supervisorView);
|
||||
}
|
||||
};
|
||||
item.add(supervisorContainer);
|
||||
|
||||
supervisorContainer.add(new BookmarkablePageLink<Void>(SELECT_STUDENT, SupervisorNewAllStudentIdeasPage.class, pp){
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisibilityAllowed(targetService.hasTargetsLeft(ap, employeeService.findByUser(SciProSession.get().getUser())));
|
||||
}
|
||||
});
|
||||
|
||||
if (supervisorView){
|
||||
supervisorContainer.add(new Label(BACHELOR_TARGETS, Integer.toString(targetService.findOne(ap, employeeService.findByUser(SciProSession.get().getUser()), projectClassService.getProjectClass(ProjectClass.BACHELOR)).getTarget())));
|
||||
supervisorContainer.add(new Label(MASTER_TARGETS, Integer.toString(targetService.findOne(ap, employeeService.findByUser(SciProSession.get().getUser()), projectClassService.getProjectClass(ProjectClass.MASTER)).getTarget())));
|
||||
|
||||
supervisorContainer.add(new Label(BACHELOR_CURRENT, Long.toString(newIdeaService.countMatched(ap, employeeService.findByUser(SciProSession.get().getUser()), projectClassService.getProjectClass(ProjectClass.BACHELOR)))));
|
||||
supervisorContainer.add(new Label(MASTER_CURRENT, Long.toString(newIdeaService.countMatched(ap, employeeService.findByUser(SciProSession.get().getUser()), projectClassService.getProjectClass(ProjectClass.MASTER)))));
|
||||
|
||||
} else {
|
||||
supervisorContainer.add(new EmptyPanel(BACHELOR_TARGETS));
|
||||
supervisorContainer.add(new EmptyPanel(MASTER_TARGETS));
|
||||
supervisorContainer.add(new EmptyPanel(BACHELOR_CURRENT));
|
||||
supervisorContainer.add(new EmptyPanel(MASTER_CURRENT));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// supervisorContainer.add(new WebMarkupContainer(NO_TARGETS){
|
||||
// @Override
|
||||
// protected void onConfigure() {
|
||||
// super.onConfigure();
|
||||
// setVisibilityAllowed(!targetService.hasTargetsLeft(ap, employeeService.findByUser(SciProSession.get().getUser())));
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,10 +154,6 @@ public class NewApplicationPeriodInfoPanel extends Panel {
|
||||
);
|
||||
}
|
||||
|
||||
private void addAvailabilityInfo() {
|
||||
add(new SupervisorNewAvailabilityPanel(AVAILABILITY, SciProSession.get().getUser()));
|
||||
}
|
||||
|
||||
private String format(Date date) {
|
||||
return new DateFormatter(DateStyle.DATETIME).createFormattedString(date);
|
||||
}
|
||||
@ -131,7 +165,14 @@ public class NewApplicationPeriodInfoPanel extends Panel {
|
||||
static final String COURSE_START_DATE = "courseStartDate";
|
||||
static final String AVAILABILITY = "availability";
|
||||
static final String EMPTY = "emptyLabel";
|
||||
static final String STUDENT_CONTAINER = "studentContainer";
|
||||
static final String SUPERVISOR_CONTAINER = "supervisorContainer";
|
||||
static final String SELECT_STUDENT = "selectStudentIdeas";
|
||||
static final String SELECT_SUPERVISOR = "selectSupervisorIdeas";
|
||||
static final String CREATE = "createIdea";
|
||||
static final String NO_TARGETS = "noTargets";
|
||||
static final String BACHELOR_TARGETS = "bachelorTargets";
|
||||
static final String MASTER_TARGETS = "masterTargets";
|
||||
static final String BACHELOR_CURRENT = "bachelorCurrent";
|
||||
static final String MASTER_CURRENT = "masterCurrent";
|
||||
}
|
||||
|
@ -0,0 +1,123 @@
|
||||
//package se.su.dsv.scipro.project.panels;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import org.apache.wicket.markup.html.basic.EnclosureContainer;
|
||||
//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.model.IModel;
|
||||
//
|
||||
//import se.su.dsv.scipro.data.dataobjects.Language;
|
||||
//import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
//import se.su.dsv.scipro.match.dataobject.IdeaParticipation;
|
||||
//import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
//import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
//import se.su.dsv.scipro.util.DateFormatter;
|
||||
//
|
||||
//public class ProjectIdeaDetailsPanel extends Panel {
|
||||
//
|
||||
// private static final long serialVersionUID = -8165939637975042836L;
|
||||
//
|
||||
// public ProjectIdeaDetailsPanel(String id, IModel<SupervisorIdea> model, boolean showAuthors, boolean showWatsons) {
|
||||
// super(id, model);
|
||||
// add(new Label("supervisor", model.getObject().getMatch().getSupervisor().getNameAsString() + " " + model.getObject().getMatch().getSupervisor().getEmailAsString()).setVisible(model.getObject().isShowSupervisor() || (model.getObject().getApplicationPeriod()!=null && model.getObject().getApplicationPeriod().getCourseStartDate().before(new Date()))));
|
||||
//
|
||||
// if (model.getObject().getFirstMeeting()!=null && model.getObject().getFirstMeeting().getFirstMeetingDate()!=null){
|
||||
// add(new DateFormatter(DateFormatter.FORMAT.EXTENDED).createFormattedDateLabel("firstMeeting", model.getObject().getFirstMeeting().getFirstMeetingDate()));
|
||||
// } else {
|
||||
// add(new Label("firstMeeting", "Not entered by supervisor yet"));
|
||||
// }
|
||||
//
|
||||
// if (model.getObject().getFirstMeeting()!=null && model.getObject().getFirstMeeting().getDescription()!=null){
|
||||
// add(new Label("firstMeetingDetails", model.getObject().getFirstMeeting().getDescription()));
|
||||
// } else {
|
||||
// add(new Label("firstMeetingDetails", "Not entered by supervisor yet"));
|
||||
// }
|
||||
//
|
||||
// add(new Label("level", model.getObject().getProjectClass().getName()));
|
||||
// add(new Label("title", model.getObject().getTitle()));
|
||||
// add(new Label("description", model.getObject().getDescription()));
|
||||
// if(model.getObject().getResearchArea()!=null)
|
||||
// add(new Label("area", model.getObject().getResearchArea().toString()));
|
||||
// else
|
||||
// add(new Label("area", "No research area selected"));
|
||||
// if(model.getObject().getRequirements()!=null)
|
||||
// add(new Label("reqs", model.getObject().getRequirements()));
|
||||
// else
|
||||
// add(new Label("reqs", "No prerequisites added"));
|
||||
// addKeywords(model);
|
||||
// addLanguages(model);
|
||||
// addAuthorsEnclosure(model, showAuthors); //List of authors so the partner knows who to write with before accepting
|
||||
// addWatsonInfo(model, showWatsons); //Watson info when viewing in supervisor view
|
||||
// }
|
||||
//
|
||||
// private void addKeywords(IModel<SupervisorIdea> model) {
|
||||
// final Set<Keyword> keywords = model.getObject().getKeywords();
|
||||
// ListView<Keyword> keyList = new ListView<Keyword>("keywords", new ArrayList<Keyword>(keywords)) {
|
||||
// private static final long serialVersionUID = 470796140309547562L;
|
||||
//
|
||||
// @Override
|
||||
// protected void populateItem(ListItem<Keyword> item) {
|
||||
// item.add(new Label("keyName", item.getModelObject().getKeyword()));
|
||||
// }
|
||||
//
|
||||
// };
|
||||
// add(new Label("noKeysLabel", "No keywords available").setVisible(keywords.isEmpty()));
|
||||
// add(keyList);
|
||||
// }
|
||||
//
|
||||
// private void addLanguages(IModel<SupervisorIdea> model) {
|
||||
// final Set<Language> languages = model.getObject().getMatch().getSupervisor().getLanguages();
|
||||
// ListView<Language> languageList = new ListView<Language>("languages", new ArrayList<Language>(languages)) {
|
||||
//
|
||||
// private static final long serialVersionUID = 6863017537282488522L;
|
||||
//
|
||||
// @Override
|
||||
// protected void populateItem(ListItem<Language> item) {
|
||||
// item.add(new Label("languageName", item.getModelObject().getName()));
|
||||
// }
|
||||
//
|
||||
// };
|
||||
// add(new Label("noLanguageLabel", "No languages selected").setVisible(languages.isEmpty()));
|
||||
// add(languageList);
|
||||
// }
|
||||
//
|
||||
// private void addAuthorsEnclosure(IModel<SupervisorIdea> model, boolean showAuthors) {
|
||||
// List<Student> authors = new ArrayList<Student>();
|
||||
// for (IdeaParticipation ip : model.getObject().getIdeaParticipations())
|
||||
// authors.add(ip.getStudent());
|
||||
// ListView<Student> authorList = new ListView<Student>("authorList", authors) {
|
||||
// private static final long serialVersionUID = -3951835080975833866L;
|
||||
//
|
||||
// @Override
|
||||
// protected void populateItem(ListItem<Student> item) {
|
||||
// item.add(new Label("authorName", item.getModelObject().getNameAsString()));
|
||||
// }
|
||||
// };
|
||||
// authorList.setVisible(showAuthors);
|
||||
// EnclosureContainer authorEnclosure = new EnclosureContainer("authorsEnclosure", authorList);
|
||||
// authorEnclosure.add(authorList);
|
||||
// add(authorEnclosure);
|
||||
// }
|
||||
//
|
||||
// private void addWatsonInfo(IModel<SupervisorIdea> model, boolean showWatsons) {
|
||||
// String whatString = model.getObject().getWatson().getWhat().equals("")?"Waiting for student to fill in":model.getObject().getWatson().getWhat();
|
||||
// String whyString = model.getObject().getWatson().getWhy().equals("")?"Waiting for student to fill in":model.getObject().getWatson().getWhy();
|
||||
// String theoryString = model.getObject().getWatson().getTheoryHow().equals("")?"Waiting for student to fill in":model.getObject().getWatson().getTheoryHow();
|
||||
// String pracString = model.getObject().getWatson().getPracticalHow().equals("")?"Waiting for student to fill in":model.getObject().getWatson().getPracticalHow();
|
||||
//
|
||||
// Label what = new Label("what", whatString);
|
||||
// what.setVisible(showWatsons);
|
||||
// EnclosureContainer watsonEnclosure = new EnclosureContainer("watsonEnclosure", what);
|
||||
// watsonEnclosure.add(new Label("why", whyString));
|
||||
// watsonEnclosure.add(new Label("theory", theoryString));
|
||||
// watsonEnclosure.add(new Label("practical", pracString));
|
||||
// watsonEnclosure.add(what);
|
||||
// add(watsonEnclosure);
|
||||
// }
|
||||
//}
|
@ -23,6 +23,7 @@ import se.su.dsv.scipro.match.dataobject.NewMatch.Status;
|
||||
import se.su.dsv.scipro.match.panel.FilterFormAreaPanel;
|
||||
import se.su.dsv.scipro.match.panel.FilterFormCheckBoxPanel;
|
||||
import se.su.dsv.scipro.match.panel.FilterKeywordsPanel;
|
||||
import se.su.dsv.scipro.reusable.SciProUtilities;
|
||||
import se.su.dsv.scipro.springdata.services.*;
|
||||
import se.su.dsv.scipro.springdata.services.NewIdeaService.FilterParams;
|
||||
|
||||
@ -75,12 +76,16 @@ public class ProjectNewAllSupervisorIdeasPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public Iterator<NewIdea> getIterator() {
|
||||
return ideaService.findIdeasWithinLimits(params, new PageRequest(getTable().getCurrentPage(), getTable().getRowsPerPage(), getSort())).iterator();
|
||||
// return ideaService.findAll(params, new PageRequest(getTable().getCurrentPage(), getTable().getRowsPerPage(), getSort())).iterator();
|
||||
// return ideaService.findIdeasWithinLimits(params, new PageRequest(getTable().getCurrentPage(), getTable().getRowsPerPage(), getSort())).iterator();
|
||||
return ideaService.findIdeasPossibleToMatch(applicationPeriod, params, new PageRequest(getTable().getCurrentPage(), getTable().getRowsPerPage(), getSort())).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return ideaService.countIdeasWithinLimits(params);
|
||||
// return SciProUtilities.safeLongToInt(ideaService.countAll(params));
|
||||
// return ideaService.countIdeasWithinLimits(params);
|
||||
return ideaService.countIdeasPossibleToMatch(applicationPeriod, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,7 +118,7 @@ public class ProjectNewAllSupervisorIdeasPanel extends Panel {
|
||||
private void addFiltering() {
|
||||
// currentLevels = projectClassService.findAllCurrentlyOpen(studentService.findByUser(SciProSession.get().getUser()));
|
||||
params = new FilterParams();
|
||||
|
||||
|
||||
//We only want to show Supervisor ideas that are unmatched
|
||||
params.setTypes(Arrays.asList(new Type[]{Type.SUPERVISOR}));
|
||||
params.setStatuses(Arrays.asList(new Status[]{Status.UNMATCHED}));
|
||||
|
@ -0,0 +1,23 @@
|
||||
package se.su.dsv.scipro.springdata.repos;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
//import se.su.dsv.scipro.match.dataobject.ProjectIdea;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: fred-fri
|
||||
* date: 2012 03 26
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public interface TargetRepo extends JpaRepository<Target, Long>, QueryDslPredicateExecutor<Target> {
|
||||
|
||||
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ 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.Student;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
@ -87,8 +88,9 @@ public class ApplicationPeriodServiceImpl extends AbstractQueryService<Applicati
|
||||
if (iterator.hasNext()){
|
||||
ApplicationPeriod earliest = iterator.next();
|
||||
while (iterator.hasNext()){
|
||||
if (iterator.next().getStartDate().before(earliest.getStartDate())){
|
||||
earliest = iterator.next();
|
||||
ApplicationPeriod check = iterator.next();
|
||||
if (check.getStartDate().before(earliest.getStartDate())){
|
||||
earliest = check;
|
||||
}
|
||||
}
|
||||
return earliest;
|
||||
@ -141,6 +143,26 @@ public class ApplicationPeriodServiceImpl extends AbstractQueryService<Applicati
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationPeriod getPrevious(ApplicationPeriod ap) {
|
||||
if (ap == null){
|
||||
return null;
|
||||
}
|
||||
Iterator<ApplicationPeriod> iterator = applicationPeriodRepo.findAll(startedBefore(ap.getStartDate())).iterator();
|
||||
|
||||
if (iterator.hasNext()){
|
||||
ApplicationPeriod latest = iterator.next();
|
||||
while (iterator.hasNext()){
|
||||
ApplicationPeriod check = iterator.next();
|
||||
if (check.getStartDate().after(latest.getStartDate())){
|
||||
latest = check;
|
||||
}
|
||||
}
|
||||
return latest;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BooleanExpression haveProjectClass(ProjectClass pc) {
|
||||
return QApplicationPeriod.applicationPeriod.projectClass.contains(pc);
|
||||
}
|
||||
@ -168,7 +190,4 @@ public class ApplicationPeriodServiceImpl extends AbstractQueryService<Applicati
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.activityplan.facade.ProjectScheduleFacade;
|
||||
import se.su.dsv.scipro.data.controllers.NotificationController;
|
||||
import se.su.dsv.scipro.data.dataobjects.*;
|
||||
@ -21,6 +22,7 @@ import se.su.dsv.scipro.notifications.dataobject.IdeaEvent;
|
||||
import se.su.dsv.scipro.notifications.dataobject.NotificationSource;
|
||||
import se.su.dsv.scipro.notifications.util.NotificationSourceGenerator;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.Pair;
|
||||
import se.su.dsv.scipro.reusable.SciProUtilities;
|
||||
import se.su.dsv.scipro.springdata.repos.NewIdeaRepo;
|
||||
import se.su.dsv.scipro.springdata.services.*;
|
||||
import se.su.dsv.scipro.util.DateFormatter;
|
||||
@ -59,6 +61,8 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
NotificationService notificationService;
|
||||
@Resource
|
||||
ProjectScheduleFacade projectScheduleFacade;
|
||||
@Resource
|
||||
TargetService targetService;
|
||||
|
||||
|
||||
private transient Logger logger = Logger.getLogger(NewIdeaService.class);
|
||||
@ -88,18 +92,6 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
public Page<NewIdea> findAuthorIdeas(Student author, Pageable pageable) {
|
||||
return newIdeaRepo.findIdeas(author, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<NewIdea> findIdeasWithinLimits(FilterParams params, Pageable pageable) {
|
||||
Iterable<NewIdea> ideas = newIdeaRepo.findAll(fromParams(params).and(isPublished(true)));
|
||||
List<NewIdea> ideasWithinLimits = new ArrayList<NewIdea>();
|
||||
for(NewIdea idea : ideas){
|
||||
if(supervisorService.withinLimits(idea.getMatch().getSupervisor(), idea.getProjectClass()))
|
||||
ideasWithinLimits.add(idea);
|
||||
}
|
||||
return newIdeaRepo.findAll(inList(ideasWithinLimits), pageable);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NewIdea> findIdeas(Status status, Student author, boolean confirmed) {
|
||||
@ -143,11 +135,6 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
return newIdeaRepo.countAuthorIdeas(author);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countMatchedIdeas(Employee supervisor, ProjectClass pc) {
|
||||
return newIdeaRepo.count(byStatus(Status.MATCHED).and(bySupervisor(supervisor)).and(byLevel(pc)).and(byMatchDate(supervisor.getCountFromDate(pc))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countIdeasByApplicationPeriod(ApplicationPeriod ap) {
|
||||
return newIdeaRepo.count(byPeriod(ap));
|
||||
@ -159,49 +146,39 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countIdeasWithinLimits(FilterParams params) {
|
||||
Iterable<NewIdea> ideas = newIdeaRepo.findAll(fromParams(params));
|
||||
List<NewIdea> ideasWithinLimits = new ArrayList<NewIdea>();
|
||||
for(NewIdea idea : ideas){
|
||||
if(supervisorService.withinLimits(idea.getMatch().getSupervisor(), idea.getProjectClass()))
|
||||
ideasWithinLimits.add(idea);
|
||||
}
|
||||
return ideasWithinLimits.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Boolean, String> validateSupervisorIdeaSubmission(NewIdea idea, SortedSet<Student> authors, List<Keyword> keywords) {
|
||||
// public Pair<Boolean, String> validateSupervisorIdeaSubmission(NewIdea idea, SortedSet<Student> authors, List<Keyword> keywords) {
|
||||
public Pair<Boolean, String> validateSupervisorIdeaSubmission(NewIdea idea, List<Keyword> keywords) {
|
||||
if (idea.getDescription().length() > DESCRIPTION_MAX_CHARS)
|
||||
return new Pair<Boolean, String>(false, "Description field is over the character limit of " + DESCRIPTION_MAX_CHARS + " characters");
|
||||
if (idea.getPrerequisites() != null && idea.getPrerequisites().length() > REQS_MAX_CHARS)
|
||||
return new Pair<Boolean, String>(false, "Required prerequisites field is over the character limit of " + REQS_MAX_CHARS + " characters");
|
||||
if (keywords == null || keywords.isEmpty())
|
||||
return new Pair<Boolean, String>(false, "You need to select at least one keyword");
|
||||
if(!authors.isEmpty()) {
|
||||
if (idea.getProjectClass().getCode().equals(ProjectClass.BACHELOR)
|
||||
&& authors.size() != BACHELOR_STUDENTS
|
||||
&& (authors.size() == 1 && !exemptionService.isExemptionGranted(authors.first(), idea.getProjectClass()))) {
|
||||
return new Pair<Boolean, String>(false, "Selected number of bachelor students is not allowed");
|
||||
}
|
||||
if (idea.getProjectClass().getCode().equals(ProjectClass.MASTER) && authors.size() > MAX_MASTER_STUDENTS) {
|
||||
return new Pair<Boolean, String>(false, "Selected number of master students is not allowed");
|
||||
}
|
||||
if (applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()) == null && applicationPeriodService.getNextPeriodByProjectClass(idea.getProjectClass()) == null)
|
||||
return new Pair<Boolean, String>(false, "No application period for the selected project level is open and no upcoming application period is available. Students may not be added to the idea");
|
||||
|
||||
ApplicationPeriod ap;
|
||||
if (applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()) != null) {
|
||||
ap = applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass());
|
||||
} else {
|
||||
ap = applicationPeriodService.getNextPeriodByProjectClass(idea.getProjectClass());
|
||||
}
|
||||
|
||||
for (Student s : authors) {
|
||||
if (authorParticipatingOnIdea(s, ap)) {
|
||||
return new Pair<Boolean, String>(false, "Student already attached to another idea");
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(!authors.isEmpty()) {
|
||||
// if (idea.getProjectClass().getCode().equals(ProjectClass.BACHELOR)
|
||||
// && authors.size() != BACHELOR_STUDENTS
|
||||
// && (authors.size() == 1 && !exemptionService.isExemptionGranted(authors.first(), idea.getProjectClass()))) {
|
||||
// return new Pair<Boolean, String>(false, "Selected number of bachelor students is not allowed");
|
||||
// }
|
||||
// if (idea.getProjectClass().getCode().equals(ProjectClass.MASTER) && authors.size() > MAX_MASTER_STUDENTS) {
|
||||
// return new Pair<Boolean, String>(false, "Selected number of master students is not allowed");
|
||||
// }
|
||||
// if (applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()) == null && applicationPeriodService.getNextPeriodByProjectClass(idea.getProjectClass()) == null)
|
||||
// return new Pair<Boolean, String>(false, "No application period for the selected project level is open and no upcoming application period is available. Students may not be added to the idea");
|
||||
//
|
||||
// ApplicationPeriod ap;
|
||||
// if (applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()) != null) {
|
||||
// ap = applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass());
|
||||
// } else {
|
||||
// ap = applicationPeriodService.getNextPeriodByProjectClass(idea.getProjectClass());
|
||||
// }
|
||||
//
|
||||
// for (Student s : authors) {
|
||||
// if (authorParticipatingOnIdea(s, ap)) {
|
||||
// return new Pair<Boolean, String>(false, "Student already attached to another idea");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return new Pair<Boolean, String>(true, "Validation passed");
|
||||
}
|
||||
|
||||
@ -243,7 +220,8 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
idea = findOne(idea.getId());
|
||||
if(!idea.getMatch().getStatus().equals(Status.UNMATCHED))
|
||||
return new Pair<Boolean, String>(false, "Idea has already been matched");
|
||||
if(!supervisorService.withinLimits(supervisor, pc)) //TODO limits within application period!
|
||||
// if(!supervisorService.withinLimits(supervisor, pc)) //TODO limits within application period!
|
||||
if (!targetService.hasTargetsLeft(idea.getApplicationPeriod(), supervisorService.findByUser(SciProSession.get().getUser()), idea.getProjectClass()) )
|
||||
return new Pair<Boolean, String>(false, "You have reached your current target numbers, you may not accept another idea");
|
||||
else
|
||||
return new Pair<Boolean, String>(true, "You are now supervising idea: " + idea.getTitle());
|
||||
@ -366,7 +344,8 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
|
||||
@Override
|
||||
@Transactional (readOnly=false)
|
||||
public NewIdea saveSupervisorIdea(NewIdea idea, Employee supervisor, SortedSet<Student> authors, List<Keyword> keywords, boolean newIdea) {
|
||||
// public NewIdea saveSupervisorIdea(NewIdea idea, Employee supervisor, SortedSet<Student> authors, List<Keyword> keywords, boolean newIdea) {
|
||||
public NewIdea saveSupervisorIdea(NewIdea idea, Employee supervisor, List<Keyword> keywords, boolean newIdea) {
|
||||
GeneralSystemSettings settings = generalSystemSettingsService.getGeneralSystemSettingsInstance();
|
||||
Set<Keyword> keywordSet = new HashSet<Keyword>(keywords);
|
||||
idea.setKeywords(keywordSet);
|
||||
@ -374,36 +353,51 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
idea.setType(NewIdea.Type.SUPERVISOR);
|
||||
if (newIdea)
|
||||
idea = save(idea);
|
||||
if (!authors.isEmpty()) {
|
||||
for (Student s : authors) {
|
||||
s = studentService.findOne(s.getId()); //Needed for lazy loading to work.
|
||||
NewIdeaParticipation ip = new NewIdeaParticipation();
|
||||
ip.setStudent(s);
|
||||
ip.setIdea(idea);
|
||||
ip.setDateCreated(new Date());
|
||||
if(settings.isMatchPartnerConfirmation())
|
||||
ip.setConfirmed(false);
|
||||
else
|
||||
ip.setConfirmed(true);
|
||||
s.addNewIdeaParticipation(ip);
|
||||
idea.addNewIdeaParticipation(ip);
|
||||
}
|
||||
// If no application period is open when attaching students, we attach the idea to the next available period for this project level.
|
||||
if (applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()) != null)
|
||||
idea.setApplicationPeriod(applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()));
|
||||
else
|
||||
idea.setApplicationPeriod(applicationPeriodService.getNextPeriodByProjectClass(idea.getProjectClass()));
|
||||
if (newIdea || idea.getMatch().getStatus().equals(Status.UNMATCHED))
|
||||
newMatchService.addNewMatch(supervisor.getUser(), supervisor, idea, Status.MATCHED);
|
||||
} else {
|
||||
// if (!authors.isEmpty()) {
|
||||
// for (Student s : authors) {
|
||||
// s = studentService.findOne(s.getId()); //Needed for lazy loading to work.
|
||||
// NewIdeaParticipation ip = new NewIdeaParticipation();
|
||||
// ip.setStudent(s);
|
||||
// ip.setIdea(idea);
|
||||
// ip.setDateCreated(new Date());
|
||||
// if(settings.isMatchPartnerConfirmation())
|
||||
// ip.setConfirmed(false);
|
||||
// else
|
||||
// ip.setConfirmed(true);
|
||||
// s.addNewIdeaParticipation(ip);
|
||||
// idea.addNewIdeaParticipation(ip);
|
||||
// }
|
||||
// // If no application period is open when attaching students, we attach the idea to the next available period for this project level.
|
||||
// if (applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()) != null)
|
||||
// idea.setApplicationPeriod(applicationPeriodService.getCurrentPeriod(new Date(), idea.getProjectClass()));
|
||||
// else
|
||||
// idea.setApplicationPeriod(applicationPeriodService.getNextPeriodByProjectClass(idea.getProjectClass()));
|
||||
// if (newIdea || idea.getMatch().getStatus().equals(Status.UNMATCHED))
|
||||
// newMatchService.addNewMatch(supervisor.getUser(), supervisor, idea, Status.MATCHED);
|
||||
// } else {
|
||||
if (newIdea || idea.getMatch().getStatus().equals(Status.MATCHED))
|
||||
newMatchService.addNewMatch(supervisor.getUser(), supervisor, idea, Status.UNMATCHED);
|
||||
}
|
||||
// }
|
||||
if (!newIdea)
|
||||
idea = save(idea);
|
||||
return idea;
|
||||
}
|
||||
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
// @Override
|
||||
// @Transactional(readOnly = false)
|
||||
// public NewIdea saveSupervisorIdea(NewIdea idea, Employee supervisor, SortedSet<Student> authors, List<Keyword> keywords, boolean isNewIdea, NotificationSourceGenerator<? super NewIdea> sourceGenerator) {
|
||||
// idea = saveSupervisorIdea(idea, supervisor, authors, keywords, isNewIdea);
|
||||
//
|
||||
// NotificationSource source = sourceGenerator.getSource(idea);
|
||||
// source.setMessage(idea.getTitle());
|
||||
// notificationController.notifyIdea(idea, IdeaEvent.Event.ADDED_AS_PARTNER, source);
|
||||
//
|
||||
// return idea;
|
||||
// }
|
||||
|
||||
//>>>>>>> develop2
|
||||
@Override
|
||||
@Transactional(readOnly = false)
|
||||
public NewIdea saveStudentIdea(NewIdea idea, Student creator, Student coAuthor, List<Keyword> keywords, boolean isNewIdea, NotificationSourceGenerator<? super NewIdea> sourceGenerator) {
|
||||
@ -807,7 +801,7 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
return "-";
|
||||
}
|
||||
|
||||
private boolean authorParticipatingOnIdea(Student author, ApplicationPeriod ap) {
|
||||
public boolean authorParticipatingOnIdea(Student author, ApplicationPeriod ap) {
|
||||
return authorParticipatingOnOtherIdea(author, ap, null);
|
||||
}
|
||||
|
||||
@ -980,6 +974,62 @@ public class NewIdeaServiceImpl extends AbstractQueryService<NewIdea, Long> impl
|
||||
return QNewIdea.newIdea.project.eq(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<NewIdea> findMatched(ApplicationPeriod ap, Employee supervisor, ProjectClass pc) {
|
||||
|
||||
NewIdeaService.FilterParams params = new FilterParams();
|
||||
HashSet<Status> status = new HashSet<Status>();
|
||||
status.add(Status.MATCHED);
|
||||
params.setStatuses(status);
|
||||
params.setPeriod(ap);
|
||||
params.setSupervisor(supervisor);
|
||||
ArrayList<ProjectClass> level = new ArrayList<ProjectClass>();
|
||||
level.add(pc);
|
||||
params.setLevels(level);
|
||||
|
||||
return findAll(params).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countMatched(ApplicationPeriod ap, Employee supervisor, ProjectClass pc) {
|
||||
|
||||
NewIdeaService.FilterParams params = new FilterParams();
|
||||
HashSet<Status> status = new HashSet<Status>();
|
||||
status.add(Status.MATCHED);
|
||||
params.setStatuses(status);
|
||||
params.setPeriod(ap);
|
||||
params.setSupervisor(supervisor);
|
||||
ArrayList<ProjectClass> level = new ArrayList<ProjectClass>();
|
||||
level.add(pc);
|
||||
params.setLevels(level);
|
||||
|
||||
return countAll(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<NewIdea> findIdeasPossibleToMatch(ApplicationPeriod applicationPeriod, FilterParams params, Pageable pageable) {
|
||||
Iterable<NewIdea> ideas = newIdeaRepo.findAll(fromParams(params).and(isPublished(true)));
|
||||
List<NewIdea> ideasWithinLimits = new ArrayList<NewIdea>();
|
||||
for(NewIdea idea : ideas){
|
||||
if (targetService.hasTargetsLeft(applicationPeriod, idea.getMatch().getSupervisor(), idea.getProjectClass()))
|
||||
ideasWithinLimits.add(idea);
|
||||
}
|
||||
return newIdeaRepo.findAll(inList(ideasWithinLimits), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countIdeasPossibleToMatch(ApplicationPeriod applicationPeriod, FilterParams params) {
|
||||
Iterable<NewIdea> ideas = newIdeaRepo.findAll(fromParams(params).and(isPublished(true)));
|
||||
List<NewIdea> ideasWithinLimits = new ArrayList<NewIdea>();
|
||||
for(NewIdea idea : ideas){
|
||||
if (targetService.hasTargetsLeft(applicationPeriod, idea.getMatch().getSupervisor(), idea.getProjectClass()))
|
||||
ideasWithinLimits.add(idea);
|
||||
}
|
||||
if (ideasWithinLimits.size()==0)
|
||||
return 0;
|
||||
return SciProUtilities.safeLongToInt(newIdeaRepo.count(inList(ideasWithinLimits)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewIdea findByProject(Project project) {
|
||||
return newIdeaRepo.findOne(connectedToProject(project));
|
||||
|
@ -120,12 +120,30 @@ public class ProjectServiceImpl extends AbstractQueryService<Project, Long> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActiveProjectsBySupervisorAndLevel(Employee employee, ProjectClass pc) {
|
||||
return projectRepo.count(isHeadSupervisor(employee)
|
||||
.and(hasStatus(ProjectStatus.ACTIVE))
|
||||
.and(hasProjectClass(pc))
|
||||
.and(createdAfter(employee.getCountFromDate(pc))));
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
// public Long countActiveProjectsBySupervisorAndLevel(Employee employee, ProjectClass pc) {
|
||||
// return projectRepo.count(isHeadSupervisor(employee)
|
||||
// .and(hasStatus(ProjectStatus.ACTIVE))
|
||||
// .and(hasProjectClass(pc))
|
||||
// .and(createdAfter(employee.getCountFromDate(pc))));
|
||||
// }
|
||||
//=======
|
||||
public Long countEmployeesProjects(Employee employee, User user, ProjectTeamMemberRoles role, ProjectStatus status, Collection<ProjectClass> projectClasses) {
|
||||
|
||||
ProjectTeamMember member = employeeService.findByUser(user);
|
||||
|
||||
if (role!=null){
|
||||
List<ProjectFollower> pf = projectFollowerService.findByFollowerAndRole(member, role);
|
||||
if (!pf.isEmpty())
|
||||
return projectRepo.count(isProjectFollower(pf).and(hasStatus(status)).and(hasProjectClass(projectClasses)));
|
||||
else return 0L;
|
||||
} else {
|
||||
if (employee != null)
|
||||
return projectRepo.count(isHeadSupervisor(employee).and(hasStatus(status)).and(hasProjectClass(projectClasses)));
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
//>>>>>>> develop2
|
||||
|
||||
@Override
|
||||
public List<Project> getProjectsByUser(User user) {
|
||||
|
@ -8,8 +8,13 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dataobjects.*;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.QEmployee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ResearchArea;
|
||||
import se.su.dsv.scipro.data.dataobjects.Unit;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.springdata.repos.SupervisorRepo;
|
||||
import se.su.dsv.scipro.springdata.services.*;
|
||||
|
||||
@ -68,64 +73,46 @@ public class SupervisorServiceImpl extends AbstractQueryService<Employee, Long>
|
||||
public Employee findByUser(User user) {
|
||||
return supervisorRepo.findByUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Availability> getNewIdeaAvailabilities(Employee supervisor) {
|
||||
List<Availability> list = new ArrayList<Availability>();
|
||||
for(ProjectClass pc : projectClassService.findAllActive())
|
||||
list.add(getNewIdeaAvailability(supervisor, pc));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Availability getNewIdeaAvailability(Employee supervisor, ProjectClass pc) {
|
||||
Integer projectLimit = supervisor.getCapabilities().getProjectLimit(pc);
|
||||
long activeNewIdeas = newIdeaService.countMatchedIdeas(supervisor, pc);
|
||||
long activeProjects = projectService.countActiveProjectsBySupervisorAndLevel(supervisor, pc);
|
||||
return new Availability(supervisor, activeNewIdeas+activeProjects, projectLimit, pc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withinLimits(Employee supervisor, ProjectClass pc) {
|
||||
Availability a = getNewIdeaAvailability(supervisor, pc);
|
||||
return a.getNumMatched() < a.getNumCapable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional ( readOnly = false)
|
||||
public void setAvailability(Availability availability) {
|
||||
availability.getSupervisor().getCapabilities().getProjectLimits().put(
|
||||
availability.getProjectClass(), availability.getNumCapable());
|
||||
save(availability.getSupervisor());
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
// @Override
|
||||
// @Transactional ( readOnly = false)
|
||||
// public void setAvailability(Availability availability) {
|
||||
// availability.getSupervisor().getCapabilities().getProjectLimits().put(
|
||||
// availability.getProjectClass(), availability.getNumCapable());
|
||||
// save(availability.getSupervisor());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional ( readOnly=false )
|
||||
// public void resetCountFromDate(ProjectClass pc, Date date) {
|
||||
// List<Employee> supervisors = supervisorRepo.findAll();
|
||||
// Date newDate = date!=null?date:new Date();
|
||||
// for (Employee e : supervisors){
|
||||
// e.setCountFromDate(pc, newDate);
|
||||
// }
|
||||
//
|
||||
// GeneralSystemSettings settings = generalSystemSettingsService.getGeneralSystemSettingsInstance();
|
||||
// if(pc.getCode().equals(ProjectClass.BACHELOR))
|
||||
// settings.setBachelorCountDate(date);
|
||||
// if(pc.getCode().equals(ProjectClass.MASTER))
|
||||
// settings.setMasterCountDate(date);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional ( readOnly=false )
|
||||
// public void resetAllTargetNumbers(ProjectClass pc) {
|
||||
// List<Employee> supervisors = supervisorRepo.findAll();
|
||||
// for (Employee e : supervisors){
|
||||
// if(e.getCapabilities().getProjectLimit(pc)>0)
|
||||
// e.getCapabilities().getProjectLimits().remove(pc);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Transactional ( readOnly=false )
|
||||
public void resetCountFromDate(ProjectClass pc, Date date) {
|
||||
List<Employee> supervisors = supervisorRepo.findAll();
|
||||
Date newDate = date!=null?date:new Date();
|
||||
for (Employee e : supervisors){
|
||||
e.setCountFromDate(pc, newDate);
|
||||
}
|
||||
|
||||
GeneralSystemSettings settings = generalSystemSettingsService.getGeneralSystemSettingsInstance();
|
||||
if(pc.getCode().equals(ProjectClass.BACHELOR))
|
||||
settings.setBachelorCountDate(date);
|
||||
if(pc.getCode().equals(ProjectClass.MASTER))
|
||||
settings.setMasterCountDate(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional ( readOnly=false )
|
||||
public void resetAllTargetNumbers(ProjectClass pc) {
|
||||
List<Employee> supervisors = supervisorRepo.findAll();
|
||||
for (Employee e : supervisors){
|
||||
if(e.getCapabilities().getProjectLimit(pc)>0)
|
||||
e.getCapabilities().getProjectLimits().remove(pc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Override
|
||||
//=======
|
||||
@Override
|
||||
//>>>>>>> develop2
|
||||
public Long count(FilterParams params) {
|
||||
return supervisorRepo.count(fromParams(params));
|
||||
}
|
||||
|
@ -0,0 +1,143 @@
|
||||
package se.su.dsv.scipro.springdata.serviceimpls;
|
||||
|
||||
import com.mysema.query.BooleanBuilder;
|
||||
import com.mysema.query.types.expr.BooleanExpression;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
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.match.dataobject.*;
|
||||
//import se.su.dsv.scipro.security.auth.roles.Employee;
|
||||
import se.su.dsv.scipro.springdata.repos.TargetRepo;
|
||||
import se.su.dsv.scipro.springdata.services.NewIdeaService;
|
||||
import se.su.dsv.scipro.springdata.services.ProjectClassService;
|
||||
import se.su.dsv.scipro.springdata.services.TargetService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author: fred-fri
|
||||
* date: 2012 03 26
|
||||
*/
|
||||
@Service ( "targetService" )
|
||||
@Transactional ( readOnly = true )
|
||||
public class TargetServiceImpl extends AbstractQueryService<Target, Long> implements TargetService {
|
||||
|
||||
@Resource
|
||||
private TargetRepo targetRepo;
|
||||
@Resource
|
||||
private ProjectClassService projectClassService;
|
||||
@Resource
|
||||
private NewIdeaService newIdeaService;
|
||||
|
||||
@Autowired
|
||||
public TargetServiceImpl(
|
||||
@Qualifier("targetRepo")
|
||||
TargetRepo targetRepo) {
|
||||
super(targetRepo, targetRepo);
|
||||
System.out.println("TargetServiceImpl instantiating...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Target findOne(ApplicationPeriod applicationPeriod, Employee supervisor, ProjectClass projectClass) {
|
||||
Target t =targetRepo.findOne(byApplicationPeriod(applicationPeriod).and(bySupervisor(supervisor)).and(byLevel(projectClass)));
|
||||
if (t==null){
|
||||
TargetId targetId = new TargetId();
|
||||
targetId.setApplicationPeriodId(applicationPeriod.getId());
|
||||
targetId.setEmployeeId(supervisor.getId());
|
||||
targetId.setProjectClassId(projectClass.getId());
|
||||
|
||||
t = new Target();
|
||||
t.setTargetId(targetId);
|
||||
t.setTarget(0);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Target> findAll(FilterParams params) {
|
||||
return targetRepo.findAll(fromParams(params)).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTargetsLeft(ApplicationPeriod applicationPeriod, Employee supervisor) {
|
||||
TargetService.FilterParams params = new FilterParams();
|
||||
params.setApplicationPeriod(applicationPeriod);
|
||||
params.setSupervisor(supervisor);
|
||||
|
||||
Iterator<Target> i = findAll(params);
|
||||
while (i.hasNext()){
|
||||
Target t = i.next();
|
||||
ProjectClass pc = projectClassService.findOne(t.getTargetId().getProjectClassId());
|
||||
if (t.getTarget()>0 && t.getTarget()>newIdeaService.countMatched(applicationPeriod, supervisor, pc)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTargetsLeft(ApplicationPeriod applicationPeriod, Employee supervisor, ProjectClass projectClass) {
|
||||
Target t = findOne(applicationPeriod, supervisor, projectClass);
|
||||
return (t.getTarget()>0 && t.getTarget()>newIdeaService.countMatched(applicationPeriod, supervisor, projectClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ProjectClass> projectClassesWithTargetsLeft(ApplicationPeriod applicationPeriod, Employee supervisor) {
|
||||
HashSet<ProjectClass> projectClasses = new HashSet<ProjectClass>();
|
||||
TargetService.FilterParams params = new FilterParams();
|
||||
params.setApplicationPeriod(applicationPeriod);
|
||||
params.setSupervisor(supervisor);
|
||||
|
||||
Iterator<Target> i = findAll(params);
|
||||
while (i.hasNext()){
|
||||
Target t = i.next();
|
||||
ProjectClass pc = projectClassService.findOne(t.getTargetId().getProjectClassId());
|
||||
if (t.getTarget()>0 && t.getTarget()>newIdeaService.countMatched(applicationPeriod, supervisor, pc)){
|
||||
projectClasses.add(pc);
|
||||
}
|
||||
}
|
||||
|
||||
return projectClasses;
|
||||
}
|
||||
|
||||
private BooleanBuilder fromParams(TargetService.FilterParams params) {
|
||||
BooleanBuilder bb = new BooleanBuilder();
|
||||
if(params.getProjectClasses()!=null && !params.getProjectClasses().isEmpty()){
|
||||
|
||||
BooleanBuilder b = new BooleanBuilder();
|
||||
for (ProjectClass pc : params.getProjectClasses()){
|
||||
b.or(byLevel(pc));
|
||||
}
|
||||
bb.and(b);
|
||||
|
||||
}
|
||||
if(params.getSupervisor()!=null)
|
||||
bb.and(bySupervisor(params.getSupervisor()));
|
||||
if(params.getApplicationPeriod()!=null)
|
||||
bb.and(byApplicationPeriod(params.getApplicationPeriod()));
|
||||
return bb;
|
||||
}
|
||||
|
||||
private BooleanExpression byApplicationPeriod(ApplicationPeriod ap) {
|
||||
return QTarget.target1.targetId.applicationPeriodId.eq(ap.getId());
|
||||
}
|
||||
|
||||
private BooleanExpression bySupervisor(Employee supervisor) {
|
||||
return QTarget.target1.targetId.employeeId.eq(supervisor.getId());
|
||||
}
|
||||
|
||||
private BooleanExpression byLevel(ProjectClass pc) {
|
||||
return QTarget.target1.targetId.projectClassId.eq(pc.getId());
|
||||
}
|
||||
}
|
@ -3,9 +3,15 @@ package se.su.dsv.scipro.springdata.services;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
import java.util.Set;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
//>>>>>>> develop2
|
||||
|
||||
public interface ApplicationPeriodService extends GenericService<ApplicationPeriod, Long>, QueryService<ApplicationPeriod, Long> {
|
||||
List<ApplicationPeriod> getCurrentPeriods();
|
||||
@ -23,4 +29,6 @@ public interface ApplicationPeriodService extends GenericService<ApplicationPeri
|
||||
boolean endDateIsReached(final ApplicationPeriod ap);
|
||||
boolean isOpen(final ApplicationPeriod ap);
|
||||
boolean hasOpenExemption(final ApplicationPeriod ap, final Student student);
|
||||
|
||||
ApplicationPeriod getPrevious(ApplicationPeriod ap);
|
||||
}
|
||||
|
@ -18,10 +18,14 @@ import java.util.*;
|
||||
|
||||
public interface NewIdeaService extends GenericService<NewIdea, Long>, QueryService<NewIdea, Long> {
|
||||
|
||||
Iterator<NewIdea> findMatched(ApplicationPeriod ap, Employee supervisor, ProjectClass pc);
|
||||
Long countMatched(ApplicationPeriod ap, Employee supervisor, ProjectClass pc);
|
||||
Page<NewIdea> findIdeasPossibleToMatch(ApplicationPeriod applicationPeriod, FilterParams params, Pageable pageable);
|
||||
int countIdeasPossibleToMatch(ApplicationPeriod applicationPeriod, FilterParams params);
|
||||
|
||||
NewIdea findByProject(Project project);
|
||||
Page<NewIdea> findAll(FilterParams params, Pageable pageable);
|
||||
Page<NewIdea> findAuthorIdeas(Student author, Pageable pageable);
|
||||
Page<NewIdea> findIdeasWithinLimits(FilterParams params, Pageable pageable);
|
||||
|
||||
List<NewIdea> findIdeas(Status status, Student author, boolean confirmed);
|
||||
Iterable<NewIdea> findAll(FilterParams params);
|
||||
@ -30,12 +34,12 @@ public interface NewIdeaService extends GenericService<NewIdea, Long>, QueryServ
|
||||
Long countAll(FilterParams params);
|
||||
Long countIdeas(Status status, ProjectClass pc);
|
||||
Long countAuthorIdeas(Student author);
|
||||
Long countMatchedIdeas(Employee supervisor, ProjectClass pc);
|
||||
|
||||
Long countIdeasByApplicationPeriod(ApplicationPeriod ap);
|
||||
Long countAuthorsByApplicationPeriod(ApplicationPeriod ap);
|
||||
int countIdeasWithinLimits(FilterParams params);
|
||||
|
||||
Pair<Boolean, String> validateSupervisorIdeaSubmission(NewIdea idea, SortedSet<Student> authors, List<Keyword> keywords);
|
||||
// Pair<Boolean, String> validateSupervisorIdeaSubmission(NewIdea idea, SortedSet<Student> authors, List<Keyword> keywords);
|
||||
Pair<Boolean, String> validateSupervisorIdeaSubmission(NewIdea idea, List<Keyword> keywords);
|
||||
Pair<Boolean, String> validateStudentIdeaSubmission(NewIdea idea, Student creator, Student coAuthor, List<Keyword> keywords);
|
||||
Pair<Boolean, String> validateSupervisorAcceptance(NewIdea idea, Employee supervisor, ProjectClass pc);
|
||||
Pair<Boolean, String> validateStudentAcceptance(NewIdea idea, User creator, Student coAuthor, final ApplicationPeriod applicationPeriod);
|
||||
@ -43,7 +47,13 @@ public interface NewIdeaService extends GenericService<NewIdea, Long>, QueryServ
|
||||
|
||||
NewIdea createProject(NewIdea idea, User creator) throws ExternalExportException;
|
||||
|
||||
NewIdea saveSupervisorIdea(NewIdea idea, Employee supervisor, SortedSet<Student> authors, List<Keyword> keywords, boolean isNewIdea);
|
||||
//<<<<<<< HEAD
|
||||
// NewIdea saveSupervisorIdea(NewIdea idea, Employee supervisor, SortedSet<Student> authors, List<Keyword> keywords, boolean isNewIdea);
|
||||
//=======
|
||||
|
||||
NewIdea saveSupervisorIdea(NewIdea idea, Employee supervisor, List<Keyword> keywords, boolean isNewIdea);
|
||||
|
||||
//>>>>>>> develop2
|
||||
NewIdea saveStudentIdea(NewIdea idea, Student creator, Student coAuthor, List<Keyword> keywords, boolean isNewIdea);
|
||||
NewIdea saveStudentIdea(NewIdea idea, Student creator, Student coAuthor, List<Keyword> keywords, boolean isNewIdea, NotificationSourceGenerator<? super NewIdea> sourceGenerator);
|
||||
void confirmSupervision(NewIdea idea, Employee supervisor, NotificationSource source);
|
||||
@ -69,7 +79,9 @@ public interface NewIdeaService extends GenericService<NewIdea, Long>, QueryServ
|
||||
boolean isConnectableToProject(NewIdea idea, SortedSet<Student> authors);
|
||||
|
||||
String getStatusString(NewIdea idea);
|
||||
|
||||
|
||||
boolean authorParticipatingOnIdea(Student author, ApplicationPeriod ap);
|
||||
|
||||
public static class FilterParams implements Serializable {
|
||||
private static final long serialVersionUID = 7038406592268422702L;
|
||||
|
||||
|
@ -22,7 +22,11 @@ public interface ProjectService extends GenericService<Project,Long>, QueryServi
|
||||
public Long countAll(FilterParams params);
|
||||
public Long count(String filterString, Date fromDate, Date toDate);
|
||||
public Long count(Date fromDate, Date toDate);
|
||||
public Long countActiveProjectsBySupervisorAndLevel(Employee employee, ProjectClass pc);
|
||||
//<<<<<<< HEAD
|
||||
// public Long countActiveProjectsBySupervisorAndLevel(Employee employee, ProjectClass pc);
|
||||
//=======
|
||||
public Long countEmployeesProjects(Employee employee, User user,ProjectTeamMemberRoles role, ProjectStatus status, Collection<ProjectClass> projectClasses);
|
||||
//>>>>>>> develop2
|
||||
public List<Project> getProjectsByUser(User user);
|
||||
public List<Project> getProjectsByUserAndStatus(User author, ProjectStatus status);
|
||||
public List<Project> getSupervisorProjectsForPeer(User supervisor, ProjectClass pc, ProjectStatus status, Student author, String title);
|
||||
|
@ -2,8 +2,11 @@ package se.su.dsv.scipro.springdata.services;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import se.su.dsv.scipro.data.dataobjects.*;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ResearchArea;
|
||||
import se.su.dsv.scipro.data.dataobjects.Unit;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@ -20,12 +23,15 @@ public interface SupervisorService extends GenericService<Employee,Long>, QueryS
|
||||
Long count(FilterParams params);
|
||||
Long countByResearchArea(ResearchArea area);
|
||||
public Employee findByUser(User user);
|
||||
List<Availability> getNewIdeaAvailabilities(Employee supervisor);
|
||||
Availability getNewIdeaAvailability(Employee supervisor, ProjectClass pc);
|
||||
boolean withinLimits(Employee supervisor, ProjectClass pc);
|
||||
void setAvailability(Availability availability);
|
||||
void resetCountFromDate(ProjectClass pc, Date date);
|
||||
void resetAllTargetNumbers(ProjectClass pc);
|
||||
//<<<<<<< HEAD
|
||||
// List<Availability> getNewIdeaAvailabilities(Employee supervisor);
|
||||
// Availability getNewIdeaAvailability(Employee supervisor, ProjectClass pc);
|
||||
// boolean withinLimits(Employee supervisor, ProjectClass pc);
|
||||
// void setAvailability(Availability availability);
|
||||
// void resetCountFromDate(ProjectClass pc, Date date);
|
||||
// void resetAllTargetNumbers(ProjectClass pc);
|
||||
//=======
|
||||
//>>>>>>> develop2
|
||||
|
||||
public static class FilterParams implements Serializable {
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
package se.su.dsv.scipro.springdata.services;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import se.su.dsv.scipro.data.dataobjects.*;
|
||||
import se.su.dsv.scipro.match.dataobject.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
//import se.su.dsv.scipro.match.dataobject.ProjectIdea;
|
||||
|
||||
/**
|
||||
* @author: fred-fri
|
||||
* date: 2012 03 26
|
||||
*/
|
||||
public interface TargetService extends GenericService<Target, Long>, QueryService<Target, Long> {
|
||||
|
||||
Target findOne(ApplicationPeriod applicationPeriod, Employee supervisor, ProjectClass projectClass);
|
||||
Iterator<Target> findAll(FilterParams params);
|
||||
boolean hasTargetsLeft(ApplicationPeriod applicationPeriod, Employee supervisor);
|
||||
boolean hasTargetsLeft(ApplicationPeriod applicationPeriod, Employee supervisor, ProjectClass projectClass);
|
||||
Set<ProjectClass> projectClassesWithTargetsLeft(ApplicationPeriod applicationPeriod, Employee supervisor);
|
||||
|
||||
public static class FilterParams implements Serializable {
|
||||
private static final long serialVersionUID = 7038406592268422701L;
|
||||
|
||||
private Collection<ProjectClass> projectClasses;
|
||||
private Employee supervisor;
|
||||
private ApplicationPeriod applicationPeriod;
|
||||
|
||||
public Collection<ProjectClass> getProjectClasses() {
|
||||
return projectClasses;
|
||||
}
|
||||
|
||||
public void setProjectClasses(Collection<ProjectClass> projectClasses) {
|
||||
this.projectClasses = projectClasses;
|
||||
}
|
||||
|
||||
public Employee getSupervisor() {
|
||||
return supervisor;
|
||||
}
|
||||
|
||||
public void setSupervisor(Employee supervisor) {
|
||||
this.supervisor = supervisor;
|
||||
}
|
||||
|
||||
public ApplicationPeriod getApplicationPeriod() {
|
||||
return applicationPeriod;
|
||||
}
|
||||
|
||||
public void setApplicationPeriod(ApplicationPeriod applicationPeriod) {
|
||||
this.applicationPeriod = applicationPeriod;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,9 @@ import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.datatables.DateColumn;
|
||||
import se.su.dsv.scipro.datatables.project.ProjectStateColumn;
|
||||
import se.su.dsv.scipro.datatables.project.ProjectTitleColumn;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
import se.su.dsv.scipro.springdata.services.ApplicationPeriodService;
|
||||
import se.su.dsv.scipro.springdata.services.EmployeeService;
|
||||
import se.su.dsv.scipro.supervisor.panels.SupervisorMyProjectsPanel;
|
||||
|
||||
@ -22,11 +25,11 @@ public class SupervisorStartPage extends AbstractSupervisorPage {
|
||||
public static final String MAIN_MENU_LABEL = "Supervisor";
|
||||
@SpringBean
|
||||
private EmployeeService employeeService;
|
||||
@SpringBean
|
||||
private ApplicationPeriodService applicationPeriodService;
|
||||
|
||||
public SupervisorStartPage(PageParameters pp) {
|
||||
super(pp);
|
||||
// add(new SupervisorProjectsOverviewPanel("projectsOverviewPanel", SciProSession.get().getUser()));
|
||||
|
||||
|
||||
add(new SupervisorMyProjectsPanel("projectsOverviewPanel") {
|
||||
@Override
|
||||
@ -55,9 +58,6 @@ public class SupervisorStartPage extends AbstractSupervisorPage {
|
||||
protected void onConfigure() {
|
||||
setVisibilityAllowed(employeeService.findByUser(SciProSession.get().getUser()) != null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ public class ProfilePanel extends Panel {
|
||||
protected void populateItem(ListItem<Language> item) {
|
||||
final Language l = item.getModelObject();
|
||||
item.add(new Label("languagelabel", l.getName()));
|
||||
item.add(new AjaxCheckBox("languagecheckbox", new Model<Boolean>(employeeModel.getObject().getCapabilities().getLanguages().contains(l))){
|
||||
item.add(new AjaxCheckBox("languagecheckbox", new Model<Boolean>(employeeModel.getObject().getLanguages().contains(l))){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
Set<Language> languages = employeeModel.getObject().getCapabilities().getLanguages();
|
||||
Set<Language> languages = employeeModel.getObject().getLanguages();
|
||||
if (getModelObject()==true){
|
||||
languages.add(l);
|
||||
System.out.println("added language " + l.getName());
|
||||
@ -72,7 +72,7 @@ public class ProfilePanel extends Panel {
|
||||
languages.remove(l);
|
||||
System.out.println("removed language " + l.getName());
|
||||
}
|
||||
employeeModel.getObject().getCapabilities().setLanguages(languages);
|
||||
employeeModel.getObject().setLanguages(languages);
|
||||
employeeModel.setObject(employeeDao.save(employeeModel.getObject()));
|
||||
}
|
||||
});
|
||||
|
@ -7,76 +7,84 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.SciProApplication;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
import se.su.dsv.scipro.match.dataobject.NewIdea;
|
||||
import se.su.dsv.scipro.match.dataobject.NewMatch;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
import se.su.dsv.scipro.notifications.dataobject.NotificationSource;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.Pair;
|
||||
import se.su.dsv.scipro.project.pages.ProjectNewIdeaStartPage;
|
||||
import se.su.dsv.scipro.project.panels.NewIdeaAuthorInfoPanel;
|
||||
import se.su.dsv.scipro.project.panels.NewIdeaDetailsPanel;
|
||||
import se.su.dsv.scipro.project.panels.NewIdeaWatsonInfoPanel;
|
||||
import se.su.dsv.scipro.springdata.services.ApplicationPeriodService;
|
||||
import se.su.dsv.scipro.springdata.services.NewIdeaService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
import se.su.dsv.scipro.springdata.services.TargetService;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorNewIdeaStartPage;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
import se.su.dsv.scipro.util.NotificationUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class SupervisorAcceptIdeaDialogPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private NewIdeaService ideaService;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
public SupervisorAcceptIdeaDialogPanel(String id, IModel<NewIdea> model, User loggedInUser) {
|
||||
super(id, model);
|
||||
FeedbackPanel feedback = new FeedbackPanel("feedback");
|
||||
feedback.setOutputMarkupId(true);
|
||||
add(feedback);
|
||||
add(new AcceptIdeaForm("form", model, loggedInUser, feedback));
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 29731924490786784L;
|
||||
@SpringBean
|
||||
private NewIdeaService ideaService;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
@SpringBean
|
||||
private TargetService targetService;
|
||||
@SpringBean
|
||||
private ApplicationPeriodService applicationPeriodService;
|
||||
|
||||
private class AcceptIdeaForm extends Form<NewIdea> {
|
||||
public SupervisorAcceptIdeaDialogPanel(String id, IModel<NewIdea> model, User loggedInUser) {
|
||||
super(id, model);
|
||||
FeedbackPanel feedback = new FeedbackPanel("feedback");
|
||||
feedback.setOutputMarkupId(true);
|
||||
add(feedback);
|
||||
add(new AcceptIdeaForm("form", model, loggedInUser, feedback));
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -9118352523380756043L;
|
||||
private static final long serialVersionUID = 29731924490786784L;
|
||||
|
||||
public AcceptIdeaForm(String id, final IModel<NewIdea> model, User loggedInUser, FeedbackPanel feedback) {
|
||||
super(id, model);
|
||||
add(new NewIdeaAuthorInfoPanel("authors", model));
|
||||
add(new NewIdeaDetailsPanel("ideaDetails", model, false));
|
||||
add(new NewIdeaWatsonInfoPanel("watson", model, true));
|
||||
addAcceptButton(model, loggedInUser, feedback);
|
||||
}
|
||||
private class AcceptIdeaForm extends Form<NewIdea> {
|
||||
|
||||
private void addAcceptButton(final IModel<NewIdea> model, final User loggedInUser, final FeedbackPanel feedback) {
|
||||
AjaxLink<Void> accept = new AjaxLink<Void>("accept"){
|
||||
private static final long serialVersionUID = -2310600904688289199L;
|
||||
private static final long serialVersionUID = -9118352523380756043L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
Employee supervisor = supervisorService.findByUser(loggedInUser);
|
||||
Pair<Boolean, String> acceptance = ideaService.validateSupervisorAcceptance(model.getObject(), supervisor, model.getObject().getProjectClass());
|
||||
if(acceptance.head){
|
||||
public AcceptIdeaForm(String id, final IModel<NewIdea> model, User loggedInUser, FeedbackPanel feedback) {
|
||||
super(id, model);
|
||||
add(new NewIdeaAuthorInfoPanel("authors", model));
|
||||
add(new NewIdeaDetailsPanel("ideaDetails", model, false));
|
||||
add(new NewIdeaWatsonInfoPanel("watson", model, true));
|
||||
addAcceptButton(model, loggedInUser, feedback);
|
||||
}
|
||||
|
||||
private void addAcceptButton(final IModel<NewIdea> model, final User loggedInUser, final FeedbackPanel feedback) {
|
||||
AjaxLink<Void> accept = new AjaxLink<Void>("accept") {
|
||||
private static final long serialVersionUID = -2310600904688289199L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
Employee supervisor = supervisorService.findByUser(loggedInUser);
|
||||
Pair<Boolean, String> acceptance = ideaService.validateSupervisorAcceptance(model.getObject(), supervisor, model.getObject().getProjectClass());
|
||||
if (acceptance.head) {
|
||||
NotificationSource source = NotificationUtils.sourceFor(SupervisorNewIdeaStartPage.class, ProjectNewIdeaStartPage.class);
|
||||
ideaService.confirmSupervision(model.getObject(), supervisor, source);
|
||||
getSession().info(acceptance.tail);
|
||||
setResponsePage(SupervisorNewIdeaStartPage.class);
|
||||
} else {
|
||||
error(acceptance.tail);
|
||||
target.addComponent(feedback);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
accept.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to accept to supervise this idea?"));
|
||||
add(accept);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
ideaService.confirmSupervision(model.getObject(), supervisor, source);
|
||||
getSession().info(acceptance.tail);
|
||||
setResponsePage(SupervisorNewIdeaStartPage.class);
|
||||
} else {
|
||||
error(acceptance.tail);
|
||||
target.addComponent(feedback);
|
||||
}
|
||||
}
|
||||
};
|
||||
accept.add(new JavascriptEventConfirmation("onclick", "Are you sure you want to accept to supervise this idea?"));
|
||||
add(accept);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.components.DialogPlus;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
@ -28,11 +29,8 @@ import se.su.dsv.scipro.match.panel.FilterFormAreaPanel;
|
||||
import se.su.dsv.scipro.match.panel.FilterFormCheckBoxPanel;
|
||||
import se.su.dsv.scipro.match.panel.FilterKeywordsPanel;
|
||||
import se.su.dsv.scipro.reusable.SciProUtilities;
|
||||
import se.su.dsv.scipro.springdata.services.GenericService;
|
||||
import se.su.dsv.scipro.springdata.services.LanguageService;
|
||||
import se.su.dsv.scipro.springdata.services.NewIdeaService;
|
||||
import se.su.dsv.scipro.springdata.services.*;
|
||||
import se.su.dsv.scipro.springdata.services.NewIdeaService.FilterParams;
|
||||
import se.su.dsv.scipro.springdata.services.ProjectClassService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -47,6 +45,10 @@ public class SupervisorNewAllStudentIdeasPanel extends Panel {
|
||||
private LanguageService languageService;
|
||||
@SpringBean
|
||||
private ExcelExportService excelExportService;
|
||||
@SpringBean
|
||||
private TargetService targetService;
|
||||
@SpringBean
|
||||
private EmployeeService employeeService;
|
||||
|
||||
private Dialog dialog;
|
||||
private FilterParams params;
|
||||
@ -158,6 +160,8 @@ public class SupervisorNewAllStudentIdeasPanel extends Panel {
|
||||
|
||||
private void addFiltering() {
|
||||
params = new FilterParams();
|
||||
|
||||
params.setPeriod(applicationPeriod);
|
||||
|
||||
//We only want to show Student ideas that are unmatched in this view
|
||||
params.setTypes(Arrays.asList(new Type[]{Type.STUDENT}));
|
||||
@ -177,8 +181,8 @@ public class SupervisorNewAllStudentIdeasPanel extends Panel {
|
||||
|
||||
@Override
|
||||
protected List<ProjectClass> choices() {
|
||||
return new ArrayList<ProjectClass>(applicationPeriod.getProjectClass());
|
||||
// return projectClassService.findAllActive();
|
||||
return new ArrayList<ProjectClass>(targetService.projectClassesWithTargetsLeft(applicationPeriod, employeeService.findByUser(SciProSession.get().getUser())));
|
||||
// return new ArrayList<ProjectClass>(applicationPeriod.getProjectClass());
|
||||
}
|
||||
};
|
||||
params.setLevels(levelFilter.getSelection());
|
||||
|
@ -1,15 +0,0 @@
|
||||
<!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>
|
||||
You should supervise <span wicket:id="targets"></span> projects.<br />
|
||||
You are currently supervising <span wicket:id="current"></span> projects.
|
||||
(Bachelor count since: <span wicket:id="bachelorDate"></span>, master count since: <span wicket:id="masterDate"></span>)
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -1,51 +0,0 @@
|
||||
package se.su.dsv.scipro.supervisor.panels;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
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.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.springdata.services.DateService;
|
||||
import se.su.dsv.scipro.springdata.services.GeneralSystemSettingsService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SupervisorNewAvailabilityPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = -9010467449322120267L;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsService generalSystemSettingsService;
|
||||
@SpringBean
|
||||
private DateService dateService;
|
||||
|
||||
public SupervisorNewAvailabilityPanel(String id, final User loggedInUser) {
|
||||
super(id);
|
||||
|
||||
GeneralSystemSettings settings = generalSystemSettingsService.getGeneralSystemSettingsInstance();
|
||||
Employee supervisor = supervisorService.findByUser(loggedInUser);
|
||||
List<Availability> targets = supervisorService.getNewIdeaAvailabilities(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)));
|
||||
add(new Label(BACHELOR_SINCE, dateService.format(settings.getBachelorCountDate())));
|
||||
add(new Label(MASTER_SINCE, dateService.format(settings.getMasterCountDate())));
|
||||
}
|
||||
|
||||
static final String TARGETS = "targets";
|
||||
static final String CURRENT = "current";
|
||||
static final String BACHELOR_SINCE = "bachelorDate";
|
||||
static final String MASTER_SINCE = "masterDate";
|
||||
}
|
@ -66,13 +66,13 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<h5>Manually match student(s) (optional): <span wicket:id="manualInfo"></span></h5>
|
||||
<!--<div class="row-fluid">-->
|
||||
<!--<div class="span3">-->
|
||||
<!--<h5>Manually match student(s) (optional): <span wicket:id="manualInfo"></span></h5>-->
|
||||
|
||||
<div wicket:id="authors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div wicket:id="authors"></div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<br />
|
||||
<div class="row-fluid">
|
||||
<button wicket:id="save">Submit idea</button>
|
||||
|
@ -76,7 +76,7 @@ public class SupervisorNewEditIdeaPanel extends Panel {
|
||||
private int remainingDescriptionChars, remainingReqChars;
|
||||
private int MAX_CHARS = 4000;
|
||||
private SelectKeywordsBasedOnResearchAreaPanel keywordsPanel;
|
||||
private AddRemoveStudentsPanel studentsPanel;
|
||||
// private AddRemoveStudentsPanel studentsPanel;
|
||||
|
||||
public IdeaForm(String id, IModel<NewIdea> model, final User currentUser, final boolean isNewIdea) {
|
||||
super(id, model);
|
||||
@ -88,7 +88,7 @@ public class SupervisorNewEditIdeaPanel extends Panel {
|
||||
addPrerequisitesField(model);
|
||||
addResearchAreaAndKeywordsSelection(model, supervisor);
|
||||
addPublishedSelection(model);
|
||||
addAuthorSelection(model);
|
||||
// addAuthorSelection(model);
|
||||
addSaveButton(model, supervisor, isNewIdea);
|
||||
}
|
||||
|
||||
@ -161,24 +161,24 @@ public class SupervisorNewEditIdeaPanel extends Panel {
|
||||
add(new HelpIconDialog("publishInfo", "publishMarkup", this, "Publish idea info", 450));
|
||||
}
|
||||
|
||||
private void addAuthorSelection(final IModel<NewIdea> model) {
|
||||
SortedSet<Student> authors = new TreeSet<Student>();
|
||||
for(NewIdeaParticipation ip : model.getObject().getNewIdeaParticipations()){
|
||||
authors.add(ip.getStudent());
|
||||
}
|
||||
|
||||
add(studentsPanel = new AddRemoveStudentsPanel("authors", authors) {
|
||||
private static final long serialVersionUID = -4261960708405947394L;
|
||||
|
||||
@Override
|
||||
public void onUpdate(AjaxRequestTarget target) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
add(new HelpIconDialog("manualInfo", "manualMarkup", this, "Manually match info", 400));
|
||||
|
||||
}
|
||||
// private void addAuthorSelection(final IModel<NewIdea> model) {
|
||||
// SortedSet<Student> authors = new TreeSet<Student>();
|
||||
// for(NewIdeaParticipation ip : model.getObject().getNewIdeaParticipations()){
|
||||
// authors.add(ip.getStudent());
|
||||
// }
|
||||
//
|
||||
// add(studentsPanel = new AddRemoveStudentsPanel("authors", authors) {
|
||||
// private static final long serialVersionUID = -4261960708405947394L;
|
||||
//
|
||||
// @Override
|
||||
// public void onUpdate(AjaxRequestTarget target) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// add(new HelpIconDialog("manualInfo", "manualMarkup", this, "Manually match info", 400));
|
||||
//
|
||||
// }
|
||||
|
||||
private void addSaveButton(final IModel<NewIdea> model, final Employee supervisor, final boolean isNewIdea) {
|
||||
add(new AjaxButton("save") {
|
||||
@ -186,9 +186,11 @@ public class SupervisorNewEditIdeaPanel extends Panel {
|
||||
|
||||
@Override
|
||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||
Pair<Boolean, String> acceptance = ideaService.validateSupervisorIdeaSubmission(model.getObject(), studentsPanel.getStudentSet(), keywordsPanel.getSelectedArray());
|
||||
// Pair<Boolean, String> acceptance = ideaService.validateSupervisorIdeaSubmission(model.getObject(), studentsPanel.getStudentSet(), keywordsPanel.getSelectedArray());
|
||||
Pair<Boolean, String> acceptance = ideaService.validateSupervisorIdeaSubmission(model.getObject(), keywordsPanel.getSelectedArray());
|
||||
if(acceptance.head) {
|
||||
ideaService.saveSupervisorIdea(model.getObject(), supervisor, studentsPanel.getStudentSet(), keywordsPanel.getSelectedArray(), isNewIdea);
|
||||
// ideaService.saveSupervisorIdea(model.getObject(), supervisor, studentsPanel.getStudentSet(), keywordsPanel.getSelectedArray(), isNewIdea);
|
||||
ideaService.saveSupervisorIdea(model.getObject(), supervisor, keywordsPanel.getSelectedArray(), isNewIdea);
|
||||
getSession().info("Idea successfully submitted");
|
||||
setResponsePage(SupervisorNewIdeaStartPage.class);
|
||||
} else {
|
||||
|
19
src/main/java/se/su/dsv/scipro/user/facade/UserFacade.java
Normal file
19
src/main/java/se/su/dsv/scipro/user/facade/UserFacade.java
Normal file
@ -0,0 +1,19 @@
|
||||
package se.su.dsv.scipro.user.facade;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.Language;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Andreas Svanberg <andreass@dsv.su.se>
|
||||
* @version 1/29/13
|
||||
*/
|
||||
public interface UserFacade {
|
||||
@Transactional
|
||||
void saveEmployeeProfileData(Employee employee, Set<Keyword> keywords, Set<Language> languages);
|
||||
@Transactional
|
||||
void saveUserProfileData(User user);
|
||||
}
|
@ -165,6 +165,7 @@ public abstract class SciProTest {
|
||||
@Mock protected FinalSeminarUploadController finalSeminarUploadController;
|
||||
@Mock protected FileRepository fileRepository;
|
||||
@Mock protected TurnitinComponent turnitinComponent;
|
||||
@Mock protected TargetService targetService;
|
||||
|
||||
protected WicketTester tester;
|
||||
protected ApplicationContextMock ctx;
|
||||
|
@ -9,18 +9,20 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.SciProTest;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.ApplicationPeriod;
|
||||
import se.su.dsv.scipro.supervisor.panels.SupervisorNewAvailabilityPanel;
|
||||
import se.su.dsv.scipro.match.dataobject.Target;
|
||||
import se.su.dsv.scipro.springdata.services.TargetService;
|
||||
import se.su.dsv.scipro.test.DomainObjects;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -39,12 +41,25 @@ public class ApplicationPeriodInfoPanelTest extends SciProTest {
|
||||
currentPeriods.add(new ApplicationPeriod("Bachelor"));
|
||||
currentPeriods.add(new ApplicationPeriod("Master"));
|
||||
when(applicationPeriodService.getCurrentPeriods()).thenReturn(currentPeriods);
|
||||
|
||||
|
||||
TargetService.FilterParams params = new TargetService.FilterParams();
|
||||
ArrayList<Target> tl = new ArrayList<Target>();
|
||||
Target t = new Target();
|
||||
tl.add(t);
|
||||
when(targetService.findAll(params)).thenReturn(tl.iterator());
|
||||
|
||||
GeneralSystemSettings settings = DomainObjects.injectId(new GeneralSystemSettings(), 1L);
|
||||
settings.setBachelorCountDate(date("2013-01-30"));
|
||||
settings.setMasterCountDate(date("2013-01-30"));
|
||||
when(generalSystemSettingsService.getGeneralSystemSettingsInstance()).thenReturn(settings);
|
||||
|
||||
|
||||
|
||||
when(employeeService.findByUser(new User())).thenReturn(new Employee());
|
||||
ProjectClass pc = new ProjectClass();
|
||||
when(projectClassService.getProjectClass(ProjectClass.BACHELOR)).thenReturn(pc);
|
||||
when(projectClassService.getProjectClass(ProjectClass.MASTER)).thenReturn(pc);
|
||||
when(targetService.findOne(new ApplicationPeriod(), new Employee(), pc)).thenReturn(new Target());
|
||||
|
||||
panel = (NewApplicationPeriodInfoPanel) tester.startPanel(new ITestPanelSource() {
|
||||
@Override
|
||||
public Panel getTestPanel(String id) {
|
||||
@ -95,11 +110,6 @@ public class ApplicationPeriodInfoPanelTest extends SciProTest {
|
||||
tester.assertComponent(path(panel.getId(), NewApplicationPeriodInfoPanel.PERIOD_LIST , i, NewApplicationPeriodInfoPanel.COURSE_START_DATE), Label.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContainsAvailabilityPanel() throws Exception {
|
||||
tester.assertComponent(path(panel.getId(), NewApplicationPeriodInfoPanel.AVAILABILITY), SupervisorNewAvailabilityPanel.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyLabelIsNotVisible() throws Exception {
|
||||
|
@ -174,16 +174,4 @@ public class TestProject {
|
||||
List<Project> reviewerProjectsCreated = Arrays.asList(new Project[]{project1});
|
||||
Assert.assertEquals(reviewerProjectsCreated, reviewerProjectsFromService);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testCountActiveProjectsBySupervisor(){
|
||||
Long activeProjects = projectService.countActiveProjectsBySupervisorAndLevel(headSupervisor, master);
|
||||
Assert.assertEquals(new Long(0), activeProjects);
|
||||
|
||||
activeProjects = projectService.countActiveProjectsBySupervisorAndLevel(headSupervisor, bachelor);
|
||||
Assert.assertEquals(new Long(1), activeProjects);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
package se.su.dsv.scipro.supervisor.panels;
|
||||
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.util.tester.ITestPanelSource;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import se.su.dsv.scipro.SciProTest;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.Availability;
|
||||
import se.su.dsv.scipro.test.DomainObjects;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SupervisorNewAvailabilityPanelTest extends SciProTest {
|
||||
|
||||
SupervisorNewAvailabilityPanel panel;
|
||||
Employee supervisor;
|
||||
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
supervisor = DomainObjects.injectId(new Employee(), 1L);
|
||||
final User user = DomainObjects.injectId(new User(), 1L);
|
||||
supervisor.setUser(user);
|
||||
|
||||
GeneralSystemSettings settings = DomainObjects.injectId(new GeneralSystemSettings(), 1L);
|
||||
settings.setBachelorCountDate(date("2013-01-30"));
|
||||
settings.setMasterCountDate(date("2013-01-30"));
|
||||
|
||||
when(generalSystemSettingsService.getGeneralSystemSettingsInstance()).thenReturn(settings);
|
||||
when(supervisorService.findByUser(user)).thenReturn(supervisor);
|
||||
when(supervisorService.getNewIdeaAvailabilities(supervisor)).thenReturn(new ArrayList<Availability>());
|
||||
|
||||
panel = (SupervisorNewAvailabilityPanel) tester.startPanel(new ITestPanelSource() {
|
||||
@Override
|
||||
public Panel getTestPanel(String id) {
|
||||
return new SupervisorNewAvailabilityPanel(id, user);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenders() throws Exception {
|
||||
tester.assertNoErrorMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTargetLabel() throws Exception {
|
||||
tester.assertComponent(path(panel.getId(), SupervisorNewAvailabilityPanel.TARGETS), Label.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrentLabel() throws Exception {
|
||||
tester.assertComponent(path(panel.getId(), SupervisorNewAvailabilityPanel.CURRENT), Label.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBachelorCountSinceLabel() throws Exception {
|
||||
tester.assertComponent(path(panel.getId(), SupervisorNewAvailabilityPanel.BACHELOR_SINCE), Label.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMasterCountSinceLabel() throws Exception {
|
||||
tester.assertComponent(path(panel.getId(), SupervisorNewAvailabilityPanel.MASTER_SINCE), Label.class);
|
||||
}
|
||||
|
||||
private Date date(String dateString) {
|
||||
try {
|
||||
return date.parse(dateString);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user