diff --git a/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/config/ActiveLearningAutoConfiguration.java b/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/config/ActiveLearningAutoConfiguration.java index 60e555498ea..a9b0782030f 100644 --- a/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/config/ActiveLearningAutoConfiguration.java +++ b/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/config/ActiveLearningAutoConfiguration.java @@ -31,6 +31,7 @@ import de.tudarmstadt.ukp.inception.active.learning.log.ActiveLearningSuggestionOfferedAdapter; import de.tudarmstadt.ukp.inception.active.learning.sidebar.ActiveLearningSidebarFactory; import de.tudarmstadt.ukp.inception.documents.api.DocumentService; +import de.tudarmstadt.ukp.inception.preferences.PreferencesService; import de.tudarmstadt.ukp.inception.recommendation.api.LearningRecordService; import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; import de.tudarmstadt.ukp.inception.recommendation.config.RecommenderServiceAutoConfiguration; @@ -73,7 +74,8 @@ public ActiveLearningSuggestionOfferedAdapter activeLearningSuggestionOfferedAda @Bean public ActiveLearningSidebarFactory activeLearningSidebarFactory( - RecommendationService aRecommendationService) + RecommendationService aRecommendationService, PreferencesService aPreferencesService, + UserDao aUserService) { return new ActiveLearningSidebarFactory(aRecommendationService); } diff --git a/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.html b/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.html index 0f5acfb325c..6530f9edf7b 100644 --- a/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.html +++ b/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.html @@ -26,6 +26,10 @@
+ + + +
+
+ + +
+
+ + +
diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.java index 31701787bf5..1ddac62003c 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.java @@ -75,16 +75,19 @@ public RecommenderListPanel(String id, IModel aProject, overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange)); add(overviewList); - LambdaAjaxLink lambdaAjaxLink = new LambdaAjaxLink(MID_CREATE_BUTTON, this::actionCreate); + var lambdaAjaxLink = new LambdaAjaxLink(MID_CREATE_BUTTON, this::actionCreate); lambdaAjaxLink.setVisible(showCreateButton); add(lambdaAjaxLink); - RecommenderGeneralSettings settings = preferencesService.loadDefaultTraitsForProject( + var settings = preferencesService.loadDefaultTraitsForProject( KEY_RECOMMENDER_GENERAL_SETTINGS, projectModel.getObject()); var form = new Form<>("form", CompoundPropertyModel.of(settings)); form.setOutputMarkupId(true); form.add(new CheckBox("waitForRecommendersOnOpenDocument").setOutputMarkupId(true)); + form.add(new CheckBox("showRecommendationsWhenViewingOtherUser").setOutputMarkupId(true)); + form.add( + new CheckBox("showRecommendationsWhenViewingCurationUser").setOutputMarkupId(true)); form.add(new LambdaAjaxButton<>("save", this::actionSaveSettings)); add(form); } diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.properties b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.properties index a44aaad2b1b..9db4038410b 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.properties +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/project/RecommenderListPanel.properties @@ -15,4 +15,6 @@ # limitations under the License. recommenders=Recommenders -waitForRecommendersOnOpenDocument=Wait for suggestions from non-trainable recommenders when opening document \ No newline at end of file +waitForRecommendersOnOpenDocument=Wait for suggestions from non-trainable recommenders when opening document +showRecommendationsWhenViewingOtherUser=Show suggestions when viewing annotations from another user +showRecommendationsWhenViewingCurationUser=Show suggestions when viewing curation annotations diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRenderer.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRenderer.java index 0c970f7684e..9e19a9785b2 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRenderer.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/render/RecommendationRenderer.java @@ -18,16 +18,20 @@ package de.tudarmstadt.ukp.inception.recommendation.render; import static de.tudarmstadt.ukp.clarin.webanno.model.Mode.ANNOTATION; +import static de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService.KEY_RECOMMENDER_GENERAL_SETTINGS; import static de.tudarmstadt.ukp.inception.recommendation.api.model.SuggestionDocumentGroup.groupByType; import static java.util.function.Function.identity; import static java.util.stream.Collectors.groupingBy; import java.util.HashMap; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; import org.springframework.core.annotation.Order; +import de.tudarmstadt.ukp.clarin.webanno.security.UserDao; +import de.tudarmstadt.ukp.inception.preferences.PreferencesService; import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; import de.tudarmstadt.ukp.inception.recommendation.api.SuggestionSupport; import de.tudarmstadt.ukp.inception.recommendation.api.SuggestionSupportRegistry; @@ -37,7 +41,6 @@ import de.tudarmstadt.ukp.inception.rendering.pipeline.RenderStep; import de.tudarmstadt.ukp.inception.rendering.request.RenderRequest; import de.tudarmstadt.ukp.inception.rendering.vmodel.VDocument; -import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService; /** *

