Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (51 sloc) 2.58 KB

Database Archetype Extensibility

The Stardog database archetypes provide a simple way to associate one or more ontologies and optionally a set of constraints with a database. Stardog provides two built-in database archetypes out-of-the-box: PROV and SKOS. This example shows a user-define archetype for FOAF.

Running FOAF Example

First build the jar file for this example using gradle:

$ ./gradlew jar

Copy the jar file to your Stardog installation directory and (re)start the server:

$ cp examples/foaf/build/libs/foaf-*.jar $STARDOG/server/dbms/
$ $STARDOG/bin/stardog-admin server start

Create a new database using the FOAF archetype:

$ $STARDOG/bin/stardog-admin db create -o database.archetypes="foaf" -n foafDB

That's it. Even though you created a database without any data you will see that there is a default namespace, ontology and constraints associated with this database:

$ bin/stardog namespace list foafDB
| Prefix  |                  Namespace                  |
| foaf    |                  |
| owl     |              |
| rdf     | |
| rdfs    |       |
| stardog | tag:stardog:api:                            |
| xsd     |           |
$ bin/stardog reasoning schema foafDB
foaf:publications a owl:ObjectProperty
foaf:jabberID a owl:InverseFunctionalProperty
foaf:jabberID a owl:DatatypeProperty
foaf:interest rdfs:domain foaf:Agent
foaf:workInfoHomepage a owl:ObjectProperty
foaf:schoolHomepage rdfs:range foaf:Document
foaf:status a owl:DatatypeProperty
foaf:currentProject rdfs:domain foaf:Person
$ bin/stardog icv export foafDB
AxiomConstraint{foaf:isPrimaryTopicOf a owl:InverseFunctionalProperty}

Registering Archetypes

User-defined archetypes are loaded to Stardog through JDK ServiceLoader framework. Create a file called com.complexible.stardog.db.DatabaseArchetype in the META-INF/services directory. The contents of this file should be all of the fully-qualified class names for your custom archetypes. The jar containing this META-INF/services directory as well as the implementations for the archetypes) it references is added on the classpath. Stardog will pick up the archetype implementations on startup.

You can’t perform that action at this time.