Skip to content

Commit

Permalink
Merge branch 'main' into refactoring/Upgrade-to-Spring-Boot-3
Browse files Browse the repository at this point in the history
* main: (26 commits)
  #4258 - Reset document button for annotators in dynamic assignment mode
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release inception-29.8
  #4266 - Improve backToProject call
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release inception-29.7
  No issue: Handle edge case
  #4263 - Spans starting before the current viewport are not rendered as partial spans
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release inception-29.6
  #4258 - Reset document button for annotators in dynamic assignment mode
  #4258 - Reset document button for annotators in dynamic assignment mode
  #4258 - Reset document button for annotators in dynamic assignment mode
  #4259 - Opening a document viewing a specific annotator from the activities list does not work
  #4235 - Direct access-by-URL to sidebar curation mode sometimes does not work
  #4235 - Direct access-by-URL to sidebar curation mode sometimes does not work
  #4256 - Avoid saving preferences immediately on load
  #4139 - Reusable popover component for annotation editors
  #4252 - Limit number of annotations displayed in annotation sidebar to avoid crash
  #4251 - Improve speed of yield calculation
  ...

% Conflicts:
%	inception/inception-app-webapp/src/main/java/de/tudarmstadt/ukp/inception/app/config/InceptionSecurityWebUIShared.java
%	inception/inception-documents/src/main/java/de/tudarmstadt/ukp/inception/documents/DocumentAccessImpl.java
%	inception/inception-ui-dashboard-activity/src/main/java/de/tudarmstadt/ukp/inception/ui/core/dashboard/activity/ActivitiesDashletControllerImpl.java
%	inception/inception-workload-dynamic/src/main/java/de/tudarmstadt/ukp/inception/workload/dynamic/annotation/DynamicAnnotatorWorkflowActionBarItemGroup.java
  • Loading branch information
reckart committed Nov 3, 2023
2 parents 147d231 + 05085c2 commit 9022f4d
Show file tree
Hide file tree
Showing 99 changed files with 6,204 additions and 4,526 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,8 @@ public void onSpanCreated(SpanCreatedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getLayer(),
aEvent.getDocument());
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().orElse(null),
aEvent.getLayer(), aEvent.getDocument());
}

@OnEvent
Expand All @@ -1122,7 +1122,7 @@ public void onRelationCreated(RelationCreatedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getLayer(),
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().get(), aEvent.getLayer(),
aEvent.getDocument());
}

Expand Down Expand Up @@ -1153,7 +1153,7 @@ public void onFeatureValueUpdated(FeatureValueUpdatedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(),
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().get(),
aEvent.getFeature().getLayer(), aEvent.getDocument());
}

Expand All @@ -1180,7 +1180,7 @@ public void onAnnotationDeleted(SpanDeletedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getLayer(),
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().get(), aEvent.getLayer(),
aEvent.getDocument());
}

Expand Down Expand Up @@ -1381,7 +1381,7 @@ public void onDocumentOpenedEvent(DocumentOpenedEvent aEvent)
// If active learning is not active, update the sidebar in case the session auto-terminated
ActiveLearningUserState alState = alStateModel.getObject();
if (!alState.isSessionActive()) {
aEvent.getRequestTarget().add(alMainContainer);
aEvent.getRequestTarget().ifPresent(target -> target.add(alMainContainer));
return;
}

Expand All @@ -1390,11 +1390,11 @@ public void onDocumentOpenedEvent(DocumentOpenedEvent aEvent)

// Maybe the prediction switch has made a new suggestion available for us to go to
if (alState.getSuggestion().isEmpty()) {
moveToNextSuggestion(aEvent.getRequestTarget());
moveToNextSuggestion(aEvent.getRequestTarget().get());
return;
}

refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget());
refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget().get());
}

@OnEvent
Expand All @@ -1405,7 +1405,7 @@ public void onPredictionsSwitched(PredictionsSwitchedEvent aEvent)
// If active learning is not active, update the sidebar in case the session auto-terminated
ActiveLearningUserState alState = alStateModel.getObject();
if (!alState.isSessionActive()) {
aEvent.getRequestTarget().add(alMainContainer);
aEvent.getRequestTarget().ifPresent(target -> target.add(alMainContainer));
return;
}

Expand All @@ -1414,11 +1414,11 @@ public void onPredictionsSwitched(PredictionsSwitchedEvent aEvent)

// Maybe the prediction switch has made a new suggestion available for us to go to
if (alState.getSuggestion().isEmpty()) {
moveToNextSuggestion(aEvent.getRequestTarget());
moveToNextSuggestion(aEvent.getRequestTarget().get());
return;
}

refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget());
refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget().get());
}

