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 @@