Skip to content

Commit

Permalink
Merge branch 'main' into feature/4931-Support-for-GraphDB-knowledge-b…
Browse files Browse the repository at this point in the history
…ases

* main:
  No issue: Minor cleaning
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release inception-34.0-beta-1
  #4935 - Incorrect repetitions of sentences
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release inception-33.2
  #4936 - Option to export project via remote API without any secondary format
  #4933 - Exporting project fails if a curation CAS is missing or document state is wrong
  No issue: Do not fail-fast
  No issue: Try caching the Maven repo
  #4916 - Support for MS SQL Server
  No issue: Formatting
  No issue: Small style fix
  No issue: Minor correction in format documentation
  #4916 - Support for MS SQL Server
  • Loading branch information
reckart committed Jul 10, 2024
2 parents 574a4db + 94973ff commit 2419187
Show file tree
Hide file tree
Showing 28 changed files with 502 additions and 143 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,38 @@ on:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
jdk: [17]

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

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}

- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
cache: maven

- name: Set up cache date
run: echo "CACHE_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Cache Maven repository
id: maven-cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.CACHE_DATE }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn --no-transfer-progress -B clean verify --file pom.xml

Expand Down
4 changes: 1 addition & 3 deletions inception/inception-annotation-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
Expand Down
13 changes: 11 additions & 2 deletions inception/inception-app-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>

<!-- JAXB DEPENDENCIES -->
<dependency>
Expand Down Expand Up @@ -711,6 +715,11 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
Expand Down Expand Up @@ -1029,6 +1038,7 @@
<usedDependency>org.hibernate.orm:hibernate-core</usedDependency>
<usedDependency>org.hsqldb:hsqldb</usedDependency>
<usedDependency>org.mariadb.jdbc:mariadb-java-client</usedDependency>
<usedDependency>com.microsoft.sqlserver:mssql-jdbc</usedDependency>
<usedDependency>mysql:mysql-connector-java</usedDependency>
<usedDependency>org.postgresql:postgresql</usedDependency>
<!-- Logging - used via reflection / optional -->
Expand Down Expand Up @@ -1172,8 +1182,7 @@
</goals>
<configuration>
<executable>true</executable>
<layoutFactory
implementation="de.tudarmstadt.ukp.inception.bootloader.ExtensibleClasspathEnabledWarLayoutFactory" />
<layoutFactory implementation="de.tudarmstadt.ukp.inception.bootloader.ExtensibleClasspathEnabledWarLayoutFactory" />
<!--
We want the original file to be the WAR and the repackaged all-inclusive runnable
thing with the embedded Tomcat to be the JAR.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ private void applyDatabaseSpecificOverrides(ConfigurableEnvironment aEnvironment
.addFirst(new MapPropertySource("PostgreSQL-Overrides", overrides));
}

if (datasourceUrl.startsWith("jdbc:sqlserver:")) {
var overrides = new HashMap<String, Object>();
// We use certain column names like `user` that are reserved words in MS SQL Server
overrides.put("spring.jpa.properties.hibernate.globally_quoted_identifiers", true);
aEnvironment.getPropertySources()
.addFirst(new MapPropertySource("MS-SQL-Server-Overrides", overrides));
}