@@ -51,17 +54,19 @@ public class RecommendationRenderer { public static final String ID = "RecommendationRenderer"; - private final AnnotationSchemaService annotationService; private final RecommendationService recommendationService; private final SuggestionSupportRegistry suggestionSupportRegistry; + private final PreferencesService preferencesService; + private final UserDao userService; - public RecommendationRenderer(AnnotationSchemaService aAnnotationService, - RecommendationService aRecommendationService, - SuggestionSupportRegistry aSuggestionSupportRegistry) + public RecommendationRenderer(RecommendationService aRecommendationService, + SuggestionSupportRegistry aSuggestionSupportRegistry, + PreferencesService aPreferencesService, UserDao aUserService) { - annotationService = aAnnotationService; recommendationService = aRecommendationService; suggestionSupportRegistry = aSuggestionSupportRegistry; + preferencesService = aPreferencesService; + userService = aUserService; } @Override @@ -84,6 +89,21 @@ public boolean accepts(RenderRequest aRequest) return false; } + var prefs = preferencesService.loadDefaultTraitsForProject(KEY_RECOMMENDER_GENERAL_SETTINGS, + aRequest.getProject()); + + // Do not show predictions when viewing annotations of another user + if (!prefs.isShowRecommendationsWhenViewingOtherUser() + && !Objects.equals(aRequest.getAnnotationUser(), aRequest.getSessionOwner())) { + return false; + } + + // Do not show predictions when viewing annotations of curation user + if (!prefs.isShowRecommendationsWhenViewingCurationUser() + && Objects.equals(aRequest.getAnnotationUser(), userService.getCurationUser())) { + return false; + } + return true; } diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java index 24187196fa8..3fdbcf15225 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/service/RecommendationServiceImpl.java @@ -116,6 +116,8 @@ import de.tudarmstadt.ukp.inception.recommendation.config.RecommenderServiceAutoConfiguration; import de.tudarmstadt.ukp.inception.recommendation.event.RecommenderDeletedEvent; import de.tudarmstadt.ukp.inception.recommendation.event.RecommenderUpdatedEvent; +import de.tudarmstadt.ukp.inception.recommendation.event.RecommendersResumedEvent; +import de.tudarmstadt.ukp.inception.recommendation.event.RecommendersSuspendedEvent; import de.tudarmstadt.ukp.inception.recommendation.model.DirtySpot; import de.tudarmstadt.ukp.inception.recommendation.tasks.NonTrainableRecommenderActivationTask; import de.tudarmstadt.ukp.inception.recommendation.tasks.PredictionTask; @@ -953,7 +955,22 @@ public boolean isSuspended(String aSessionOwner, Project aProject) @Override public void setSuspended(String aSessionOwner, Project aProject, boolean aState) { + var suspended = isSuspended(aSessionOwner, aProject); + if (suspended == aState) { + return; + } + getState(aSessionOwner, aProject).setSuspended(aState); + if (aState) { + applicationEventPublisher + .publishEvent(new RecommendersSuspendedEvent(this, aProject, aSessionOwner)); + ; + } + else { + applicationEventPublisher + .publishEvent(new RecommendersResumedEvent(this, aProject, aSessionOwner)); + ; + } } @EventListener diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.html index 682d5773059..383fede09aa 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.html +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.html @@ -77,16 +77,24 @@ -

