Skip to content

Commit

Permalink
Merge pull request #4619 from inception-project/bugfix/4618-Resizing-…
Browse files Browse the repository at this point in the history
…a-span-does-not-update-annotations-on-disk

#4618 - Resizing a span does not update annotations on disk
  • Loading branch information
reckart authored Mar 11, 2024
2 parents 7f36c44 + 3d6d4cd commit c2a7980
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 158 deletions.
24 changes: 24 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Set the default behavior, in case people don't have core.autocrlf set.
# means that files that GIT determines to be text files, will be
# converted from CRLF -> LF upon being added to the repo, and
# converted from LF -> LF or CRLF when checked out (depending on the platform, I think)
# * text=auto

# We force LF for all text files because we have Checkstyle set up in such a way
# The "text" by itself says these files must be line-ending-conversion controlled on check-in / out
# The internal repo form for these is always lf,
# The eol=lf means on check-out do nothing, and on check-in, if the file has crlf, convert to lf
* text eol=lf
# *.sh text eol=lf

# Make sure that these files are treated as binary so that newlines are preserved.
# overrides GIT's determination if a file is text or not
*.bin binary
*.dump binary
*.xcas binary
*.xmi binary
# next is probably the default
*.pdf binary
*.ser binary
*.png binary
*.jpg binary
14 changes: 9 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ on:

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
jdk: [17]

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
1 change: 1 addition & 0 deletions inception/inception-app-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@
uber-JAR and we get ClassNotFoundExceptions at runtime.
-->
<ignoredDependency>com.nimbusds:nimbus-jose-jwt</ignoredDependency>
<ignoredDependency>org.apache.logging.log4j:log4j-api</ignoredDependency>
<!--
- Detection of this dependency is flickering. We need it for a menu-item. So
- for the moment, completely ignore it in the dependency checking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Map;
import java.util.UUID;

import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
Expand Down Expand Up @@ -77,6 +78,7 @@ static void setup()
var issuerUrl = oauth2Server.url(ISSUER_ID).toString();

setProperty("java.awt.headless", "true");
setProperty("database.url", "jdbc:hsqldb:mem:testdb");
setProperty("inception.home", appHome.toString());
setProperty("remote-api.enabled", "true");
setProperty("remote-api.oauth2.enabled", "true");
Expand Down Expand Up @@ -110,6 +112,7 @@ static void teardown()
}
context.close();
oauth2Server.shutdown();
LogManager.shutdown();
}

@Test
Expand Down
4 changes: 0 additions & 4 deletions inception/inception-curation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.apache.uima.UIMAException;
import org.apache.uima.cas.CAS;
import org.springframework.security.access.prepost.PreAuthorize;

import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.ConcurentCasModificationException;
import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument;
Expand All @@ -50,7 +49,6 @@ public interface CurationDocumentService
* @throws IOException
* if an I/O error occurs.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER')")
void writeCurationCas(CAS aCas, SourceDocument document, boolean aUpdateTimestamp)
throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
import java.io.IOException;

import org.apache.uima.cas.CAS;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.request.Request;
import org.springframework.core.annotation.Order;

