From d7c6741b1de883db5e003c0d0ac11c50b3797fba Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Sun, 16 Apr 2023 11:21:47 +0200 Subject: [PATCH] #3944 - Ability to use recommenders as curator - Rename methods and variables to better reflect the separation between session owner and document owner --- .../sidebar/ActiveLearningSidebar.java | 8 +-- .../events/AnnotationCreatedEvent.java | 2 +- .../events/AnnotationDeletedEvent.java | 2 +- .../annotation/events/AnnotationEvent.java | 24 ++++---- .../events/BeforeDocumentOpenedEvent.java | 18 +++--- .../events/BulkAnnotationEvent.java | 12 ++-- .../events/DocumentOpenedEvent.java | 19 +++--- .../events/FeatureValueUpdatedEvent.java | 2 +- .../annotation/layer/chain/ChainAdapter.java | 2 +- .../annotation/layer/chain/ChainEvent.java | 2 +- .../layer/relation/RelationCreatedEvent.java | 5 +- .../layer/relation/RelationDeletedEvent.java | 4 +- .../layer/relation/RelationEvent.java | 8 +-- .../span/CreateSpanAnnotationRequest.java | 10 +-- .../layer/span/MoveSpanAnnotationRequest.java | 10 +-- .../annotation/layer/span/SpanAdapter.java | 29 ++++----- .../span/SpanAnnotationRequest_ImplBase.java | 14 ++--- .../layer/span/SpanCreatedEvent.java | 4 +- .../layer/span/SpanDeletedEvent.java | 4 +- .../annotation/layer/span/SpanEvent.java | 4 +- .../inception/schema/adapter/TypeAdapter.java | 10 +-- .../inception/curation/merge/CasMerge.java | 18 +++--- .../docanno/event/DocumentMetadataEvent.java | 2 +- ...MetadataLayerSingletonCreatingWatcher.java | 2 +- .../log/DocumentMetadataEventAdapter.java | 2 +- .../adapter/BulkAnnotationEventAdapter.java | 2 +- .../log/adapter/ChainLinkEventAdapter.java | 2 +- .../log/adapter/ChainSpanEventAdapter.java | 2 +- .../adapter/DocumentOpenedEventAdapter.java | 4 +- .../FeatureValueUpdatedEventAdapter.java | 2 +- .../log/adapter/RelationEventAdapter.java | 2 +- .../log/adapter/SpanEventAdapter.java | 2 +- .../api/RecommendationService.java | 16 ++--- .../RecommendationEditorExtension.java | 13 ++-- .../recommendation/model/DirtySpot.java | 2 +- .../service/RecommendationServiceImpl.java | 61 ++++++++++--------- .../webanno/ui/annotation/AnnotationPage.java | 4 +- .../actions/AnnotationAction_ImplBase.java | 2 +- .../detail/AnnotationDetailEditorPanel.java | 2 +- .../sidebar/CurationSidebarServiceImpl.java | 2 +- 40 files changed, 169 insertions(+), 166 deletions(-) diff --git a/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.java b/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.java index 2388d80a076..d4beed41199 100644 --- a/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.java +++ b/inception/inception-active-learning/src/main/java/de/tudarmstadt/ukp/inception/active/learning/sidebar/ActiveLearningSidebar.java @@ -1071,7 +1071,7 @@ public void onSpanCreated(SpanCreatedEvent aEvent) } // Does event match the current active learning configuration? - if (!aEvent.getUser().equals(getModelObject().getUser().getUsername()) + if (!aEvent.getDocumentOwner().equals(getModelObject().getUser().getUsername()) || !aEvent.getLayer().equals(alState.getLayer())) { return; } @@ -1090,7 +1090,7 @@ public void onRelationCreated(RelationCreatedEvent aEvent) } // Does event match the current active learning configuration? - if (!aEvent.getUser().equals(getModelObject().getUser().getUsername()) + if (!aEvent.getDocumentOwner().equals(getModelObject().getUser().getUsername()) || !aEvent.getLayer().equals(alState.getLayer())) { return; } @@ -1119,7 +1119,7 @@ public void onFeatureValueUpdated(FeatureValueUpdatedEvent aEvent) } // Does event match the current active learning configuration? - if (!aEvent.getUser().equals(getModelObject().getUser().getUsername()) + if (!aEvent.getDocumentOwner().equals(getModelObject().getUser().getUsername()) || !aEvent.getFeature().getLayer().equals(alState.getLayer()) || !aEvent.getFeature().getName() .equals(alState.getSuggestion().get().getFeature())) { @@ -1148,7 +1148,7 @@ public void onAnnotationDeleted(SpanDeletedEvent aEvent) } // Does event match the current active learning configuration? - if (!aEvent.getUser().equals(getModelObject().getUser().getUsername()) + if (!aEvent.getDocumentOwner().equals(getModelObject().getUser().getUsername()) || !aEvent.getLayer().equals(alState.getLayer())) { return; } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationCreatedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationCreatedEvent.java index 94cdbaa79a6..3b811198e24 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationCreatedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationCreatedEvent.java @@ -28,7 +28,7 @@ public interface AnnotationCreatedEvent { SourceDocument getDocument(); - String getUser(); + String getDocumentOwner(); AnnotationLayer getLayer(); diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationDeletedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationDeletedEvent.java index 56e8da2b465..d7d7b23d217 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationDeletedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationDeletedEvent.java @@ -28,7 +28,7 @@ public interface AnnotationDeletedEvent { SourceDocument getDocument(); - String getUser(); + String getDocumentOwner(); AnnotationLayer getLayer(); diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationEvent.java index 812673e416f..c2eec6109ec 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/AnnotationEvent.java @@ -34,23 +34,25 @@ public abstract class AnnotationEvent private final Project project; private final SourceDocument document; - private final String user; + private final String documentOwner; private final AnnotationLayer layer; - public AnnotationEvent(Object aSource, Project aProject, String aUser, AnnotationLayer aLayer) + public AnnotationEvent(Object aSource, Project aProject, String aDocumentOwner, + AnnotationLayer aLayer) { - this(aSource, aProject, null, aUser, aLayer); + this(aSource, aProject, null, aDocumentOwner, aLayer); } - public AnnotationEvent(Object aSource, SourceDocument aDocument, String aUser, + public AnnotationEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner, AnnotationLayer aLayer) { - this(aSource, aDocument != null ? aDocument.getProject() : null, aDocument, aUser, aLayer); + this(aSource, aDocument != null ? aDocument.getProject() : null, aDocument, aDocumentOwner, + aLayer); Validate.notNull(getProject(), "Project must be specified"); Validate.notNull(getDocument(), "Document must be specified"); Validate.notNull(getLayer(), "Layer must be specified"); - Validate.notNull(getUser(), "User must be specified"); + Validate.notNull(getDocumentOwner(), "User must be specified"); } public AnnotationEvent(Object aSource, SourceDocument aDocument, String aUser) @@ -59,16 +61,16 @@ public AnnotationEvent(Object aSource, SourceDocument aDocument, String aUser) Validate.notNull(getProject(), "Project must be specified"); Validate.notNull(getDocument(), "Document must be specified"); - Validate.notNull(getUser(), "User must be specified"); + Validate.notNull(getDocumentOwner(), "Document owner must be specified"); } private AnnotationEvent(Object aSource, Project aProject, SourceDocument aDocument, - String aUser, AnnotationLayer aLayer) + String aDocumentOwner, AnnotationLayer aLayer) { super(aSource); project = aProject; document = aDocument; - user = aUser; + documentOwner = aDocumentOwner; layer = aLayer; } @@ -82,9 +84,9 @@ public SourceDocument getDocument() return document; } - public String getUser() + public String getDocumentOwner() { - return user; + return documentOwner; } public AnnotationLayer getLayer() diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java index f8198f63123..9161db21c16 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BeforeDocumentOpenedEvent.java @@ -35,19 +35,19 @@ public class BeforeDocumentOpenedEvent private final CAS cas; private final SourceDocument document; // user who owns/annotates the opened document - private final String annotator; + private final String documentOwner; // user who opened the document - private final String opener; + private final String sessionOwner; private final boolean editable; public BeforeDocumentOpenedEvent(Object aSource, CAS aCas, SourceDocument aDocument, - String aAnnotator, String aOpener, boolean aEditable) + String aDocumentOwner, String aSessionOwner, boolean aEditable) { super(aSource); cas = aCas; document = aDocument; - annotator = aAnnotator; - opener = aOpener; + documentOwner = aDocumentOwner; + sessionOwner = aSessionOwner; editable = aEditable; } @@ -61,14 +61,14 @@ public SourceDocument getDocument() return document; } - public String getUser() + public String getSessionOwner() { - return opener; + return sessionOwner; } - public String getAnnotator() + public String getDocumentOwner() { - return annotator; + return documentOwner; } public boolean isEditable() diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BulkAnnotationEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BulkAnnotationEvent.java index 1dc4849248c..3b64b6f7e66 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BulkAnnotationEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/BulkAnnotationEvent.java @@ -34,21 +34,21 @@ public class BulkAnnotationEvent { private static final long serialVersionUID = -1187536069360130349L; - public BulkAnnotationEvent(Object aSource, Project aProject, String aUser, + public BulkAnnotationEvent(Object aSource, Project aProject, String aDocumentOwner, AnnotationLayer aLayer) { - super(aSource, aProject, aUser, aLayer); + super(aSource, aProject, aDocumentOwner, aLayer); } - public BulkAnnotationEvent(Object aSource, SourceDocument aDocument, String aUser, + public BulkAnnotationEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner, AnnotationLayer aLayer) { - super(aSource, aDocument, aUser, aLayer); + super(aSource, aDocument, aDocumentOwner, aLayer); } - public BulkAnnotationEvent(Object aSource, SourceDocument aDocument, String aUser) + public BulkAnnotationEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner) { - super(aSource, aDocument, aUser); + super(aSource, aDocument, aDocumentOwner); } @Override diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/DocumentOpenedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/DocumentOpenedEvent.java index 027e36655ac..dcdc03326ab 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/DocumentOpenedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/DocumentOpenedEvent.java @@ -33,19 +33,20 @@ public class DocumentOpenedEvent private final CAS cas; private final SourceDocument document; // user who owns/annotates the opened document - private final String annotator; + private final String documentOwner; // user who opened the document - private final String opener; + private final String sessionOwner; private final AnnotationDocumentState stateBeforeOpening; public DocumentOpenedEvent(Object aSource, CAS aCas, SourceDocument aDocument, - AnnotationDocumentState aStateBeforeOpening, String aAnnotator, String aOpener) + AnnotationDocumentState aStateBeforeOpening, String aDocumentOwner, + String aSessionOwner) { super(aSource); cas = aCas; document = aDocument; - annotator = aAnnotator; - opener = aOpener; + documentOwner = aDocumentOwner; + sessionOwner = aSessionOwner; stateBeforeOpening = aStateBeforeOpening; } @@ -59,14 +60,14 @@ public SourceDocument getDocument() return document; } - public String getUser() + public String getSessionOwner() { - return opener; + return sessionOwner; } - public String getAnnotator() + public String getDocumentOwner() { - return annotator; + return documentOwner; } public AnnotationDocumentState getStateBeforeOpening() diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/FeatureValueUpdatedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/FeatureValueUpdatedEvent.java index 7fbce1481bb..a6b3e7628db 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/FeatureValueUpdatedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/events/FeatureValueUpdatedEvent.java @@ -89,7 +89,7 @@ public String toString() builder.append("docID="); builder.append(getDocument()); builder.append(", user="); - builder.append(getUser()); + builder.append(getDocumentOwner()); builder.append(", "); } builder.append("addr="); diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java index dea4e8055c2..0ff8e01d14b 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainAdapter.java @@ -105,7 +105,7 @@ public AnnotationFS handle(CreateSpanAnnotationRequest aRequest) throws Annotati AnnotationFS newSpan = createChainElementAnnotation(request); - publishEvent(new ChainSpanCreatedEvent(this, aRequest.getDocument(), aRequest.getUsername(), + publishEvent(new ChainSpanCreatedEvent(this, aRequest.getDocument(), aRequest.getDocumentOwner(), getLayer(), newSpan)); return newSpan; diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainEvent.java index 4396b320200..7c091916b28 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/chain/ChainEvent.java @@ -59,7 +59,7 @@ public String toString() builder.append("docID="); builder.append(getDocument().getId()); builder.append(", user="); - builder.append(getUser()); + builder.append(getDocumentOwner()); builder.append(", "); } builder.append("element=["); diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCreatedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCreatedEvent.java index 00b3105d843..60463c7d45e 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCreatedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationCreatedEvent.java @@ -29,10 +29,11 @@ public class RelationCreatedEvent { private static final long serialVersionUID = 1729547025986959164L; - public RelationCreatedEvent(Object aSource, SourceDocument aDocument, String aUser, + public RelationCreatedEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner, AnnotationLayer aLayer, AnnotationFS aRelationFS, AnnotationFS aTargetAnnotation, AnnotationFS aSourceAnnotation) { - super(aSource, aDocument, aUser, aLayer, aRelationFS, aTargetAnnotation, aSourceAnnotation); + super(aSource, aDocument, aDocumentOwner, aLayer, aRelationFS, aTargetAnnotation, + aSourceAnnotation); } } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationDeletedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationDeletedEvent.java index a310da73470..ca62f1ef389 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationDeletedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationDeletedEvent.java @@ -29,10 +29,10 @@ public class RelationDeletedEvent { private static final long serialVersionUID = -3212535102141634478L; - public RelationDeletedEvent(Object aSource, SourceDocument aDocument, String aUser, + public RelationDeletedEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner, AnnotationLayer aLayer, AnnotationFS aRelationFS, AnnotationFS aTargetAnnotation, AnnotationFS aSourceAnnotation) { - super(aSource, aDocument, aUser, aLayer, aRelationFS, aTargetAnnotation, aSourceAnnotation); + super(aSource, aDocument, aDocumentOwner, aLayer, aRelationFS, aTargetAnnotation, aSourceAnnotation); } } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationEvent.java index 3488f4881e2..2578b9d9caa 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/relation/RelationEvent.java @@ -33,11 +33,11 @@ public abstract class RelationEvent private final AnnotationFS targetAnno; private final AnnotationFS sourceAnno; - public RelationEvent(Object aSource, SourceDocument aDocument, String aUser, + public RelationEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner, AnnotationLayer aLayer, AnnotationFS aRelationFS, AnnotationFS aTargetAnnotation, AnnotationFS aSourceAnnotation) { - super(aSource, aDocument, aUser, aLayer); + super(aSource, aDocument, aDocumentOwner, aLayer); relation = aRelationFS; targetAnno = aTargetAnnotation; @@ -76,8 +76,8 @@ public String toString() if (getDocument() != null) { builder.append("docID="); builder.append(getDocument()); - builder.append(", user="); - builder.append(getUser()); + builder.append(", docOwner="); + builder.append(getDocumentOwner()); builder.append(", "); } builder.append("relation=["); diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/CreateSpanAnnotationRequest.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/CreateSpanAnnotationRequest.java index 92d31c9ea90..691cc2ff9c2 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/CreateSpanAnnotationRequest.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/CreateSpanAnnotationRequest.java @@ -24,22 +24,22 @@ public class CreateSpanAnnotationRequest extends SpanAnnotationRequest_ImplBase { - public CreateSpanAnnotationRequest(SourceDocument aDocument, String aUsername, CAS aCas, + public CreateSpanAnnotationRequest(SourceDocument aDocument, String aDocumentOwner, CAS aCas, int aBegin, int aEnd) { - this(null, aDocument, aUsername, aCas, aBegin, aEnd); + this(null, aDocument, aDocumentOwner, aCas, aBegin, aEnd); } private CreateSpanAnnotationRequest(CreateSpanAnnotationRequest aOriginal, - SourceDocument aDocument, String aUsername, CAS aCas, int aBegin, int aEnd) + SourceDocument aDocument, String aDocumentOwner, CAS aCas, int aBegin, int aEnd) { - super(null, aDocument, aUsername, aCas, aBegin, aEnd); + super(null, aDocument, aDocumentOwner, aCas, aBegin, aEnd); } @Override public CreateSpanAnnotationRequest changeSpan(int aBegin, int aEnd) { - return new CreateSpanAnnotationRequest(this, getDocument(), getUsername(), getCas(), aBegin, + return new CreateSpanAnnotationRequest(this, getDocument(), getDocumentOwner(), getCas(), aBegin, aEnd); } } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/MoveSpanAnnotationRequest.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/MoveSpanAnnotationRequest.java index 38fe190efa5..6b602e98a12 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/MoveSpanAnnotationRequest.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/MoveSpanAnnotationRequest.java @@ -27,16 +27,16 @@ public class MoveSpanAnnotationRequest { private final AnnotationFS annotation; - public MoveSpanAnnotationRequest(SourceDocument aDocument, String aUsername, CAS aCas, + public MoveSpanAnnotationRequest(SourceDocument aDocument, String aDocumentOwner, CAS aCas, AnnotationFS aAnnotation, int aBegin, int aEnd) { - this(null, aDocument, aUsername, aCas, aAnnotation, aBegin, aEnd); + this(null, aDocument, aDocumentOwner, aCas, aAnnotation, aBegin, aEnd); } private MoveSpanAnnotationRequest(MoveSpanAnnotationRequest aOriginal, SourceDocument aDocument, - String aUsername, CAS aCas, AnnotationFS aAnnotation, int aBegin, int aEnd) + String aDocumentOwner, CAS aCas, AnnotationFS aAnnotation, int aBegin, int aEnd) { - super(null, aDocument, aUsername, aCas, aBegin, aEnd); + super(null, aDocument, aDocumentOwner, aCas, aBegin, aEnd); annotation = aAnnotation; } @@ -48,7 +48,7 @@ public AnnotationFS getAnnotation() @Override public MoveSpanAnnotationRequest changeSpan(int aBegin, int aEnd) { - return new MoveSpanAnnotationRequest(this, getDocument(), getUsername(), getCas(), + return new MoveSpanAnnotationRequest(this, getDocument(), getDocumentOwner(), getCas(), getAnnotation(), aBegin, aEnd); } } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAdapter.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAdapter.java index a349daecce2..fb6c502b2af 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAdapter.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAdapter.java @@ -83,7 +83,7 @@ public SpanAdapter(LayerSupportRegistry aLayerSupportRegistry, * * @param aDocument * the document to which the CAS belongs - * @param aUsername + * @param aDocumentOwner * the user to which the CAS belongs * @param aCas * the CAS. @@ -95,16 +95,17 @@ public SpanAdapter(LayerSupportRegistry aLayerSupportRegistry, * @throws AnnotationException * if the annotation cannot be created/updated. */ - public AnnotationFS add(SourceDocument aDocument, String aUsername, CAS aCas, int aBegin, + public AnnotationFS add(SourceDocument aDocument, String aDocumentOwner, CAS aCas, int aBegin, int aEnd) throws AnnotationException { - return handle(new CreateSpanAnnotationRequest(aDocument, aUsername, aCas, aBegin, aEnd)); + return handle( + new CreateSpanAnnotationRequest(aDocument, aDocumentOwner, aCas, aBegin, aEnd)); } public AnnotationFS handle(CreateSpanAnnotationRequest aRequest) throws AnnotationException { - CreateSpanAnnotationRequest request = aRequest; + var request = aRequest; // Adjust the creation request (e.g. adjust offsets to the configured granularity) or // reject the creation (e.g. reject cross-sentence annotations) @@ -112,10 +113,10 @@ public AnnotationFS handle(CreateSpanAnnotationRequest aRequest) throws Annotati request = behavior.onCreate(this, request); } - AnnotationFS newAnnotation = createSpanAnnotation(request.getCas(), request.getBegin(), + var newAnnotation = createSpanAnnotation(request.getCas(), request.getBegin(), request.getEnd()); - publishEvent(new SpanCreatedEvent(this, request.getDocument(), request.getUsername(), + publishEvent(new SpanCreatedEvent(this, request.getDocument(), request.getDocumentOwner(), getLayer(), newAnnotation)); return newAnnotation; @@ -126,7 +127,7 @@ public AnnotationFS handle(CreateSpanAnnotationRequest aRequest) throws Annotati * * @param aDocument * the document to which the CAS belongs - * @param aUsername + * @param aDocumentOwner * the user to which the CAS belongs * @param aCas * the CAS. @@ -140,11 +141,11 @@ public AnnotationFS handle(CreateSpanAnnotationRequest aRequest) throws Annotati * @throws AnnotationException * if the annotation cannot be created/updated. */ - public AnnotationFS move(SourceDocument aDocument, String aUsername, CAS aCas, + public AnnotationFS move(SourceDocument aDocument, String aDocumentOwner, CAS aCas, AnnotationFS aAnnotation, int aBegin, int aEnd) throws AnnotationException { - return handle(new MoveSpanAnnotationRequest(aDocument, aUsername, aCas, aAnnotation, aBegin, + return handle(new MoveSpanAnnotationRequest(aDocument, aDocumentOwner, aCas, aAnnotation, aBegin, aEnd)); } @@ -163,7 +164,7 @@ public AnnotationFS handle(MoveSpanAnnotationRequest aRequest) throws Annotation moveSpanAnnotation(request.getCas(), request.getAnnotation(), request.getBegin(), request.getEnd()); - publishEvent(new SpanMovedEvent(this, request.getDocument(), request.getUsername(), + publishEvent(new SpanMovedEvent(this, request.getDocument(), request.getDocumentOwner(), getLayer(), request.getAnnotation(), oldBegin, oldEnd)); return request.getAnnotation(); @@ -210,7 +211,7 @@ private AnnotationFS moveSpanAnnotation(CAS aCas, AnnotationFS aAnnotation, int } @Override - public void delete(SourceDocument aDocument, String aUsername, CAS aCas, VID aVid) + public void delete(SourceDocument aDocument, String aDocumentOwner, CAS aCas, VID aVid) { AnnotationFS fs = selectByAddr(aCas, AnnotationFS.class, aVid.getId()); aCas.removeFsFromIndexes(fs); @@ -220,10 +221,10 @@ public void delete(SourceDocument aDocument, String aUsername, CAS aCas, VID aVi detatch(aCas, fs); } - publishEvent(new SpanDeletedEvent(this, aDocument, aUsername, getLayer(), fs)); + publishEvent(new SpanDeletedEvent(this, aDocument, aDocumentOwner, getLayer(), fs)); } - public AnnotationFS restore(SourceDocument aDocument, String aUsername, CAS aCas, VID aVid) + public AnnotationFS restore(SourceDocument aDocument, String aDocumentOwner, CAS aCas, VID aVid) throws AnnotationException { AnnotationFS fs = selectByAddr(aCas, AnnotationFS.class, aVid.getId()); @@ -234,7 +235,7 @@ public AnnotationFS restore(SourceDocument aDocument, String aUsername, CAS aCas aCas.addFsToIndexes(fs); - publishEvent(new SpanCreatedEvent(this, aDocument, aUsername, getLayer(), fs)); + publishEvent(new SpanCreatedEvent(this, aDocument, aDocumentOwner, getLayer(), fs)); return fs; } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnnotationRequest_ImplBase.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnnotationRequest_ImplBase.java index ff2a6e7afd2..f3d14254393 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnnotationRequest_ImplBase.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanAnnotationRequest_ImplBase.java @@ -27,27 +27,27 @@ public abstract class SpanAnnotationRequest_ImplBase> { private final SourceDocument document; - private final String username; + private final String documentOwner; private final CAS cas; private final int begin; private final int end; private final T originalRequest; - public SpanAnnotationRequest_ImplBase(SourceDocument aDocument, String aUsername, CAS aCas, + public SpanAnnotationRequest_ImplBase(SourceDocument aDocument, String aDocumentOwner, CAS aCas, int aBegin, int aEnd) { - this(null, aDocument, aUsername, aCas, aBegin, aEnd); + this(null, aDocument, aDocumentOwner, aCas, aBegin, aEnd); } protected SpanAnnotationRequest_ImplBase(T aOriginal, SourceDocument aDocument, - String aUsername, CAS aCas, int aBegin, int aEnd) + String aDocumentOwner, CAS aCas, int aBegin, int aEnd) { Validate.isTrue(aBegin <= aEnd, "Annotation begin [%d] must smaller or equal to end [%d]", aBegin, aEnd); originalRequest = aOriginal; document = aDocument; - username = aUsername; + documentOwner = aDocumentOwner; cas = aCas; begin = aBegin; end = aEnd; @@ -58,9 +58,9 @@ public SourceDocument getDocument() return document; } - public String getUsername() + public String getDocumentOwner() { - return username; + return documentOwner; } public CAS getCas() diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCreatedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCreatedEvent.java index ced6fe06828..f15f9395c00 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCreatedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanCreatedEvent.java @@ -29,9 +29,9 @@ public class SpanCreatedEvent { private static final long serialVersionUID = 5206262614840209407L; - public SpanCreatedEvent(Object aSource, SourceDocument aDocument, String aUser, + public SpanCreatedEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner, AnnotationLayer aLayer, AnnotationFS aAnnotation) { - super(aSource, aDocument, aUser, aLayer, aAnnotation); + super(aSource, aDocument, aDocumentOwner, aLayer, aAnnotation); } } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanDeletedEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanDeletedEvent.java index 29ef3ed2e62..6dbcaa893e5 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanDeletedEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanDeletedEvent.java @@ -29,9 +29,9 @@ public class SpanDeletedEvent { private static final long serialVersionUID = 5206262614840209407L; - public SpanDeletedEvent(Object aSource, SourceDocument aDocument, String aUser, + public SpanDeletedEvent(Object aSource, SourceDocument aDocument, String aDocumentOwner, AnnotationLayer aLayer, AnnotationFS aAnnotation) { - super(aSource, aDocument, aUser, aLayer, aAnnotation); + super(aSource, aDocument, aDocumentOwner, aLayer, aAnnotation); } } diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanEvent.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanEvent.java index 13de22a528f..7613fdad4f5 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanEvent.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanEvent.java @@ -58,8 +58,8 @@ public String toString() if (getDocument() != null) { builder.append("docID="); builder.append(getDocument().getId()); - builder.append(", user="); - builder.append(getUser()); + builder.append(", docOwner="); + builder.append(getDocumentOwner()); builder.append(", "); } builder.append("span=["); diff --git a/inception/inception-api-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/adapter/TypeAdapter.java b/inception/inception-api-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/adapter/TypeAdapter.java index 28d427926f0..8bee663c4ab 100644 --- a/inception/inception-api-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/adapter/TypeAdapter.java +++ b/inception/inception-api-schema/src/main/java/de/tudarmstadt/ukp/inception/schema/adapter/TypeAdapter.java @@ -106,14 +106,14 @@ default public String getAnnotationTypeName() * * @param aDocument * the document to which the CAS belongs - * @param aUsername + * @param aDocumentOwner * the user to which the CAS belongs * @param aCas * the CAS object * @param aVid * the VID of the object to be deleted. */ - void delete(SourceDocument aDocument, String aUsername, CAS aCas, VID aVid); + void delete(SourceDocument aDocument, String aDocumentOwner, CAS aCas, VID aVid); /** * @return the layer for which this adapter has been created. @@ -132,7 +132,7 @@ default public String getAnnotationTypeName() * * @param aDocument * the document to which the CAS belongs - * @param aUsername + * @param aDocumentOwner * the user to which the CAS belongs * @param aCas * the CAS. @@ -145,7 +145,7 @@ default public String getAnnotationTypeName() * @throws AnnotationException * if there was an error setting the feature value */ - void setFeatureValue(SourceDocument aDocument, String aUsername, CAS aCas, int aAddress, + void setFeatureValue(SourceDocument aDocument, String aDocumentOwner, CAS aCas, int aAddress, AnnotationFeature aFeature, Object aValue) throws AnnotationException; @@ -183,7 +183,7 @@ void setFeatureValue(SourceDocument aDocument, String aUsername, CAS aCas, int a List> validate(CAS aCas); /** - * Disable the adapter from dispatching any events. This is useful for backend bulk operations + * Disable the adapter from dispatching any events. This is useful for back-end bulk operations * that should not be tracked in detail. */ void silenceEvents(); diff --git a/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java b/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java index 6c53409620c..01b5e60fdab 100644 --- a/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java +++ b/inception/inception-curation/src/main/java/de/tudarmstadt/ukp/inception/curation/merge/CasMerge.java @@ -543,7 +543,7 @@ public CasMergeOperationResult mergeSpanAnnotation(SourceDocument aDocument, Str boolean aAllowStacking) throws AnnotationException { - SpanAdapter adapter = (SpanAdapter) adapterCache.get(aAnnotationLayer); + var adapter = (SpanAdapter) adapterCache.get(aAnnotationLayer); if (silenceEvents) { adapter.silenceEvents(); } @@ -555,13 +555,13 @@ public CasMergeOperationResult mergeSpanAnnotation(SourceDocument aDocument, Str // a) if stacking allowed add this new annotation to the mergeview Type targetType = CasUtil.getType(aTargetCas, adapter.getAnnotationTypeName()); - List existingAnnos = selectAt(aTargetCas, targetType, aSourceFs.getBegin(), + var existingAnnos = selectAt(aTargetCas, targetType, aSourceFs.getBegin(), aSourceFs.getEnd()); if (existingAnnos.isEmpty() || aAllowStacking) { // Create the annotation via the adapter - this also takes care of attaching to an // annotation if necessary - AnnotationFS mergedSpan = adapter.add(aDocument, aUsername, aTargetCas, - aSourceFs.getBegin(), aSourceFs.getEnd()); + var mergedSpan = adapter.add(aDocument, aUsername, aTargetCas, aSourceFs.getBegin(), + aSourceFs.getEnd()); int mergedSpanAddr = -1; try { @@ -571,7 +571,7 @@ public CasMergeOperationResult mergeSpanAnnotation(SourceDocument aDocument, Str catch (AnnotationException e) { // If there was an error while setting the features, then we skip the entire // annotation - adapter.delete(aDocument, aUsername, aTargetCas, new VID(mergedSpan)); + adapter.delete(aDocument, aUsername, aTargetCas, VID.of(mergedSpan)); throw e; } return new CasMergeOperationResult(CasMergeOperationResult.ResultState.CREATED, @@ -609,10 +609,8 @@ public CasMergeOperationResult mergeRelationAnnotation(SourceDocument aDocument, SpanAdapter spanAdapter = (SpanAdapter) adapterCache.get(aAnnotationLayer.getAttachType()); - List candidateOrigins = getCandidateAnnotations(aTargetCas, spanAdapter, - originFsClicked); - List candidateTargets = getCandidateAnnotations(aTargetCas, spanAdapter, - targetFsClicked); + var candidateOrigins = getCandidateAnnotations(aTargetCas, spanAdapter, originFsClicked); + var candidateTargets = getCandidateAnnotations(aTargetCas, spanAdapter, targetFsClicked); // check if target/source exists in the mergeview if (candidateOrigins.isEmpty() || candidateTargets.isEmpty()) { @@ -656,7 +654,7 @@ public CasMergeOperationResult mergeRelationAnnotation(SourceDocument aDocument, catch (AnnotationException e) { // If there was an error while setting the features, then we skip the entire // annotation - relationAdapter.delete(aDocument, aUsername, aTargetCas, new VID(mergedRelation)); + relationAdapter.delete(aDocument, aUsername, aTargetCas, VID.of(mergedRelation)); } return new CasMergeOperationResult(CasMergeOperationResult.ResultState.CREATED, getAddr(mergedRelation)); diff --git a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/event/DocumentMetadataEvent.java b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/event/DocumentMetadataEvent.java index a74db0895a5..47ba502b511 100644 --- a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/event/DocumentMetadataEvent.java +++ b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/event/DocumentMetadataEvent.java @@ -60,7 +60,7 @@ public String toString() builder.append("docID="); builder.append(getDocument().getId()); builder.append(", user="); - builder.append(getUser()); + builder.append(getDocumentOwner()); } builder.append("]"); return builder.toString(); diff --git a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/layer/DocumentMetadataLayerSingletonCreatingWatcher.java b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/layer/DocumentMetadataLayerSingletonCreatingWatcher.java index 8949cf6a40e..5acf06ab5ac 100644 --- a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/layer/DocumentMetadataLayerSingletonCreatingWatcher.java +++ b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/layer/DocumentMetadataLayerSingletonCreatingWatcher.java @@ -80,7 +80,7 @@ public void onBeforeDocumentOpenedEvent(BeforeDocumentOpenedEvent aEvent) DocumentMetadataLayerAdapter adapter = (DocumentMetadataLayerAdapter) annotationService .getAdapter(layer); if (cas.select(adapter.getAnnotationType(cas)).isEmpty()) { - adapter.add(aEvent.getDocument(), aEvent.getUser(), cas); + adapter.add(aEvent.getDocument(), aEvent.getSessionOwner(), cas); } } } diff --git a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/log/DocumentMetadataEventAdapter.java b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/log/DocumentMetadataEventAdapter.java index 1af91bf4545..bc84ca0591d 100644 --- a/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/log/DocumentMetadataEventAdapter.java +++ b/inception/inception-layer-docmetadata/src/main/java/de/tudarmstadt/ukp/inception/ui/core/docanno/log/DocumentMetadataEventAdapter.java @@ -51,7 +51,7 @@ public long getProject(DocumentMetadataEvent aEvent) @Override public String getAnnotator(DocumentMetadataEvent aEvent) { - return aEvent.getUser(); + return aEvent.getDocumentOwner(); } @Override diff --git a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/BulkAnnotationEventAdapter.java b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/BulkAnnotationEventAdapter.java index fad538a6710..b736a8da4f5 100644 --- a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/BulkAnnotationEventAdapter.java +++ b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/BulkAnnotationEventAdapter.java @@ -48,6 +48,6 @@ public long getProject(BulkAnnotationEvent aEvent) @Override public String getAnnotator(BulkAnnotationEvent aEvent) { - return aEvent.getUser(); + return aEvent.getDocumentOwner(); } } diff --git a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainLinkEventAdapter.java b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainLinkEventAdapter.java index 19e29a115bb..2cbacd67356 100644 --- a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainLinkEventAdapter.java +++ b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainLinkEventAdapter.java @@ -51,7 +51,7 @@ public long getProject(ChainLinkEvent aEvent) @Override public String getAnnotator(ChainLinkEvent aEvent) { - return aEvent.getUser(); + return aEvent.getDocumentOwner(); } @Override diff --git a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainSpanEventAdapter.java b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainSpanEventAdapter.java index a15a556632a..bd413794fcb 100644 --- a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainSpanEventAdapter.java +++ b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/ChainSpanEventAdapter.java @@ -50,7 +50,7 @@ public long getProject(ChainSpanEvent aEvent) @Override public String getAnnotator(ChainSpanEvent aEvent) { - return aEvent.getUser(); + return aEvent.getDocumentOwner(); } @Override diff --git a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/DocumentOpenedEventAdapter.java b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/DocumentOpenedEventAdapter.java index f950a07b802..5abd0ff940a 100644 --- a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/DocumentOpenedEventAdapter.java +++ b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/DocumentOpenedEventAdapter.java @@ -47,12 +47,12 @@ public long getProject(DocumentOpenedEvent aEvent) @Override public String getUser(DocumentOpenedEvent aEvent) { - return aEvent.getUser(); + return aEvent.getSessionOwner(); } @Override public String getAnnotator(DocumentOpenedEvent aEvent) { - return aEvent.getAnnotator(); + return aEvent.getDocumentOwner(); } } diff --git a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/FeatureValueUpdatedEventAdapter.java b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/FeatureValueUpdatedEventAdapter.java index b13de3dd8b0..55b476d3234 100644 --- a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/FeatureValueUpdatedEventAdapter.java +++ b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/FeatureValueUpdatedEventAdapter.java @@ -50,7 +50,7 @@ public long getProject(FeatureValueUpdatedEvent aEvent) @Override public String getAnnotator(FeatureValueUpdatedEvent aEvent) { - return aEvent.getUser(); + return aEvent.getDocumentOwner(); } @Override diff --git a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/RelationEventAdapter.java b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/RelationEventAdapter.java index e4a9d49ffae..cac396a12b7 100644 --- a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/RelationEventAdapter.java +++ b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/RelationEventAdapter.java @@ -54,7 +54,7 @@ public long getDocument(RelationEvent aEvent) @Override public String getAnnotator(RelationEvent aEvent) { - return aEvent.getUser(); + return aEvent.getDocumentOwner(); } @Override diff --git a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/SpanEventAdapter.java b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/SpanEventAdapter.java index f26fe376952..5d5267304aa 100644 --- a/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/SpanEventAdapter.java +++ b/inception/inception-log/src/main/java/de/tudarmstadt/ukp/inception/log/adapter/SpanEventAdapter.java @@ -50,7 +50,7 @@ public long getProject(SpanEvent aEvent) @Override public String getAnnotator(SpanEvent aEvent) { - return aEvent.getUser(); + return aEvent.getDocumentOwner(); } @Override diff --git a/inception/inception-recommendation-api/src/main/java/de/tudarmstadt/ukp/inception/recommendation/api/RecommendationService.java b/inception/inception-recommendation-api/src/main/java/de/tudarmstadt/ukp/inception/recommendation/api/RecommendationService.java index df63496557d..56210dca004 100644 --- a/inception/inception-recommendation-api/src/main/java/de/tudarmstadt/ukp/inception/recommendation/api/RecommendationService.java +++ b/inception/inception-recommendation-api/src/main/java/de/tudarmstadt/ukp/inception/recommendation/api/RecommendationService.java @@ -153,7 +153,7 @@ Optional getEvaluatedRecommender(User aSessionOwner, * * @param aDocument * the source document to which the annotations belong - * @param aUsername + * @param aDocumentOwner * the annotator user to whom the annotations belong * @param aCas * the CAS containing the annotations @@ -167,12 +167,12 @@ Optional getEvaluatedRecommender(User aSessionOwner, * the position of the annotation (in case it is created) * @param aEnd * the position of the annotation (in case it is created) - * + * * @return the CAS address of the created/updated annotation. * @throws AnnotationException * if there was an annotation-level problem */ - int upsertSpanFeature(SourceDocument aDocument, String aUsername, CAS aCas, + int upsertSpanFeature(SourceDocument aDocument, String aDocumentOwner, CAS aCas, AnnotationLayer layer, AnnotationFeature aFeature, String aValue, int aBegin, int aEnd) throws AnnotationException; @@ -192,7 +192,7 @@ int upsertRelationFeature(SourceDocument aDocument, String aUsername, CAS aCas, * @return the new predictions. */ Predictions computePredictions(User aSessionOwner, Project aProject, - List aDocuments, String aDataOwner); + List aDocuments, String aDocumentOwner); /** * Compute predictions. @@ -212,7 +212,7 @@ Predictions computePredictions(User aSessionOwner, Project aProject, * @return the new predictions. */ Predictions computePredictions(User aSessionOwner, Project aProject, - SourceDocument aCurrentDocument, String aDataOwner, List aInherit, + SourceDocument aCurrentDocument, String aDocumentOwner, List aInherit, int aPredictionBegin, int aPredictionEnd); void calculateSpanSuggestionVisibility(SourceDocument aDocument, CAS aCas, String aUser, @@ -226,13 +226,13 @@ void calculateRelationSuggestionVisibility(CAS aCas, String aUser, AnnotationLay void clearState(String aSessionOwner); void triggerPrediction(String aSessionOwner, String aEventName, SourceDocument aDocument, - String aDataOwner); + String aDocumentOwner); void triggerTrainingAndPrediction(String aSessionOwner, Project aProject, String aEventName, - SourceDocument aCurrentDocument, String aDataOwner); + SourceDocument aCurrentDocument, String aDocumentOwner); void triggerSelectionTrainingAndPrediction(String aSessionOwner, Project aProject, - String aEventName, SourceDocument aCurrentDocument, String aDataOwner); + String aEventName, SourceDocument aCurrentDocument, String aDocumentOwner); boolean isPredictForAllDocuments(String aSessionOwner, Project aProject); diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/RecommendationEditorExtension.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/RecommendationEditorExtension.java index ed6289994f1..61abaa0882f 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/RecommendationEditorExtension.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/RecommendationEditorExtension.java @@ -227,9 +227,9 @@ private void actionAcceptSpanRecommendation(SpanSuggestion suggestion, SourceDoc throws AnnotationException, IOException { // Upsert an annotation based on the suggestion - AnnotationLayer layer = annotationService.getLayer(suggestion.getLayerId()); - AnnotationFeature feature = annotationService.getFeature(suggestion.getFeature(), layer); - int address = recommendationService.upsertSpanFeature(aState.getDocument(), + var layer = annotationService.getLayer(suggestion.getLayerId()); + var feature = annotationService.getFeature(suggestion.getFeature(), layer); + var address = recommendationService.upsertSpanFeature(aState.getDocument(), aState.getUser().getUsername(), aCas, layer, feature, suggestion.getLabel(), suggestion.getBegin(), suggestion.getEnd()); @@ -252,10 +252,9 @@ private void actionAcceptRelationRecommendation(RelationSuggestion suggestion, AjaxRequestTarget aTarget, CAS aCas, VID aVID) throws AnnotationException, IOException { - AnnotationLayer layer = annotationService.getLayer(suggestion.getLayerId()); - AnnotationFeature feature = annotationService.getFeature(suggestion.getFeature(), layer); - - int address = recommendationService.upsertRelationFeature(document, + var layer = annotationService.getLayer(suggestion.getLayerId()); + var feature = annotationService.getFeature(suggestion.getFeature(), layer); + var address = recommendationService.upsertRelationFeature(document, aState.getUser().getUsername(), aCas, layer, feature, suggestion); AnnotationFS relation = ICasUtil.selectAnnotationByAddr(aCas, address); diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/model/DirtySpot.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/model/DirtySpot.java index 6b3021cb0b0..5bb9712a64d 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/model/DirtySpot.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/model/DirtySpot.java @@ -33,7 +33,7 @@ public class DirtySpot public DirtySpot(AnnotationEvent aEvent) { document = aEvent.getDocument(); - user = aEvent.getUser(); + user = aEvent.getDocumentOwner(); affectedRange = aEvent.getAffectedRange(); } 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 b119eaee7fb..b26faad6d3a 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 @@ -201,7 +201,7 @@ public class RecommendationServiceImpl private final UserDao userRepository; private final RecommenderFactoryRegistry recommenderFactoryRegistry; private final SchedulingService schedulingService; - private final AnnotationSchemaService annoService; + private final AnnotationSchemaService schemaService; private final DocumentService documentService; private final LearningRecordService learningRecordService; private final ProjectService projectService; @@ -243,7 +243,7 @@ public RecommendationServiceImpl(PreferencesService aPreferencesService, userRepository = aUserRepository; recommenderFactoryRegistry = aRecommenderFactoryRegistry; schedulingService = aSchedulingService; - annoService = aAnnoService; + schemaService = aAnnoService; documentService = aDocumentService; learningRecordService = aLearningRecordService; projectService = aProjectService; @@ -511,8 +511,8 @@ public List listRecommenders(AnnotationLayer aLayer) public void onDocumentOpened(DocumentOpenedEvent aEvent) { var project = aEvent.getDocument().getProject(); - var sessionOwner = aEvent.getUser(); - var dataOwner = aEvent.getAnnotator(); + var sessionOwner = aEvent.getSessionOwner(); + var dataOwner = aEvent.getDocumentOwner(); var doc = aEvent.getDocument(); var predictions = getState(sessionOwner, project).getActivePredictions(); var predictionSessionExistedOnOpen = predictions != null; @@ -637,8 +637,8 @@ private void autoAccept(AjaxRequestTarget aTarget, User aUser, SourceDocument aD prediction.clearAutoAccept(); } - AnnotationLayer layer = annoService.getLayer(prediction.getLayerId()); - AnnotationFeature feature = annoService.getFeature(prediction.getFeature(), layer); + var layer = schemaService.getLayer(prediction.getLayerId()); + var feature = schemaService.getFeature(prediction.getFeature(), layer); try { if (prediction instanceof SpanSuggestion) { @@ -1023,22 +1023,23 @@ public void putContext(User aUser, Recommender aRecommender, RecommenderContext } @Override - public int upsertSpanFeature(SourceDocument aDocument, String aUsername, CAS aCas, + public int upsertSpanFeature(SourceDocument aDocument, String aDocumentOwner, CAS aCas, AnnotationLayer aLayer, AnnotationFeature aFeature, String aValue, int aBegin, int aEnd) throws AnnotationException { // The feature of the predicted label - SpanAdapter adapter = (SpanAdapter) annoService.getAdapter(aLayer); + var adapter = (SpanAdapter) schemaService.getAdapter(aLayer); // Check if there is already an annotation of the target type at the given location - Type type = CasUtil.getType(aCas, adapter.getAnnotationTypeName()); - AnnotationFS annoFS = selectAt(aCas, type, aBegin, aEnd).stream().findFirst().orElse(null); + var annoFS = aCas. select(adapter.getAnnotationTypeName()) // + .at(aBegin, aEnd).nullOK().get(); int address; if (annoFS == null || aLayer.isAllowStacking()) { // ... if not or if stacking is allowed, then we create a new annotation - this also // takes care of attaching to an annotation if necessary - address = ICasUtil.getAddr(adapter.add(aDocument, aUsername, aCas, aBegin, aEnd)); + var newAnnotation = adapter.add(aDocument, aDocumentOwner, aCas, aBegin, aEnd); + address = ICasUtil.getAddr(newAnnotation); } else { // ... if yes and stacking is not allowed, then we update the feature on the existing @@ -1047,29 +1048,29 @@ public int upsertSpanFeature(SourceDocument aDocument, String aUsername, CAS aCa } // Update the feature value - adapter.setFeatureValue(aDocument, aUsername, aCas, address, aFeature, aValue); + adapter.setFeatureValue(aDocument, aDocumentOwner, aCas, address, aFeature, aValue); return address; } @Override - public int upsertRelationFeature(SourceDocument aDocument, String aUsername, CAS aCas, + public int upsertRelationFeature(SourceDocument aDocument, String aDocumentOwner, CAS aCas, AnnotationLayer layer, AnnotationFeature aFeature, RelationSuggestion aSuggestion) throws AnnotationException { - RelationAdapter adapter = (RelationAdapter) annoService.getAdapter(layer); + var adapter = (RelationAdapter) schemaService.getAdapter(layer); - int sourceBegin = aSuggestion.getPosition().getSourceBegin(); - int sourceEnd = aSuggestion.getPosition().getSourceEnd(); - int targetBegin = aSuggestion.getPosition().getTargetBegin(); - int targetEnd = aSuggestion.getPosition().getTargetEnd(); + var sourceBegin = aSuggestion.getPosition().getSourceBegin(); + var sourceEnd = aSuggestion.getPosition().getSourceEnd(); + var targetBegin = aSuggestion.getPosition().getTargetBegin(); + var targetEnd = aSuggestion.getPosition().getTargetEnd(); // Check if there is already a relation for the given source and target - Type type = CasUtil.getType(aCas, adapter.getAnnotationTypeName()); - Type attachType = CasUtil.getType(aCas, adapter.getAttachTypeName()); + var type = CasUtil.getType(aCas, adapter.getAnnotationTypeName()); + var attachType = CasUtil.getType(aCas, adapter.getAttachTypeName()); - Feature sourceFeature = type.getFeatureByBaseName(FEAT_REL_SOURCE); - Feature targetFeature = type.getFeatureByBaseName(FEAT_REL_TARGET); + var sourceFeature = type.getFeatureByBaseName(FEAT_REL_SOURCE); + var targetFeature = type.getFeatureByBaseName(FEAT_REL_TARGET); // The begin and end feature of a relation in the CAS are of the dependent/target // annotation. See also RelationAdapter::createRelationAnnotation. @@ -1117,13 +1118,13 @@ else if (candidates.size() == 2) { throw new IllegalStateException(msg); } - relation = adapter.add(aDocument, aUsername, source, target, aCas); + relation = adapter.add(aDocument, aDocumentOwner, source, target, aCas); } int address = ICasUtil.getAddr(relation); // Update the feature value - adapter.setFeatureValue(aDocument, aUsername, aCas, address, aFeature, + adapter.setFeatureValue(aDocument, aDocumentOwner, aCas, address, aFeature, aSuggestion.getLabel()); return address; @@ -1582,7 +1583,7 @@ private void computePredictions(Predictions aPredictions, CAS aPredictionCas, LazyCas originalCas = new LazyCas(aDocument, aDataOwner); for (EvaluatedRecommender r : recommenders) { - var layer = annoService.getLayer(r.getRecommender().getLayer().getId()); + var layer = schemaService.getLayer(r.getRecommender().getLayer().getId()); if (!layer.isEnabled()) { continue; } @@ -2064,7 +2065,7 @@ public void calculateSpanSuggestionVisibility(SourceDocument aDocument, CAS aCas // Get all the skipped/rejected entries for the current layer List recordedAnnotations = learningRecordService.listRecords(aUser, aLayer); - for (AnnotationFeature feature : annoService.listSupportedFeatures(aLayer)) { + for (AnnotationFeature feature : schemaService.listSupportedFeatures(aLayer)) { Feature feat = type.getFeatureByBaseName(feature.getName()); if (feat == null) { @@ -2245,7 +2246,7 @@ public void calculateRelationSuggestionVisibility(CAS aCas, String aUser, groupedRecordedAnnotations.put(relationPosition, learningRecord); } - for (AnnotationFeature feature : annoService.listSupportedFeatures(aLayer)) { + for (AnnotationFeature feature : schemaService.listSupportedFeatures(aLayer)) { Feature feat = type.getFeatureByBaseName(feature.getName()); if (feat == null) { @@ -2352,9 +2353,9 @@ CAS cloneAndMonkeyPatchCAS(Project aProject, CAS aSourceCas, CAS aTargetCas) throws UIMAException, IOException { try (StopWatch watch = new StopWatch(LOG, "adding score features")) { - TypeSystemDescription tsd = annoService.getFullProjectTypeSystem(aProject); + TypeSystemDescription tsd = schemaService.getFullProjectTypeSystem(aProject); - for (AnnotationLayer layer : annoService.listAnnotationLayer(aProject)) { + for (AnnotationLayer layer : schemaService.listAnnotationLayer(aProject)) { TypeDescription td = tsd.getType(layer.getName()); if (td == null) { @@ -2378,7 +2379,7 @@ CAS cloneAndMonkeyPatchCAS(Project aProject, CAS aSourceCas, CAS aTargetCas) td.addFeature(FEATURE_NAME_IS_PREDICTION, "Is Prediction", TYPE_NAME_BOOLEAN); } - annoService.upgradeCas(aSourceCas, aTargetCas, tsd); + schemaService.upgradeCas(aSourceCas, aTargetCas, tsd); } return aTargetCas; diff --git a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/AnnotationPage.java b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/AnnotationPage.java index 8d12bd057ff..f01c9ee88a4 100755 --- a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/AnnotationPage.java +++ b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/AnnotationPage.java @@ -231,7 +231,7 @@ public void onAnnotationEvent(AnnotationEvent aEvent) if (!Objects.equals(state.getProject(), aEvent.getProject()) || !Objects.equals(state.getDocument(), aEvent.getDocument()) - || !Objects.equals(state.getUser().getUsername(), aEvent.getUser())) { + || !Objects.equals(state.getUser().getUsername(), aEvent.getDocumentOwner())) { return; } @@ -254,7 +254,7 @@ public void onFeatureValueUpdatedEvent(FeatureValueUpdatedEvent aEvent) if (!Objects.equals(state.getProject(), aEvent.getProject()) || !Objects.equals(state.getDocument(), aEvent.getDocument()) - || !Objects.equals(state.getUser().getUsername(), aEvent.getUser())) { + || !Objects.equals(state.getUser().getUsername(), aEvent.getDocumentOwner())) { return; } diff --git a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/actionbar/undo/actions/AnnotationAction_ImplBase.java b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/actionbar/undo/actions/AnnotationAction_ImplBase.java index e578e7044b9..f652b23d46d 100644 --- a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/actionbar/undo/actions/AnnotationAction_ImplBase.java +++ b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/actionbar/undo/actions/AnnotationAction_ImplBase.java @@ -40,7 +40,7 @@ public AnnotationAction_ImplBase(long aRequestId, AnnotationEvent aEvent, VID aV requestId = aRequestId; vid = aVid; document = aEvent.getDocument(); - user = aEvent.getUser(); + user = aEvent.getDocumentOwner(); layer = aEvent.getLayer(); } diff --git a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java index 293d929ab02..d2ae4a2c221 100644 --- a/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java +++ b/inception/inception-ui-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/annotation/detail/AnnotationDetailEditorPanel.java @@ -1213,7 +1213,7 @@ private boolean isAnnotationEventRelevant(AnnotationEvent aEvent) return false; } - if (!state.getUser().getUsername().equals(aEvent.getUser())) { + if (!state.getUser().getUsername().equals(aEvent.getDocumentOwner())) { return false; } diff --git a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java index 6a4e33b5f80..e2c0d586421 100644 --- a/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java +++ b/inception/inception-ui-curation/src/main/java/de/tudarmstadt/ukp/inception/ui/curation/sidebar/CurationSidebarServiceImpl.java @@ -354,7 +354,7 @@ public void closeSession(String aSessionOwner, long aProjectId) @Transactional public void onDocumentOpened(DocumentOpenedEvent aEvent) { - setDefaultSelectedUsersForDocument(aEvent.getUser(), aEvent.getDocument()); + setDefaultSelectedUsersForDocument(aEvent.getSessionOwner(), aEvent.getDocument()); } @Override