private void refreshCurrentSuggestionOrMoveToNextSuggestion(AjaxRequestTarget aTarget)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ private IconType getStateIcon()
@OnEvent
public void sessionStarted(ActiveLearningSessionStartedEvent aEvent)
{
aEvent.getRequestTarget().add(this);
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}

@OnEvent
public void sessionStarted(ActiveLearningSessionCompletedEvent aEvent)
{
aEvent.getRequestTarget().add(this);
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.apache.wicket.request.IRequestParameters;
import org.apache.wicket.request.RequestHandlerExecutor.ReplaceHandlerException;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.flow.RedirectToUrlException;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
Expand Down Expand Up @@ -83,7 +82,7 @@ public abstract class AnnotationPageBase
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

public static final String PAGE_PARAM_DOCUMENT = "d";
public static final String PAGE_PARAM_USER = "u";
public static final String PAGE_PARAM_DATA_OWNER = "u";
public static final String PAGE_PARAM_FOCUS = "f";

private @SpringBean AnnotationSchemaService annotationService;
Expand All @@ -100,31 +99,34 @@ protected AnnotationPageBase(PageParameters aParameters)
super(aParameters);

var params = getPageParameters();
StringValue documentParameter = params.get(PAGE_PARAM_DOCUMENT);
StringValue userParameter = params.get(PAGE_PARAM_USER);
var documentParameter = params.get(PAGE_PARAM_DOCUMENT);
var userParameter = params.get(PAGE_PARAM_DATA_OWNER);

// If the page was accessed using an URL form ending in a document ID, let's move
// the document ID into the fragment and redirect to the form without the document ID.
// This ensures that any links on the page do not carry the document ID, so that we can
// happily switch between documents using AJAX without having to worry about links with
// a document ID potentially sending us back to a specific document.
if (!documentParameter.isEmpty()) {
RequestCycle requestCycle = getRequestCycle();
Url clientUrl = requestCycle.getRequest().getClientUrl();
clientUrl.resolveRelative(Url.parse("./"));
List<String> fragmentParams = new ArrayList<>();
var requestCycle = getRequestCycle();

var fragmentParams = new ArrayList<String>();
fragmentParams.add(format("%s=%s", PAGE_PARAM_DOCUMENT, documentParameter.toString()));
params.remove(PAGE_PARAM_DOCUMENT);

if (!userParameter.isEmpty()) {
fragmentParams.add(format("%s=%s", PAGE_PARAM_USER, userParameter.toString()));
params.remove(PAGE_PARAM_USER);
}
for (var namedParam : params.getAllNamed()) {
clientUrl.setQueryParameter(namedParam.getKey(), namedParam.getValue());
fragmentParams
.add(format("%s=%s", PAGE_PARAM_DATA_OWNER, userParameter.toString()));
params.remove(PAGE_PARAM_DATA_OWNER);
}
clientUrl.setFragment("!" + fragmentParams.stream().collect(joining("&")));
String url = requestCycle.getUrlRenderer().renderRelativeUrl(clientUrl);
throw new RedirectToUrlException(url.toString());

var url = Url.parse(requestCycle.urlFor(this.getClass(), params));
url.setFragment("!" + fragmentParams.stream().collect(joining("&")));
var finalUrl = requestCycle.getUrlRenderer().renderFullUrl(url);
LOG.trace(
"Pushing parameter for document [{}] and user [{}] into fragment: {} (URL redirect)",
documentParameter, userParameter, finalUrl);
throw new RedirectToUrlException(finalUrl.toString());
}
}

Expand Down Expand Up @@ -196,18 +198,18 @@ protected UrlParametersReceivingBehavior createUrlFragmentBehavior()
protected void onParameterArrival(IRequestParameters aRequestParameters,
AjaxRequestTarget aTarget)
{
StringValue document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT);
StringValue focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS);
StringValue user = aRequestParameters.getParameterValue(PAGE_PARAM_USER);
var document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT);
var focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS);
var user = aRequestParameters.getParameterValue(PAGE_PARAM_DATA_OWNER);

// nothing changed, do not check for project, because inception always opens
// on a project
if (document.isEmpty() && focus.isEmpty()) {
return;
}

SourceDocument previousDoc = getModelObject().getDocument();
User aPreviousUser = getModelObject().getUser();
LOG.trace("URL fragment update: {}@{} focus {}", user, document, focus);

var previousDoc = getModelObject().getDocument();
var aPreviousUser = getModelObject().getUser();
handleParameters(document, focus, user);