import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase;
import de.tudarmstadt.ukp.inception.annotation.layer.span.SpanAdapter;
import de.tudarmstadt.ukp.inception.diam.editor.config.DiamAutoConfig;
import de.tudarmstadt.ukp.inception.diam.model.ajax.DefaultAjaxResponse;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
import de.tudarmstadt.ukp.inception.rendering.model.Range;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VID;
import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService;
Expand Down Expand Up @@ -66,12 +63,13 @@ public String getCommand()
public DefaultAjaxResponse handle(AjaxRequestTarget aTarget, Request aRequest)
{
try {
AnnotationPageBase page = getPage();
CAS cas = page.getEditorCas();
var page = getPage();
var cas = page.getEditorCas();
var vid = getVid(aRequest);
AnnotatorState state = getAnnotatorState();
var state = getAnnotatorState();
var range = getRangeFromRequest(state, aRequest.getRequestParameters(), cas);
moveSpan(aTarget, cas, vid, range);
page.writeEditorCas(cas);
return new DefaultAjaxResponse(getAction(aRequest));
}
catch (Exception e) {
Expand All @@ -82,12 +80,11 @@ public DefaultAjaxResponse handle(AjaxRequestTarget aTarget, Request aRequest)
private void moveSpan(AjaxRequestTarget aTarget, CAS aCas, VID aVid, Range aRange)
throws IOException, AnnotationException
{
AnnotatorState state = getAnnotatorState();
var state = getAnnotatorState();

AnnotationFS annoFs = ICasUtil.selectAnnotationByAddr(aCas, aVid.getId());
var annoFs = ICasUtil.selectAnnotationByAddr(aCas, aVid.getId());

SpanAdapter adapter = (SpanAdapter) annotationService.findAdapter(state.getProject(),
annoFs);
var adapter = (SpanAdapter) annotationService.findAdapter(state.getProject(), annoFs);

adapter.move(state.getDocument(), state.getUser().getUsername(), aCas, annoFs,
aRange.getBegin(), aRange.getEnd());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,18 @@ public void tearDown()
@Test
public void thatViewportBasedMessageRoutingWorks() throws Exception
{
CountDownLatch subscriptionDone = new CountDownLatch(2);
CountDownLatch initDone = new CountDownLatch(2);
var subscriptionDone = new CountDownLatch(2);
var initDone = new CountDownLatch(2);

ViewportDefinition vpd1 = new ViewportDefinition(testAnnotationDocument, 10, 20,
FORMAT_LEGACY);
ViewportDefinition vpd2 = new ViewportDefinition(testAnnotationDocument, 30, 40,
FORMAT_LEGACY);
var vpd1 = new ViewportDefinition(testAnnotationDocument, 10, 20, FORMAT_LEGACY);
var vpd2 = new ViewportDefinition(testAnnotationDocument, 30, 40, FORMAT_LEGACY);

var sessionHandler1 = new SessionHandler(subscriptionDone, initDone, vpd1);
var sessionHandler2 = new SessionHandler(subscriptionDone, initDone, vpd2);

// try {
StompSession session1 = stompClient.connect(websocketUrl, sessionHandler1).get(1000,
SECONDS);
StompSession session2 = stompClient.connect(websocketUrl, sessionHandler2).get(1000,
SECONDS);
var session1 = stompClient.connect(websocketUrl, sessionHandler1).get(1000, SECONDS);
var session2 = stompClient.connect(websocketUrl, sessionHandler2).get(1000, SECONDS);
// }
// catch (Exception e) {
// Thread.sleep(Duration.of(3, ChronoUnit.HOURS).toMillis());
Expand Down Expand Up @@ -341,7 +337,7 @@ public ApplicationContextProvider applicationContextProvider()
public DaoAuthenticationProvider internalAuthenticationProvider(PasswordEncoder aEncoder,
@Lazy UserDetailsManager aUserDetailsManager)
{
DaoAuthenticationProvider authProvider = new InceptionDaoAuthenticationProvider();
var authProvider = new InceptionDaoAuthenticationProvider();
authProvider.setUserDetailsService(aUserDetailsManager);
authProvider.setPasswordEncoder(aEncoder);
return authProvider;
Expand All @@ -362,7 +358,7 @@ public String getId()
@Override
public void render(VDocument aResponse, RenderRequest aRequest)
{
AnnotationLayer layer = new AnnotationLayer();
var layer = new AnnotationLayer();
layer.setId(1l);
aResponse.add(
new VSpan(layer, new VID(1), new VRange(aRequest.getWindowBeginOffset(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.uima.cas.CAS;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.wicket.validation.ValidationError;
import org.springframework.security.access.prepost.PreAuthorize;

import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode;
import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasUpgradeMode;
Expand Down Expand Up @@ -71,7 +70,6 @@ public interface DocumentService
* {@link SourceDocument} to be created
* @return the source document
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER','ROLE_REMOTE')")
SourceDocument createSourceDocument(SourceDocument document);

/**
Expand Down Expand Up @@ -152,7 +150,6 @@ List<SourceDocument> listSourceDocumentsInState(Project aProject,
* @throws IOException
* If the source document searched for deletion is not available
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER', 'ROLE_REMOTE')")
void removeSourceDocument(SourceDocument document) throws IOException;

/**
Expand All @@ -168,7 +165,6 @@ List<SourceDocument> listSourceDocumentsInState(Project aProject,
* @throws UIMAException
* if a conversion error occurs.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER','ROLE_REMOTE')")
void uploadSourceDocument(InputStream file, SourceDocument document)
throws IOException, UIMAException;

Expand All @@ -188,7 +184,6 @@ void uploadSourceDocument(InputStream file, SourceDocument document)
* @throws UIMAException
* if a conversion error occurs.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER','ROLE_REMOTE')")
void uploadSourceDocument(InputStream file, SourceDocument document,
TypeSystemDescription aFullProjectTypeSystem)
throws IOException, UIMAException;
Expand Down Expand Up @@ -221,7 +216,6 @@ SourceDocumentState setSourceDocumentState(SourceDocument aDocument,
* and id of {@link User}
* @return the annotation document.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER')")
AnnotationDocument createAnnotationDocument(AnnotationDocument annotationDocument);

/**
Expand All @@ -237,7 +231,6 @@ SourceDocumentState setSourceDocumentState(SourceDocument aDocument,
* @throws IOException
* if an I/O error occurs.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER')")
void writeAnnotationCas(CAS aCas, AnnotationDocument aAnnotationDocument,
boolean aExplicitAnnotatorUserAction)
throws IOException;
Expand All @@ -257,7 +250,6 @@ void writeAnnotationCas(CAS aCas, AnnotationDocument aAnnotationDocument,
* @throws IOException
* if an I/O error occurs.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER')")
void writeAnnotationCas(CAS aCas, SourceDocument aDocument, User aUser,
boolean aExplicitAnnotatorUserAction)
throws IOException;
Expand Down Expand Up @@ -295,7 +287,6 @@ void writeAnnotationCas(CAS aCas, SourceDocument aDocument, String aUser,
* @throws IOException
* if an I/O error occurs.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER')")
void resetAnnotationCas(SourceDocument aDocument, User aUser,
AnnotationDocumentStateChangeFlag... aFlags)
throws UIMAException, IOException;
Expand Down
Loading

0 comments on commit c2a7980

Please sign in to comment.