-
- - -
-
-
-
+ +
+ + + -
+
+
+
+ + +
+
+
+
+
+
+
diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.java index 50829faf71e..4bfcfa6c398 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.java @@ -17,12 +17,14 @@ */ package de.tudarmstadt.ukp.inception.recommendation.sidebar; +import static de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService.KEY_RECOMMENDER_GENERAL_SETTINGS; import static de.tudarmstadt.ukp.inception.support.lambda.HtmlElementEvents.CHANGE_EVENT; import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhen; import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhenNot; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -34,6 +36,7 @@ import org.apache.wicket.markup.html.form.NumberTextField; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.IModel; +import org.apache.wicket.model.LoadableDetachableModel; import org.apache.wicket.model.StringResourceModel; import org.apache.wicket.model.util.ListModel; import org.apache.wicket.spring.injection.annot.SpringBean; @@ -47,6 +50,7 @@ import de.tudarmstadt.ukp.clarin.webanno.ui.annotation.AnnotationPage; import de.tudarmstadt.ukp.clarin.webanno.ui.annotation.sidebar.AnnotationSidebar_ImplBase; import de.tudarmstadt.ukp.inception.editor.action.AnnotationActionHandler; +import de.tudarmstadt.ukp.inception.preferences.PreferencesService; import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; import de.tudarmstadt.ukp.inception.recommendation.api.model.Preferences; import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; @@ -67,7 +71,9 @@ public class RecommendationSidebar private @SpringBean RecommendationService recommendationService; private @SpringBean AnnotationSchemaService annoService; private @SpringBean UserDao userRepository; + private @SpringBean PreferencesService preferencesService; + private IModel recommendersAvailable; private WebMarkupContainer warning; private StringResourceModel tipModel; private Form form; @@ -80,6 +86,12 @@ public RecommendationSidebar(String aId, IModel aModel, { super(aId, aModel, aActionHandler, aCasProvider, aAnnotationPage); + recommendersAvailable = LoadableDetachableModel.of(this::isRecommendersAvailable); + + var mainContainer = new WebMarkupContainer("mainContainer"); + mainContainer.add(visibleWhen(recommendersAvailable)); + add(mainContainer); + var sessionOwner = userRepository.getCurrentUser(); var modelPreferences = LambdaModelAdapter.of( () -> recommendationService.getPreferences(sessionOwner, @@ -102,6 +114,10 @@ public RecommendationSidebar(String aId, IModel aModel, noRecommendersLabel.add(visibleWhen(() -> recommenders.isEmpty())); add(noRecommendersLabel); + var notAvailableNotice = new WebMarkupContainer("notAvailableNotice"); + notAvailableNotice.add(visibleWhenNot(recommendersAvailable)); + add(notAvailableNotice); + add(new LambdaAjaxLink("showLog", this::actionShowLog) .add(visibleWhenNot(recommenders::isEmpty))); @@ -113,9 +129,10 @@ public RecommendationSidebar(String aId, IModel aModel, aModel.getObject().getProject()), (v) -> recommendationService.setSuspended(sessionOwner.getUsername(), aModel.getObject().getProject(), !v)); - add(new CheckBox("enabled", modelEnabled).setOutputMarkupId(true) + mainContainer.add(new CheckBox("enabled", modelEnabled).setOutputMarkupId(true) .add(new LambdaAjaxFormComponentUpdatingBehavior(CHANGE_EVENT))); - add(new EvaluationProgressPanel("progress", aModel.map(AnnotatorState::getProject))); + mainContainer.add( + new EvaluationProgressPanel("progress", aModel.map(AnnotatorState::getProject))); form = new Form<>("form", CompoundPropertyModel.of(modelPreferences)); form.setOutputMarkupId(true); @@ -142,12 +159,19 @@ public RecommendationSidebar(String aId, IModel aModel, recommenderInfos = new RecommenderInfoPanel("recommenders", aModel); recommenderInfos.add(visibleWhen(() -> !recommenders.isEmpty())); - add(recommenderInfos); + mainContainer.add(recommenderInfos); logDialog = new LogDialog("logDialog"); add(logDialog); } + @Override + protected void onDetach() + { + super.onDetach(); + recommendersAvailable.detach(); + } + @Override protected void onConfigure() { @@ -159,6 +183,27 @@ protected void onConfigure() recommenderInfos.setEnabled(enabled); } + private boolean isRecommendersAvailable() + { + var state = getModelObject(); + var prefs = preferencesService.loadDefaultTraitsForProject(KEY_RECOMMENDER_GENERAL_SETTINGS, + state.getProject()); + + // Do not show predictions when viewing annotations of another user + if (!prefs.isShowRecommendationsWhenViewingOtherUser() + && !Objects.equals(state.getUser(), userRepository.getCurrentUser())) { + return false; + } + + // Do not show predictions when viewing annotations of curation user + if (!prefs.isShowRecommendationsWhenViewingCurationUser() + && Objects.equals(state.getUser(), userRepository.getCurationUser())) { + return false; + } + + return true; + } + protected void configureMismatched() { var mismatchedRecommenders = findMismatchedRecommenders(); diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.properties b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.properties index 67b51c71d23..c2acef3cb29 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.properties +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebar.properties @@ -25,3 +25,4 @@ retrain=Retrain showLog=Log noRecommenders=None of the layers have any recommenders configured. Please set the recommenders first in the Project Settings. progressTowardsEvaluation=Progress towards next evaluation +notAvailableNotice=Currently not available \ No newline at end of file diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebarFactory.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebarFactory.java index 5c869ab623b..bef73eaf1f9 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebarFactory.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommendationSidebarFactory.java @@ -22,8 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; -import de.agilecoders.wicket.core.markup.html.bootstrap.image.Icon; -import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesome5IconType; import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasProvider; import de.tudarmstadt.ukp.clarin.webanno.model.Project; import de.tudarmstadt.ukp.clarin.webanno.ui.annotation.AnnotationPage; @@ -68,7 +66,7 @@ public String getDescription() @Override public Component createIcon(String aId, IModel aState) { - return new Icon(aId, FontAwesome5IconType.chart_line_s); + return new RecommenderSidebarIcon(aId, aState); } @Override diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderSidebarIcon.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderSidebarIcon.html new file mode 100644 index 00000000000..b11677a1e94 --- /dev/null +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderSidebarIcon.html @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderSidebarIcon.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderSidebarIcon.java new file mode 100644 index 00000000000..4f1bc0c465e --- /dev/null +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/RecommenderSidebarIcon.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.tudarmstadt.ukp.inception.recommendation.sidebar; + +import java.util.Set; + +import org.apache.wicket.ClassAttributeModifier; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.LoadableDetachableModel; +import org.apache.wicket.spring.injection.annot.SpringBean; +import org.wicketstuff.event.annotation.OnEvent; + +import de.agilecoders.wicket.core.markup.html.bootstrap.image.Icon; +import de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType; +import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesome5IconType; +import de.tudarmstadt.ukp.clarin.webanno.security.UserDao; +import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; +import de.tudarmstadt.ukp.inception.recommendation.event.RecommendersResumedEvent; +import de.tudarmstadt.ukp.inception.recommendation.event.RecommendersSuspendedEvent; +import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; + +public class RecommenderSidebarIcon + extends Panel +{ + private static final long serialVersionUID = -1870047500327624860L; + + private @SpringBean RecommendationService recommendationService; + private @SpringBean UserDao userService; + + public RecommenderSidebarIcon(String aId, IModel aState) + { + super(aId, aState); + + setOutputMarkupId(true); + + queue(new Icon("icon", FontAwesome5IconType.robot_s)); + queue(new Icon("badge", LoadableDetachableModel.of(this::getStateIcon)) + .add(new ClassAttributeModifier() + { + private static final long serialVersionUID = 4534226094224688646L; + + @Override + protected Set update(Set aClasses) + { + if (isSessionActive()) { + aClasses.add("text-primary"); + aClasses.remove("text-muted"); + } + else { + aClasses.add("text-muted"); + aClasses.remove("text-primary"); + } + + return aClasses; + } + })); + } + + @SuppressWarnings("unchecked") + public IModel getModel() + { + return (IModel) getDefaultModel(); + } + + public AnnotatorState getModelObject() + { + return (AnnotatorState) getDefaultModelObject(); + } + + private boolean isSessionActive() + { + return !recommendationService.isSuspended(userService.getCurrentUsername(), + getModelObject().getProject()); + } + + private IconType getStateIcon() + { + if (isSessionActive()) { + return FontAwesome5IconType.play_circle_s; + } + + return FontAwesome5IconType.stop_circle_s; + } + + @OnEvent + public void sessionStarted(RecommendersSuspendedEvent aEvent) + { + aEvent.getRequestTarget().ifPresent(target -> target.add(this)); + } + + @OnEvent + public void sessionStarted(RecommendersResumedEvent aEvent) + { + aEvent.getRequestTarget().ifPresent(target -> target.add(this)); + } +} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/tasks/TrainingTask.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/tasks/TrainingTask.java index 40907c34d9e..7a7f16f1c7f 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/tasks/TrainingTask.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/tasks/TrainingTask.java @@ -245,10 +245,10 @@ private void schedulePredictionTask() schedulingService.enqueue(predictionTask); } - private void commitContext(User user, Recommender recommender, RecommenderContext ctx) + private void commitContext(User aSessionOwner, Recommender recommender, RecommenderContext ctx) { ctx.close(); - recommenderService.putContext(user, recommender, ctx); + recommenderService.putContext(aSessionOwner, recommender, ctx); } private void logTrainingOverallEnd(long overallStartTime) @@ -372,9 +372,10 @@ private void logTrainingSuccessful(LazyCasLoader casses, Recommender recommender private void logTrainingOverallStart() { - LOG.debug("[{}][{}]: Starting training for project {} triggered by [{}]...", getId(), - getSessionOwner().getUsername(), getProject(), getTrigger()); - info("Starting training triggered by [%s]...", getTrigger()); + LOG.debug( + "[{}][{}]: Starting training for project {} on data from [{}] triggered by [{}]...", + getId(), getSessionOwner().getUsername(), getProject(), dataOwner, getTrigger()); + info("Starting training on data from [%s] triggered by [%s]...", dataOwner, getTrigger()); } private void logTrainingRecommenderStart(LazyCasLoader aLoader, Recommender recommender, diff --git a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarPanel.java b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarPanel.java index b7f9250a9b5..7b64e3dc8bb 100644 --- a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarPanel.java +++ b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarPanel.java @@ -101,16 +101,15 @@ public void refreshTabs(AjaxRequestTarget aTarget) private List makeTabs() { - List tabs = new ArrayList<>(); - for (AnnotationSidebarFactory factory : sidebarRegistry.getSidebarFactories()) { + var tabs = new ArrayList(); + for (var factory : sidebarRegistry.getSidebarFactories()) { if (!factory.applies(stateModel.getObject())) { continue; } - String factoryId = factory.getBeanName(); - SidebarTab tab = new SidebarTab(Model.of(factory.getDisplayName()), - factory.getBeanName()) + var factoryId = factory.getBeanName(); + var tab = new SidebarTab(Model.of(factory.getDisplayName()), factory.getBeanName()) { private static final long serialVersionUID = 2144644282070158783L; diff --git a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTab.java b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTab.java index 687400a4402..849b27f191d 100644 --- a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTab.java +++ b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTab.java @@ -20,7 +20,6 @@ import org.apache.wicket.Component; import org.apache.wicket.extensions.markup.html.tabs.AbstractTab; import org.apache.wicket.model.IModel; -import org.springframework.context.ApplicationContext; import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; import de.tudarmstadt.ukp.inception.support.spring.ApplicationContextProvider; @@ -49,13 +48,12 @@ public Component getIcon(String aId, IModel aState) // We need to get the methods and services directly in here so // that the lambda doesn't have a dependency on the non-serializable // AnnotationSidebarFactory class. - ApplicationContext ctx = ApplicationContextProvider.getApplicationContext(); + var ctx = ApplicationContextProvider.getApplicationContext(); return ctx.getBean(AnnotationSidebarRegistry.class).getSidebarFactory(factoryId) .createIcon(aId, aState); } catch (Exception e) { throw new RuntimeException(e); } - } } diff --git a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTabbedPanel.java b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTabbedPanel.java index 9180d40205a..ee867dba722 100644 --- a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTabbedPanel.java +++ b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/sidebar/SidebarTabbedPanel.java @@ -37,7 +37,6 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.image.Icon; import de.tudarmstadt.ukp.clarin.webanno.security.UserDao; -import de.tudarmstadt.ukp.clarin.webanno.security.model.User; import de.tudarmstadt.ukp.inception.preferences.Key; import de.tudarmstadt.ukp.inception.preferences.PreferencesService; import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; @@ -69,7 +68,7 @@ public SidebarTabbedPanel(String aId, List aTabs, IModel aSta setOutputMarkupId(true); setVisible(!aTabs.isEmpty()); - LambdaAjaxLink showHideLink = new LambdaAjaxLink("showHideLink", this::showHideAction); + var showHideLink = new LambdaAjaxLink("showHideLink", this::showHideAction); showHideLink.add(new Icon("showHideIcon", LoadableDetachableModel.of(() -> isExpanded() ? chevron_left_s : chevron_right_s))); @@ -121,7 +120,7 @@ private void saveSidebarState() var sidebarState = new AnnotationSidebarState(); sidebarState.setSelectedTab(getTabs().get(getSelectedTab()).getFactoryId()); sidebarState.setExpanded(expanded); - User user = userService.getCurrentUser(); + var user = userService.getCurrentUser(); prefService.saveTraitsForUserAndProject(KEY_SIDEBAR_STATE, user, state.getObject().getProject(), sidebarState); } @@ -145,8 +144,8 @@ private void loadSidebarState() @Override protected Component newTitle(String aTitleId, IModel aTitleModel, int aIndex) { - SidebarTab tab = getTabs().get(aIndex); - Component icon = tab.getIcon("icon", state); + var tab = getTabs().get(aIndex); + var icon = tab.getIcon("icon", state); icon.add(new AttributeModifier("title", aTitleModel)); return icon; }