Skip to content

Commit

Permalink
Upgrade TypeQL and Driver to 2.18.x (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingsilverfin committed Jul 28, 2023
1 parent 81fbbb6 commit 37baf49
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 251 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
---

###
###

[![TypeDB Loader Test](https://github.com/bayer-science-for-a-better-life/grami/actions/workflows/testandbuild.yaml/badge.svg)](https://github.com/bayer-science-for-a-better-life/grami/actions/workflows/testandbuild.yaml)
[![TypeDB Loader Build](https://github.com/bayer-science-for-a-better-life/grami/actions/workflows/release.yaml/badge.svg)](https://github.com/bayer-science-for-a-better-life/grami/actions/workflows/release.yaml)
Expand Down Expand Up @@ -129,7 +129,7 @@ public class LoadingData {

## Step-by-Step Tutorial

A complete tutorial for TypeDB version >= 2.5.0 is in work and will be published asap.
A complete tutorial for TypeDB version >= 2.5.0 is in work and will be published.

An example of configuration and usage of TypeDB Loader on real data can be
found [in the TypeDB Examples](https://github.com/vaticle/typedb-examples/tree/master/biology/catalogue_of_life).
Expand All @@ -142,6 +142,7 @@ There is an [example repository](https://github.com/bayer-science-for-a-better-l
## Connecting to TypeDB Cluster

To connect to TypeDB Cluster, a set of options is provided:

```
--typedb-cluster=<address:port>
--username=<username>
Expand All @@ -154,18 +155,20 @@ To connect to TypeDB Cluster, a set of options is provided:

Ranges are [inclusive, exclusive).

| TypeDB Loader | TypeDB Client (internal) | TypeDB | TypeDB Cluster |
|:--------------:|:------------------------:|:----------------:|:----------------:|
| 1.6.0 | 2.14.2 | 2.14.x to 2.16.x | 2.14.x to 2.16.x |
| 1.2.0 to 1.6.0 | 2.8.0 - 2.14.0 | 2.8.0 to 2.14.0 | N/A |
| 1.1.0 to 1.2.0 | 2.8.0 | 2.8.x | N/A |
| 1.0.0 | 2.5.0 to 2.7.1 | 2.5.x to 2.7.x | N/A |
| 0.1.1 | 2.0.0 to 2.5.0 | 2.0.x to 2.4.x | N/A |
| <0.1 | 1.8.0 | 1.8.x | N/A |
| TypeDB Loader | TypeDB Client (internal) | TypeDB | TypeDB Cluster |
|:-------------:|:------------------------:|:---------------:|:---------------:|
| 1.7.0 | 2.18.1 | 2.18.x - | 2.18.x - |
| 1.6.0 | 2.14.2 | 2.14.x - 2.17.x | 2.14.x - 2.16.x |
| 1.2.0 - 1.6.0 | 2.8.0 - 2.14.0 | 2.8.0 - 2.14.0 | N/A |
| 1.1.0 - 1.2.0 | 2.8.0 | 2.8.x | N/A |
| 1.0.0 | 2.5.0 - 2.7.1 | 2.5.x - 2.7.x | N/A |
| 0.1.1 | 2.0.0 - 2.5.0 | 2.0.x - 2.4.x | N/A |
| <0.1 | 1.8.0 | 1.8.x | N/A |

* [Type DB](https://github.com/vaticle/typedb)

Find the Readme for GraMi for grakn < 2.0 [here](https://github.com/bayer-science-for-a-better-life/grami/blob/b3d6d272c409d6c40254354027b49f90b255e1c3/README.md)
Find the Readme for GraMi for grakn <
2.0 [here](https://github.com/bayer-science-for-a-better-life/grami/blob/b3d6d272c409d6c40254354027b49f90b255e1c3/README.md)

## Contributions

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.vaticle.typedb-osi'
version '1.6.0'
version '1.7.0'

repositories {
mavenCentral()
Expand All @@ -15,8 +15,8 @@ repositories {
}

dependencies {
implementation("com.vaticle.typedb:typedb-client:2.14.2")
implementation("com.vaticle.typeql:typeql-grammar:2.14.0")
implementation("com.vaticle.typedb:typedb-client:2.18.1")
implementation("com.vaticle.typeql:typeql-lang:2.18.0")
implementation("com.google.code.gson:gson:2.8.6")
implementation("org.slf4j:slf4j-api:1.7.25")
implementation("org.apache.logging.log4j:log4j-api:2.17.1")
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -130,7 +129,6 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
207 changes: 103 additions & 104 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,104 +1,103 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Configuration {
public static AttributeValueType getValueType(TypeDBSession session, String conceptType) {
AttributeValueType valueType = null;
try (TypeDBTransaction txn = session.transaction(TypeDBTransaction.Type.READ)) {
Set<ConceptMap> answers = txn.query().match(TypeQL.match(TypeQL.var("t").type(conceptType)).get("t")).collect(Collectors.toSet());
Set<ConceptMap> answers = txn.query().match(TypeQL.match(TypeQL.cVar("t").type(conceptType)).get(TypeQL.cVar("t"))).collect(Collectors.toSet());
assert answers.size() == 1;
for (ConceptMap answer : answers) {
valueType = AttributeValueType.valueOf(answer.get("t").asAttributeType().getValueType().name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private boolean valConceptTypeInSchema(HashMap<String, ArrayList<String>> valida
String conceptType,
String breadcrumbConceptType) {
boolean exists = false;
TypeQLMatch query = TypeQL.match(TypeQL.var("t").type(conceptType));
TypeQLMatch query = TypeQL.match(TypeQL.cVar("t").type(conceptType));
try (TypeDBTransaction txn = session.transaction(TypeDBTransaction.Type.READ)) {
Util.trace(Integer.toString((int) txn.query().match(query).count()));
exists = true;
Expand Down Expand Up @@ -532,7 +532,7 @@ private void valRoleType(HashMap<String, ArrayList<String>> validationReport,
String breadcrumbs,
String relationType,
String roleType) {
TypeQLMatch query = TypeQL.match(TypeQL.type(relationType).relates(TypeQL.var("r"))).get("r");
TypeQLMatch query = TypeQL.match(TypeQL.type(relationType).relates(TypeQL.cVar("r"))).get(TypeQL.cVar("r"));
try (TypeDBTransaction txn = session.transaction(TypeDBTransaction.Type.READ)) {
Stream<ConceptMap> answers = txn.query().match(query);
if (answers.noneMatch(a -> a.get("r").asRoleType().getLabel().name().equals(roleType))) {
Expand All @@ -547,7 +547,7 @@ private void valRolePlayedByConcept(HashMap<String, ArrayList<String>> validatio
String relationType,
String role,
String conceptType) {
TypeQLMatch query = TypeQL.match(TypeQL.var("c").plays(relationType, role)).get("c");
TypeQLMatch query = TypeQL.match(TypeQL.cVar("c").plays(relationType, role)).get(TypeQL.cVar("c"));
try (TypeDBTransaction txn = session.transaction(TypeDBTransaction.Type.READ)) {
Stream<ConceptMap> answers = txn.query().match(query);
if (answers.noneMatch(c -> c.get("c").asThingType().getLabel().name().equals(conceptType))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.vaticle.typeql.lang.TypeQL;
import com.vaticle.typeql.lang.pattern.constraint.ThingConstraint;
import com.vaticle.typeql.lang.pattern.variable.ThingVariable;
import com.vaticle.typeql.lang.pattern.variable.UnboundVariable;
import com.vaticle.typeql.lang.pattern.variable.UnboundConceptVariable;
import com.vaticle.typeql.lang.query.TypeQLInsert;
import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -87,22 +87,22 @@ public void write(TypeDBTransaction tx, String[] row, boolean allowMultiInsert)

public TypeQLInsert generateMatchInsertStatement(String[] row) {
if (row.length > 0) {
ThingVariable.Thing entityMatchStatement = TypeQL.var("thing")
ThingVariable.Thing entityMatchStatement = TypeQL.cVar("thing")
.isa(appendConfiguration.getMatch().getType());
for (Configuration.Definition.Attribute consAtt : appendConfiguration.getMatch().getOwnerships()) {
ArrayList<ThingConstraint.Value<?>> constraintValues = GeneratorUtil.generateValueConstraintsConstrainingAttribute(
ArrayList<ThingConstraint.Predicate> constraintValues = GeneratorUtil.generateValueConstraintsConstrainingAttribute(
row, header, filePath, fileSeparator, consAtt);
for (ThingConstraint.Value<?> constraintValue : constraintValues) {
for (ThingConstraint.Predicate constraintValue : constraintValues) {
entityMatchStatement.constrain(GeneratorUtil.valueToHasConstraint(consAtt.getAttribute(), constraintValue));
}
}

UnboundVariable insertUnboundVar = TypeQL.var("thing");
UnboundConceptVariable insertUnboundVar = TypeQL.cVar("thing");
ThingVariable.Thing insertStatement = null;
for (Configuration.Definition.Attribute attributeToAppend : appendConfiguration.getInsert().getOwnerships()) {
ArrayList<ThingConstraint.Value<?>> constraintValues = GeneratorUtil.generateValueConstraintsConstrainingAttribute(
ArrayList<ThingConstraint.Predicate> constraintValues = GeneratorUtil.generateValueConstraintsConstrainingAttribute(
row, header, filePath, fileSeparator, attributeToAppend);
for (ThingConstraint.Value<?> constraintValue : constraintValues) {
for (ThingConstraint.Predicate constraintValue : constraintValues) {
if (insertStatement == null) {
insertStatement = insertUnboundVar.constrain(GeneratorUtil.valueToHasConstraint(attributeToAppend.getAttribute(), constraintValue));
} else {
Expand All @@ -114,10 +114,10 @@ public TypeQLInsert generateMatchInsertStatement(String[] row) {
if (insertStatement != null) {
return TypeQL.match(entityMatchStatement).insert(insertStatement);
} else {
return TypeQL.insert(TypeQL.var("null").isa("null").has("null", "null"));
return TypeQL.insert(TypeQL.cVar("null").isa("null").has("null", "null"));
}
} else {
return TypeQL.insert(TypeQL.var("null").isa("null").has("null", "null"));
return TypeQL.insert(TypeQL.cVar("null").isa("null").has("null", "null"));
}
}

Expand Down
Loading

0 comments on commit 37baf49

Please sign in to comment.