diff --git a/core/src/main/java/se/su/dsv/scipro/DataInitializer.java b/core/src/main/java/se/su/dsv/scipro/DataInitializer.java index 85a1f413a7..6086ff7e73 100644 --- a/core/src/main/java/se/su/dsv/scipro/DataInitializer.java +++ b/core/src/main/java/se/su/dsv/scipro/DataInitializer.java @@ -11,6 +11,7 @@ import java.util.*; import se.su.dsv.scipro.checklist.ChecklistCategory; import se.su.dsv.scipro.match.ApplicationPeriod; import se.su.dsv.scipro.match.Keyword; +import se.su.dsv.scipro.match.Target; import se.su.dsv.scipro.milestones.dataobjects.MilestoneActivityTemplate; import se.su.dsv.scipro.milestones.dataobjects.MilestonePhaseTemplate; import se.su.dsv.scipro.milestones.service.MilestoneActivityTemplateService; @@ -75,6 +76,7 @@ public class DataInitializer implements Lifecycle { private ResearchArea researchArea2; private ProjectType masterClass; private ProjectType magisterClass; + private ApplicationPeriod applicationPeriod; @Transactional @Override @@ -89,6 +91,7 @@ public class DataInitializer implements Lifecycle { createMilestonesIfNotDone(); createUsers(); createProjects(); + createTarget(); } if (profile.getCurrentProfile() == Profiles.DEV && noAdminUser()) { createAdmin(); @@ -103,7 +106,7 @@ public class DataInitializer implements Lifecycle { } private void createApplicationPeriodIfNotDone() { - ApplicationPeriod applicationPeriod = new ApplicationPeriod("HT 2014"); + applicationPeriod = new ApplicationPeriod("HT 2014"); applicationPeriod.setStartDate(LocalDate.now().minusDays(APPLICATION_PERIOD_START_MINUS_DAYS)); applicationPeriod.setEndDate(LocalDate.now().plusDays(APPLICATION_PERIOD_END_PLUS_DAYS)); applicationPeriod.setCourseStartDate(LocalDate.now().plusDays(APPLICATION_PERIOD_COURSE_START_PLUS_DAYS)); @@ -254,6 +257,12 @@ public class DataInitializer implements Lifecycle { save(getMagisterTemplate()); } + private void createTarget() { + Target target = new Target(eric_employee, applicationPeriod, bachelorClass); + target.setTarget(10); + save(target); + } + private GradingReportTemplate getBachelorTemplate() { GradingReportTemplate gradingReportTemplate = new GradingReportTemplate( bachelorClass, diff --git a/view/src/main/java/se/su/dsv/scipro/match/AbstractAdminIdeaPanel.java b/view/src/main/java/se/su/dsv/scipro/match/AbstractAdminIdeaPanel.java index e7f1301dcf..af3feebc88 100644 --- a/view/src/main/java/se/su/dsv/scipro/match/AbstractAdminIdeaPanel.java +++ b/view/src/main/java/se/su/dsv/scipro/match/AbstractAdminIdeaPanel.java @@ -205,17 +205,35 @@ public abstract class AbstractAdminIdeaPanel extends Panel { ideaService.adminUnmatchIdea(idea, SciProSession.get().getUser()); info("Unmatched idea: " + idea.getTitle()); } else { - if ( - targetService.hasTargetsLeft( - idea.getApplicationPeriod(), - newSelection, - idea.getProjectType() - ) - ) { - ideaService.changeSupervisor(idea, newSelection, SciProSession.get().getUser()); - info("Supervisor changed"); + ideaService.changeSupervisor(idea, newSelection, SciProSession.get().getUser()); + + Target currentTarget = targetService.findOne( + idea.getApplicationPeriod(), + newSelection, + idea.getProjectType() + ); + Long countMatched = ideaService.countMatched( + idea.getApplicationPeriod(), + newSelection, + idea.getProjectType() + ); + + int targetCounter = (currentTarget == null) ? 0 : currentTarget.getTarget(); + long matchedCounter = (countMatched == null) ? 0L : countMatched; + + String msg = + "Supervisor changed: matched/target -> " + + matchedCounter + + " / " + + targetCounter + + " (" + + idea.getProjectType().getName() + + ")"; + + if (matchedCounter > targetCounter) { + warn(msg); } else { - error("The supervisor have reached current target numbers"); + info(msg); } } target.addListener(new AjaxFeedbackPanelUpdater()); diff --git a/view/src/main/webapp/css/scipro_m.css b/view/src/main/webapp/css/scipro_m.css index 5c4184a9c0..7ce4954a00 100755 --- a/view/src/main/webapp/css/scipro_m.css +++ b/view/src/main/webapp/css/scipro_m.css @@ -129,6 +129,12 @@ footer a:hover { color: #d95e00;} border-color: #EBCCD1; } +.feedbackPanelWARNING { + color: #000000; + background-color: #FFD105; + border-color: #EBCCD1; +} + .feedbackPanelINFO { color: #3C763D; background-color: #DFF0D8; diff --git a/war/src/main/resources/application.properties b/war/src/main/resources/application.properties index bb89287006..0df6b375e6 100644 --- a/war/src/main/resources/application.properties +++ b/war/src/main/resources/application.properties @@ -9,6 +9,7 @@ spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.Ph # We also need to set the implicit strategy to be JPA compliant, as we rely on this naming strategy for certain # join tables (idea_Keyword vs idea_keyword) spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl +spring.jpa.show-sql=false spring.mvc.servlet.path=/api