diff --git a/Jenkinsfile b/Jenkinsfile
index 26619af..c5a699b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -12,7 +12,7 @@ def notifyBranch = [recipients: [brokenTestsSuspects(), requestor()]]
pipeline {
agent {
node {
- label 'alpine-jdk8-mvn-3.5'
+ label 'alpine-jdk8-mvn3.6'
}
}
parameters {
diff --git a/README.md b/README.md
index e996f8d..83f2a95 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,15 @@
# strongbox-db
## The goal of this project
-This project has been created in order speed up the building of the OrientDB database snapshots during the initial [Strongbox](https://github.com/strongbox/strongbox) startup. Before this project was born, it took some time to do all of the database changes from the beginning of time up until the most recent version, so that the OrientDB database structure would be populated properly.
+This project has been created in order speed up the building of the JanusGraph database snapshots during the initial [Strongbox](https://github.com/strongbox/strongbox) startup. Before this project was born, it took some time to do all of the database changes from the beginning of time up until the most recent version, so that the JanusGraph database structure would be populated properly.
## Architecture
This application consists of the following modules:
-* `strongbox-db-liquibase` which creates a `jar` file consiting of the liquibase changesets that construct the [Strongbox](https://github.com/strongbox/strongbox) OrientDB database schema
+* `strongbox-db-liquibase` which creates a `jar` file consiting of the liquibase changesets that construct the [Strongbox](https://github.com/strongbox/strongbox) JanusGraph database schema
* `strongbox-db-import` which creates a `zip` file with packed built database snapshot built from the liquibase changesets
## How is this project used in [strongbox](https://github.com/strongbox/strongbox) ?
-[strongbox](https://github.com/strongbox/strongbox) uses this project submodules as required dependencies. During the startup of [Strongbox](https://github.com/strongbox/strongbox), the application detects if an OrientDB database already exists. If not, then the application uses an extracted empty OrientDB database snapshot from the `strongbox-db-import` artifact. If the OrientDB database already exists, then the application applies all missing liquibase changesets from the `strongbox-db-liquibase` artifact.
+[strongbox](https://github.com/strongbox/strongbox) uses this project submodules as required dependencies. During the startup of [Strongbox](https://github.com/strongbox/strongbox), the application detects if an JanusGraph database already exists. If not, then the application uses an extracted empty JanusGraph database snapshot from the `strongbox-db-import` artifact. If the JanusGraph database already exists, then the application applies all missing changesets from the `strongbox-db-schema` artifact.
## How to build this project ?
To build the code, simply execute:
@@ -17,5 +17,5 @@ To build the code, simply execute:
## What's the result of the build process ?
This project produces the following artifacts:
-* `strongbox-db-liquibase-${version}.jar` : Located in `strongbox-db-liquibase/target`, which contains current database liquibase changesets
+* `strongbox-db-shcema-${version}.jar` : Located in `strongbox-db-schema/target`, which contains current database changesets
* `strongbox-db-import-${version}.zip` : Located in `strongbox-db-import/target`, which contains zipped fresh database snapshot built from the above changesets
diff --git a/pom.xml b/pom.xml
index 7cad30f..acca070 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,12 +6,12 @@
org.carlspring.strongbox
strongbox-parent
- 1.0-SNAPSHOT
+ 1.0-PR-62-SNAPSHOT
strongbox-db
pom
- 1.0-SNAPSHOT
+ 1.0-PR-20-SNAPSHOT
@@ -48,7 +48,7 @@
- strongbox-db-liquibase
+ strongbox-db-schema
strongbox-db-import
strongbox-db-server
diff --git a/strongbox-db-import/pom.xml b/strongbox-db-import/pom.xml
index 4d89a31..e557956 100644
--- a/strongbox-db-import/pom.xml
+++ b/strongbox-db-import/pom.xml
@@ -8,37 +8,28 @@
org.carlspring.strongbox
strongbox-db
- 1.0-SNAPSHOT
+ 1.0-PR-20-SNAPSHOT
../pom.xml
strongbox-db-import
2019
-
- ${project.build.directory}/db
-
-
${project.groupId}
- strongbox-db-liquibase
+ strongbox-db-server
${project.version}
${project.groupId}
- strongbox-db-server
+ strongbox-db-schema
${project.version}
-
+
org.springframework.boot
- spring-boot-starter-jdbc
-
-
-
- com.orientechnologies
- orientdb-jdbc
+ spring-boot-starter
@@ -46,49 +37,9 @@
commons-beanutils
-
-
- org.apache.ant
- ant
- 1.10.5
-
-
- org.liquibase
- liquibase-core
-
-
- org.apache.ant
- ant
-
-
-
-
- org.unbroken-dome.liquibase-orientdb
- liquibase-orientdb
-
-
- com.mattbertolini
- liquibase-slf4j
-
-
- org.hibernate.validator
- hibernate-validator
-
-
-
-
- org.apache.commons
- commons-lang3
-
-
-
- src/main/resources
- true
-
-
org.springframework.boot
@@ -102,6 +53,7 @@
-Xmx1024m
+ --strongbox.db.janus-graph.storage-root=${project.build.directory}/db
diff --git a/strongbox-db-import/src/main/assembly/db-schema.xml b/strongbox-db-import/src/main/assembly/db-schema.xml
index 794716a..e2f794f 100644
--- a/strongbox-db-import/src/main/assembly/db-schema.xml
+++ b/strongbox-db-import/src/main/assembly/db-schema.xml
@@ -9,8 +9,8 @@
- ${project.build.directory}/db/strongbox
- META-INF/resources/strongbox/db/strongbox
+ ${project.build.directory}/db
+ META-INF/org/carlsparing/strongbox/db
\ No newline at end of file
diff --git a/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/Application.java b/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/Application.java
index 2bdd916..44c1460 100644
--- a/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/Application.java
+++ b/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/Application.java
@@ -2,12 +2,13 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
/**
* @author Przemyslaw Fusik
*/
-@SpringBootApplication
+@SpringBootApplication(exclude = ValidationAutoConfiguration.class)
public class Application
{
diff --git a/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/orient/OrientDbConfiguration.java b/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/orient/OrientDbConfiguration.java
deleted file mode 100644
index bff6c37..0000000
--- a/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/orient/OrientDbConfiguration.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.carlspring.strongbox.db.orient;
-
-import java.lang.reflect.Field;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.autoconfigure.liquibase.LiquibaseDataSource;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.util.ReflectionUtils;
-import org.strongbox.db.server.EmbeddedOrientDbServer;
-import org.strongbox.db.server.OrientDbServer;
-import org.strongbox.db.server.OrientDbServerConfiguration;
-import org.strongbox.db.server.OrientDbServerProperties;
-import org.strongbox.db.server.OrientDbStudioConfiguration;
-import org.strongbox.db.server.OrientDbStudioProperties;
-
-import com.orientechnologies.orient.core.db.ODatabasePool;
-import com.orientechnologies.orient.core.db.ODatabaseType;
-import com.orientechnologies.orient.core.db.OrientDB;
-import com.orientechnologies.orient.core.db.OrientDBConfig;
-import com.orientechnologies.orient.jdbc.OrientDataSource;
-
-/**
- * @author Przemyslaw Fusik
- */
-@Configuration
-class OrientDbConfiguration
-{
-
- private static final Logger logger = LoggerFactory.getLogger(OrientDbConfiguration.class);
-
- @Bean
- OrientDbServer orientDbServer(OrientDbServerConfiguration serverProperties, OrientDbStudioConfiguration studioProperties) {
- return new EmbeddedOrientDbServer(studioProperties, serverProperties);
- }
-
- @Bean
- @ConfigurationProperties(prefix = "strongbox.orientdb.studio")
- OrientDbStudioConfiguration orientDbStudioProperties() {
- return new OrientDbStudioProperties();
- }
-
- @Bean
- @ConfigurationProperties(prefix = "strongbox.orientdb.server")
- OrientDbServerConfiguration orientDbServerProperties() {
- return new OrientDbServerProperties();
- }
-
- @Bean(destroyMethod = "close")
- @DependsOn("orientDbServer")
- OrientDB orientDB(OrientDbServerConfiguration orientDbServerProperties)
- {
- OrientDB orientDB = new OrientDB(StringUtils.substringBeforeLast(orientDbServerProperties.getUrl(), "/"),
- orientDbServerProperties.getUsername(),
- orientDbServerProperties.getPassword(),
- OrientDBConfig.defaultConfig());
- String database = orientDbServerProperties.getDatabase();
-
- if (!orientDB.exists(database))
- {
- logger.info(String.format("Creating database [%s]...", database));
-
- orientDB.create(database, ODatabaseType.PLOCAL);
- }
- else
- {
- logger.info("Re-using existing database " + database + ".");
- }
- return orientDB;
- }
-
- @Bean
- @LiquibaseDataSource
- DataSource dataSource(ODatabasePool pool,
- OrientDB orientDB)
- {
- OrientDataSource ds = new OrientDataSource(orientDB);
-
- ds.setInfo(new Properties());
-
- // DEV note:
- // NPEx hotfix for OrientDataSource.java:134 :)
- Field poolField = ReflectionUtils.findField(OrientDataSource.class, "pool");
- ReflectionUtils.makeAccessible(poolField);
- ReflectionUtils.setField(poolField, ds, pool);
-
- return ds;
- }
-
- @Bean(destroyMethod = "close")
- ODatabasePool databasePool(OrientDB orientDB, OrientDbServerConfiguration orientDbServerProperties)
- {
- return new ODatabasePool(orientDB,
- orientDbServerProperties.getDatabase(),
- orientDbServerProperties.getUsername(),
- orientDbServerProperties.getPassword());
- }
-
-}
diff --git a/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/schema/SchemaConfig.java b/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/schema/SchemaConfig.java
new file mode 100644
index 0000000..fad51c4
--- /dev/null
+++ b/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/schema/SchemaConfig.java
@@ -0,0 +1,16 @@
+package org.carlspring.strongbox.db.schema;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SchemaConfig
+{
+
+ @Bean
+ StrongboxSchema strongboxSchema()
+ {
+ return new StrongboxSchema();
+ }
+
+}
diff --git a/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/server/EmbeddedDbServerConfiguration.java b/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/server/EmbeddedDbServerConfiguration.java
new file mode 100644
index 0000000..b4bdc9b
--- /dev/null
+++ b/strongbox-db-import/src/main/java/org/carlspring/strongbox/db/server/EmbeddedDbServerConfiguration.java
@@ -0,0 +1,53 @@
+package org.carlspring.strongbox.db.server;
+
+import org.janusgraph.core.JanusGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.strongbox.db.server.CassandraEmbeddedConfiguration;
+import org.strongbox.db.server.CassandraEmbeddedProperties;
+import org.strongbox.db.server.EmbeddedDbServer;
+import org.strongbox.db.server.EmbeddedJanusGraphWithCassandraServer;
+import org.strongbox.db.server.JanusGraphConfiguration;
+import org.strongbox.db.server.JanusGraphProperties;
+
+/**
+ * @author Przemyslaw Fusik
+ * @author sbespalov
+ */
+@Configuration
+class EmbeddedDbServerConfiguration
+{
+
+ private static final Logger logger = LoggerFactory.getLogger(EmbeddedDbServerConfiguration.class);
+
+ @Bean
+ EmbeddedDbServer embeddedDbServer(CassandraEmbeddedConfiguration cassandraConfiguration,
+ JanusGraphConfiguration janusGraphConfiguration)
+ {
+ return new EmbeddedJanusGraphWithCassandraServer(cassandraConfiguration, janusGraphConfiguration);
+ }
+
+ @Bean
+ JanusGraph JanusGraph(EmbeddedDbServer server)
+ {
+ return ((EmbeddedJanusGraphWithCassandraServer) server).getJanusGraph();
+ }
+
+ @Bean
+ @ConfigurationProperties(prefix = "strongbox.db.janus-graph")
+ JanusGraphConfiguration janusGraphConfiguration()
+ {
+ return new JanusGraphProperties();
+ }
+
+ @Bean
+ CassandraEmbeddedConfiguration cassandraEmbeddedConfiguration(JanusGraphConfiguration janusGraphConfiguration)
+ {
+ return CassandraEmbeddedProperties.getInstance(janusGraphConfiguration.getStorageRoot(),
+ janusGraphConfiguration.getStoragePort());
+ }
+
+}
diff --git a/strongbox-db-import/src/main/resources/application.yml b/strongbox-db-import/src/main/resources/application.yml
index 620fd9d..e48e1fb 100644
--- a/strongbox-db-import/src/main/resources/application.yml
+++ b/strongbox-db-import/src/main/resources/application.yml
@@ -1,23 +1,15 @@
spring:
main:
web-application-type: NONE
- liquibase:
- change-log: classpath:/db/changelog/db.changelog-master.xml
strongbox:
- orientdb:
- server:
- protocol: remote
- host: 127.0.0.1
- port: "2025"
- database: strongbox
- username: admin
- password: password
- path: @strongbox.orientdb.path@
- studio:
- ipAddress: 127.0.0.1
- port: 2480
- enabled: true
- path: @strongbox.orientdb.path@
+ db:
+ janus-graph:
+ #TODO: [First start] randomize
+ storage-username: cassandra
+ storage-password: cassandra
+ storage-host: 127.0.0.1
+ storage-port: 49142
+ storage-root: ./target/db
logging:
level:
liquibase: INFO
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/db.changelog-master.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/db.changelog-master.xml
deleted file mode 100644
index 6523632..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/db.changelog-master.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/db.changelog-1.0.0.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/db.changelog-1.0.0.xml
deleted file mode 100644
index 5811154..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/db.changelog-1.0.0.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.10__ArtifactEntry.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.10__ArtifactEntry.xml
deleted file mode 100644
index 3a29163..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.10__ArtifactEntry.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.11__ArtifactEntry_cleanup.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.11__ArtifactEntry_cleanup.xml
deleted file mode 100644
index e08ec53..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.11__ArtifactEntry_cleanup.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- artifactCoordinates IS NULL
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.12__Configuration_cleanup.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.12__Configuration_cleanup.xml
deleted file mode 100644
index 237a238..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.12__Configuration_cleanup.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.13__ArtifactEntry_path.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.13__ArtifactEntry_path.xml
deleted file mode 100644
index 374ec08..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.13__ArtifactEntry_path.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.14__User_cleanup.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.14__User_cleanup.xml
deleted file mode 100644
index 05e66fb..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.14__User_cleanup.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.15__Authorization_cleanup.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.15__Authorization_cleanup.xml
deleted file mode 100644
index 656fd39..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.15__Authorization_cleanup.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.16__CronTaskConfiguration_cleanup.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.16__CronTaskConfiguration_cleanup.xml
deleted file mode 100644
index 717a529..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.16__CronTaskConfiguration_cleanup.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.17__ArtifactArchiveListing.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.17__ArtifactArchiveListing.xml
deleted file mode 100644
index 9dab10f..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.17__ArtifactArchiveListing.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.18__ArtifactGroup.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.18__ArtifactGroup.xml
deleted file mode 100644
index 76ec48e..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.18__ArtifactGroup.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.19__ArtifactEntry.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.19__ArtifactEntry.xml
deleted file mode 100644
index c8291f1..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.19__ArtifactEntry.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.1__GenericEntity.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.1__GenericEntity.xml
deleted file mode 100644
index 9c5f443..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.1__GenericEntity.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.20__User.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.20__User.xml
deleted file mode 100644
index 3a15116..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.20__User.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.21__ArtifactEntry.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.21__ArtifactEntry.xml
deleted file mode 100644
index fde581f..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.21__ArtifactEntry.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.22__UserEntry.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.22__UserEntry.xml
deleted file mode 100644
index 4329f5c..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.22__UserEntry.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.2__ArtifactEntry.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.2__ArtifactEntry.xml
deleted file mode 100644
index 14aaf94..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.2__ArtifactEntry.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.3__AuthorizationConfig.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.3__AuthorizationConfig.xml
deleted file mode 100644
index 97f69be..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.3__AuthorizationConfig.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.4__BinaryConfiguration.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.4__BinaryConfiguration.xml
deleted file mode 100644
index 7351386..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.4__BinaryConfiguration.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.5__CronTaskConfiguration.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.5__CronTaskConfiguration.xml
deleted file mode 100644
index e6ed941..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.5__CronTaskConfiguration.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.6__User.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.6__User.xml
deleted file mode 100644
index fff2dd9..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.6__User.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.7__Configuration.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.7__Configuration.xml
deleted file mode 100644
index bffbc8a..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.7__Configuration.xml
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.8__AuthorizationConfig.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.8__AuthorizationConfig.xml
deleted file mode 100644
index 43b3b9b..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.8__AuthorizationConfig.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.9__Repository.xml b/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.9__Repository.xml
deleted file mode 100644
index 71e2de4..0000000
--- a/strongbox-db-liquibase/src/main/resources/db/changelog/v1.0.0/v1.0.0.9__Repository.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/strongbox-db-liquibase/pom.xml b/strongbox-db-schema/pom.xml
similarity index 75%
rename from strongbox-db-liquibase/pom.xml
rename to strongbox-db-schema/pom.xml
index 8a79119..4a75a44 100644
--- a/strongbox-db-liquibase/pom.xml
+++ b/strongbox-db-schema/pom.xml
@@ -8,18 +8,18 @@
org.carlspring.strongbox
strongbox-db
- 1.0-SNAPSHOT
+ 1.0-PR-20-SNAPSHOT
../pom.xml
- strongbox-db-liquibase
+ strongbox-db-schema
2019
- com.google.guava
- guava
+ org.janusgraph
+ janusgraph-core
diff --git a/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Edges.java b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Edges.java
new file mode 100644
index 0000000..53ecebe
--- /dev/null
+++ b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Edges.java
@@ -0,0 +1,13 @@
+package org.carlspring.strongbox.db.schema;
+
+public interface Edges
+{
+
+ String ARTIFACT_HAS_ARTIFACT_COORDINATES = "ArtifactHasArtifactCoordinates";
+ String ARTIFACT_HAS_TAGS = "ArtifactHasTags";
+ String ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES = "ArtifactCoordinatesInheritGenericArtifactCoordinates";
+ String ARTIFACT_GROUP_HAS_ARTIFACTS = "ArtifactGroupHasArtifacts";
+ String REMOTE_ARTIFACT_INHERIT_ARTIFACT = "RemoteArtifactInheritArtifact";
+ String ARTIFACT_HAS_ARTIFACT_ARCHIVE_LISTING = "ArtifactHasArtifactArchiveListing";
+
+}
diff --git a/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Properties.java b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Properties.java
new file mode 100644
index 0000000..9fb1fa8
--- /dev/null
+++ b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Properties.java
@@ -0,0 +1,47 @@
+package org.carlspring.strongbox.db.schema;
+
+/**
+ * @author ankit.tomar
+ */
+public interface Properties
+{
+
+ String UUID = "uuid";
+ String STORAGE_ID = "storageId";
+ String REPOSITORY_ID = "repositoryId";
+ String NAME = "name";
+ String LAST_UPDATED = "lastUpdated";
+ String SIZE_IN_BYTES = "sizeInBytes";
+ String LAST_USED = "lastUsed";
+ String CREATED = "created";
+ String DOWNLOAD_COUNT = "downloadCount";
+ String CHECKSUMS = "checksums";
+ String CACHED = "cached";
+ String VERSION = "version";
+ String PASSWORD = "password";
+ String ENABLED = "enabled";
+ String ROLES = "roles";
+ String SECURITY_TOKEN_KEY = "securityTokenKey";
+ String SOURCE_ID = "sourceId";
+ String FILE_NAME = "fileName";
+ String COORDINATES_EXTENSION = "coordinates.extension";
+ String COORDINATES_NAME = "coordinates.name";
+ String COORDINATES_GROUP_ID = "coordinates.groupId";
+ String COORDINATES_ARTIFACT_ID = "coordinates.artifactId";
+ String COORDINATES_CLASSIFIER = "coordinates.classifier";
+ String COORDINATES_SCOPE = "coordinates.scope";
+ String COORDINATES_ID = "coordinates.id";
+ String COORDINATES_FILENAME = "coordinates.filename";
+ String COORDINATES_BUILD = "coordinates.build";
+ String COORDINATES_ABI = "coordinates.abi";
+ String COORDINATES_PLATFORM = "coordinates.platform";
+ String COORDINATES_PACKAGING = "coordinates.packaging";
+ String COORDINATES_DISTRIBUTION = "coordinates.distribution";
+ String COORDINATES_PATH = "coordinates.path";
+ String COORDINATES_BASE_NAME = "coordinates.base_name";
+ String COORDINATES_RELEASE = "coordinates.release";
+ String COORDINATES_ARCHITECTURE = "coordinates.architecture";
+ String COORDINATES_PACKAGE_TYPE = "coordinates.package_type";
+ String COORDINATES_LANGUAGE_IMPLEMENTATION_VERSION = "coordinates.languageImplementationVersion";
+
+}
\ No newline at end of file
diff --git a/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/StrongboxSchema.java b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/StrongboxSchema.java
new file mode 100644
index 0000000..cf7c037
--- /dev/null
+++ b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/StrongboxSchema.java
@@ -0,0 +1,635 @@
+package org.carlspring.strongbox.db.schema;
+
+import static org.carlspring.strongbox.db.schema.Edges.ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Edges.ARTIFACT_GROUP_HAS_ARTIFACTS;
+import static org.carlspring.strongbox.db.schema.Edges.ARTIFACT_HAS_ARTIFACT_ARCHIVE_LISTING;
+import static org.carlspring.strongbox.db.schema.Edges.ARTIFACT_HAS_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Edges.ARTIFACT_HAS_TAGS;
+import static org.carlspring.strongbox.db.schema.Edges.REMOTE_ARTIFACT_INHERIT_ARTIFACT;
+import static org.carlspring.strongbox.db.schema.Properties.CACHED;
+import static org.carlspring.strongbox.db.schema.Properties.CHECKSUMS;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_ABI;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_ARCHITECTURE;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_ARTIFACT_ID;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_BASE_NAME;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_BUILD;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_CLASSIFIER;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_DISTRIBUTION;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_EXTENSION;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_FILENAME;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_GROUP_ID;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_ID;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_LANGUAGE_IMPLEMENTATION_VERSION;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_NAME;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_PACKAGE_TYPE;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_PACKAGING;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_PATH;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_PLATFORM;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_RELEASE;
+import static org.carlspring.strongbox.db.schema.Properties.COORDINATES_SCOPE;
+import static org.carlspring.strongbox.db.schema.Properties.CREATED;
+import static org.carlspring.strongbox.db.schema.Properties.DOWNLOAD_COUNT;
+import static org.carlspring.strongbox.db.schema.Properties.ENABLED;
+import static org.carlspring.strongbox.db.schema.Properties.FILE_NAME;
+import static org.carlspring.strongbox.db.schema.Properties.LAST_UPDATED;
+import static org.carlspring.strongbox.db.schema.Properties.LAST_USED;
+import static org.carlspring.strongbox.db.schema.Properties.NAME;
+import static org.carlspring.strongbox.db.schema.Properties.PASSWORD;
+import static org.carlspring.strongbox.db.schema.Properties.REPOSITORY_ID;
+import static org.carlspring.strongbox.db.schema.Properties.ROLES;
+import static org.carlspring.strongbox.db.schema.Properties.SECURITY_TOKEN_KEY;
+import static org.carlspring.strongbox.db.schema.Properties.SIZE_IN_BYTES;
+import static org.carlspring.strongbox.db.schema.Properties.SOURCE_ID;
+import static org.carlspring.strongbox.db.schema.Properties.STORAGE_ID;
+import static org.carlspring.strongbox.db.schema.Properties.UUID;
+import static org.carlspring.strongbox.db.schema.Properties.VERSION;
+import static org.carlspring.strongbox.db.schema.Vertices.ARTIFACT;
+import static org.carlspring.strongbox.db.schema.Vertices.ARTIFACT_ARCHIVE_LISTING;
+import static org.carlspring.strongbox.db.schema.Vertices.ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Vertices.ARTIFACT_ID_GROUP;
+import static org.carlspring.strongbox.db.schema.Vertices.ARTIFACT_TAG;
+import static org.carlspring.strongbox.db.schema.Vertices.GENERIC_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Vertices.MAVEN_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Vertices.NPM_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Vertices.NUGET_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Vertices.PYPI_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Vertices.RAW_ARTIFACT_COORDINATES;
+import static org.carlspring.strongbox.db.schema.Vertices.REMOTE_ARTIFACT;
+import static org.carlspring.strongbox.db.schema.Vertices.USER;
+import static org.janusgraph.core.Multiplicity.MANY2ONE;
+import static org.janusgraph.core.Multiplicity.MULTI;
+import static org.janusgraph.core.Multiplicity.ONE2MANY;
+import static org.janusgraph.core.Multiplicity.ONE2ONE;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.Cardinality;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.Multiplicity;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.VertexLabel;
+import org.janusgraph.core.schema.ConsistencyModifier;
+import org.janusgraph.core.schema.EdgeLabelMaker;
+import org.janusgraph.core.schema.JanusGraphIndex;
+import org.janusgraph.core.schema.JanusGraphManagement;
+import org.janusgraph.core.schema.JanusGraphManagement.IndexBuilder;
+import org.janusgraph.core.schema.JanusGraphSchemaType;
+import org.janusgraph.core.schema.PropertyKeyMaker;
+import org.janusgraph.core.schema.SchemaAction;
+import org.janusgraph.graphdb.database.management.ManagementSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StrongboxSchema
+{
+
+ private static final Logger logger = LoggerFactory.getLogger(StrongboxSchema.class);
+
+ public void createSchema(JanusGraph jg)
+ throws InterruptedException
+ {
+ JanusGraphManagement jgm = jg.openManagement();
+ try
+ {
+ applySchemaChanges(jgm);
+ jgm.commit();
+ }
+ catch (Exception e)
+ {
+ logger.error("Failed to apply schema changes.", e);
+ jgm.rollback();
+ throw new RuntimeException("Failed to apply schema changes.", e);
+ }
+
+ jgm = jg.openManagement();
+ Set indexes;
+ try
+ {
+ indexes = createIndexes(jg, jgm);
+ jgm.commit();
+ }
+ catch (Exception e)
+ {
+ logger.error("Failed to create indexes.", e);
+ jgm.rollback();
+ throw new RuntimeException("Failed to create indexes.", e);
+ }
+
+ for (String janusGraphIndex : indexes)
+ {
+ logger.info(String.format("Wait index [%s] to be registered.", janusGraphIndex));
+ ManagementSystem.awaitGraphIndexStatus(jg, janusGraphIndex).call();
+ }
+
+ jgm = jg.openManagement();
+ try
+ {
+ enableIndexes(jgm, indexes);
+ jgm.commit();
+ }
+ catch (Exception e)
+ {
+ logger.error("Failed to enable indexes.", e);
+ jgm.rollback();
+ throw new RuntimeException("Failed to enable indexes.", e);
+ }
+
+ jgm = jg.openManagement();
+ try
+ {
+ logger.info(String.format("Schema: %n%s", jgm.printSchema()));
+ } finally
+ {
+ jgm.rollback();
+ }
+ }
+
+ protected void enableIndexes(JanusGraphManagement jgm,
+ Set indexes)
+ throws InterruptedException,
+ ExecutionException
+ {
+ for (String janusGraphIndex : indexes)
+ {
+ logger.info(String.format("Enabling index [%s].", janusGraphIndex));
+ jgm.updateIndex(jgm.getGraphIndex(janusGraphIndex), SchemaAction.ENABLE_INDEX).get();
+ }
+ }
+
+ protected Set createIndexes(JanusGraph jg,
+ JanusGraphManagement jgm)
+ throws InterruptedException
+ {
+ Set result = new HashSet<>();
+
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(ARTIFACT),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(REMOTE_ARTIFACT),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(ARTIFACT_COORDINATES),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(RAW_ARTIFACT_COORDINATES),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(MAVEN_ARTIFACT_COORDINATES),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(NPM_ARTIFACT_COORDINATES),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(NUGET_ARTIFACT_COORDINATES),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(PYPI_ARTIFACT_COORDINATES),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(ARTIFACT_TAG),
+ true,
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(ARTIFACT_ID_GROUP),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(ARTIFACT_ID_GROUP),
+ false,
+ false,
+ jgm.getPropertyKey(STORAGE_ID),
+ jgm.getPropertyKey(REPOSITORY_ID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(ARTIFACT_ID_GROUP),
+ true,
+ jgm.getPropertyKey(STORAGE_ID),
+ jgm.getPropertyKey(REPOSITORY_ID),
+ jgm.getPropertyKey(NAME)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(USER),
+ true,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+ buildIndexIfNecessary(jgm,
+ Vertex.class,
+ jgm.getVertexLabel(ARTIFACT_ARCHIVE_LISTING),
+ false,
+ jgm.getPropertyKey(UUID)).ifPresent(result::add);
+
+ return result;
+ }
+
+ private void applySchemaChanges(JanusGraphManagement jgm)
+ {
+ // Properties
+ createProperties(jgm);
+
+ // Vertices
+ makeVertexLabelIfDoesNotExist(jgm, ARTIFACT);
+ makeVertexLabelIfDoesNotExist(jgm, REMOTE_ARTIFACT);
+ makeVertexLabelIfDoesNotExist(jgm, GENERIC_ARTIFACT_COORDINATES);
+ makeVertexLabelIfDoesNotExist(jgm, ARTIFACT_COORDINATES);
+ makeVertexLabelIfDoesNotExist(jgm, RAW_ARTIFACT_COORDINATES);
+ makeVertexLabelIfDoesNotExist(jgm, MAVEN_ARTIFACT_COORDINATES);
+ makeVertexLabelIfDoesNotExist(jgm, NPM_ARTIFACT_COORDINATES);
+ makeVertexLabelIfDoesNotExist(jgm, NUGET_ARTIFACT_COORDINATES);
+ makeVertexLabelIfDoesNotExist(jgm, PYPI_ARTIFACT_COORDINATES);
+ makeVertexLabelIfDoesNotExist(jgm, ARTIFACT_TAG);
+ makeVertexLabelIfDoesNotExist(jgm, ARTIFACT_ID_GROUP);
+ makeVertexLabelIfDoesNotExist(jgm, USER);
+ makeVertexLabelIfDoesNotExist(jgm, ARTIFACT_ARCHIVE_LISTING);
+
+ // Edges
+ makeEdgeLabelIfDoesNotExist(jgm, ARTIFACT_HAS_ARTIFACT_COORDINATES, MANY2ONE);
+ makeEdgeLabelIfDoesNotExist(jgm, ARTIFACT_HAS_TAGS, MULTI);
+ makeEdgeLabelIfDoesNotExist(jgm, REMOTE_ARTIFACT_INHERIT_ARTIFACT, ONE2ONE);
+ makeEdgeLabelIfDoesNotExist(jgm, ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES, ONE2ONE);
+ makeEdgeLabelIfDoesNotExist(jgm, ARTIFACT_GROUP_HAS_ARTIFACTS, ONE2MANY);
+ makeEdgeLabelIfDoesNotExist(jgm, ARTIFACT_HAS_ARTIFACT_ARCHIVE_LISTING, ONE2MANY);
+
+ // Add property constraints
+ applyPropertyConstraints(jgm);
+
+ // Add connection constraints
+ applyConnectionConstraints(jgm);
+ }
+
+ private void applyConnectionConstraints(JanusGraphManagement jgm)
+ {
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_HAS_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(ARTIFACT),
+ jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_HAS_TAGS),
+ jgm.getVertexLabel(ARTIFACT),
+ jgm.getVertexLabel(ARTIFACT_TAG));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_GROUP_HAS_ARTIFACTS),
+ jgm.getVertexLabel(ARTIFACT_ID_GROUP),
+ jgm.getVertexLabel(ARTIFACT));
+
+ jgm.addConnection(jgm.getEdgeLabel(REMOTE_ARTIFACT_INHERIT_ARTIFACT),
+ jgm.getVertexLabel(REMOTE_ARTIFACT),
+ jgm.getVertexLabel(ARTIFACT));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(RAW_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(NUGET_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(NPM_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(MAVEN_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(PYPI_ARTIFACT_COORDINATES),
+ jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
+
+ jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_HAS_ARTIFACT_ARCHIVE_LISTING),
+ jgm.getVertexLabel(ARTIFACT),
+ jgm.getVertexLabel(ARTIFACT_ARCHIVE_LISTING));
+
+ }
+
+ private void applyPropertyConstraints(JanusGraphManagement jgm)
+ {
+ // Vertex Property Constraints
+ addVertexPropertyConstraints(jgm,
+ ARTIFACT,
+ UUID,
+ STORAGE_ID,
+ REPOSITORY_ID,
+ CREATED,
+ LAST_UPDATED,
+ LAST_USED,
+ SIZE_IN_BYTES,
+ DOWNLOAD_COUNT,
+ CHECKSUMS);
+
+ addVertexPropertyConstraints(jgm,
+ REMOTE_ARTIFACT,
+ UUID,
+ CACHED,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ GENERIC_ARTIFACT_COORDINATES,
+ UUID,
+ VERSION,
+ COORDINATES_ID,
+ COORDINATES_EXTENSION,
+ COORDINATES_NAME,
+ COORDINATES_PATH,
+ COORDINATES_SCOPE,
+ COORDINATES_GROUP_ID,
+ COORDINATES_ARTIFACT_ID,
+ COORDINATES_CLASSIFIER,
+ COORDINATES_DISTRIBUTION,
+ COORDINATES_BUILD,
+ COORDINATES_ABI,
+ COORDINATES_PLATFORM,
+ COORDINATES_PACKAGING,
+ COORDINATES_LANGUAGE_IMPLEMENTATION_VERSION,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ RAW_ARTIFACT_COORDINATES,
+ UUID,
+ VERSION,
+ COORDINATES_EXTENSION,
+ COORDINATES_NAME,
+ COORDINATES_PATH,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ MAVEN_ARTIFACT_COORDINATES,
+ UUID,
+ VERSION,
+ COORDINATES_EXTENSION,
+ COORDINATES_NAME,
+ COORDINATES_GROUP_ID,
+ COORDINATES_ARTIFACT_ID,
+ COORDINATES_CLASSIFIER,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ NPM_ARTIFACT_COORDINATES,
+ UUID,
+ VERSION,
+ COORDINATES_EXTENSION,
+ COORDINATES_NAME,
+ COORDINATES_SCOPE,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ NUGET_ARTIFACT_COORDINATES,
+ UUID,
+ VERSION,
+ COORDINATES_EXTENSION,
+ COORDINATES_NAME,
+ COORDINATES_ID,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ PYPI_ARTIFACT_COORDINATES,
+ UUID,
+ VERSION,
+ COORDINATES_EXTENSION,
+ COORDINATES_NAME,
+ COORDINATES_BUILD,
+ COORDINATES_ABI,
+ COORDINATES_PLATFORM,
+ COORDINATES_PACKAGING,
+ COORDINATES_DISTRIBUTION,
+ COORDINATES_LANGUAGE_IMPLEMENTATION_VERSION,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ ARTIFACT_TAG,
+ UUID,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ ARTIFACT_ID_GROUP,
+ UUID,
+ STORAGE_ID,
+ REPOSITORY_ID,
+ NAME,
+ CREATED);
+
+ addVertexPropertyConstraints(jgm,
+ USER,
+ UUID,
+ PASSWORD,
+ ENABLED,
+ ROLES,
+ SECURITY_TOKEN_KEY,
+ SOURCE_ID,
+ CREATED,
+ LAST_UPDATED);
+
+ addVertexPropertyConstraints(jgm,
+ ARTIFACT_ARCHIVE_LISTING,
+ UUID,
+ STORAGE_ID,
+ REPOSITORY_ID,
+ FILE_NAME,
+ CREATED);
+ }
+
+ private void addVertexPropertyConstraints(JanusGraphManagement jgm,
+ String vertex,
+ String... propertykeys)
+ {
+ VertexLabel vertexLabel = jgm.getVertexLabel(vertex);
+ for (String propertyKey : propertykeys)
+ {
+ jgm.addProperties(vertexLabel, jgm.getPropertyKey(propertyKey));
+ }
+ }
+
+ private void createProperties(JanusGraphManagement jgm)
+ {
+ makePropertyKeyIfDoesNotExist(jgm, UUID,
+ String.class).ifPresent(p -> jgm.setConsistency(p, ConsistencyModifier.LOCK));
+ makePropertyKeyIfDoesNotExist(jgm, STORAGE_ID, String.class);
+ makePropertyKeyIfDoesNotExist(jgm, REPOSITORY_ID, String.class);
+ makePropertyKeyIfDoesNotExist(jgm, NAME, String.class);
+ makePropertyKeyIfDoesNotExist(jgm, LAST_UPDATED, Long.class, Cardinality.SINGLE);
+
+ // Artifact
+ makePropertyKeyIfDoesNotExist(jgm, SIZE_IN_BYTES, Long.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, LAST_USED, Long.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, CREATED, Long.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, DOWNLOAD_COUNT, Integer.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, FILE_NAME, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, CHECKSUMS, String.class, Cardinality.SET);
+
+ // RemoteArtifact
+ makePropertyKeyIfDoesNotExist(jgm, CACHED, Boolean.class, Cardinality.SINGLE);
+
+ // Common coordinates
+ makePropertyKeyIfDoesNotExist(jgm, VERSION, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_EXTENSION, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_NAME, String.class, Cardinality.SINGLE);
+
+ // Maven
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_GROUP_ID, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_ARTIFACT_ID, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_CLASSIFIER, String.class, Cardinality.SINGLE);
+
+ // Npm
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_SCOPE, String.class, Cardinality.SINGLE);
+
+ // Nuget
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_ID, String.class, Cardinality.SINGLE);
+
+ // P2
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_FILENAME, String.class, Cardinality.SINGLE);
+
+ // Pypi
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_BUILD, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_LANGUAGE_IMPLEMENTATION_VERSION, String.class,
+ Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_ABI, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_PLATFORM, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_PACKAGING, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_DISTRIBUTION, String.class, Cardinality.SINGLE);
+
+ // Raw
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_PATH, String.class, Cardinality.SINGLE);
+
+ // Rpm
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_BASE_NAME, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_RELEASE, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_ARCHITECTURE, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, COORDINATES_PACKAGE_TYPE, String.class, Cardinality.SINGLE);
+
+ // User
+ makePropertyKeyIfDoesNotExist(jgm, PASSWORD, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, ENABLED, Boolean.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, ROLES, String.class, Cardinality.SET);
+ makePropertyKeyIfDoesNotExist(jgm, SECURITY_TOKEN_KEY, String.class, Cardinality.SINGLE);
+ makePropertyKeyIfDoesNotExist(jgm, SOURCE_ID, String.class, Cardinality.SINGLE);
+ }
+
+ private Optional buildIndexIfNecessary(final JanusGraphManagement jgm,
+ final Class extends Element> elementType,
+ final JanusGraphSchemaType schemaType,
+ final boolean unique,
+ final PropertyKey... properties)
+ {
+ return buildIndexIfNecessary(jgm, elementType, schemaType, unique, true, properties);
+ }
+
+ private Optional buildIndexIfNecessary(final JanusGraphManagement jgm,
+ final Class extends Element> elementType,
+ final JanusGraphSchemaType schemaType,
+ final boolean unique,
+ final boolean consistent,
+ final PropertyKey... properties)
+ {
+ final String name = schemaType.name() + "By"
+ + Arrays.stream(properties)
+ .map(PropertyKey::name)
+ .map(StringUtils::capitalize)
+ .reduce((p1,
+ p2) -> p1 + "And" + p2)
+ .get();
+ if (jgm.containsGraphIndex(name))
+ {
+ return Optional.empty();
+ }
+
+ IndexBuilder indexBuilder = jgm.buildIndex(name, elementType)
+ .indexOnly(schemaType);
+ Arrays.stream(properties).forEach(indexBuilder::addKey);
+
+ if (unique)
+ {
+ indexBuilder = indexBuilder.unique();
+ }
+ JanusGraphIndex intex = indexBuilder.buildCompositeIndex();
+ if (consistent)
+ {
+ jgm.setConsistency(intex, ConsistencyModifier.LOCK);
+ }
+
+ return Optional.of(intex.name());
+ }
+
+ private void makeEdgeLabelIfDoesNotExist(final JanusGraphManagement jgm,
+ final String name,
+ final Multiplicity multiplicity)
+ {
+ if (jgm.containsEdgeLabel(name))
+ {
+ return;
+ }
+ EdgeLabelMaker edgeLabelMaker = jgm.makeEdgeLabel(name);
+ if (multiplicity != null)
+ {
+ edgeLabelMaker = edgeLabelMaker.multiplicity(multiplicity);
+ }
+
+ edgeLabelMaker.make();
+ }
+
+ private void makeVertexLabelIfDoesNotExist(final JanusGraphManagement jgm,
+ final String name)
+ {
+ if (jgm.containsVertexLabel(name))
+ {
+ return;
+ }
+ jgm.makeVertexLabel(name).make();
+ }
+
+ private Optional makePropertyKeyIfDoesNotExist(final JanusGraphManagement jgm,
+ final String name,
+ final Class> dataType)
+ {
+ return makePropertyKeyIfDoesNotExist(jgm, name, dataType, null);
+ }
+
+ private Optional makePropertyKeyIfDoesNotExist(final JanusGraphManagement jgm,
+ final String name,
+ final Class> dataType,
+ final Cardinality cardinality)
+ {
+ if (jgm.containsPropertyKey(name))
+ {
+ return Optional.empty();
+ }
+
+ PropertyKeyMaker propertyKeyMaker = jgm.makePropertyKey(name).dataType(dataType);
+ if (cardinality != null)
+ {
+ propertyKeyMaker = propertyKeyMaker.cardinality(cardinality);
+ }
+ return Optional.of(propertyKeyMaker.make());
+ }
+
+}
\ No newline at end of file
diff --git a/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Vertices.java b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Vertices.java
new file mode 100644
index 0000000..ded0aff
--- /dev/null
+++ b/strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Vertices.java
@@ -0,0 +1,21 @@
+package org.carlspring.strongbox.db.schema;
+
+public interface Vertices
+{
+
+ String ARTIFACT = "Artifact";
+ String REMOTE_ARTIFACT = "RemoteArtifact";
+ String GENERIC_ARTIFACT_COORDINATES = "GenericArtifactCoordinates";
+ String ARTIFACT_COORDINATES = "ArtifactCoordinates";
+ String RAW_ARTIFACT_COORDINATES = "RawArtifactCoordinates";
+ String MAVEN_ARTIFACT_COORDINATES = "MavenArtifactCoordinates";
+ String NPM_ARTIFACT_COORDINATES = "NpmArtifactCoordinates";
+ String NUGET_ARTIFACT_COORDINATES = "NugetArtifactCoordinates";
+ String PYPI_ARTIFACT_COORDINATES = "PypiArtifactCoordinates";
+ String RPM_ARTIFACT_COORDINATES = "RpmArtifactCoordinates";
+ String ARTIFACT_TAG = "ArtifactTag";
+ String ARTIFACT_ID_GROUP = "ArtifactIdGroup";
+ String USER = "User";
+ String ARTIFACT_ARCHIVE_LISTING = "ArtifactArchiveListing";
+
+}
\ No newline at end of file
diff --git a/strongbox-db-server/pom.xml b/strongbox-db-server/pom.xml
index 9a40a73..35c4d00 100644
--- a/strongbox-db-server/pom.xml
+++ b/strongbox-db-server/pom.xml
@@ -9,7 +9,7 @@
org.carlspring.strongbox
strongbox-db
- 1.0-SNAPSHOT
+ 1.0-PR-20-SNAPSHOT
../pom.xml
@@ -22,36 +22,74 @@
UTF-8
-
+
com.fasterxml.jackson.core
jackson-databind
- com.orientechnologies
- orientdb-core
+ org.janusgraph
+ janusgraph-cql
- com.orientechnologies
- orientdb-client
+ org.janusgraph
+ janusgraph-inmemory
- com.orientechnologies
- orientdb-server
+ org.apache.cassandra
+ cassandra-all
- com.orientechnologies
- orientdb-object
+ io.dropwizard.metrics
+ metrics-core
+
+
+ org.apache.tinkerpop
+ gremlin-core
+
+
+ org.apache.tinkerpop
+ gremlin-driver
+
+
+ org.apache.tinkerpop
+ gremlin-server
+
+
+ org.apache.tinkerpop
+ gremlin-groovy
+
+
- com.orientechnologies
- orientdb-graphdb
+ org.opencypher.gremlin
+ cypher-gremlin-neo4j-driver
+
+ org.opencypher.gremlin
+ cypher-gremlin-server-plugin
+
+
+
+ org.neo4j.driver
+ neo4j-java-driver
+
+
+ org.neo4j
+ neo4j-ogm-api
+
+
+
-
- org.webjars
- orientdb-studio
+
+ commons-lang
+ commons-lang
+ 2.6
+
diff --git a/strongbox-db-server/src/main/java/org/opencypher/gremlin/neo4j/driver/CypherGremlinStatementRunner.java b/strongbox-db-server/src/main/java/org/opencypher/gremlin/neo4j/driver/CypherGremlinStatementRunner.java
new file mode 100644
index 0000000..093dad1
--- /dev/null
+++ b/strongbox-db-server/src/main/java/org/opencypher/gremlin/neo4j/driver/CypherGremlinStatementRunner.java
@@ -0,0 +1,168 @@
+package org.opencypher.gremlin.neo4j.driver;
+
+import static org.opencypher.gremlin.translation.ReturnProperties.ID;
+import static org.opencypher.gremlin.translation.ReturnProperties.INV;
+import static org.opencypher.gremlin.translation.ReturnProperties.LABEL;
+import static org.opencypher.gremlin.translation.ReturnProperties.OUTV;
+import static org.opencypher.gremlin.translation.ReturnProperties.RELATIONSHIP_TYPE;
+import static org.opencypher.gremlin.translation.ReturnProperties.TYPE;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.CompletionStage;
+
+import org.janusgraph.core.JanusGraphTransaction;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.graphdb.relations.RelationIdentifier;
+import org.neo4j.driver.v1.Record;
+import org.neo4j.driver.v1.Session;
+import org.neo4j.driver.v1.Statement;
+import org.neo4j.driver.v1.StatementResult;
+import org.neo4j.driver.v1.StatementResultCursor;
+import org.neo4j.driver.v1.StatementRunner;
+import org.neo4j.driver.v1.Value;
+import org.neo4j.driver.v1.types.TypeSystem;
+import org.opencypher.gremlin.client.CypherGremlinClient;
+import org.opencypher.gremlin.neo4j.ogm.transaction.GremlinTransaction;
+import org.strongbox.util.Commons;
+
+/**
+ * @author sbespalov
+ */
+public class CypherGremlinStatementRunner implements StatementRunner
+{
+
+ private final Session session;
+ private final GremlinTransaction gremlinTransaction;
+
+ public CypherGremlinStatementRunner(GremlinTransaction gremlinTransaction)
+ {
+ this.gremlinTransaction = gremlinTransaction;
+ this.session = new GremlinServerSession(null,
+ CypherGremlinClient.inMemory(gremlinTransaction.getNativeTransaction().traversal()),
+ new JanusGraphValueConverter(false));
+ }
+
+ public StatementResult run(String statementTemplate,
+ Value parameters)
+ {
+ return session.run(statementTemplate, parameters);
+ }
+
+ public StatementResult run(String statementTemplate,
+ Map statementParameters)
+ {
+ return session.run(statementTemplate, statementParameters);
+ }
+
+ public StatementResult run(String statementTemplate,
+ Record statementParameters)
+ {
+ return session.run(statementTemplate, statementParameters);
+ }
+
+ public StatementResult run(String statementTemplate)
+ {
+ return session.run(statementTemplate);
+ }
+
+ public StatementResult run(Statement statement)
+ {
+ return session.run(statement);
+ }
+
+ public TypeSystem typeSystem()
+ {
+ return session.typeSystem();
+ }
+
+ class JanusGraphValueConverter extends GremlinCypherValueConverter
+ {
+
+ public JanusGraphValueConverter(boolean ignoreIds)
+ {
+ super(ignoreIds);
+ }
+
+ @Override
+ Record toRecord(Map map)
+ {
+ map.entrySet().forEach(this::normalizeValue);
+
+ return super.toRecord(map);
+ }
+
+ private void normalizeValue(Entry e)
+ {
+ Object value = e.getValue();
+ if (value instanceof Map)
+ {
+ Map nodeMap = (Map) value;
+ nodeMap.entrySet().forEach(this::normalizeValue);
+ }
+ else if (e.getValue() instanceof RelationIdentifier)
+ {
+ JanusGraphTransaction tx = (JanusGraphTransaction) gremlinTransaction.getNativeTransaction();
+ RelationIdentifier relationIdentifier = (RelationIdentifier) e.getValue();
+ if (ID.equals(e.getKey()))
+ {
+ e.setValue(relationIdentifier.getRelationId());
+
+ return;
+ }
+
+ Map expectedValue = new HashMap<>();
+ expectedValue.put(TYPE, RELATIONSHIP_TYPE);
+ expectedValue.put(ID, relationIdentifier.getRelationId());
+ expectedValue.put(OUTV, relationIdentifier.getOutVertexId());
+ expectedValue.put(INV, relationIdentifier.getInVertexId());
+
+ JanusGraphVertex typeVertex = tx.getVertex(relationIdentifier.getTypeId());
+ expectedValue.put(LABEL, typeVertex.label());
+
+ e.setValue(expectedValue);
+ }
+ else if (value instanceof Date)
+ {
+ e.setValue(Commons.toLocalDateTime((Date) value));
+ }
+ }
+
+ }
+
+ @Override
+ public CompletionStage runAsync(String statementTemplate,
+ Value parameters)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CompletionStage runAsync(String statementTemplate,
+ Map statementParameters)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CompletionStage runAsync(String statementTemplate,
+ Record statementParameters)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CompletionStage runAsync(String statementTemplate)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CompletionStage runAsync(Statement statement)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/strongbox-db-server/src/main/java/org/opencypher/gremlin/neo4j/driver/Neo4jDriverEntityAdapter.java b/strongbox-db-server/src/main/java/org/opencypher/gremlin/neo4j/driver/Neo4jDriverEntityAdapter.java
new file mode 100644
index 0000000..8b17ed2
--- /dev/null
+++ b/strongbox-db-server/src/main/java/org/opencypher/gremlin/neo4j/driver/Neo4jDriverEntityAdapter.java
@@ -0,0 +1,117 @@
+package org.opencypher.gremlin.neo4j.driver;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.neo4j.driver.internal.value.ListValue;
+import org.neo4j.driver.v1.Value;
+import org.neo4j.driver.v1.types.Entity;
+import org.neo4j.driver.v1.types.Node;
+import org.neo4j.driver.v1.types.Path;
+import org.neo4j.driver.v1.types.Relationship;
+import org.neo4j.ogm.driver.TypeSystem.NoNativeTypes;
+
+/**
+ * @author sbespalov
+ */
+public class Neo4jDriverEntityAdapter
+{
+
+ public boolean isPath(Object value)
+ {
+ return value instanceof Path;
+ }
+
+ public boolean isNode(Object value)
+ {
+ return value instanceof Node;
+ }
+
+ public boolean isRelationship(Object value)
+ {
+ return value instanceof Relationship;
+ }
+
+ public long nodeId(Object node)
+ {
+ return ((Node) node).id();
+ }
+
+ public List labels(Object value)
+ {
+ Node node = (Node) value;
+ List labels = new ArrayList<>();
+ for (String label : node.labels())
+ {
+ labels.add(label);
+ }
+ return labels;
+ }
+
+ public long relationshipId(Object relationship)
+ {
+ return ((Relationship) relationship).id();
+ }
+
+ public String relationshipType(Object relationship)
+ {
+ return ((Relationship) relationship).type();
+ }
+
+ public Long startNodeId(Object relationship)
+ {
+ return ((Relationship) relationship).startNodeId();
+ }
+
+ public Long endNodeId(Object relationship)
+ {
+ return ((Relationship) relationship).endNodeId();
+ }
+
+ public Map properties(Object container)
+ {
+ return ((Entity) container).asMap(this::toMapped);
+ }
+
+ public List