if (datasourceUrl.startsWith("jdbc:mysql:")) {
var overrides = new HashMap<String, Object>();
// We use certain column names like `rank` that are reserved words in MySQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<Logger name="de.tudarmstadt" level="INFO"/>
<Logger name="de.tudarmstadt.ukp.inception" level="INFO"/>
<Logger name="org.springframework.boot.web.embedded.tomcat.TomcatWebServer" level="INFO"/>
<Logger name="liquibase" level="ERROR"/>
<Logger name="liquibase" level="WARN"/>
<Logger name="org.apache.uima" level="ERROR"/>
<Logger name="ch.rasc.piwik.tracking.PiwikTracker" level="FATAL"/>
<Logger name="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" level="ERROR"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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.db;

import java.nio.file.Path;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.MSSQLServerContainer;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers(disabledWithoutDocker = true)
class InceptionMSSQLServerIntegrationTest
{
@SuppressWarnings("resource")
static final MSSQLServerContainer<?> dbContainer = new MSSQLServerContainer<>(
"mcr.microsoft.com/mssql/server:2022-latest") //
.acceptLicense();

static @TempDir Path tempDir;

static ConfigurableApplicationContext appContext;

@BeforeAll
static void setupClass()
{
dbContainer.start();
}

@AfterAll
static void tearDownClass()
{
if (appContext != null) {
appContext.close();
}

if (dbContainer != null && dbContainer.isRunning()) {
dbContainer.stop();
}
}

@Nested
class SpringApplcationContext
extends InceptionIntegrationTest_ImplBase
{
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry)
{
registry.add("database.url", dbContainer::getJdbcUrl);
registry.add("database.username", dbContainer::getUsername);
registry.add("database.password", dbContainer::getPassword);
registry.add("inception.home", () -> tempDir.toString());
}

@BeforeEach
void setup(ConfigurableApplicationContext aAppContext)
{
appContext = aAppContext;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import static java.util.Arrays.asList;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.uima.cas.text.AnnotationPredicates.covering;
import static org.apache.uima.cas.text.AnnotationPredicates.overlappingAtBegin;
import static org.apache.uima.cas.text.AnnotationPredicates.overlappingAtEnd;
import static org.apache.uima.fit.util.CasUtil.getType;
import static org.apache.uima.fit.util.CasUtil.select;

Expand Down Expand Up @@ -330,7 +332,7 @@ private void renderBratRowsFromUnits(GetDocumentResponse aResponse, RenderReques
* (window-relative positions)
* @return list of ranges.
*/
private List<Offsets> split(List<Offsets> aRows, String aText, int aWindowBegin, int aBegin,
static List<Offsets> split(List<Offsets> aRows, String aText, int aWindowBegin, int aBegin,
int aEnd)
{
// Zero-width spans never need to be split
Expand Down Expand Up @@ -370,28 +372,31 @@ private List<Offsets> split(List<Offsets> aRows, String aText, int aWindowBegin,

var coveredRows = aRows.subList(aRows.indexOf(beginRow), aRows.indexOf(endRow) + 1);

var ranges = new ArrayList<Offsets>();
var segments = new ArrayList<Offsets>();
for (var row : coveredRows) {
Offsets range;
Offsets segment;

if (row.getBegin() <= aBegin && aBegin < row.getEnd()) {
range = new Offsets(aBegin, row.getEnd());
if (covering(aBegin, aEnd, row.getBegin(), row.getEnd())) {
segment = new Offsets(row.getBegin(), row.getEnd());
}
else if (row.getBegin() <= aEnd && aEnd <= row.getEnd()) {
range = new Offsets(row.getBegin(), aEnd);
else if (overlappingAtBegin(row.getBegin(), row.getEnd(), aBegin, aEnd)) {
segment = new Offsets(aBegin, row.getEnd());
}
else if (overlappingAtEnd(row.getBegin(), row.getEnd(), aBegin, aEnd)) {
segment = new Offsets(row.getBegin(), aEnd);
}
else {
range = new Offsets(row.getBegin(), row.getEnd());
continue;
}

trim(aText, range);
trim(aText, segment);

if (!range.isEmpty()) {
ranges.add(range);
if (!segment.isEmpty()) {
segments.add(segment);
}
}

return ranges;
return segments;
}

public static String abbreviate(String aName)
Expand Down Expand Up @@ -440,7 +445,7 @@ public static String abbreviate(String aName)
* @param aOffsets
* the offsets.
*/
static private void trim(CharSequence aText, Offsets aOffsets)
static void trim(CharSequence aText, Offsets aOffsets)
{
if (aOffsets.getBegin() == aOffsets.getEnd()) {
// Nothing to do on empty spans
Expand All @@ -465,7 +470,7 @@ static private void trim(CharSequence aText, Offsets aOffsets)
aOffsets.setEnd(end);
}

private static boolean trimChar(final char aChar)
static boolean trimChar(final char aChar)
{
switch (aChar) {
case '\n': // Line break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static com.fasterxml.jackson.core.JsonToken.VALUE_NUMBER_INT;

import java.io.IOException;
import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.JsonParser;
Expand Down Expand Up @@ -52,7 +53,6 @@ public Offsets()

public Offsets(int aBegin, int aEnd)
{
super();
begin = aBegin;
end = aEnd;
}
Expand Down Expand Up @@ -127,4 +127,21 @@ public Offsets deserialize(JsonParser aJp, DeserializationContext aCtxt) throws
return offsets;
}
}

@Override
public boolean equals(final Object other)
{
if (!(other instanceof Offsets)) {
return false;
}

var castOther = (Offsets) other;
return Objects.equals(begin, castOther.begin) && Objects.equals(end, castOther.end);
}

@Override
public int hashCode()
{
return Objects.hash(begin, end);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ export class Visualizer {
let firstFrom: number | null = null
let chunkNo = 0
let space: string
let chunk: Chunk
let chunk: Chunk | null = null
const chunks : Chunk[] = []

for (const fragment of sortedFragments) {
Expand All @@ -831,9 +831,7 @@ export class Visualizer {
}
}

tokenOffsets.forEach(offset => {
const from = offset[0]
const to = offset[1]
for (const [from, to] of tokenOffsets) {
if (firstFrom === null) {
firstFrom = from
}
Expand All @@ -850,7 +848,7 @@ export class Visualizer {
}
// if yes, the next token is in the same chunk
if (currentFragmentId < numFragments && to > sortedFragments[currentFragmentId].from) {
return
continue
}

// otherwise, create the chunk found so far
Expand All @@ -866,7 +864,7 @@ export class Visualizer {
chunks.push(chunk)
lastTo = to
firstFrom = null
})
}

for (const fragment of sortedFragments) {
if (fragment.span.id === 'rel:1-after') {
Expand Down
Loading

0 comments on commit 2419187

Please sign in to comment.