updateDocumentView(aTarget, previousDoc, aPreviousUser, focus);
Expand All @@ -218,6 +220,20 @@ protected void onParameterArrival(IRequestParameters aRequestParameters,
protected abstract void handleParameters(StringValue aDocumentParameter,
StringValue aFocusParameter, StringValue aUser);

/**
* Switch between documents. Note that the document and data owner to switch to are obtained
* from the {@link AnnotatorState}. The parameters indicate the the old document and data owner
* before the switch!
*
* @param aTarget
* a request target.
* @param aPreviousDocument
* the document before the switch.
* @param aPreviousUser
* the data owner before the switch.
* @param aFocusParameter
* the focus before the switch.
*/
protected abstract void updateDocumentView(AjaxRequestTarget aTarget,
SourceDocument aPreviousDocument, User aPreviousUser, StringValue aFocusParameter);

Expand Down Expand Up @@ -510,14 +526,14 @@ private class UrlFragmentUpdateListener
@Override
public void onTargetRespond(AjaxRequestTarget aTarget)
{
AnnotatorState state = getModelObject();
var state = getModelObject();

if (state.getDocument() == null) {
return;
}

Long currentDocumentId = state.getDocument().getId();
int currentFocusUnitIndex = state.getFocusUnitIndex();
var currentDocumentId = state.getDocument().getId();
var currentFocusUnitIndex = state.getFocusUnitIndex();

// Check if the relevant parameters have actually changed since the URL parameters were
// last set - if this is not the case, then let's not set the parameters because that
Expand All @@ -531,7 +547,7 @@ public void onTargetRespond(AjaxRequestTarget aTarget)
urlFragmentLastDocumentId = currentDocumentId;
urlFragmentLastFocusUnitIndex = currentFocusUnitIndex;

UrlFragment fragment = new UrlFragment(aTarget);
var fragment = new UrlFragment(aTarget);

fragment.putParameter(PAGE_PARAM_DOCUMENT, currentDocumentId);

Expand All @@ -547,10 +563,10 @@ public void onTargetRespond(AjaxRequestTarget aTarget)
// the CURATION_USER here.
if (Set.of(userRepository.getCurrentUsername(), CURATION_USER)
.contains(state.getUser().getUsername())) {
fragment.removeParameter(PAGE_PARAM_USER);
fragment.removeParameter(PAGE_PARAM_DATA_OWNER);
}
else {
fragment.putParameter(PAGE_PARAM_USER, state.getUser().getUsername());
fragment.putParameter(PAGE_PARAM_DATA_OWNER, state.getUser().getUsername());
}

// If we do not manually set editedFragment to false, then changing the URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
import de.tudarmstadt.ukp.inception.rendering.paging.Unit;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VID;

public class SentenceOrientedPagingStrategy
extends PagingStrategy_ImplBase
Expand Down Expand Up @@ -78,7 +79,8 @@ private Unit toUnit(int aIndex, AnnotationFS aSentence)
catch (IllegalArgumentException e) {
// Ignore if there is no "id" feature on the sentence
}
return new Unit(sentId, aIndex, aSentence.getBegin(), aSentence.getEnd());
return new Unit(VID.of(aSentence), sentId, aIndex, aSentence.getBegin(),
aSentence.getEnd());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.annotation.events;

import org.springframework.context.ApplicationEvent;

import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase;
import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument;
import de.tudarmstadt.ukp.clarin.webanno.support.wicket.event.HybridApplicationUIEvent;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;

/**
* Fire this event to give listeners a chance to look at or even modify the {@link AnnotatorState}
* before actually loading the data.
*/
public class PreparingToOpenDocumentEvent
extends ApplicationEvent
implements HybridApplicationUIEvent
{
private static final long serialVersionUID = -5971290341142438144L;

private final SourceDocument document;
// user who owns/annotates the opened document
private final String documentOwner;
// user who opened the document
private final String sessionOwner;

public PreparingToOpenDocumentEvent(AnnotationPageBase aSource, SourceDocument aDocument,
String aDocumentOwner, String aSessionOwner)
{
super(aSource);
document = aDocument;
documentOwner = aDocumentOwner;
sessionOwner = aSessionOwner;
}

public SourceDocument getDocument()
{
return document;
}

public String getSessionOwner()
{
return sessionOwner;
}

public String getDocumentOwner()
{
return documentOwner;
}

@Override
public AnnotationPageBase getSource()
{
return (AnnotationPageBase) super.getSource();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public static void handleException(Component aComponent, AjaxRequestTarget aTarg
public void onAnnotationDeleted(AnnotationDeletedEvent aEvent)
{
// It could be that a slot filler was deleted - so just in case, we re-render ourself.
aEvent.getRequestTarget().add(this);
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}

@OnEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ public void onTagEvent(TagEvent aEvent)

// If the tag was created in the tagset used by this editor, then we re-render the editor
// to ensure it picks up the new tag
AjaxRequestTarget target = aEvent.getRequestTarget();
if (target != null) {
target.add(this);
}
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}

@SuppressWarnings("rawtypes")
Expand Down
Loading

0 comments on commit 9022f4d

Please sign in to comment.