diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java index 61bafbcb050..050b2d41c57 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/inception/annotation/layer/span/SpanRenderer.java @@ -166,6 +166,7 @@ private void renderSlots(AnnotationFS aFS, List aSpansAndSlots) int fi = 0; nextFeature: for (AnnotationFeature feat : typeAdapter.listFeatures()) { if (!feat.isEnabled()) { + fi++; continue nextFeature; } @@ -191,6 +192,7 @@ private void renderSlots(AnnotationFS aFS, List aSpansAndSlots) aSpansAndSlots.add(arc); } } + fi++; } } diff --git a/inception/inception-docker/src/main/docker/Dockerfile b/inception/inception-docker/src/main/docker/Dockerfile index 4971cf0cffe..79c6d2e50b9 100644 --- a/inception/inception-docker/src/main/docker/Dockerfile +++ b/inception/inception-docker/src/main/docker/Dockerfile @@ -12,7 +12,8 @@ MAINTAINER INCEpTION Team RUN set -ex \ && DEBIAN_FRONTEND=noninteractive \ && apt-get update \ - && apt-get install -y --no-install-recommends locales + && apt-get install -y --no-install-recommends locales \ + && apt-get upgrade -y RUN set -ex \ && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ && dpkg-reconfigure --frontend=noninteractive locales \ @@ -31,4 +32,4 @@ EXPOSE 8080 ENV JAVA_OPTS="-Xmx750m" -CMD java ${JAVA_OPTS} -Djava.awt.headless=true -Dinception.home=/export -jar inception-app-standalone.jar \ No newline at end of file +CMD java ${JAVA_OPTS} -Djava.awt.headless=true -Dinception.home=/export -jar inception-app-standalone.jar diff --git a/inception/inception-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/ProjectServiceImpl.java b/inception/inception-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/ProjectServiceImpl.java index 2f89e45d4fd..5c1a9d3e2ef 100644 --- a/inception/inception-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/ProjectServiceImpl.java +++ b/inception/inception-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/project/ProjectServiceImpl.java @@ -539,7 +539,7 @@ public List listProjectUsersWithPermissions(Project aProject, } @Override - @Transactional + @Transactional(noRollbackFor = NoResultException.class) public Project getProjectBySlug(String aSlug) { String query = "FROM Project WHERE slug = :slug"; @@ -549,7 +549,7 @@ public Project getProjectBySlug(String aSlug) } @Override - @Transactional + @Transactional(noRollbackFor = NoResultException.class) public Project getProject(long aId) { String query = "FROM Project " + "WHERE id = :id"; @@ -597,7 +597,6 @@ public Date getProjectTimeStamp(Project aProject) } @Override - @Transactional(noRollbackFor = NoResultException.class) public List listProjectsWithFinishedAnnos() { String query = String.join("\n", // diff --git a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java index 639421c3ea2..1358673ea8e 100644 --- a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java +++ b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java @@ -285,6 +285,13 @@ public void beforeProjectRemove(BeforeProjectRemovedEvent aEvent) throws IOExcep { Project project = aEvent.getProject(); + if (isBeingDeleted(project.getId())) { + log.trace( + "Ignoring repeated attempt to delete project which is already in progress of being deleted", + project); + return; + } + log.trace("Removing index for project {} because project is being removed", project); try (PooledIndex pooledIndex = acquireIndex(project.getId())) { @@ -315,6 +322,17 @@ public void afterProjectRemove(AfterProjectRemovedEvent aEvent) throws IOExcepti private final Map indexes = new HashMap<>(); + private boolean isBeingDeleted(long aProjectId) + { + synchronized (indexes) { + PooledIndex pooledIndex = indexes.get(aProjectId); + if (pooledIndex != null && pooledIndex.isTombstone()) { + return true; + } + return false; + } + } + private PooledIndex acquireIndex(long aProjectId) { synchronized (indexes) { diff --git a/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasDocumentIndex.java b/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasDocumentIndex.java index e4bf24e1d71..a9e96072b89 100644 --- a/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasDocumentIndex.java +++ b/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasDocumentIndex.java @@ -1071,11 +1071,12 @@ else if (annotationDocumentId != -1 .filter(t -> t.getPositionStart() >= matchStart && t.getPositionEnd() < matchEnd) .mapToInt(MtasTokenString::getOffsetStart).min() - .getAsInt()); + .orElse(matchStart)); result.setOffsetEnd(tokens.stream() .filter(t -> t.getPositionStart() >= matchStart && t.getPositionEnd() < matchEnd) - .mapToInt(MtasTokenString::getOffsetEnd).max().getAsInt()); + .mapToInt(MtasTokenString::getOffsetEnd).max() + .orElse(matchEnd)); result.setTokenStart(matchStart); result.setTokenLength(matchEnd - matchStart); result.setReadOnly(annotationDocument != null diff --git a/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java b/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java index 27c03ffb48a..e3bd3370e8d 100644 --- a/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java +++ b/inception/inception-search-mtas/src/main/java/de/tudarmstadt/ukp/inception/search/index/mtas/MtasUimaParser.java @@ -431,8 +431,8 @@ private int indexFeatures(AnnotationFS aAnnotation, String aLayer, String aPrefi MultiValuedMap fieldsAndValues = fis.get().indexFeatureValue(aLayer, aAnnotation, aPrefix, feature); for (Entry e : fieldsAndValues.entries()) { - indexFeatureValue(e.getKey(), e.getValue(), mtasId++, aAnnotation.getBegin(), - aAnnotation.getEnd(), aRange, aFSAddress); + indexFeatureValue(getIndexedName(e.getKey()), e.getValue(), mtasId++, + aAnnotation.getBegin(), aAnnotation.getEnd(), aRange, aFSAddress); } if (LOG.isTraceEnabled()) { diff --git a/inception/inception-websocket/pom.xml b/inception/inception-websocket/pom.xml index ff1d248300b..8c8d0768c3b 100644 --- a/inception/inception-websocket/pom.xml +++ b/inception/inception-websocket/pom.xml @@ -118,8 +118,8 @@ javax.persistence javax.persistence-api - test + org.apache.tomcat.embed tomcat-embed-websocket diff --git a/inception/inception-websocket/src/main/java/de/tudarmstadt/ukp/inception/websocket/controller/LoggedEventsWebsocketControllerImpl.java b/inception/inception-websocket/src/main/java/de/tudarmstadt/ukp/inception/websocket/controller/LoggedEventsWebsocketControllerImpl.java index 44a095479e9..6cb0bed7944 100644 --- a/inception/inception-websocket/src/main/java/de/tudarmstadt/ukp/inception/websocket/controller/LoggedEventsWebsocketControllerImpl.java +++ b/inception/inception-websocket/src/main/java/de/tudarmstadt/ukp/inception/websocket/controller/LoggedEventsWebsocketControllerImpl.java @@ -22,6 +22,9 @@ import java.security.Principal; import java.util.Date; import java.util.List; +import java.util.Objects; + +import javax.persistence.NoResultException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; @@ -99,7 +102,7 @@ private List getMostRecentLoggedEvents(String aUsername, int return eventRepo.listRecentActivity(aUsername, aMaxEvents).stream() .map(event -> createLoggedEventMessage(event.getUser(), event.getProject(), event.getCreated(), event.getEvent(), event.getDocument())) - .collect(toList()); + .filter(Objects::nonNull).collect(toList()); } private LoggedEventMessage createLoggedEventMessage(String aUsername, long aProjectId, @@ -109,10 +112,16 @@ private LoggedEventMessage createLoggedEventMessage(String aUsername, long aProj String docName = null; if (aProjectId > -1) { - projectName = projectService.getProject(aProjectId).getName(); + try { + projectName = projectService.getProject(aProjectId).getName(); - if (aDocId > -1) { - docName = docService.getSourceDocument(aProjectId, aDocId).getName(); + if (aDocId > -1) { + docName = docService.getSourceDocument(aProjectId, aDocId).getName(); + } + } + catch (NoResultException e) { + // This may happen if the document or project have meanwhile been deleted + return null; } }