Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
schaertl_andreas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
supervision
schaertl_andreas
Commits
c9303ed8
Commit
c9303ed8
authored
4 years ago
by
Andreas Schärtl
Browse files
Options
Downloads
Patches
Plain Diff
graphcli: establish connection to GraphDB server
parent
8c7822ad
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
graphdb/graphcli/pom.xml
+12
-3
12 additions, 3 deletions
graphdb/graphcli/pom.xml
graphdb/graphcli/src/main/java/me/schaertl/graphcli/Main.java
+60
-2
60 additions, 2 deletions
...hdb/graphcli/src/main/java/me/schaertl/graphcli/Main.java
with
72 additions
and
5 deletions
graphdb/graphcli/pom.xml
+
12
−
3
View file @
c9303ed8
...
...
@@ -3,10 +3,19 @@
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>
<groupId>
me.schaertl
</groupId>
<artifactId>
graphcli
</artifactId>
<version>
indev
</version>
<properties>
<maven.compiler.source>
1.11
</maven.compiler.source>
<maven.compiler.target>
1.11
</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.ontotext.graphdb/graphdb-free-runtime -->
<dependency>
<groupId>
com.ontotext.graphdb
</groupId>
<artifactId>
graphdb-free-runtime
</artifactId>
<version>
9.2.0
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
graphdb/graphcli/src/main/java/me/schaertl/graphcli/Main.java
+
60
−
2
View file @
c9303ed8
package
me.schaertl.graphcli
;
import
org.eclipse.rdf4j.model.Resource
;
import
org.eclipse.rdf4j.model.impl.TreeModel
;
import
org.eclipse.rdf4j.model.vocabulary.RDF
;
import
org.eclipse.rdf4j.repository.Repository
;
import
org.eclipse.rdf4j.repository.RepositoryConnection
;
import
org.eclipse.rdf4j.repository.config.RepositoryConfig
;
import
org.eclipse.rdf4j.repository.config.RepositoryConfigSchema
;
import
org.eclipse.rdf4j.repository.manager.LocalRepositoryManager
;
import
org.eclipse.rdf4j.repository.manager.RemoteRepositoryManager
;
import
org.eclipse.rdf4j.repository.manager.RepositoryManager
;
import
org.eclipse.rdf4j.rio.RDFFormat
;
import
org.eclipse.rdf4j.rio.RDFParser
;
import
org.eclipse.rdf4j.rio.Rio
;
import
org.eclipse.rdf4j.rio.helpers.StatementCollector
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Hello, World!"
);
private
static
void
hello
()
throws
IOException
{
// Code taken from http://graphdb.ontotext.com/documentation/standard/using-graphdb-with-the-rdf4j-api.html
// Instantiate a local repository manager and initialize it
final
RepositoryManager
repositoryManager
=
new
RemoteRepositoryManager
(
"http://rdf:7200"
);
repositoryManager
.
initialize
();
// Instantiate a repository graph model
// final TreeModel graph = new TreeModel();
// Read repository configuration file
// InputStream config = EmbeddedGraphDB.class.getResourceAsStream("/repo-defaults.ttl");
// RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE);
// rdfParser.setRDFHandler(new StatementCollector(graph));
// rdfParser.parse(config, RepositoryConfigSchema.NAMESPACE);
// config.close();
// Retrieve the repository node as a resource
// Resource repositoryNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RepositoryConfigSchema.REPOSITORY);
// Create a repository configuration object and add it to the repositoryManager
// RepositoryConfig repositoryConfig = RepositoryConfig.create(graph, repositoryNode);
// repositoryManager.addRepositoryConfig(repositoryConfig);
// Get the repository from repository manager, note the repository id set in configuration .ttl file
final
Repository
repository
=
repositoryManager
.
getRepository
(
"chem"
);
// Open a connection to this repository
final
RepositoryConnection
repositoryConnection
=
repository
.
getConnection
();
// ... use the repository
// Shutdown connection, repository and manager
repositoryConnection
.
close
();
repository
.
shutDown
();
repositoryManager
.
shutDown
();
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
Main
.
hello
();
System
.
out
.
println
(
"done running the program"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment