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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
supervision
schaertl_andreas
Commits
842ecc87
Commit
842ecc87
authored
5 years ago
by
Andreas Schärtl
Browse files
Options
Downloads
Patches
Plain Diff
Play around w/ rdf4j
parent
8c3f3683
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
graphdb/graphcli/src/main/java/me/schaertl/graphcli/Main.java
+7
-32
7 additions, 32 deletions
...hdb/graphcli/src/main/java/me/schaertl/graphcli/Main.java
with
7 additions
and
32 deletions
graphdb/graphcli/src/main/java/me/schaertl/graphcli/Main.java
+
7
−
32
View file @
842ecc87
package
me.schaertl.graphcli
;
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.Repository
;
import
org.eclipse.rdf4j.repository.RepositoryConnection
;
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.RemoteRepositoryManager
;
import
org.eclipse.rdf4j.repository.manager.RepositoryManager
;
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.IOException
;
import
java.io.InputStream
;
public
class
Main
{
public
class
Main
{
private
static
void
hello
()
throws
IOException
{
private
static
void
hello
()
throws
IOException
{
// Code taken from http://graphdb.ontotext.com/documentation/standard/using-graphdb-with-the-rdf4j-api.html
// Code taken from http://graphdb.ontotext.com/documentation/standard/using-graphdb-with-the-rdf4j-api.html
//
// XXX: This code has bad error handling. The API isn't helpful, but in production code
// I would never do such things.
// Instantiate a local repository manager and initialize it
// Instantiate a local repository manager and initialize it
final
RepositoryManager
repositoryManager
=
new
RemoteRepositoryManager
(
"http://rdf:7200"
);
final
RepositoryManager
repositoryManager
=
new
RemoteRepositoryManager
(
"http://rdf:7200"
);
repositoryManager
.
init
ialize
();
repositoryManager
.
init
();
// 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"
);
final
Repository
repository
=
repositoryManager
.
getRepository
(
"chem"
);
if
(
repository
==
null
)
{
throw
new
IOException
(
"no such repository"
);
}
// Open a connection to this repository
// Open a connection to this repository
final
RepositoryConnection
repositoryConnection
=
repository
.
getConnection
();
final
RepositoryConnection
repositoryConnection
=
repository
.
getConnection
();
...
@@ -60,6 +36,5 @@ public class Main {
...
@@ -60,6 +36,5 @@ public class Main {
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
Main
.
hello
();
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