├── .gitattributes ├── .gitignore ├── .profile ├── LICENSE ├── build.gradle ├── config ├── database.properties ├── obfuscation.ttl ├── readme.md ├── stardog-cluster.yaml └── stardog.properties ├── demo-days └── data-exploration-star-wars │ ├── data │ └── orgs.csv │ ├── empire.srs │ ├── exercise.sparql │ ├── readme.md │ ├── rebels.srs │ ├── rules.srs │ └── workbook.sparql ├── examples ├── 3rd_party │ └── nifi │ │ ├── covid19-stardog.xml │ │ └── nyt-covid.sms ├── Designer Exercise - C360 │ ├── Customers.csv │ ├── Locations.csv │ └── Purchases.csv ├── JavaStardogClient │ ├── .gitattributes │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── org.eclipse.buildship.core.prefs │ ├── app │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings │ │ │ └── org.eclipse.buildship.core.prefs │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── JavaStardogClient │ │ │ │ └── App.java │ │ │ └── resources │ │ │ └── marvel.rdf │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── aml │ ├── address-mapping.ttl │ ├── aml.properties │ ├── aml_dataset_addresses.csv │ ├── aml_dataset_bank_accounts.csv │ ├── aml_dataset_companies.csv │ ├── aml_dataset_companies_accounts.csv │ ├── aml_dataset_companies_addresses.csv │ ├── aml_dataset_companies_shares.csv │ ├── aml_dataset_people.csv │ ├── aml_dataset_people_accounts.csv │ ├── aml_dataset_people_addresses.csv │ ├── aml_dataset_people_shares.csv │ ├── aml_dataset_transactions.csv │ ├── aml_rules.ttl │ ├── bank-account-mapping.ttl │ ├── company-mapping.ttl │ ├── company_account-mapping.ttl │ ├── company_address-mapping.ttl │ ├── company_shares-mapping.ttl │ ├── create_db.sh │ ├── load_transactions-mysql.sql │ ├── load_transactions.sql │ ├── namespaces.ttl │ ├── people-mapping.ttl │ ├── people_account-mapping.ttl │ ├── people_address-mapping.ttl │ ├── people_shares-mapping.ttl │ ├── queries.sparql │ ├── readme.md │ ├── transaction-mapping-sql.ttl │ └── transaction-mapping.ttl ├── analyzer │ ├── build.gradle │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── com.complexible.stardog.search.AnalyzerFactory │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ └── examples │ │ │ └── analyzer │ │ │ └── FrenchAnalyzerFactory.java │ └── readme.md ├── api │ ├── build.gradle │ ├── data │ │ ├── University0_0.owl │ │ ├── catalog.rdf │ │ ├── lubmSchema.owl │ │ ├── music_beatles.ttl │ │ ├── music_shacl.ttl │ │ ├── obfConfig.ttl │ │ ├── remove_data.nt │ │ ├── sp2b.ttl │ │ ├── starwars-schema.ttl │ │ ├── starwars.ttl │ │ └── vehicles.trig │ ├── docs │ │ ├── ConnectionAPIExample.html │ │ ├── ConnectionPoolsExample.html │ │ ├── ExplanationExample.html │ │ ├── JenaExample.html │ │ ├── ReasoningExample.html │ │ ├── WaldoAPIExample.html │ │ ├── docco.css │ │ └── public │ │ │ ├── fonts │ │ │ ├── aller-bold.eot │ │ │ ├── aller-bold.ttf │ │ │ ├── aller-bold.woff │ │ │ ├── aller-light.eot │ │ │ ├── aller-light.ttf │ │ │ ├── aller-light.woff │ │ │ ├── novecento-bold.eot │ │ │ ├── novecento-bold.ttf │ │ │ └── novecento-bold.woff │ │ │ └── stylesheets │ │ │ └── normalize.css │ ├── main │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ └── examples │ │ │ ├── TestServer.java │ │ │ ├── api │ │ │ ├── ConnectionAPIExample.java │ │ │ ├── ConnectionPoolsExample.java │ │ │ ├── GraphQLExample.java │ │ │ ├── ReasoningExample.java │ │ │ ├── ReasoningExplanationExample.java │ │ │ ├── SHACLExample.java │ │ │ └── SearchExample.java │ │ │ ├── jena │ │ │ └── JenaExample.java │ │ │ └── rdf4j │ │ │ └── RDF4JExample.java │ └── readme.md ├── cli │ ├── cluster │ │ └── terraform │ │ │ ├── README.md │ │ │ ├── base │ │ │ └── setup.sh │ │ │ ├── haproxy.tf │ │ │ ├── haproxy │ │ │ ├── haproxy.cfg.tpl │ │ │ ├── haproxy_redirect.tpl │ │ │ └── setup.sh │ │ │ ├── main.tf │ │ │ ├── outputs.tf │ │ │ ├── stardog.tf │ │ │ ├── stardog │ │ │ ├── log4j2.xml │ │ │ ├── setup.sh │ │ │ ├── stardog.properties.tpl │ │ │ ├── start.sh │ │ │ └── zk_conn_server.tpl │ │ │ ├── variables.tf.template │ │ │ ├── zookeeper.tf │ │ │ └── zookeeper │ │ │ ├── server-spec.tpl │ │ │ ├── setup.sh │ │ │ └── zoo.cfg.tpl │ └── virtual │ │ └── csv │ │ ├── cars.csv │ │ ├── cars.ttl │ │ ├── cars_autogenerate.properties │ │ ├── cars_autogenerate.ttl │ │ ├── cars_mappings.sms │ │ └── readme.md ├── connectable │ ├── build.gradle │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── com.complexible.stardog.StardogModule │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ └── examples │ │ │ └── connectable │ │ │ └── listener │ │ │ ├── ExampleConnectable.java │ │ │ ├── ExampleConnectableConnection.java │ │ │ ├── ExampleConnectableFactory.java │ │ │ ├── ExampleConnectableOption.java │ │ │ └── ExampleModule.java │ ├── readme.md │ └── test │ │ └── src │ │ └── com │ │ └── complexible │ │ └── stardog │ │ └── examples │ │ └── connectable │ │ └── listener │ │ └── ExampleConnectableTest.java ├── describe │ ├── build.gradle │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── com.complexible.stardog.plan.describe.DescribeStrategy │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ └── examples │ │ │ └── describe │ │ │ └── ExampleDescribe.java │ └── test │ │ └── src │ │ └── com │ │ └── complexible │ │ └── stardog │ │ └── examples │ │ └── describe │ │ └── TestExampleDescribe.java ├── docs │ ├── blog │ │ ├── article.txt │ │ └── person_movie.ttl │ ├── build.gradle │ ├── input.pdf │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── com.complexible.stardog.docs.extraction.RDFExtractor │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ └── examples │ │ │ └── docs │ │ │ └── WordCountExtractor.java │ ├── readme.md │ └── test │ │ └── src │ │ └── com │ │ └── complexible │ │ └── stardog │ │ └── examples │ │ └── docs │ │ └── WordCountExtractorTest.java ├── dotnet │ ├── DotNetRDFConsoleSample │ │ ├── DotNetRDFConsoleSample.csproj │ │ └── Program.cs │ ├── HttpApiConsoleSample │ │ ├── HttpApiConsoleSample.csproj │ │ └── Program.cs │ ├── README.md │ ├── StardogDotNetSamples.sln │ ├── TrinityConsoleSample │ │ ├── ObjectModels │ │ │ ├── Album.cs │ │ │ ├── Artist.cs │ │ │ ├── Band.cs │ │ │ ├── IArtist.cs │ │ │ ├── Person.cs │ │ │ ├── SoloArtist.cs │ │ │ ├── Song.cs │ │ │ └── Songwriter.cs │ │ ├── Ontologies │ │ │ ├── music_schema.ttl │ │ │ ├── rdf.ttl │ │ │ └── rdfs.ttl │ │ ├── Program.cs │ │ ├── TrinityConsoleSample.csproj │ │ └── ontologies.config │ ├── build.gradle │ └── gradle.properties ├── entity-resolution-databricks │ ├── Entity_Resolution_Blog_Data_Consumption.dbc │ ├── Entity_Resolution_Blog_Data_Preparation.dbc │ ├── er.properties │ ├── np_providers_vg.sms │ ├── op_providers_vg.sms │ ├── provider_model.ttl │ └── readme.md ├── function │ ├── build.gradle │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── com.complexible.stardog.plan.filter.functions.Function │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ ├── examples │ │ │ └── functions │ │ │ │ └── TitleCase.java │ │ │ └── plan │ │ │ └── aggregates │ │ │ └── GMean.java │ ├── readme.md │ └── test │ │ └── src │ │ └── com │ │ └── complexible │ │ └── stardog │ │ └── examples │ │ └── functions │ │ └── TestTitleCaseFunction.java ├── grafana │ ├── README.md │ ├── img │ │ ├── All_Databases_-_Grafana_1.png │ │ ├── All_Databases_-_Grafana_2.png │ │ ├── Stardog_Overview_-_Grafana_1.png │ │ ├── Stardog_Overview_-_Grafana_2.png │ │ └── stardog-import-grafana.png │ ├── prometheus-stardog-values.yaml │ ├── prometheus-static-config.yaml │ ├── stardog-databases.json │ └── stardog-overview.json ├── graph-analytics │ ├── README.md │ ├── RouterNotebook.scala │ ├── basic.ttl │ ├── build.sh │ ├── databricks_job.png │ ├── network.png │ ├── network.properties │ ├── network.sh │ ├── network.ttl │ ├── network_spark.sh │ ├── onto.ttl │ ├── onto_symmetric.ttl │ ├── router.properties │ ├── router.ttl │ ├── routers.csv │ ├── routers.sms │ ├── routers_scope.csv │ ├── run_spark.sh │ ├── scope.sms │ └── solutions.sh ├── http_handler │ ├── README.md │ ├── build.gradle │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── io.undertow.server.HttpHandler │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ └── examples │ │ │ └── handler │ │ │ └── ExtHttpHandler.java │ └── test │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── io.undertow.server.HttpHandler │ │ └── src │ │ └── com │ │ └── complexible │ │ └── stardog │ │ └── examples │ │ └── handler │ │ └── TestHttpHandler.java ├── machinelearning │ ├── 1-histogram.sparql │ ├── 2-simple_model.sparql │ ├── 2.1-score.sparql │ ├── 3-tweaked_parameters.sparql │ ├── 3.1-score.sparql │ ├── 4-predicted_ratings.sparql │ ├── 5-top_recommended_movies.sparql │ ├── 6-recommender_model.sparql │ ├── 6.1.score.sparql │ ├── 7-recommended_movies.sparql │ ├── 8-similarity_model.sparql │ ├── 9-similarity_search.sparql │ ├── delete_model.sparql │ ├── movies.ttl │ └── readme.md ├── python-client │ ├── .gitignore │ ├── requirements.txt │ └── sdclient │ │ ├── __init__.py │ │ ├── app.py │ │ └── resources │ │ └── GettingStarted_Music_Data.ttl ├── service │ ├── build.gradle │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── com.complexible.stardog.StardogModule │ │ └── src │ │ │ └── com │ │ │ └── complexible │ │ │ └── stardog │ │ │ └── examples │ │ │ └── service │ │ │ ├── ExampleService.java │ │ │ └── ExampleServiceModule.java │ └── test │ │ └── src │ │ └── com │ │ └── complexible │ │ └── stardog │ │ └── examples │ │ └── service │ │ └── TestExampleService.java ├── stardog_free │ ├── flight_planning │ │ └── flights.csv │ └── readme.md ├── virtual │ └── optimization │ │ ├── 01uniquekeys.sms │ │ ├── 01uniquekeys.sql │ │ ├── 02denormalized_songs.sql │ │ ├── 02denormalized_songs_v1.sms │ │ ├── 02denormalized_songs_v2.sms │ │ ├── 02denormalized_songs_v3.sms │ │ ├── 03denormalized.sql │ │ ├── 03denormalized_v1.sms │ │ ├── 03denormalized_v2.sms │ │ ├── 04rdftype.sql │ │ ├── 04rdftype_v1.sms │ │ ├── 04rdftype_v2.sms │ │ ├── 05dataset1_v1.sms │ │ ├── 05dataset1_v2.sms │ │ ├── 05dataset2_v1.sms │ │ ├── 05dataset2_v2.sms │ │ ├── 05predicates.sms │ │ ├── 05predicates.sql │ │ ├── 05templates.sms │ │ ├── 06functions.sms │ │ ├── 06functions.sql │ │ ├── examples.properties │ │ ├── examples.rq │ │ ├── examples.sh │ │ └── readme.md └── workbook.sparql ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── readme.md ├── settings.gradle └── weblog ├── beaches.zip ├── readme.md ├── stardog-client ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── java │ └── com │ │ └── stardog │ │ └── examples │ │ ├── StardogAdmin.java │ │ ├── StardogClient.java │ │ └── StardogSpringClient.java │ └── resources │ ├── applicationContext.xml │ ├── foaf.rdf │ ├── marvel.rdf │ └── marvel_v2.rdf └── stardog-d3 ├── css ├── style_1.css └── tabs.css ├── demo.html ├── images ├── Info_Simple.svg ├── stardog-logo.png └── stardog.png ├── js ├── Console2.js ├── babel.min.js ├── d3.v5.js ├── lodash.core.min.js ├── lodash.js ├── prop-types.js ├── react-dom.production.min.js ├── react.min.js ├── stardog.js ├── stardog.min.js └── stardogd3.js └── stardogDemo.ttl /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set the merge driver for project and solution files 8 | # 9 | # Merging from the command prompt will add diff markers to the files if there 10 | # are conflicts (Merging from VS is not affected by the settings below, in VS 11 | # the diff markers are never inserted). Diff markers may cause the following 12 | # file extensions to fail to load in VS. An alternative would be to treat 13 | # these files as binary and thus will always conflict and require user 14 | # intervention with every merge. 15 | ############################################################################### 16 | 17 | *.sln text eol=crlf 18 | *.csproj text eol=crlf 19 | *.vbproj text eol=crlf 20 | *.vcxproj text eol=crlf 21 | *.vcproj text eol=crlf 22 | *.dbproj text eol=crlf 23 | *.fsproj text eol=crlf 24 | *.lsproj text eol=crlf 25 | *.wixproj text eol=crlf 26 | *.modelproj text eol=crlf 27 | *.sqlproj text eol=crlf 28 | *.wmaproj text eol=crlf 29 | 30 | *.xproj text eol=crlf 31 | *.props text eol=crlf 32 | *.filters text eol=crlf 33 | *.vcxitems text eol=crlf 34 | -------------------------------------------------------------------------------- /.profile: -------------------------------------------------------------------------------- 1 | JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/ 2 | export JAVA_HOME; -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | ext { 4 | stardogVersion = project.hasProperty("stardogVersion") ? project.getProperty("stardogVersion") : '9.0.0' 5 | projectVersion = '0.0.6' 6 | 7 | distPath = "${projectDir}/dist" 8 | stardogRepo = project.hasProperty("stardogRepo") ? project.getProperty("stardogRepo") : "http://maven.stardog.com" 9 | stardogLib = project.hasProperty("stardogLib") ? project.getProperty("stardogLib") : "." 10 | 11 | guavaVersion = "33.2.1-jre" 12 | junitVersion = "4.12" 13 | rdf4jRuntimeVersion = "2.2.4" 14 | slf4jVersion = "2.0.13" 15 | } 16 | 17 | allprojects { 18 | apply plugin: 'idea' 19 | group = 'com.complexible.stardog' 20 | version = projectVersion 21 | // also configure in idea.gradle 22 | sourceCompatibility = '11' 23 | targetCompatibility = '11' 24 | 25 | repositories { 26 | maven { 27 | url stardogRepo 28 | } 29 | mavenLocal() 30 | mavenCentral() 31 | maven { 32 | url 'https://jitpack.io' 33 | } 34 | 35 | } 36 | 37 | tasks.withType(Test) { 38 | systemProperty 'stardog.home', rootProject.projectDir 39 | systemProperty 'java.library.path', project.stardogLib 40 | } 41 | } 42 | 43 | subprojects { 44 | apply plugin: "java" 45 | 46 | // common deps 47 | dependencies { 48 | implementation("com.google.guava:guava:$guavaVersion") { 49 | version { 50 | require "$guavaVersion" 51 | } 52 | exclude group: "com.google.code.findbugs" 53 | exclude group: "com.google.guava", module: "failureaccess" 54 | } 55 | implementation "org.slf4j:slf4j-api:$slf4jVersion" 56 | implementation "org.slf4j:slf4j-jdk14:$slf4jVersion" 57 | 58 | testImplementation "junit:junit:$junitVersion" 59 | } 60 | 61 | sourceSets { 62 | all { 63 | // work around a Gradle-metadata bug introduced in Guava v32.1.0 64 | configurations.all { 65 | attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm") 66 | } 67 | } 68 | main { 69 | java { 70 | srcDir 'main/src' 71 | } 72 | resources { 73 | srcDir 'main/resources' 74 | } 75 | } 76 | test { 77 | java { 78 | srcDir 'test/src' 79 | } 80 | resources { 81 | srcDir 'test/resources' 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /config/database.properties: -------------------------------------------------------------------------------- 1 | database.name = configDB 2 | 3 | index.named.graphs = true 4 | index.literals.canonical = true 5 | index.differential.enable.limit = 100000 6 | index.differential.merge.limit = 1000 7 | 8 | reasoning.schema.graphs = default , http\://www.example.org/mySchema 9 | reasoning.punning.enabled = false 10 | 11 | icv.enabled = true 12 | icv.reasoning.enabled = true 13 | icv.active.graphs = * 14 | 15 | search.enabled = true 16 | 17 | transactions.durable = false 18 | 19 | -------------------------------------------------------------------------------- /config/obfuscation.ttl: -------------------------------------------------------------------------------- 1 | # This is an example configuration file that can be used for 2 | # the obfuscation commands. This configuration file is an 3 | # extended version of the default which does not obfuscate 4 | # rules, Stardog filter functions, and magic properties. 5 | 6 | # Default namespace will be used as the base URI of the output 7 | @prefix : . 8 | 9 | # Namespaces that will be used in pattern specification 10 | # These namespaces will also be used in the output RDF 11 | @prefix rdf: . 12 | @prefix rdfs: . 13 | @prefix owl: . 14 | @prefix xsd: . 15 | @prefix stardog: . 16 | @prefix swrl: . 17 | @prefix swrlb: . 18 | @prefix xpath: . 19 | @prefix math: . 20 | 21 | # Obfuscation namespace is used only for parsing the config file 22 | @prefix obf: . 23 | 24 | 25 | [] a obf:Obfuscation ; 26 | 27 | # Message digest algorithm that will be used to obfuscate terms 28 | # Should be a message digest algorithm supported by Java 29 | obf:digest "SHA-256" ; 30 | 31 | # Any URI and literal value will be pattern matched with the filters. 32 | # Only the values that match the include pattern and do not match the 33 | # exclude pattern will be obfuscated. 34 | 35 | # The patterns in a filter expression has a position identifier which 36 | # is one of [any, subject, predicate, object]. The pattern will be 37 | # applied to a value depending on the position of the value. 38 | # For example, it is possible to write filter expressions 39 | # such that the same URI will be obfuscated when it is used in the 40 | # subject position but not in the object position. The pattern 41 | # expression should be a valid Java regular expression. For more 42 | # information, see: 43 | # http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html 44 | 45 | obf:include [ 46 | obf:position obf:any ; 47 | obf:pattern ".*" 48 | ] ; 49 | 50 | # Filter expression may just refer to a namespace which means any URI 51 | # belonging to that namespace will be matched. The value of the 52 | # namespace should be defined in the namespaces declaration. 53 | 54 | obf:exclude [ 55 | obf:position obf:any ; 56 | obf:namespace "rdf" 57 | ] ; 58 | obf:exclude [ 59 | obf:position obf:any ; 60 | obf:namespace "owl" 61 | ] ; 62 | obf:exclude [ 63 | obf:position obf:predicate ; 64 | obf:namespace "rdfs" 65 | ] ; 66 | obf:exclude [ 67 | obf:position obf:any ; 68 | obf:namespace "stardog" 69 | ] ;; 70 | obf:exclude [ 71 | obf:position obf:any ; 72 | obf:namespace "swrl" 73 | ] ; 74 | obf:exclude [ 75 | obf:position obf:any ; 76 | obf:namespace "swrlb" 77 | ] ; 78 | obf:exclude [ 79 | obf:position obf:any ; 80 | obf:namespace "xpath" 81 | ] ; 82 | obf:exclude [ 83 | obf:position obf:any ; 84 | obf:namespace "math" 85 | ] . 86 | -------------------------------------------------------------------------------- /config/readme.md: -------------------------------------------------------------------------------- 1 | # Configuration Examples 2 | 3 | ## database.properties 4 | 5 | An example of a configuration file that can be provided to the `db create` command of the Stardog CLI to define database metadata for the newly created database. 6 | 7 | ## stardog.properties 8 | 9 | A properties file showing all of the valid properties for the Stardog server, their usage, and a short discussion for each. 10 | 11 | ## obfuscation.ttl 12 | 13 | A configuration file that can be used for `data obfuscate` and `query obfuscate` commands to customize how database contents will be obfuscated. 14 | 15 | ## stardog-cluster.yaml 16 | 17 | A Kubernetes configuration file for a complete Stardog Cluster deployment (including 3 node ZooKeeper ensemble). 18 | You must provide base64-encoded strings of your Artifactory credentials (to get the Stardog Docker image) and a 19 | Stardog License, replacing `` and `` 20 | in the file before you apply it via `kubectl -f stardog-cluster.yaml`. 21 | 22 | -------------------------------------------------------------------------------- /demo-days/data-exploration-star-wars/data/orgs.csv: -------------------------------------------------------------------------------- 1 | name,parent 2 | Kuat Drive Yards,Techno Union 3 | Kuat Systems Engineering,Kuat Drive Yards 4 | Sienar Fleet Systems,Sienar Technologies 5 | Incom Corporation, 6 | Corellian Engineering Corporation,Techno Union 7 | Techno Union, 8 | Corellian Arms,Corellian Engineering Corporation 9 | Geonosian Industries,Techno Union 10 | Baktoid Industries, 11 | Trade Federation, 12 | Sienar Technologies,Santhe Corporation 13 | Santhe Corporation, 14 | Cygnus Spaceworks, 15 | Subpro Corporation, 16 | Nubia Star Drives, 17 | Theed Palace Space Vessel Engineering Corps, 18 | Galactic Republic, 19 | Galactic Senate,Galactic Republic 20 | Rebel Alliance, 21 | Rebel Alliance Navy,Rebel Alliance Military 22 | New Republic, 23 | Galactic Empire, 24 | First Order, 25 | Final Order, 26 | Jedi Council,Jedi Order 27 | Starfighter Corps,Rebel Alliance Navy 28 | Red Squadron,Starfighter Corps 29 | Gold Squadron,Starfighter Corps 30 | Green Squadron,Starfighter Corps 31 | Galactic Navy, 32 | Army of the Republic,Galactic Republic 33 | Black Squadron,Galactic Navy 34 | Inferno Squadron,Galactic Navy 35 | Resistance, 36 | Sapphire Squadron,Galactic Navy 37 | Blade Squadron,Starfighter Corps 38 | Blue Squadron,Starfighter Corps 39 | Corona Squadron,Starfighter Corps 40 | Grey Squadron,Starfighter Corps 41 | Jedi Order, 42 | Rebel Alliance Military,Rebel Alliance 43 | Rebel Alliance Army,Rebel Alliance Military -------------------------------------------------------------------------------- /demo-days/data-exploration-star-wars/empire.srs: -------------------------------------------------------------------------------- 1 | prefix : 2 | 3 | # 24) Defining the enemies of the Empire 4 | :EnemiesOfTheEmpire rdfs:label "The entire rebel alliance are enemies as well as the Jedi." 5 | Rule :EnemiesOfTheEmpire 6 | if { 7 | { 8 | ?person :modelConceptRelationship:member :modelConceptClass:Organization-Rebel%20Alliance 9 | } union { 10 | ?person a :modelConceptClass:Jedi . 11 | } 12 | } 13 | then { 14 | ?person a :modelConceptClass:Enemy . 15 | } -------------------------------------------------------------------------------- /demo-days/data-exploration-star-wars/rebels.srs: -------------------------------------------------------------------------------- 1 | prefix : 2 | 3 | # 23) defining the enemies of the Rebel Alliance 4 | Rule :EnemiesOfTheRebels 5 | if { 6 | ?person :modelConceptRelationship:member :modelConceptClass:Organization-Galactic%20Empire 7 | } 8 | then { 9 | ?person a :modelConceptClass:Enemy . 10 | } -------------------------------------------------------------------------------- /demo-days/data-exploration-star-wars/workbook.sparql: -------------------------------------------------------------------------------- 1 | prefix kg: 2 | 3 | # # Overview 4 | # This is a simple Stardog Knowledge Graph workbook 5 | # Below you will find a number of example queries that you can use 6 | # to explore your knowledge graph. Simply place your cursor in the query 7 | # you want to execute and hit the "Run" button. Make sure you've selected 8 | # any runtime configuration, such the database to execute against, or 9 | # whether or not to use reasoning, prior to executing. 10 | 11 | # Return a list of all sub-graphs in your knowledge graph 12 | select DISTINCT ?g { graph ?g {} } 13 | 14 | # Return the contents of specified graph as a table 15 | select distinct ?s ?p ?o where { bind( as ?g) graph ?g { ?s ?p ?o } } 16 | 17 | # Return the specified graph as a graph 18 | construct { ?s ?p ?o } where { bind( as ?g) graph ?g { ?s ?p ?o } } 19 | 20 | # Return all classes 21 | select DISTINCT ?cls from kg:local { ?cls a owl:Class } order by ?cls 22 | 23 | # Return all defined properties 24 | select DISTINCT ?p from kg:local { { ?p a owl:DatatypeProperty } union {?p a owl:ObjectProperty} union { ?p a rdf:Property } } order by ?p 25 | 26 | # Return all properties in use, regardless of whether or not they've been defined 27 | select DISTINCT ?p from kg:local { ?s ?p ?o } order by ?p 28 | 29 | # return all instances of a particular classes 30 | select DISTINCT ?cls from kg:local { ?cls a } order by ?cls 31 | 32 | # Delete everything, use with caution 33 | DELETE WHERE { graph ?g { ?s ?p ?o } } 34 | 35 | # delete a specific graph 36 | clear silent graph -------------------------------------------------------------------------------- /examples/3rd_party/nifi/nyt-covid.sms: -------------------------------------------------------------------------------- 1 | # A basic SMS2 mapping. 2 | MAPPING 3 | FROM CSV { 4 | } 5 | TO { 6 | ?reportIRI a :Report ; 7 | :county ?countyIRI ; 8 | :date ?dateTyped ; 9 | :cases ?casesTyped ; 10 | :deaths ?deathsTyped . 11 | ?countyIRI a :County ; 12 | rdfs:label ?county ; 13 | :state ?stateIRI ; 14 | :fips ?fips . 15 | ?stateIRI a :State ; 16 | rdfs:label ?state. 17 | } 18 | WHERE { 19 | BIND(xsd:date(?date) AS ?dateTyped) 20 | BIND(xsd:integer(?cases) AS ?casesTyped) 21 | BIND(xsd:integer(?deaths) AS ?deathsTyped) 22 | BIND(TEMPLATE("http://api.stardog.com/County{fips}") AS ?countyIRI) 23 | BIND(TEMPLATE("http://api.stardog.com/{state}") AS ?stateIRI) 24 | BIND(UUID() AS ?reportIRI) 25 | } 26 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | # Compiled class file 8 | *.class 9 | 10 | # Log file 11 | *.log 12 | 13 | # BlueJ files 14 | *.ctxt 15 | 16 | # Mobile Tools for Java (J2ME) 17 | .mtj.tmp/ 18 | 19 | # Package Files # 20 | *.jar 21 | *.war 22 | *.nar 23 | *.ear 24 | *.zip 25 | *.tar.gz 26 | *.rar 27 | 28 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 29 | hs_err_pid* 30 | replay_pid* 31 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaStardogClient 4 | Project JavaStardogClient created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | 19 | 1636478069926 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments= 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir= 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | app 4 | Project app created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | 25 | 1636478069930 26 | 27 | 30 28 | 29 | org.eclipse.core.resources.regexFilterMatcher 30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/app/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir=.. 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | 4 | group 'org.example' 5 | version '1.0-SNAPSHOT' 6 | 7 | repositories { 8 | maven { url "https://maven.stardog.com" } 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | implementation('com.complexible.stardog:client-http:7.7.2') 14 | } 15 | 16 | application { 17 | mainClass = 'JavaStardogClient.App' 18 | } 19 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/app/src/main/resources/marvel.rdf: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix foaf: . 3 | 4 | :incredibleHulk rdf:type foaf:Person ; 5 | foaf:name "Robert Bruce Banner"^^xsd:string ; 6 | foaf:title "Incredible Hulk"^^xsd:string ; 7 | foaf:givenname "Robert"^^xsd:string ; 8 | foaf:family_name "Banner"^^xsd:string ; 9 | foaf:knows :captainAmerica, :blackWidow, :thor, :ironMan . 10 | 11 | :captainAmerica rdf:type foaf:Person ; 12 | foaf:name "Steven Rogers"^^xsd:string ; 13 | foaf:title "Captian America"^^xsd:string ; 14 | foaf:givenname "Steven"^^xsd:string ; 15 | foaf:family_name "Rogers"^^xsd:string ; 16 | foaf:nick "Steve"^^xsd:string ; 17 | foaf:knows :incredibleHulk, :blackWidow, :thor, :ironMan . 18 | 19 | :thor rdf:type foaf:Person ; 20 | foaf:name "Thor Odinson"^^xsd:string ; 21 | foaf:title "Thor"^^xsd:string ; 22 | foaf:givenname "Thor"^^xsd:string ; 23 | foaf:family_name "Odinson"^^xsd:string ; 24 | foaf:knows :incredibleHulk, :blackWidow, :captainAmerica, :ironMan . 25 | 26 | :blackWidow rdf:type foaf:Person ; 27 | foaf:name "Natalia Alianovna Romanova"^^xsd:string ; 28 | foaf:title "Black Widow"^^xsd:string ; 29 | foaf:givenname "Natalia"^^xsd:string ; 30 | foaf:family_name "Romanova"^^xsd:string ; 31 | foaf:nick "Natasha"^^xsd:string ; 32 | foaf:knows :incredibleHulk, :thor, :captainAmerica, :ironMan . -------------------------------------------------------------------------------- /examples/JavaStardogClient/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/JavaStardogClient/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/JavaStardogClient/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /examples/JavaStardogClient/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.2/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'JavaStardogClient' 11 | include('app') 12 | -------------------------------------------------------------------------------- /examples/aml/address-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix wgs: . 3 | 4 | :Address-{id} a :Address ; 5 | :city "{city}" ; 6 | :country "{country}" ; 7 | wgs:lat "{lat}"^^xsd:decimal ; 8 | wgs:long "{long}"^^xsd:decimal ; 9 | :zipCode "{zip_code}" ; 10 | :street "{street}" ; 11 | . 12 | -------------------------------------------------------------------------------- /examples/aml/aml.properties: -------------------------------------------------------------------------------- 1 | base=tag:stardog:demo:aml: 2 | 3 | jdbc.url=jdbc:mysql://localhost/stardog 4 | jdbc.username=admin 5 | jdbc.password=admin 6 | jdbc.driver=com.mysql.jdbc.Driver 7 | parser.sql.quoting=ANSI 8 | -------------------------------------------------------------------------------- /examples/aml/aml_dataset_companies_shares.csv: -------------------------------------------------------------------------------- 1 | company1,company2,share 2 | 12,732,51 3 | 20,759,93 4 | 28,355,51 5 | 40,767,40 6 | 44,61,48 7 | 45,609,20 8 | 50,707,35 9 | 68,876,37 10 | 82,139,66 11 | 93,516,20 12 | 102,547,50 13 | 117,711,27 14 | 128,999,65 15 | 148,589,35 16 | 152,700,1 17 | 152,835,15 18 | 157,174,42 19 | 172,434,51 20 | 173,764,44 21 | 177,73,32 22 | 178,778,40 23 | 182,998,1 24 | 192,131,42 25 | 217,150,37 26 | 224,240,26 27 | 225,179,90 28 | 231,463,70 29 | 240,635,70 30 | 246,102,33 31 | 253,297,80 32 | 256,707,15 33 | 264,952,9 34 | 264,327,15 35 | 268,36,12 36 | 272,569,50 37 | 282,262,1 38 | 297,690,100 39 | 299,2,42 40 | 331,707,50 41 | 353,932,37 42 | 365,628,8 43 | 376,297,6 44 | 386,109,53 45 | 386,275,75 46 | 388,20,30 47 | 392,543,27 48 | 395,488,50 49 | 401,289,100 50 | 410,77,9 51 | 413,989,46 52 | 416,825,79 53 | 442,107,56 54 | 450,783,12 55 | 451,786,79 56 | 453,245,5 57 | 456,82,63 58 | 471,93,85 59 | 472,667,70 60 | 486,664,55 61 | 494,857,57 62 | 505,170,92 63 | 507,785,60 64 | 510,677,21 65 | 526,562,13 66 | 546,678,13 67 | 561,807,72 68 | 568,299,63 69 | 598,778,37 70 | 598,478,51 71 | 614,926,4 72 | 639,395,40 73 | 641,954,24 74 | 644,74,1 75 | 654,997,78 76 | 656,486,50 77 | 663,674,28 78 | 665,330,58 79 | 666,806,26 80 | 676,664,75 81 | 677,851,77 82 | 689,626,56 83 | 690,309,54 84 | 704,480,68 85 | 707,630,55 86 | 709,1000,88 87 | 724,41,1 88 | 747,595,13 89 | 749,122,38 90 | 768,28,16 91 | 770,981,82 92 | 785,999,35 93 | 801,316,50 94 | 805,416,89 95 | 818,705,43 96 | 820,906,93 97 | 835,163,3 98 | 837,172,100 99 | 860,573,38 100 | 864,706,25 101 | 881,657,100 102 | 886,828,39 103 | 908,5,11 104 | 916,201,100 105 | 918,518,100 106 | 965,939,6 107 | 981,51,91 108 | -------------------------------------------------------------------------------- /examples/aml/aml_dataset_people_shares.csv: -------------------------------------------------------------------------------- 1 | person,company,share 2 | 25,962,1 3 | 29,679,14 4 | 30,861,51 5 | 80,727,42 6 | 80,767,60 7 | 99,386,66 8 | 118,783,64 9 | 125,445,31 10 | 151,363,1 11 | 160,457,18 12 | 162,644,27 13 | 176,165,100 14 | 190,968,11 15 | 194,145,72 16 | 214,401,100 17 | 259,734,81 18 | 299,669,90 19 | 300,355,49 20 | 324,328,38 21 | 335,9,50 22 | 343,129,66 23 | 374,127,33 24 | 374,589,65 25 | 378,645,86 26 | 418,52,100 27 | 431,529,5 28 | 438,842,47 29 | 466,555,52 30 | 466,385,100 31 | 471,341,33 32 | 499,548,13 33 | 515,425,56 34 | 523,668,21 35 | 527,380,9 36 | 548,949,48 37 | 559,176,44 38 | 592,422,87 39 | 598,60,51 40 | 599,683,100 41 | 669,623,47 42 | 676,361,7 43 | 696,15,87 44 | 722,194,64 45 | 737,565,50 46 | 768,438,86 47 | 772,455,51 48 | 772,555,51 49 | 793,562,65 50 | 834,725,5 51 | 836,336,77 52 | 842,801,66 53 | 851,18,26 54 | 870,80,70 55 | 876,1000,3 56 | 908,766,12 57 | 916,926,36 58 | 979,475,75 59 | -------------------------------------------------------------------------------- /examples/aml/aml_rules.ttl: -------------------------------------------------------------------------------- 1 | IF { 2 | ?x :holds ?holding . 3 | ?holding :company ?c . 4 | ?holding :share ?share . 5 | filter (?share >= 50) 6 | } 7 | THEN { 8 | ?x :hasAffiliation ?c . 9 | ?c :hasAffiliation ?x . 10 | } 11 | 12 | IF { 13 | ?x :hasAddress ?a . 14 | ?y :hasAddress ?a . 15 | filter (?x != ?y) 16 | } 17 | THEN { 18 | ?x :hasAffiliation ?y . 19 | } 20 | -------------------------------------------------------------------------------- /examples/aml/bank-account-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :BankAccount-{number} a :BankAccount ; 4 | :number "{number}" ; 5 | :balance "{total}"^^xsd:decimal ; 6 | . -------------------------------------------------------------------------------- /examples/aml/company-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Company-{id} a :Company ; 4 | :name "{name}" ; 5 | :description "{description}" ; 6 | . -------------------------------------------------------------------------------- /examples/aml/company_account-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Company-{company} :hasBankAccount :BankAccount-{account} . 4 | -------------------------------------------------------------------------------- /examples/aml/company_address-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Company-{company} :hasAddress :Address-{address} . 4 | -------------------------------------------------------------------------------- /examples/aml/company_shares-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Company-{company1} :holds :Holding-C{company1}-{company2} . 4 | :Holding-C{company1}-{company2} a :Holding ; 5 | :company :Company-{company2} ; 6 | :share "{share}"^^xsd:integer . 7 | -------------------------------------------------------------------------------- /examples/aml/create_db.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | 5 | DB=fraud_demo 6 | 7 | stardog-admin db drop $DB 8 | 9 | stardog-admin db create -o spatial.enabled=true -o search.enabled=true -n $DB 10 | stardog namespace add $DB --prefix "" --uri tag:stardog:demo:aml: 11 | stardog namespace add $DB --prefix wgs --uri http://www.w3.org/2003/01/geo/wgs84_pos# 12 | 13 | stardog-admin virtual import $DB address-mapping.ttl aml_dataset_addresses.csv 14 | stardog-admin virtual import $DB bank-account-mapping.ttl aml_dataset_bank_accounts.csv 15 | stardog-admin virtual import $DB company-mapping.ttl aml_dataset_companies.csv 16 | stardog-admin virtual import $DB people-mapping.ttl aml_dataset_people.csv 17 | 18 | # These files allow multiple people and companies to share addresses 19 | stardog-admin virtual import $DB company_address-mapping.ttl aml_dataset_companies_addresses.csv 20 | stardog-admin virtual import $DB people_address-mapping.ttl aml_dataset_people_addresses.csv 21 | 22 | stardog-admin virtual import $DB company_account-mapping.ttl aml_dataset_companies_accounts.csv 23 | stardog-admin virtual import $DB people_account-mapping.ttl aml_dataset_people_accounts.csv 24 | 25 | stardog-admin virtual import $DB company_shares-mapping.ttl aml_dataset_companies_shares.csv 26 | stardog-admin virtual import $DB people_shares-mapping.ttl aml_dataset_people_shares.csv 27 | 28 | # Uncomment this line to import transactions into Stardog 29 | stardog-admin virtual import $DB transaction-mapping.ttl aml_dataset_transactions.csv 30 | 31 | # Or, comment the prior line and uncomment these lines to load the transactions into MySQL 32 | # Alternatively, can use load_transactions.sql instead of load_transactions-mysql.sql 33 | #mysql -uadmin -padmin -hlocalhost stardog < load_transactions-mysql.sql 34 | #stardog-admin virtual add aml.properties transaction-mapping-sql.ttl 35 | 36 | stardog data add -g graph:schema $DB aml_rules.ttl 37 | -------------------------------------------------------------------------------- /examples/aml/load_transactions-mysql.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `stardog`; 2 | 3 | USE `stardog`; 4 | 5 | DROP TABLE IF EXISTS `transactions`; 6 | 7 | CREATE TABLE `transactions` ( 8 | `tx_id` INTEGER PRIMARY KEY, 9 | `account1` VARCHAR(20), 10 | `account2` VARCHAR(20), 11 | `amount` INTEGER, 12 | `tx_date` DATE 13 | ); 14 | 15 | LOAD DATA LOCAL INFILE 16 | 'C:/@cyg/demos/aml/raw/aml_dataset_transactions.csv' 17 | INTO TABLE `transactions` 18 | FIELDS TERMINATED BY ',' 19 | -- Change line termination to \r\n for Windows 20 | LINES TERMINATED BY '\n' 21 | IGNORE 1 ROWS 22 | (`tx_id`,`account1`,`account2`,`amount`,`tx_date`); 23 | 24 | CREATE INDEX `account1` ON `transactions` (`account1`); 25 | 26 | CREATE INDEX `account2` ON `transactions` (`account2`); 27 | 28 | CREATE INDEX `account1_2` ON `transactions` (`account1`, `account2`); 29 | 30 | -------------------------------------------------------------------------------- /examples/aml/namespaces.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix geo: . 3 | @prefix owl: . 4 | @prefix qudt: . 5 | @prefix rdf: . 6 | @prefix rdfs: . 7 | @prefix stardog: . 8 | @prefix wgs: . 9 | @prefix xsd: . 10 | @prefix swrlb: . 11 | -------------------------------------------------------------------------------- /examples/aml/people-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Person-{id} a :Person ; 4 | :firstName "{first_name}" ; 5 | :lastName "{last_name}" ; 6 | :email "{email}" ; 7 | :country "{country}" ; 8 | . -------------------------------------------------------------------------------- /examples/aml/people_account-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Person-{person} :hasBankAccount :BankAccount-{account} . 4 | -------------------------------------------------------------------------------- /examples/aml/people_address-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Person-{person} :hasAddress :Address-{address} . 4 | -------------------------------------------------------------------------------- /examples/aml/people_shares-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :Person-{person} :holds :Holding-P{person}-{company} . 4 | :Holding-P{person}-{company} a :Holding ; 5 | :company :Company-{company} ; 6 | :share "{share}"^^xsd:integer . 7 | -------------------------------------------------------------------------------- /examples/aml/transaction-mapping-sql.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix sm: . 3 | 4 | :BankAccount-{account1} :originated :Tx-{tx_id} ; 5 | sm:map [ 6 | sm:table "transactions" ; 7 | ] . 8 | 9 | :Tx-{tx_id} a :Transaction ; 10 | :beneficiary :BankAccount-{account2} ; 11 | :amount "{amount}"^^xsd:integer ; 12 | :date "{tx_date}"^^xsd:date ; 13 | sm:map [ 14 | sm:table "transactions" ; 15 | ] . 16 | -------------------------------------------------------------------------------- /examples/aml/transaction-mapping.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :BankAccount-{account1} :originated :Tx-{tx_id} . 4 | :Tx-{tx_id} a :Transaction ; 5 | :beneficiary :BankAccount-{account2} ; 6 | :amount "{amount}"^^xsd:integer ; 7 | :date "{tx_date}"^^xsd:date . -------------------------------------------------------------------------------- /examples/analyzer/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.complexible.stardog.examples.analyzer" 2 | 3 | dependencies { 4 | implementation "org.apache.lucene:lucene-analyzers-common:4.7.2" 5 | 6 | implementation platform("com.complexible.stardog:server:${stardogVersion}") 7 | } 8 | -------------------------------------------------------------------------------- /examples/analyzer/main/resources/META-INF/services/com.complexible.stardog.search.AnalyzerFactory: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.analyzer.FrenchAnalyzerFactory -------------------------------------------------------------------------------- /examples/analyzer/main/src/com/complexible/stardog/examples/analyzer/FrenchAnalyzerFactory.java: -------------------------------------------------------------------------------- 1 | package com.complexible.stardog.examples.analyzer; 2 | 3 | import com.complexible.stardog.search.AnalyzerFactory; 4 | import org.apache.lucene.analysis.Analyzer; 5 | import org.apache.lucene.analysis.fr.FrenchAnalyzer; 6 | import org.apache.lucene.util.Version; 7 | 8 | /** 9 | *

10 | * 11 | * @author Michael Grove 12 | * @since 3.0 13 | * @version 4.0 14 | */ 15 | public final class FrenchAnalyzerFactory implements AnalyzerFactory { 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | @Override 21 | public Analyzer get() { 22 | return new FrenchAnalyzer(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/analyzer/readme.md: -------------------------------------------------------------------------------- 1 | # Custom Analyzers 2 | 3 | By default, the full-text index in Stardog uses Lucene's 4 | [StandardAnalyzer](https://lucene.apache.org/core/4_7_2/analyzers-common/org/apache/lucene/analysis/standard/StandardAnalyzer.html). 5 | 6 | However, any class implementing `org.apache.lucene.analysis.Analyzer` can be used in place of the default analyzer. To 7 | specify a different `Analyzer` a service named `com.complexible.stardog.search.AnalyzerFactory` should be registered. 8 | `AnalyzerFactory` returns the desired `Analyzer` implementation to be used when creating the Lucene index from the 9 | RDF contained in the database. 10 | 11 | This is an example of an AnalyzerFactory which uses the built-in Lucene analyzer for the French language: 12 | 13 | ```java 14 | public final class FrenchAnalyzerFactory implements AnalyzerFactory { 15 | 16 | /** 17 | * {@inheritDoc} 18 | */ 19 | @Override 20 | public Analyzer get() { 21 | return new FrenchAnalyzer(Version.LUCENE_47); 22 | } 23 | } 24 | ``` 25 | 26 | 27 | Any of the [common Lucene analyzers](https://lucene.apache.org/core/4_7_2/analyzers-common/index.html) can be used as 28 | well as any custom implementation of `Analyzer`. In the latter case, be sure your implementation is in Stardog's 29 | class path. 30 | 31 | Create a file called `com.complexible.stardog.search.AnalyzerFactory` in the `META-INF/services` directory. 32 | The contents of this file should be the *fully-qualified* class name of your `AnalyzerFactory`. The 33 | jar containing this `META-INF/services` directory as well as the implementation for the class it references is then 34 | added on the classpath. Stardog will pick up the implementation on startup by using the JDK `ServiceLoader` framework. 35 | 36 | Note, as of Stardog 3.0, only *one* `AnalyzerFactory` can be registered at a time, attempts to register more than one 37 | will yield errors on startup. 38 | -------------------------------------------------------------------------------- /examples/api/data/music_beatles.ttl: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX rdf: 3 | PREFIX xsd: 4 | PREFIX sh: 5 | 6 | :The_Beatles rdf:type :Band . 7 | :The_Beatles :name "The Beatles" . 8 | :The_Beatles :member :John_Lennon . 9 | :The_Beatles :member :Paul_McCartney . 10 | :The_Beatles :member :Ringo_Starr . 11 | :The_Beatles :member :George_Harrison . 12 | :John_Lennon rdf:type :SoloArtist . 13 | :Paul_McCartney rdf:type :SoloArtist . 14 | :Ringo_Starr rdf:type :SoloArtist . 15 | :George_Harrison rdf:type :SoloArtist . 16 | :Please_Please_Me rdf:type :Album . 17 | :Please_Please_Me :name "Please Please Me" . 18 | :Please_Please_Me :date "1963-03-22"^^xsd:date . 19 | :Please_Please_Me :artist :The_Beatles . 20 | :Please_Please_Me :track :Love_Me_Do . 21 | :Love_Me_Do rdf:type :Song . 22 | :Love_Me_Do :name "Love Me Do" . 23 | :Love_Me_Do :length 125 . 24 | :Love_Me_Do :writer :John_Lennon . 25 | :Love_Me_Do :writer :Paul_McCartney . 26 | 27 | :McCartney rdf:type :Album . 28 | :McCartney :name "McCartney" . 29 | :McCartney :date "1970-04-17"^^xsd:date . 30 | :McCartney :artist :Paul_McCartney . 31 | 32 | :Imagine rdf:type :Album . 33 | :Imagine :name "Imagine" . 34 | :Imagine :date "1971-10-11"^^xsd:date . 35 | :Imagine :artist :John_Lennon . -------------------------------------------------------------------------------- /examples/api/data/music_shacl.ttl: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | PREFIX sh: 3 | prefix xsd: 4 | 5 | :NameShape a sh:NodeShape ; 6 | sh:property [ 7 | sh:path :name ; 8 | sh:minCount 1 ; 9 | sh:datatype xsd:string 10 | ] . 11 | 12 | :ArtistShape a sh:NodeShape ; 13 | sh:targetClass :Artist ; 14 | sh:node :NameShape . 15 | 16 | :BandShape a sh:NodeShape ; 17 | sh:targetClass :Band ; 18 | sh:not [ sh:class :Person ] ; 19 | sh:property :BandMemberShape . 20 | 21 | :BandMemberShape a sh:PropertyShape ; 22 | sh:path :member ; 23 | sh:minCount 1 ; 24 | sh:class :SoloArtist . 25 | 26 | :AlbumShape a sh:NodeShape ; 27 | sh:targetClass :Album ; 28 | sh:node :NameShape ; 29 | sh:property :AlbumDateShape ; 30 | sh:property :AlbumArtistShape ; 31 | sh:property :AlbumTrackShape . 32 | 33 | :AlbumDateShape a sh:PropertyShape ; 34 | sh:path :date ; 35 | sh:minCount 1 ; 36 | sh:maxCount 1 ; 37 | sh:datatype xsd:date . 38 | 39 | :AlbumArtistShape a sh:PropertyShape ; 40 | sh:path :artist ; 41 | sh:minCount 1 ; 42 | sh:class :Artist . 43 | 44 | :AlbumTrackShape a sh:PropertyShape ; 45 | sh:path :track ; 46 | sh:minCount 1 ; 47 | sh:class :Song . 48 | 49 | :SongShape a sh:NodeShape ; 50 | sh:targetClass :Song ; 51 | sh:node :NameShape ; 52 | sh:property :SongLengthShape . 53 | 54 | :SongLengthShape a sh:PropertyShape ; 55 | sh:path :length ; 56 | sh:datatype xsd:integer . 57 | -------------------------------------------------------------------------------- /examples/api/data/obfConfig.ttl: -------------------------------------------------------------------------------- 1 | # This is an example configuration file that can be used for 2 | # the obfuscation commands. This configuration file is an 3 | # extended version of the default which does not obfuscate 4 | # rules, Stardog filter functions, and magic proeprties. 5 | 6 | # Default namespace will be used as the base URI of the output 7 | @prefix : . 8 | 9 | # Namespaces that will be used in pattern specification 10 | # These namespaces will also be used in the output RDF 11 | @prefix rdf: . 12 | @prefix rdfs: . 13 | @prefix owl: . 14 | @prefix xsd: . 15 | @prefix stardog: . 16 | @prefix swrl: . 17 | @prefix swrlb: . 18 | @prefix xpath: . 19 | @prefix math: . 20 | 21 | # Obfuscation namespace is used only for parsing the config file 22 | @prefix obf: . 23 | 24 | 25 | [] a obf:Obfuscation ; 26 | 27 | # Message digest algorithm that will be used to obfuscate terms 28 | # Should be a message digest algorithm supported by Java 29 | obf:digest "SHA-256" ; 30 | 31 | # Any URI and literal value will be pattern matched with the filters. 32 | # Only the values that match the include pattern and do not match the 33 | # exclude pattern will be obfuscated. 34 | 35 | # The patterns in a filter expression has a position identifier which 36 | # is one of [any, subject, predicate, object]. The pattern will be 37 | # applied to a value depending on the position of the value. 38 | # For example, it is possible to write filter expressions 39 | # such that the same URI will be obfuscated when it is used in the 40 | # subject position but not in the object position. The pattern 41 | # expression should be a valid Java regular expression. For more 42 | # information, see: 43 | # http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html 44 | 45 | obf:include [ 46 | obf:position obf:any ; 47 | obf:pattern ".*" 48 | ] ; 49 | 50 | # Filter expression may just refer to a namespace which means any URI 51 | # belonging to that namespace will be matched. The value of the 52 | # namespace should be defined in the namespaces declaration. 53 | 54 | obf:exclude [ 55 | obf:position obf:any ; 56 | obf:namespace "rdf" 57 | ] ; 58 | obf:exclude [ 59 | obf:position obf:any ; 60 | obf:namespace "owl" 61 | ] ; 62 | obf:exclude [ 63 | obf:position obf:predicate ; 64 | obf:namespace "rdfs" 65 | ] ; 66 | obf:exclude [ 67 | obf:position obf:any ; 68 | obf:namespace "stardog" 69 | ] ;; 70 | obf:exclude [ 71 | obf:position obf:any ; 72 | obf:namespace "swrl" 73 | ] ; 74 | obf:exclude [ 75 | obf:position obf:any ; 76 | obf:namespace "swrlb" 77 | ] ; 78 | obf:exclude [ 79 | obf:position obf:any ; 80 | obf:namespace "xpath" 81 | ] ; 82 | obf:exclude [ 83 | obf:position obf:any ; 84 | obf:namespace "math" 85 | ] . 86 | -------------------------------------------------------------------------------- /examples/api/data/remove_data.nt: -------------------------------------------------------------------------------- 1 | . 2 | "householder overeducated objurgate treaties preprocessor despising loftily yabber reprovingly blungers dwarflike effulgences coreless tuberculoses environs hulled preexamination oralogy tibetans slavishly hipless prs bluejays cuppier nonsurgical skimpiest outpoured dissociated heartier petitionee brill neologic intermuscular fobbed transcribed swifters redigesting ostinato recalculation safest signiory latchets inflecting trephines hops exec junketeers isolators reducing nethermost nonfiction retrogressions eliminates unknowns mongoloids danker raunchiness perspicuously disjoined nigglings midmonths labium peeped daydreams permuting immediately canzona interrelated cooked reformers goodwife technicolor plenishes nippy bounden occulters blubberer amenities desecrated tetrachlorides loutish polygony malines cliffhanger entailments reindexed bedstraws thoughtless elation swampland earings circumscribed paralyzingly pouchy surrejoinders chestiest measurage tonsils pasturage thurifer teazle"^^. 3 | "http://www.dwelling.tld/prat/islanded.html"^^. 4 | "http://www.scrapped.tld/islanded/burlily.html"^^. 5 | "8"^^. 6 | "fringier rhythmical wastebaskets powderer immigrates inserter plights corollaries"^^. 7 | "114"^^. 8 | "prat burlily thanklessly"^^. 9 | "http://www.islanded.tld/thanklessly/swiveled.html"^^. 10 | . -------------------------------------------------------------------------------- /examples/api/data/starwars-schema.ttl: -------------------------------------------------------------------------------- 1 | :Character a owl:Class . 2 | 3 | :id a owl:DatatypeProperty , owl:FunctionalProperty ; 4 | rdfs:domain :Character ; 5 | rdfs:range xsd:int . 6 | 7 | :name a owl:DatatypeProperty , owl:FunctionalProperty; 8 | rdfs:range xsd:string . 9 | 10 | :friends a owl:ObjectProperty; 11 | rdfs:domain :Character ; 12 | rdfs:range :Character. 13 | 14 | :appearsIn a owl:ObjectProperty; 15 | rdfs:domain :Character ; 16 | rdfs:range :Episode. 17 | 18 | :Human a owl:Class ; 19 | rdfs:subClassOf :Character . 20 | 21 | :homePlanet a owl:ObjectProperty , owl:FunctionalProperty; 22 | rdfs:domain :Human ; 23 | rdfs:range :Planet. 24 | 25 | :Droid a owl:Class ; 26 | rdfs:subClassOf :Character . 27 | 28 | :primaryFunction a owl:DatatypeProperty , owl:FunctionalProperty; 29 | rdfs:domain :Droid ; 30 | rdfs:range xsd:string . 31 | 32 | :Episode a owl:Class . 33 | 34 | :index a owl:DatatypeProperty , owl:FunctionalProperty; 35 | rdfs:domain :Episode ; 36 | rdfs:range xsd:int . 37 | 38 | :Planet a owl:Class . 39 | 40 | :region a owl:ObjectProperty , owl:FunctionalProperty; 41 | rdfs:domain :Planet ; 42 | rdfs:range :Region . 43 | 44 | :sector a owl:ObjectProperty , owl:FunctionalProperty; 45 | rdfs:domain :Planet ; 46 | rdfs:range :Sector . 47 | 48 | :system a owl:ObjectProperty ; 49 | rdfs:domain :Planet ; 50 | rdfs:range :System . 51 | -------------------------------------------------------------------------------- /examples/api/data/starwars.ttl: -------------------------------------------------------------------------------- 1 | :Character a rdfs:Class . 2 | 3 | :Human a owl:Class ; 4 | rdfs:subClassOf :Character . 5 | 6 | :Droid a owl:Class ; 7 | rdfs:subClassOf :Character . 8 | 9 | :luke a :Human ; 10 | :id 1000 ; 11 | :name 'Luke Skywalker' ; 12 | :friends :han , :leia , :threepio , :artoo ; 13 | :appearsIn :NewHope , :Empire , :Jedi ; 14 | :homePlanet :Tatooine . 15 | 16 | 17 | :vader a :Human ; 18 | :id 1001 ; 19 | :name 'Darth Vader' ; 20 | :friends :tarkin ; 21 | :appearsIn :NewHope , :Empire , :Jedi ; 22 | :homePlanet :Tatooine . 23 | 24 | :han a :Human ; 25 | :id 1002 ; 26 | :name 'Han Solo' ; 27 | :friends :luke , :leia , :artoo ; 28 | :appearsIn :NewHope , :Empire , :Jedi . 29 | 30 | :leia a :Human ; 31 | :id 1003 ; 32 | :name 'Leia Organa' ; 33 | :friends :luke , :han , :threepio , :artoo ; 34 | :appearsIn :NewHope , :Empire , :Jedi ; 35 | :homePlanet :Alderaan . 36 | 37 | :tarkin a :Human ; 38 | :id 1004 ; 39 | :name 'Wilhuff Tarkin' ; 40 | :friends :vader ; 41 | :appearsIn :NewHope . 42 | 43 | :threepio a :Droid ; 44 | :id 2000 ; 45 | :name 'C-3PO' ; 46 | :friends :luke , :han , :leia , :artoo ; 47 | :appearsIn :NewHope , :Empire , :Jedi ; 48 | :primaryFunction 'Protocol' . 49 | 50 | :artoo a :Droid ; 51 | :id 2001 ; 52 | :name 'R2-D2' ; 53 | :friends :luke , :han , :leia ; 54 | :appearsIn :NewHope , :Empire , :Jedi ; 55 | :primaryFunction 'Astromech' . 56 | 57 | :NewHope a :Episode ; 58 | :name "A New Hope" ; 59 | :index 4 . 60 | 61 | :Empire a :Episode ; 62 | :name "The Empire Strikes Back" ; 63 | :index 5 . 64 | 65 | :Jedi a :Episode ; 66 | :name "Return of the Jedi" ; 67 | :index 6 . 68 | 69 | :Tatooine a :Planet ; 70 | :region :OuterRim ; 71 | :sector :Arkanis ; 72 | :system :Tatoo . 73 | 74 | :Alderaan a :Planet ; 75 | :region :CoreWorlds ; 76 | :sector :Alderaan ; 77 | :system :Alderaan . -------------------------------------------------------------------------------- /examples/api/data/vehicles.trig: -------------------------------------------------------------------------------- 1 | # Sample obtained from: 2 | # http://www.dotnetrdf.org/content.asp?pageID=Inference%20and%20Reasoning 3 | 4 | @prefix rdfs: . 5 | @prefix xsd: . 6 | @prefix vh: . 7 | @prefix : . 8 | 9 | @prefix rule: . 10 | 11 | # Tbox 12 | vh:schema 13 | { 14 | vh:Vehicle a owl:Class . 15 | vh:Car rdfs:subClassOf vh:Vehicle . 16 | vh:SportsCar rdfs:subClassOf vh:Car . 17 | 18 | vh:LatestModel a owl:Class . 19 | vh:OldModel a owl:Class . 20 | 21 | # throwing some rules here 22 | [] a rule:SPARQLRule ; 23 | rule:content """ 24 | PREFIX vh: 25 | IF { 26 | ?v a vh:Vehicle ; 27 | vh:yearModel ?year . 28 | bind(year(now()) - ?year as ?yearDiff) . 29 | FILTER(?yearDiff = 0) . 30 | } 31 | THEN { 32 | ?v a vh:LatestModel . 33 | } 34 | """ . 35 | 36 | [] a rule:SPARQLRule ; 37 | rule:content """ 38 | PREFIX vh: 39 | IF { 40 | ?v a vh:Vehicle ; 41 | vh:yearModel ?year . 42 | bind(year(now()) - ?year as ?yearDiff) . 43 | FILTER(?yearDiff > 10) . 44 | } 45 | THEN { 46 | ?v a vh:OldModel . 47 | } 48 | """ . 49 | } 50 | 51 | # default graph contains Abox data 52 | { 53 | :car1 a vh:Car ; 54 | vh:model "Camaro" ; 55 | vh:yearModel "2001"^^xsd:int . 56 | 57 | :car2 a vh:Car ; 58 | vh:model "Tesla" ; 59 | vh:yearModel "2015"^^xsd:int . 60 | 61 | :car3 a vh:SportsCar ; 62 | vh:model "Ferrari" ; 63 | vh:yearModel "2009"^^xsd:int . 64 | } -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/aller-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/aller-bold.eot -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/aller-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/aller-bold.ttf -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/aller-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/aller-bold.woff -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/aller-light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/aller-light.eot -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/aller-light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/aller-light.ttf -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/aller-light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/aller-light.woff -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/novecento-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/novecento-bold.eot -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/novecento-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/novecento-bold.ttf -------------------------------------------------------------------------------- /examples/api/docs/public/fonts/novecento-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/api/docs/public/fonts/novecento-bold.woff -------------------------------------------------------------------------------- /examples/api/main/src/com/complexible/stardog/examples/TestServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2018 Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.complexible.stardog.examples; 17 | 18 | import java.net.InetSocketAddress; 19 | 20 | import com.complexible.common.protocols.server.Server; 21 | import com.complexible.common.protocols.server.ServerException; 22 | import com.complexible.stardog.Stardog; 23 | 24 | /** 25 | * A simple class to start and shutdown a Stardog server. Normally, Stardog server would be running independently outside the JVM where client code 26 | * is running. The examples can be made to work with a remote Stardog server by not using this class and adjusting the server URL. 27 | */ 28 | public class TestServer { 29 | public static final String HOSTNAME = "localhost"; 30 | public static final int PORT = 5820; 31 | 32 | private final Stardog stardog; 33 | private final Server server; 34 | 35 | public TestServer() throws ServerException { 36 | // first need to initialize the Stardog instance 37 | stardog = Stardog.builder().create(); 38 | // start an http server on the default port 39 | server = stardog.newServer() 40 | .bind(new InetSocketAddress(HOSTNAME, PORT)) 41 | .start(); 42 | } 43 | 44 | public String getServerURL() { 45 | return "http://" + HOSTNAME + ":" + PORT; 46 | } 47 | 48 | public void shutdown() throws Exception { 49 | try { 50 | // stop the http server 51 | server.stop(); 52 | } 53 | finally { 54 | // stop the Stardog kernel 55 | stardog.shutdown(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /examples/api/readme.md: -------------------------------------------------------------------------------- 1 | # Stardog API Examples 2 | 3 | ## ConnectionAPIExample 4 | 5 | A short example showing how to use the core SNARL APIs -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/base/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -v 2 | 3 | # 4 | # Ubuntu Equip 5 | # Java 8 Equip 6 | # Licence: MIT 7 | # see http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html 8 | # http://stackoverflow.com/questions/13018626/add-apt-repository-not-found 9 | 10 | # make sure we have the latest 11 | sudo apt-get update -y 12 | sudo apt-get install -y python-software-properties debconf-utils 13 | 14 | sudo echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo /usr/bin/debconf-set-selections 15 | wget --no-check-certificate https://github.com/aglover/ubuntu-equip/raw/master/equip_base.sh && bash equip_base.sh 16 | 17 | sudo add-apt-repository ppa:webupd8team/java -y 18 | sudo apt-get update -y 19 | sudo apt-get install oracle-java8-installer -y 20 | sudo apt-get install ant -y 21 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/haproxy.tf: -------------------------------------------------------------------------------- 1 | resource "template_file" "haproxy_redirect" { 2 | count = "${var.stardogs.size}" 3 | template = "${file("haproxy/haproxy_redirect.tpl")}" 4 | vars { 5 | id = "${count.index + 1}" 6 | host = "${lookup(var.stardogs, count.index)}" 7 | } 8 | } 9 | 10 | resource "template_file" "haproxy_conf" { 11 | template = "${file("haproxy/haproxy.cfg.tpl")}" 12 | vars { 13 | redirects = "${join(" ", template_file.haproxy_redirect.*.rendered)}" 14 | } 15 | } 16 | 17 | resource "aws_instance" "haproxy" { 18 | 19 | instance_type = "${var.haproxy_type}" 20 | 21 | availability_zone = "${var.aws_az}" 22 | 23 | # not supported with t1.micro 24 | placement_group = "stardog-cluster" 25 | 26 | # Lookup the correct AMI based on the region 27 | # we specified 28 | ami = "${lookup(var.aws_amis, var.aws_region)}" 29 | 30 | # Settings for SSH connection 31 | connection { 32 | # The default username for our AMI 33 | user = "ubuntu" 34 | 35 | # The path to your key file 36 | key_file = "${var.key_path}" 37 | 38 | agent = false 39 | } 40 | 41 | key_name = "${var.key_name}" 42 | 43 | vpc_security_group_ids = ["${aws_security_group.stardog-cluster.id}"] 44 | 45 | subnet_id = "${aws_subnet.terraform.id}" 46 | 47 | private_ip = "${var.haproxy_ip}" 48 | 49 | # making sure the root block has 8 GB 50 | root_block_device { 51 | volume_size = "8" 52 | } 53 | 54 | # adding some storage to hold STARDOG_HOME 55 | #ebs_block_device { 56 | # device_name = "/dev/sdb" 57 | # volume_size = "30" 58 | # delete_on_termination = true 59 | #} 60 | 61 | # Instance tags 62 | tags { 63 | Name = "HA Proxy" 64 | } 65 | 66 | # Provisioning settings 67 | 68 | # Setup script 69 | provisioner "remote-exec" { 70 | scripts = ["haproxy/setup.sh"] 71 | } 72 | 73 | provisioner "file" { 74 | source = "${var.stardog_dist}" 75 | destination = "/opt/stardog/stardog.zip" 76 | } 77 | 78 | provisioner "remote-exec" { 79 | inline = [ 80 | "echo '${template_file.haproxy_conf.rendered}' > /var/haproxy/haproxy.cfg", 81 | "sudo haproxy -f /var/haproxy/haproxy.cfg" 82 | ] 83 | } 84 | 85 | # Export system variable to be able to use it in other scripts 86 | provisioner "local-exec" { 87 | command = "export STARDOG_CLUSTER='${self.public_dns}'" 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/haproxy/haproxy.cfg.tpl: -------------------------------------------------------------------------------- 1 | global 2 | daemon 3 | maxconn 256 4 | 5 | defaults 6 | option http-no-delay 7 | timeout connect 5s 8 | timeout client 1h 9 | timeout server 1h 10 | 11 | frontend stardog-in 12 | mode http 13 | option tcpka # keep-alive 14 | bind *:5820 15 | default_backend stardogs 16 | 17 | backend stardogs 18 | mode http 19 | 20 | balance roundrobin 21 | 22 | # the following line performs a health check 23 | option httpchk GET /admin/healthcheck 24 | # replace these IP addresses with the corresponding node address 25 | ${redirects} 26 | 27 | listen stats 28 | bind *:9000 29 | mode http 30 | stats enable 31 | stats hide-version 32 | stats realm HAproxy\ Statistics 33 | stats uri / 34 | stats auth admin:admin 35 | stats refresh 5s 36 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/haproxy/haproxy_redirect.tpl: -------------------------------------------------------------------------------- 1 | server stardog${id} ${host}:5820 #maxconn 32 check 2 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/haproxy/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -v 2 | 3 | # Install haproxy 4 | sudo add-apt-repository ppa:vbernat/haproxy-1.6 -y 5 | 6 | sudo apt-get update -y 7 | sudo apt-get install haproxy -y 8 | 9 | haproxy_dir=/var/haproxy 10 | sudo mkdir ${haproxy_dir} 11 | sudo chown -R ubuntu ${haproxy_dir} 12 | sudo chmod 775 ${haproxy_dir} 13 | 14 | # static http server for copying the stardog binaries 15 | stardog_dir=/opt/stardog 16 | sudo mkdir -p ${stardog_dir} 17 | sudo chown -R ubuntu ${stardog_dir} 18 | cd ${stardog_dir} 19 | sudo chown -R ubuntu /usr/local/bin 20 | 21 | echo "python3 -m http.server 8080 > /dev/null &" > /usr/local/bin/httpserver 22 | sudo chmod +x /usr/local/bin/httpserver 23 | nohup httpserver 24 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/main.tf: -------------------------------------------------------------------------------- 1 | # Specify the provider and access details 2 | provider "aws" { 3 | region = "${var.aws_region}" 4 | } 5 | 6 | ########################## 7 | # Cluster's network setup 8 | ########################## 9 | 10 | resource "aws_vpc" "terraform-vpc" { 11 | cidr_block = "10.0.1.0/24" 12 | enable_dns_hostnames = true 13 | tags { 14 | Name = "stardog-aws-vpc" 15 | } 16 | } 17 | 18 | resource "aws_internet_gateway" "default" { 19 | vpc_id = "${aws_vpc.terraform-vpc.id}" 20 | } 21 | 22 | resource "aws_subnet" "terraform" { 23 | availability_zone = "${var.aws_az}" 24 | vpc_id = "${aws_vpc.terraform-vpc.id}" 25 | cidr_block = "10.0.1.0/24" 26 | 27 | map_public_ip_on_launch = true 28 | 29 | tags { 30 | Name = "stardog-terraform-subnet" 31 | } 32 | } 33 | 34 | resource "aws_route_table" "terraform-public" { 35 | vpc_id = "${aws_vpc.terraform-vpc.id}" 36 | route { 37 | cidr_block = "0.0.0.0/0" 38 | gateway_id = "${aws_internet_gateway.default.id}" 39 | } 40 | tags { 41 | Name = "Public subnet" 42 | } 43 | } 44 | 45 | resource "aws_route_table_association" "routing" { 46 | subnet_id = "${aws_subnet.terraform.id}" 47 | route_table_id = "${aws_route_table.terraform-public.id}" 48 | } 49 | 50 | resource "aws_security_group" "stardog-cluster" { 51 | name = "stardog-cluster" 52 | description = "Allow cluster traffic" 53 | 54 | vpc_id = "${aws_vpc.terraform-vpc.id}" 55 | 56 | # allow ssh from anywhere 57 | ingress { 58 | from_port = 22 59 | to_port = 22 60 | protocol = "tcp" 61 | cidr_blocks = ["0.0.0.0/0"] 62 | } 63 | 64 | # stardog port 65 | ingress { 66 | from_port = 5820 67 | to_port = 5820 68 | protocol = "tcp" 69 | cidr_blocks = ["0.0.0.0/0"] 70 | } 71 | 72 | # haproxy stats port 73 | ingress { 74 | from_port = 9000 75 | to_port = 9000 76 | protocol = "tcp" 77 | cidr_blocks = ["0.0.0.0/0"] 78 | } 79 | 80 | # zookeeper ports 81 | ingress { 82 | from_port = 2181 83 | to_port = 2181 84 | protocol = "tcp" 85 | cidr_blocks = ["0.0.0.0/0"] 86 | } 87 | 88 | ingress { 89 | from_port = 2888 90 | to_port = 2888 91 | protocol = "tcp" 92 | cidr_blocks = ["0.0.0.0/0"] 93 | } 94 | 95 | ingress { 96 | from_port = 3888 97 | to_port = 3888 98 | protocol = "tcp" 99 | cidr_blocks = ["0.0.0.0/0"] 100 | } 101 | 102 | # for serving the stardog binaries 103 | ingress { 104 | from_port = 8080 105 | to_port = 8080 106 | protocol = "tcp" 107 | cidr_blocks = ["0.0.0.0/0"] 108 | } 109 | 110 | egress { 111 | from_port = 0 112 | to_port = 0 113 | protocol = "-1" 114 | cidr_blocks = ["0.0.0.0/0"] 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/outputs.tf: -------------------------------------------------------------------------------- 1 | output "haproxy" { 2 | value = "${aws_instance.haproxy.public_dns}" 3 | } 4 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/stardog.tf: -------------------------------------------------------------------------------- 1 | ########################## 2 | # Stardog node 3 | ########################## 4 | 5 | resource "template_file" "zk_conn" { 6 | count = "${var.zookeepers.size}" 7 | template = "${file("stardog/zk_conn_server.tpl")}" 8 | vars { 9 | zk_server = "${lookup(var.zookeepers, count.index)}" 10 | } 11 | } 12 | 13 | resource "template_file" "stardog_props" { 14 | count = "${var.stardogs.size}" 15 | template = "${file("stardog/stardog.properties.tpl")}" 16 | vars { 17 | host = "${lookup(var.stardogs, count.index)}" 18 | zk_conn_string = "${replace(join(",", template_file.zk_conn.*.rendered), "\n", "")}" 19 | } 20 | } 21 | 22 | resource "aws_instance" "stardog" { 23 | depends_on = ["aws_instance.zookeeper", "aws_instance.haproxy"] 24 | 25 | instance_type = "${var.stardog_type}" 26 | 27 | availability_zone = "${var.aws_az}" 28 | 29 | count = "${var.stardogs.size}" 30 | 31 | # not supported with t1.micro 32 | placement_group = "stardog-cluster" 33 | 34 | # Lookup the correct AMI based on the region 35 | # we specified 36 | ami = "${lookup(var.stardog_ami, var.aws_region)}" 37 | 38 | # Settings for SSH connection 39 | connection { 40 | # The default username for our AMI 41 | user = "ubuntu" 42 | 43 | # The path to your key file 44 | key_file = "${var.key_path}" 45 | 46 | agent = false 47 | } 48 | 49 | key_name = "${var.key_name}" 50 | 51 | vpc_security_group_ids = ["${aws_security_group.stardog-cluster.id}"] 52 | 53 | subnet_id = "${aws_subnet.terraform.id}" 54 | 55 | private_ip = "${lookup(var.stardogs, count.index)}" 56 | 57 | # making sure the root block has 8 GB 58 | root_block_device { 59 | volume_size = "8" 60 | } 61 | 62 | ephemeral_block_device { 63 | device_name = "/dev/sdb" 64 | virtual_name = "ephemeral0" 65 | } 66 | 67 | ephemeral_block_device { 68 | device_name = "/dev/sdc" 69 | virtual_name = "ephemeral1" 70 | } 71 | 72 | # adding some storage to hold STARDOG_HOME 73 | ebs_block_device { 74 | device_name = "/dev/sdd" 75 | volume_size = "700" // minimum size for max iops (20k) 76 | volume_type = "io1" 77 | iops = "10000" 78 | delete_on_termination = true 79 | } 80 | 81 | # Instance tags 82 | tags { 83 | Name = "stardog cluster node" 84 | } 85 | 86 | # Provisioning settings 87 | 88 | # Setup scripts 89 | provisioner "remote-exec" { 90 | scripts = ["stardog/setup.sh"] 91 | } 92 | 93 | // # Provision stardog 94 | // provisioner "file" { 95 | // source = "${var.stardog_dist}" 96 | // destination = "/usr/local/stardog" 97 | // } 98 | 99 | # Provision stardog license 100 | provisioner "file" { 101 | source = "${var.stardog_license}" 102 | destination = "/mnt/data/stardog-home/stardog-license-key.bin" 103 | } 104 | 105 | # Provision logging settings 106 | provisioner "file" { 107 | source = "stardog/log4j2.xml" 108 | destination = "/mnt/data/stardog-home/log4j2.xml" 109 | } 110 | 111 | provisioner "remote-exec" { 112 | inline = [ 113 | "echo '${element(template_file.stardog_props.*.rendered, count.index)}' > /mnt/data/stardog-home/stardog.properties" 114 | ] 115 | } 116 | 117 | provisioner "remote-exec" { 118 | script = "stardog/start.sh" 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/stardog/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | stardog 9 | zookeeper 10 | ${sys:stardog.home} 11 | ${LOG_DIR}/.logs_archive 12 | %-5level %d [%t] %c:%M(%L): %m%n 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/stardog/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -v 2 | 3 | sudo apt-get update 4 | sudo apt-get install unzip -y 5 | 6 | DEVICE=/dev/xvdd 7 | MOUNT_POINT=/mnt/data 8 | # mount the ebs drive 9 | sudo mkfs -t ext4 $DEVICE 10 | sudo mkdir $MOUNT_POINT 11 | sudo mount $DEVICE $MOUNT_POINT 12 | 13 | # Create stardog-home 14 | sudo mkdir -p $MOUNT_POINT/stardog-home 15 | sudo chmod 775 -R $MOUNT_POINT/stardog-home 16 | sudo chown -R ubuntu $MOUNT_POINT/stardog-home 17 | 18 | # Make some directories writable for the main user 19 | sudo chmod 775 -R /usr/local 20 | sudo chown -R ubuntu /usr/local 21 | 22 | sudo mkdir /mnt/.tmp 23 | sudo chown -R ubuntu /mnt/.tmp 24 | sudo chmod 775 -R /mnt/.tmp 25 | 26 | pushd /usr/local 27 | # todo - do not hardcode the address? 28 | wget http://10.0.1.25:8080/stardog.zip 29 | unzip stardog.zip 30 | sd_dir=$(ls | `which grep` stardog-) 31 | if [ -z "${sd_dir}" ]; then 32 | echo "error setting up stardog" 33 | exit 1 34 | fi 35 | mv /usr/local/${sd_dir} /usr/local/stardog 36 | popd 37 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/stardog/stardog.properties.tpl: -------------------------------------------------------------------------------- 1 | # Flag to enable the cluster, without this flag set, the rest of the properties have no effect 2 | pack.enabled=true 3 | 4 | # this node IP address 5 | pack.node.address=${host} 6 | 7 | # the connection string for ZooKeeper where cluster state is stored 8 | pack.zookeeper.address=${zk_conn_string} 9 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/stardog/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -v 2 | 3 | # make sure that stardog scripts have execution permissions 4 | chmod 775 /usr/local/stardog/bin/stardog 5 | chmod 775 /usr/local/stardog/bin/stardog-admin 6 | 7 | # Create symlink to stardog scripts 8 | sudo ln -s /usr/local/stardog/bin/stardog /usr/local/bin/stardog 9 | sudo ln -s /usr/local/stardog/bin/stardog-admin /usr/local/bin/stardog-admin 10 | 11 | tmp_dir=/mnt/.tmp 12 | 13 | export STARDOG_HOME=/mnt/data/stardog-home 14 | export STARDOG_JAVA_ARGS="-Xms8g -Xmx8g -XX:MaxDirectMemorySize=10g -Djava.io.tmpdir=${tmp_dir}" 15 | echo "export STARDOG_HOME=${STARDOG_HOME}" >> /home/ubuntu/.bashrc 16 | echo "export STARDOG_JAVA_ARGS='${STARDOG_JAVA_ARGS}'" >> /home/ubuntu/.bashrc 17 | 18 | # Execute server start 19 | ulimit -n 2048 20 | nohup stardog-admin server start --disable-security 21 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/stardog/zk_conn_server.tpl: -------------------------------------------------------------------------------- 1 | ${zk_server}:2181 2 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/zookeeper.tf: -------------------------------------------------------------------------------- 1 | ########################## 2 | # ZooKeeper resources 3 | ########################## 4 | 5 | resource "template_file" "zk_server" { 6 | count = "${var.zookeepers.size}" 7 | template = "${file("zookeeper/server-spec.tpl")}" 8 | vars { 9 | id = "${count.index + 1}" 10 | host = "${lookup(var.zookeepers, count.index)}" 11 | } 12 | } 13 | 14 | resource "template_file" "zk_conf" { 15 | template = "${file("zookeeper/zoo.cfg.tpl")}" 16 | vars { 17 | zk_server_list = "${join("", template_file.zk_server.*.rendered)}" 18 | } 19 | } 20 | 21 | resource "aws_instance" "zookeeper" { 22 | instance_type = "${var.zookeeper_type}" 23 | 24 | count = "${var.zookeepers.size}" 25 | 26 | availability_zone = "${var.aws_az}" 27 | 28 | # not supported with t1.micro 29 | placement_group = "stardog-cluster" 30 | 31 | # Lookup the correct AMI based on the region 32 | # we specified 33 | ami = "${lookup(var.zookeeper_ami, var.aws_region)}" 34 | 35 | # Settings for SSH connection 36 | connection { 37 | # The default username for our AMI 38 | user = "ubuntu" 39 | 40 | # The path to your key file 41 | key_file = "${var.key_path}" 42 | 43 | agent = false 44 | } 45 | 46 | key_name = "${var.key_name}" 47 | 48 | vpc_security_group_ids = ["${aws_security_group.stardog-cluster.id}"] 49 | 50 | subnet_id = "${aws_subnet.terraform.id}" 51 | 52 | private_ip = "${lookup(var.zookeepers, count.index)}" 53 | 54 | # making sure the root block has 8 GB 55 | root_block_device { 56 | volume_size = "8" 57 | } 58 | 59 | # adding some storage to hold STARDOG_HOME 60 | #ebs_block_device { 61 | # device_name = "/dev/sdb" 62 | # volume_size = "30" 63 | # delete_on_termination = true 64 | #} 65 | 66 | # Instance tags 67 | tags { 68 | Name = "ZooKeeper node" 69 | } 70 | 71 | # Provisioning settings 72 | 73 | # Setup script 74 | provisioner "remote-exec" { 75 | scripts = ["zookeeper/setup.sh"] 76 | } 77 | 78 | provisioner "remote-exec" { 79 | inline = [ 80 | "echo '${template_file.zk_conf.rendered}' > /usr/local/zookeeper-3.4.6/conf/zoo.cfg", 81 | "echo ${count.index + 1} > /var/zkdata/myid", 82 | "/usr/local/zookeeper-3.4.6/bin/zkServer.sh start" 83 | ] 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/zookeeper/server-spec.tpl: -------------------------------------------------------------------------------- 1 | server.${id}=${host}:2888:3888 2 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/zookeeper/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -v 2 | 3 | # Install ZooKeeper 4 | zookeeper_version=3.4.6 5 | sudo wget http://mirror.metrocast.net/apache/zookeeper/zookeeper-${zookeeper_version}/zookeeper-${zookeeper_version}.tar.gz && sudo tar -xvzf zookeeper-${zookeeper_version}.tar.gz 6 | sudo mv zookeeper-${zookeeper_version} /usr/local 7 | sudo chgrp -R ubuntu /usr/local/zookeeper-${zookeeper_version} 8 | sudo chmod 775 -R /usr/local/zookeeper-${zookeeper_version} 9 | 10 | # Create zk data directory 11 | sudo mkdir -p /var/zkdata 12 | sudo chgrp -R ubuntu /var/zkdata 13 | sudo chmod 775 -R /var/zkdata 14 | -------------------------------------------------------------------------------- /examples/cli/cluster/terraform/zookeeper/zoo.cfg.tpl: -------------------------------------------------------------------------------- 1 | # http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html 2 | 3 | # The number of milliseconds of each tick 4 | tickTime=2000 5 | # The number of ticks that the initial 6 | # synchronization phase can take 7 | initLimit=10 8 | # The number of ticks that can pass between 9 | # sending a request and getting an acknowledgement 10 | syncLimit=5 11 | # the directory where the snapshot is stored. 12 | dataDir=/var/zkdata 13 | # Place the dataLogDir to a separate physical disc for better performance 14 | # dataLogDir=/disk2/zookeeper 15 | 16 | # the port at which the clients will connect 17 | clientPort=2181 18 | 19 | # specify all zookeeper servers 20 | # The fist port is used by followers to connect to the leader 21 | # The second one is used for leader election 22 | ${zk_server_list} 23 | 24 | 25 | # To avoid seeks ZooKeeper allocates space in the transaction log file in 26 | # blocks of preAllocSize kilobytes. The default block size is 64M. One reason 27 | # for changing the size of the blocks is to reduce the block size if snapshots 28 | # are taken more often. (Also, see snapCount). 29 | #preAllocSize=65536 30 | 31 | # Clients can submit requests faster than ZooKeeper can process them, 32 | # especially if there are a lot of clients. To prevent ZooKeeper from running 33 | # out of memory due to queued requests, ZooKeeper will throttle clients so that 34 | # there is no more than globalOutstandingLimit outstanding requests in the 35 | # system. The default limit is 1,000.ZooKeeper logs transactions to a 36 | # transaction log. After snapCount transactions are written to a log file a 37 | # snapshot is started and a new transaction log file is started. The default 38 | # snapCount is 10,000. 39 | #snapCount=1000 40 | 41 | # If this option is defined, requests will be will logged to a trace file named 42 | # traceFile.year.month.day. 43 | #traceFile= 44 | 45 | # Leader accepts client connections. Default value is "yes". The leader machine 46 | # coordinates updates. For higher update throughput at thes slight expense of 47 | # read throughput the leader can be configured to not accept clients and focus 48 | # on coordination. 49 | #leaderServes=yes 50 | -------------------------------------------------------------------------------- /examples/cli/virtual/csv/cars.csv: -------------------------------------------------------------------------------- 1 | Year,Make,Model,Description,Price 2 | 1997,Ford,E350,"ac, abs, moon",3000.0 3 | 1999,Chevy,"Venture ""Extended Edition""","",4900.0 4 | 1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.0 5 | 1996,Jeep,Grand Cherokee,"MUST SELL! 6 | air, moon roof, loaded",4799.0 -------------------------------------------------------------------------------- /examples/cli/virtual/csv/cars_autogenerate.properties: -------------------------------------------------------------------------------- 1 | # The base property will be used as a base for all IRIs generated from column titles. 2 | base=http://example.org/cars 3 | 4 | # The unique.key.sets property determines which columns will be used to generate the subject IRI. 5 | # NOTE: Column names are case-sensitive. 6 | unique.key.sets=(Make,Model) 7 | 8 | # The subject IRI will be given an rdf:type value that's specified by the csv.class property. 9 | csv.class=http://purl.org/vso/ns#Automobile 10 | 11 | # The default field delimiter is comma (,). 12 | csv.separator=, 13 | 14 | # The default quote is double quote. "Use two ""double quotes"" to escape a double quote within a quoted string." 15 | csv.quote=" 16 | 17 | # By default, the first row will be treated as a header record. 18 | csv.header=true 19 | 20 | # If csv.skip.empty is true, a blank field ("") will be treated as a missing field. (fifth,field,is,missing,,"",sixth,is,blank) 21 | csv.skip.empty=true 22 | -------------------------------------------------------------------------------- /examples/cli/virtual/csv/cars_autogenerate.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix vso: . 3 | 4 | a vso:Automobile ; 5 | :Make "Ford" ; 6 | :Description "ac, abs, moon" ; 7 | :Model "E350" ; 8 | :Price "3000.0" ; 9 | :Year "1997" . 10 | a vso:Automobile ; 11 | :Make "Chevy" ; 12 | :Model "Venture \"Extended Edition\"" ; 13 | :Price "4900.0" ; 14 | :Year "1999" . 15 | a vso:Automobile ; 16 | :Make "Chevy" ; 17 | :Model "Venture \"Extended Edition, Very Large\"" ; 18 | :Price "5000.0" ; 19 | :Year "1999" . 20 | a vso:Automobile ; 21 | :Make "Jeep" ; 22 | :Description """MUST SELL! 23 | air, moon roof, loaded""" ; 24 | :Model "Grand Cherokee" ; 25 | :Price "4799.0" ; 26 | :Year "1996" . -------------------------------------------------------------------------------- /examples/cli/virtual/csv/cars_mappings.sms: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix gr: 3 | prefix vso: 4 | 5 | MAPPING 6 | # Use an empty FROM CSV clause to indicate this is a delimited input. 7 | FROM CSV { 8 | } 9 | TO { 10 | ?car_iri a vso:Automobile, gr:ActualProductOrServiceInstance ; 11 | rdfs:label ?car_label ; 12 | gr:hasManufacturer ?make_iri ; 13 | gr:hasMakeAndModel ?model_iri ; 14 | vso:modelDate ?model_date . 15 | 16 | ?make_iri a gr:BusinessEntity ; 17 | rdfs:label ?Make . 18 | 19 | ?model_iri a gr:ProductOrServiceModel ; 20 | rdfs:label ?model_string ; 21 | gr:hasManufacturer ?make_iri . 22 | 23 | ?offer_iri a gr:Offering ; 24 | rdfs:comment ?Description ; 25 | gr:includes ?car_iri ; 26 | gr:hasBusinessFunction gr:Sell ; 27 | gr:hasPriceSpecification ?price_bnode . 28 | 29 | ?price_bnode a gr:UnitPriceSpecification ; 30 | gr:hasCurrency "USD"^^xsd:string ; 31 | :uuid ?uuidstr ; 32 | gr:hasCurrencyValue ?price_float . 33 | } 34 | WHERE { 35 | # A variable (?Make, ?Model) will be created for each column. Column names are case-sensitive, and will be taken from 36 | # the header row (or use ?0, ?1, ?2... for column names if there is no header). 37 | 38 | # New variables can be created in the WHERE clause using the SPARQL BIND function. 39 | 40 | # Use the special TEMPLATE function to construct IRIs from column names. 41 | BIND(TEMPLATE("http://example.org/cars#Manufacturer-{Make}") AS ?make_iri) 42 | BIND(TEMPLATE("http://example.org/cars#Model-{Model}") AS ?model_iri) 43 | 44 | # The SPARQL CONCAT function can be used to build up new String variables from columns. 45 | BIND(CONCAT(?Make, " ", ?Model) AS ?model_string) 46 | BIND(CONCAT(?Make, " ", ?Model, " (", ?Year, ")") AS ?car_label) 47 | 48 | # For delimited import (only), a special _ROW_NUMBER_ variable will contain the current ROW number of the CSV file. 49 | BIND(TEMPLATE("http://example.org/cars#Car-{_ROW_NUMBER_}") AS ?car_iri) 50 | BIND(TEMPLATE("http://example.org/cars#Offer-{_ROW_NUMBER_}") AS ?offer_iri) 51 | 52 | # Cast Price column from String to Float. 53 | BIND(xsd:float(?Price) AS ?price_float) 54 | 55 | # SPARQL functions can be combined as needed. 56 | BIND(xsd:date(CONCAT(?Year, "-01-01")) AS ?model_date) 57 | 58 | # The SPARQL BNODE function can be used to create blank nodes. An optional argument can supply the ID. 59 | # The SPARQL UUID a STRUUID functions can be used to generate unique IRIs and Strings, respectively. 60 | BIND(BNODE(CONCAT("price-", STRUUID())) AS ?price_bnode) 61 | } 62 | -------------------------------------------------------------------------------- /examples/cli/virtual/csv/readme.md: -------------------------------------------------------------------------------- 1 | CSV example 2 | =========== 3 | 4 | This example shows how to map a [simple CSV file](cars.csv) (original csv from 5 | [wikipedia](http://en.wikipedia.org/wiki/Comma-separated_values#Example)) into the 6 | [Vehicle Sales Ontology (VSO)](http://www.heppnetz.de/ontologies/vso/ns) that extends 7 | [GoodRelations vocabulary](http://www.heppnetz.de/projects/goodrelations/). See the comments in 8 | [the template file](cars_mappings.sms) for the details of the mapping. The final output can be seen in 9 | [cars.ttl](cars.ttl). 10 | 11 | The following command can be used to import the contents of the CSV file into the Stardog database `mydb`: 12 | 13 | ``` 14 | stardog-admin virtual import --format sms2 mydb cars_mappings.sms cars.csv 15 | ``` 16 | 17 | Mappings can be ommitted from the virtual import command for delimited files and the mappings will be generated 18 | automatically. Both source files with and without a header row can be imported without mappings. For those 19 | without a header row, IRIs will be generated using the index of the columns. See the comments in the 20 | [cars_autogenerate.properties](cars_autogenerate.properties) file for a description of the needed properties for 21 | automatic mappings generation. The final output for an import with generated mappings can be seen in 22 | [cars_autogenerate.ttl](cars_autogenerate.ttl). 23 | 24 | The following command can be used to import the contents of the CSV file using automatically generated mappings into 25 | the Stardog database `mydb`: 26 | 27 | ``` 28 | stardog-admin virtual import mydb cars_autogenerate.properties cars.csv 29 | ``` 30 | -------------------------------------------------------------------------------- /examples/connectable/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.complexible.stardog.examples.connectable" 2 | 3 | dependencies { 4 | // server core modules 5 | implementation platform("com.complexible.stardog:server:${stardogVersion}") 6 | implementation "com.stardog.stark.io:stardog-stark-io-api:${stardogVersion}" 7 | 8 | testRuntimeOnly platform("com.complexible.stardog:client-http:${stardogVersion}") 9 | } 10 | -------------------------------------------------------------------------------- /examples/connectable/main/resources/META-INF/services/com.complexible.stardog.StardogModule: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.connectable.listener.ExampleModule -------------------------------------------------------------------------------- /examples/connectable/main/src/com/complexible/stardog/examples/connectable/listener/ExampleConnectable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2018 Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.complexible.stardog.examples.connectable.listener; 17 | 18 | import com.complexible.stardog.db.Connectable; 19 | import com.complexible.stardog.db.ConnectableConnection; 20 | import com.complexible.stardog.db.ConnectableMetadata; 21 | import com.complexible.stardog.db.ConnectionContext; 22 | import com.google.common.base.Preconditions; 23 | 24 | /** 25 | * Connectable implementation for the example. Sole responsibility for this class is to create a (sub)connection when the 26 | * user connects to a database. 27 | * 28 | * @author Evren Sirin 29 | */ 30 | final class ExampleConnectable implements Connectable { 31 | private final ConnectableMetadata mMetadata; 32 | 33 | private boolean mClosed = false; 34 | 35 | private boolean mInitialized = false; 36 | 37 | public ExampleConnectable(final ConnectableMetadata theMetadata) { 38 | mMetadata = theMetadata; 39 | } 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | @Override 45 | public void initialize() throws Exception { 46 | Preconditions.checkState(!mClosed, "Already closed"); 47 | 48 | if (!mInitialized) { 49 | mInitialized = true; 50 | } 51 | } 52 | 53 | /** 54 | * {@inheritDoc} 55 | */ 56 | @Override 57 | public void close() throws Exception { 58 | if (!mClosed) { 59 | mClosed = true; 60 | } 61 | } 62 | 63 | /** 64 | * {@inheritDoc} 65 | */ 66 | @Override 67 | public ConnectableConnection openConnection(final ConnectionContext theContext) throws Exception { 68 | // retrieve the database name from the connnection context and pass it to the connection 69 | String aDbName = theContext.require(ConnectionContext.NAME, String.class); 70 | return new ExampleConnectableConnection(aDbName, () -> mMetadata.get(ExampleConnectableOption.ENABLE_LOGGING)); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/connectable/main/src/com/complexible/stardog/examples/connectable/listener/ExampleConnectableFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2018 Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.complexible.stardog.examples.connectable.listener; 17 | 18 | import java.io.PrintStream; 19 | import java.util.Optional; 20 | 21 | import com.complexible.stardog.db.ConnectableFactory; 22 | import com.complexible.stardog.db.ConnectableMetadata; 23 | import com.complexible.stardog.index.Index; 24 | import com.complexible.stardog.util.backup.Backup; 25 | 26 | /** 27 | * Example connectable factory. This factory is a singleton and used to create one connectable for each database instance. 28 | * 29 | * @author Evren Sirin 30 | */ 31 | final class ExampleConnectableFactory implements ConnectableFactory { 32 | /** 33 | * {@inheritDoc} 34 | */ 35 | @Override 36 | public Optional create(final ConnectableMetadata theMetadata, final Index theIndex) throws Exception { 37 | return Optional.of(new ExampleConnectable(theMetadata)); 38 | } 39 | 40 | /** 41 | * {@inheritDoc} 42 | */ 43 | @Override 44 | public Optional restore(final ConnectableMetadata theMetadata, final Index theIndex, 45 | final Backup theBackup, final PrintStream theStream) throws Exception { 46 | return Optional.of(new ExampleConnectable(theMetadata)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/connectable/main/src/com/complexible/stardog/examples/connectable/listener/ExampleConnectableOption.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2018 Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.complexible.stardog.examples.connectable.listener; 17 | 18 | import com.complexible.stardog.metadata.ConfigProperty; 19 | import com.complexible.stardog.metadata.MetaPropertyProvider; 20 | 21 | import static com.complexible.stardog.metadata.MetaProperty.config; 22 | 23 | /** 24 | * Example class for defining a new database option. If the custom connectable requires some configuration parameters they can be defined 25 | * in this class, set by users using the regular admin functionality and read by the connectable at runtime. 26 | * 27 | * @author Evren Sirin 28 | */ 29 | public final class ExampleConnectableOption implements MetaPropertyProvider { 30 | public static final ConfigProperty ENABLE_LOGGING = config("example.connectable.enabled", true) 31 | .database() 32 | .creatable() 33 | .readable() 34 | .writableWhileOnline() 35 | .build(); 36 | } 37 | -------------------------------------------------------------------------------- /examples/connectable/main/src/com/complexible/stardog/examples/connectable/listener/ExampleModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2018 Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.complexible.stardog.examples.connectable.listener; 17 | 18 | import com.complexible.stardog.AbstractStardogModule; 19 | import com.complexible.stardog.db.ConnectableFactory; 20 | import com.complexible.stardog.metadata.MetaProperties; 21 | 22 | import com.google.inject.Singleton; 23 | import com.google.inject.multibindings.Multibinder; 24 | 25 | /** 26 | * Guice module to register the example connectable factory. 27 | * 28 | * @author Evren Sirin 29 | */ 30 | public final class ExampleModule extends AbstractStardogModule { 31 | @Override 32 | protected void configure() { 33 | // database options need to be registered at the beginning 34 | MetaProperties.register(ExampleConnectableOption.class); 35 | 36 | Multibinder.newSetBinder(binder(), ConnectableFactory.class) 37 | .addBinding() 38 | .to(ExampleConnectableFactory.class) 39 | .in(Singleton.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/connectable/readme.md: -------------------------------------------------------------------------------- 1 | # Transaction Listener 2 | 3 | Stardog transaction framework provides extension points for adding custom behavior for transactions. This 4 | extension mechanism is internally used for features like free text search and geospatial indexing. This 5 | example shows a simple way to use this framework for attaching transaction listeners so every triple 6 | added/removed in a transaction can be seen and processed. This example simply prints the contents of the 7 | transaction in the log file but any custom behavior can be implemented by simple modifying one function 8 | in the [ListenerConnectableConnection](main/src/com/complexible/stardog/examples/listener/ListenerConnectableConnection.java) 9 | class. 10 | -------------------------------------------------------------------------------- /examples/describe/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.complexible.stardog.examples.connectable" 2 | 3 | dependencies { 4 | // server core modules 5 | implementation platform("com.complexible.stardog:server:${stardogVersion}") 6 | implementation "com.stardog.stark.query:stardog-stark-query-api:${stardogVersion}" 7 | } 8 | -------------------------------------------------------------------------------- /examples/describe/main/resources/META-INF/services/com.complexible.stardog.plan.describe.DescribeStrategy: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.describe.ExampleDescribe -------------------------------------------------------------------------------- /examples/docs/blog/article.txt: -------------------------------------------------------------------------------- 1 | Netflix is eyeing the Watergate scandal as the subject of its next high-profile miniseries. 2 | A drama titled Watergate is being developed by George Clooney and Bridge of Spies writer Matt Charman. Clooney’s Smokehouse Pictures will produce the eight-episode limited series, with the film star and his partner Grant Heslov serving as executive producers. Charman is writing the script for the project, which also hails from Sonar Entertainment (which signed a first-look deal with Smokehouse last year). Netflix declined to comment. 3 | 4 | Source: https://www.hollywoodreporter.com/live-feed/watergate-series-george-clooney-works-at-netflix-1068566 -------------------------------------------------------------------------------- /examples/docs/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.complexible.stardog.examples.docs" 2 | 3 | dependencies { 4 | implementation platform("com.complexible.stardog:server:${stardogVersion}") 5 | implementation platform("com.complexible.stardog:client-http:${stardogVersion}") 6 | implementation "com.complexible.stardog.bites:stardog-bites-protocols-http:${stardogVersion}" 7 | } 8 | -------------------------------------------------------------------------------- /examples/docs/input.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/docs/input.pdf -------------------------------------------------------------------------------- /examples/docs/main/resources/META-INF/services/com.complexible.stardog.docs.extraction.RDFExtractor: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.docs.WordCountExtractor 2 | -------------------------------------------------------------------------------- /examples/docs/main/src/com/complexible/stardog/examples/docs/WordCountExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2018 Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.complexible.stardog.examples.docs; 17 | 18 | import java.io.BufferedReader; 19 | import java.io.Reader; 20 | 21 | import com.complexible.common.rdf.StatementSource; 22 | import com.complexible.common.rdf.impl.MemoryStatementSource; 23 | import com.complexible.stardog.api.Connection; 24 | import com.complexible.stardog.docs.extraction.tika.TextProvidingRDFExtractor; 25 | import com.google.common.collect.ImmutableSet; 26 | import com.stardog.stark.IRI; 27 | import com.stardog.stark.Statement; 28 | import com.stardog.stark.Values; 29 | 30 | /** 31 | * A Stardog RDF extractor that will process the document to compute 32 | * a word count. The word count is asserted as an RDF statement.

33 | * This extractor inherits from {@link TextProvidingRDFExtractor} 34 | * which directly provides the text in the form of a Reader. The 35 | * document can be accessed directly by implementing {@link 36 | * com.complexible.stardog.docs.extraction.RDFExtractor}. In this case 37 | * the extractor is responsible for dealing with the format of the 38 | * file (pdf, docx, etc). 39 | */ 40 | public class WordCountExtractor extends TextProvidingRDFExtractor { 41 | 42 | /** 43 | * Compute the word count, create an RDF triple linking the word count to the document, return it as a graph. 44 | */ 45 | @Override 46 | protected StatementSource extractFromText(final Connection theConnection, final IRI theDocIri, final Reader theText) throws Exception { 47 | int words = 0; 48 | String line; 49 | BufferedReader aBufferedReader = new BufferedReader(theText); 50 | 51 | while ((line = aBufferedReader.readLine()) != null) { 52 | words += line.split(" ").length; 53 | } 54 | 55 | Statement aWordCountStatement = Values.statement(theDocIri, Values.iri("tag:stardog:example:wordcount"), Values.literal(words)); 56 | 57 | return MemoryStatementSource.of(ImmutableSet.of(aWordCountStatement)); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /examples/docs/readme.md: -------------------------------------------------------------------------------- 1 | # Docs Examples 2 | 3 | ## WordCountExtractor 4 | 5 | This is an RDF extractor that processes documents to extract an RDF 6 | model about the document. The extractor is called when a document is 7 | added or updated in the document store. 8 | 9 | RDF extractors must be registered using the service loader. Check the 10 | main/resources/META-INF/services for how this is done. 11 | 12 | RDF extractors can be configured for each DB with the property 13 | "docs.default.rdf.extractors". This is a comma separated list of extractors 14 | that can consist of the following: 15 | 16 | * A fully qualified class name of an RDF extractor registered via the service loader 17 | * A simple class name of an RDF extractor registered via the service loader 18 | * The string "tika" to enable the Apache Tika metadata extractor which reads embedded metadata 19 | 20 | RDF extractors can be also be chosen for each `put()` request by 21 | providing a sequence of extractor names to the appropriate version of 22 | the `put()` method on a `BitesConnection`. 23 | 24 | ## Usage 25 | 26 | - Run `gradle clean jar` 27 | - In build\libs there should now be a `docs-x.y.z.jar` 28 | - Copy that jar into [$STARDOG_EXT](https://www.stardog.com/docs/#_extending_stardog) or somewhere such as `$STARDOG\server\dbms` that is on your Stardog classpath 29 | - Restart your Stardog server 30 | - `WordCountExtractor` will be available as an RDF extractor 31 | 32 | See `WordCountExtractorTest.java` for an API usage example. 33 | -------------------------------------------------------------------------------- /examples/dotnet/DotNetRDFConsoleSample/DotNetRDFConsoleSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | DotNetRDFConsoleSample 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/dotnet/HttpApiConsoleSample/HttpApiConsoleSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | HttpApiConsoleSample 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/dotnet/README.md: -------------------------------------------------------------------------------- 1 | # Stardog .NET Examples 2 | 3 | - [Stardog .NET Examples](#stardog-net-examples) 4 | - [Prequisites to run any of the samples](#prequisites-to-run-any-of-the-samples) 5 | - [Running an Example](#running-an-example) 6 | - [The Examples](#the-examples) 7 | - [HTTP API Example](#http-api-example) 8 | - [dotNetRDF Example](#dotnetrdf-example) 9 | - [TrinityRDF Example](#trinityrdf-example) 10 | - [Prerequisites](#prerequisites) 11 | 12 | The Stardog .NET examples show how you can use .NET code to connect to a Stardog server, manage Stardog databases and query them. 13 | 14 | ## Prequisites to run any of the samples 15 | 16 | * C# development environment (e.g., Visual Studio Community, Visual Studio for Mac, Visual Studio Code, .NET Core SDK, etc.) 17 | 18 | ## Running an Example 19 | 20 | In Visual Studio, select the example project you want to run as the Startup Project. 21 | Build the project and run the resulting program. The program will connect to Stardog and run several queries and print the results to STDOUT. 22 | 23 | ## The Examples 24 | 25 | ### HTTP API Example 26 | 27 | This example project demonstrates how to connect to a Stardog server using Stardog's HTTP API and list, create, and drop databases. 28 | 29 | ### dotNetRDF Example 30 | 31 | This example project demonstrates how to connect to a Stardog server using [dotNetRDF](https://github.com/dotnetrdf/dotnetrdf) and list, create, and drop databases; how to insert triples into a graph and query a graph using SPARQL. 32 | 33 | ### TrinityRDF Example 34 | 35 | This example project demonstrates how to connect to a Stardog server using [TrinityRDF](https://trinity-rdf.net/) and execute queries using SPARQL and LINQ. 36 | 37 | TrinityRDF provides an object mapper layer similar to Entity Framework for RDF data. The ontologies the sample uses can be found in the solution's `Ontologies/` folder. Trinity RDF discovers the ontologies in the solution's `ontologies.config` file. TrinityRDF uses the ontologies to generate mapping code - `Ontologies/Ontologies.g.cs`. A developer uses this generated code to create object models (see the files under the solution's `ObjectModels/` folder) with annotations that connect the C# object to the RDF data. These object models then allow .NET developers to create powerful applications without the need to learn SPARQL! 38 | 39 | #### Prerequisites 40 | 41 | * Stardog with a database named "music" populated the data from `./examples/dotnet/TrinityConsoleSample/Ontologies/music_schema.ttl` and [`music.ttl.gz`](https://github.com/stardog-union/stardog-tutorials/blob/master/music/music.ttl.gz) in a named graph called `http://stardog.com/tutorial` -------------------------------------------------------------------------------- /examples/dotnet/StardogDotNetSamples.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2881138B-762A-484D-966C-8C38F64B0212}" 5 | ProjectSection(SolutionItems) = preProject 6 | README.md = README.md 7 | EndProjectSection 8 | EndProject 9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrinityConsoleSample", "TrinityConsoleSample\TrinityConsoleSample.csproj", "{5C32FFE3-D22E-4829-AF93-72AD4CE0C2F8}" 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetRDFConsoleSample", "DotNetRDFConsoleSample\DotNetRDFConsoleSample.csproj", "{128E972A-8599-4863-B4B6-894AE29C57BB}" 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpApiConsoleSample", "HttpApiConsoleSample\HttpApiConsoleSample.csproj", "{610A0047-ABEC-4BD8-B428-9ACC1315D4F0}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {5C32FFE3-D22E-4829-AF93-72AD4CE0C2F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {5C32FFE3-D22E-4829-AF93-72AD4CE0C2F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {5C32FFE3-D22E-4829-AF93-72AD4CE0C2F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {5C32FFE3-D22E-4829-AF93-72AD4CE0C2F8}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {128E972A-8599-4863-B4B6-894AE29C57BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {128E972A-8599-4863-B4B6-894AE29C57BB}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {128E972A-8599-4863-B4B6-894AE29C57BB}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {128E972A-8599-4863-B4B6-894AE29C57BB}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {610A0047-ABEC-4BD8-B428-9ACC1315D4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {610A0047-ABEC-4BD8-B428-9ACC1315D4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {610A0047-ABEC-4BD8-B428-9ACC1315D4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {610A0047-ABEC-4BD8-B428-9ACC1315D4F0}.Release|Any CPU.Build.0 = Release|Any CPU 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/Album.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | using System; 18 | using System.Collections.Generic; 19 | 20 | namespace TrinityConsoleSample.ObjectModels 21 | { 22 | ///

23 | /// A collection of songs released by an artist on physical or digital medium. 24 | /// 25 | [RdfClass(MUSIC.Album)] 26 | public class Album : Resource 27 | { 28 | 29 | #region Members 30 | 31 | /// 32 | /// The name of an entity. 33 | /// 34 | [RdfProperty(MUSIC.name)] 35 | public string Name { get; set; } 36 | 37 | /// 38 | /// The release date of an album. 39 | /// 40 | [RdfProperty(MUSIC.date)] 41 | public DateTime ReleaseDate { get; set; } 42 | 43 | /// 44 | /// The artist that performed this album. 45 | /// 46 | [RdfProperty(MUSIC.artist)] 47 | public Artist Artist { get; set; } 48 | 49 | /// 50 | /// A song included in an album. 51 | /// 52 | [RdfProperty(MUSIC.track)] 53 | public List Tracks { get; set; } 54 | 55 | #endregion 56 | 57 | #region Constructors 58 | 59 | public Album(Uri uri) : base(uri) { } 60 | 61 | #endregion 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/Artist.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | using System; 18 | 19 | namespace TrinityConsoleSample.ObjectModels 20 | { 21 | /// 22 | /// A person or a group of people creating and performing music 23 | /// 24 | [RdfClass(MUSIC.Artist)] 25 | public class Artist : Resource, IArtist 26 | { 27 | 28 | #region Members 29 | 30 | /// 31 | /// The name of an entity. 32 | /// 33 | [RdfProperty(MUSIC.name)] 34 | public string Name { get; set; } 35 | 36 | #endregion 37 | 38 | #region Constructors 39 | 40 | public Artist(Uri uri) : base(uri) { } 41 | 42 | #endregion 43 | } 44 | } -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/Band.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | using System; 18 | using System.Collections.Generic; 19 | 20 | namespace TrinityConsoleSample.ObjectModels 21 | { 22 | /// 23 | /// A music group; that is, is a group of people creating and performing music together. 24 | /// 25 | [RdfClass(MUSIC.Band)] 26 | class Band : Artist 27 | { 28 | #region Members 29 | 30 | /// 31 | /// A member of a band. Does not distinguish between past vs current members 32 | /// 33 | [RdfProperty(MUSIC.member)] 34 | public List Members { get; set; } 35 | 36 | #endregion 37 | 38 | #region Constructors 39 | 40 | public Band(Uri uri) : base(uri) { } 41 | 42 | #endregion 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/IArtist.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | 18 | namespace TrinityConsoleSample.ObjectModels 19 | { 20 | public interface IArtist 21 | { 22 | #region Members 23 | 24 | /// 25 | /// The name of an entity. 26 | /// 27 | string Name { get; set; } 28 | 29 | #endregion 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/Person.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | using System; 18 | 19 | namespace TrinityConsoleSample.ObjectModels 20 | { 21 | /// 22 | /// A person. 23 | /// 24 | [RdfClass(MUSIC.Person)] 25 | public class Person : Resource 26 | { 27 | #region Members 28 | 29 | /// 30 | /// The name of an entity. 31 | /// 32 | [RdfProperty(MUSIC.name)] 33 | public string Name { get; set; } 34 | 35 | #endregion 36 | 37 | #region Constructors 38 | 39 | public Person(Uri uri) : base(uri) { } 40 | 41 | #endregion 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/SoloArtist.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | using System; 18 | 19 | namespace TrinityConsoleSample.ObjectModels 20 | { 21 | // NOTE: in the ontology SoloArtist is a sub class of Artist AND Person. In C#, 22 | // we can handle that by inheriting from one of the concrete classes and interfaces which 23 | // represent the other classes 24 | 25 | /// 26 | /// A single person who is a musical artist. 27 | /// 28 | [RdfClass(MUSIC.SoloArtist)] 29 | class SoloArtist : Person, IArtist 30 | { 31 | #region Constructors 32 | 33 | public SoloArtist(Uri uri) : base(uri) { } 34 | 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/Song.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | using System; 18 | using System.Collections.Generic; 19 | 20 | namespace TrinityConsoleSample.ObjectModels 21 | { 22 | /// 23 | /// A music recording that is a single work of music. 24 | /// 25 | [RdfClass(MUSIC.Song)] 26 | public class Song : Resource 27 | { 28 | 29 | #region Members 30 | 31 | /// 32 | /// The name of an entity. 33 | /// 34 | [RdfProperty(MUSIC.name)] 35 | public string Name { get; set; } 36 | 37 | /// 38 | /// A person or a group of people who participated in the creation of song as a composer or a lyricist. 39 | /// 40 | [RdfProperty(MUSIC.writer)] 41 | public List Writers { get; set; } 42 | 43 | /// 44 | /// The length of a song in the album expressed in seconds. 45 | /// 46 | [RdfProperty(MUSIC.length)] 47 | public int Length { get; set; } 48 | 49 | #endregion 50 | 51 | #region Constructors 52 | 53 | public Song(Uri uri) : base(uri) { } 54 | 55 | #endregion 56 | } 57 | } -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ObjectModels/Songwriter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2019, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | using example; 16 | using Semiodesk.Trinity; 17 | using System; 18 | 19 | namespace TrinityConsoleSample.ObjectModels 20 | { 21 | /// 22 | /// A person or a group of people who participated in the creation of song as a composer or a lyricist. 23 | /// 24 | [RdfClass(MUSIC.Songwriter)] 25 | public class Songwriter : Person 26 | { 27 | #region Constructors 28 | 29 | public Songwriter(Uri uri) : base(uri) { } 30 | 31 | #endregion 32 | } 33 | } -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/Ontologies/music_schema.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix rdf: . 3 | @prefix rdfs: . 4 | @prefix xsd: . 5 | 6 | :Person a rdfs:Class ; 7 | rdfs:label "Person" ; 8 | rdfs:comment "A person." . 9 | 10 | :Artist a rdfs:Class ; 11 | rdfs:label "Artist" ; 12 | rdfs:comment "A person or a group of people creating and performing music." . 13 | 14 | :Band a rdfs:Class ; 15 | rdfs:label "Band" ; 16 | rdfs:comment "A music group; that is, is a group of people creating and performing music together." ; 17 | rdfs:subClassOf :Artist . 18 | 19 | :SoloArtist a rdfs:Class ; 20 | rdfs:label "SoloArtist" ; 21 | rdfs:comment "A single person who is a musical artist." ; 22 | rdfs:subClassOf :Artist , :Person . 23 | 24 | :Album a rdfs:Class ; 25 | rdfs:label "Album" ; 26 | rdfs:comment "A collection of songs released by an artist on physical or digital medium." . 27 | 28 | :Song a rdfs:Class ; 29 | rdfs:label "Song" ; 30 | rdfs:comment "A music recording that is a single work of music." . 31 | 32 | :Songwriter a rdfs:Class ; 33 | rdfs:label "Songwriter" ; 34 | rdfs:comment "A person or a group of people who participated in the creation of song as a composer or a lyricist." ; 35 | rdfs:subClassOf :Person . 36 | 37 | :name a rdf:Property ; 38 | rdfs:label "name" ; 39 | rdfs:comment "The name of an entity." ; 40 | rdfs:range xsd:string . 41 | 42 | :member a rdf:Property ; 43 | rdfs:label "member" ; 44 | rdfs:comment "A member of a band. Does not distinguish between past vs current members." ; 45 | rdfs:domain :Band ; 46 | rdfs:range :SoloArtist . 47 | 48 | :date a rdf:Property ; 49 | rdfs:label "date" ; 50 | rdfs:comment "The release date of an album." ; 51 | rdfs:domain :Album ; 52 | rdfs:range xsd:date . 53 | 54 | :artist a rdf:Property ; 55 | rdfs:label "artist" ; 56 | rdfs:comment "The artist that performed this album." ; 57 | rdfs:domain :Album ; 58 | rdfs:range :Artist . 59 | 60 | :track a rdf:Property ; 61 | rdfs:label "track" ; 62 | rdfs:comment "A song included in an album." ; 63 | rdfs:domain :Album ; 64 | rdfs:range :Song . 65 | 66 | :writer a rdf:Property ; 67 | rdfs:label "writer" ; 68 | rdfs:comment "A person or a group of people who participated in the creation of song as a composer or a lyricist." ; 69 | rdfs:domain :Song ; 70 | rdfs:range :Songwriter . 71 | 72 | :length a rdf:Property ; 73 | rdfs:label "length" ; 74 | rdfs:comment "The length of a song in the album expressed in seconds." ; 75 | rdfs:domain :Song ; 76 | rdfs:range xsd:integer . 77 | -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/TrinityConsoleSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | TrinityConsoleSample.Program 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Always 15 | 16 | 17 | Always 18 | 19 | 20 | Always 21 | 22 | 23 | Always 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/dotnet/TrinityConsoleSample/ontologies.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/dotnet/build.gradle: -------------------------------------------------------------------------------- 1 | task DotnetClean (type:Exec){ 2 | commandLine 'dotnet', 'clean', '-c', 'Release', '-v', 'normal', project.solution 3 | } 4 | 5 | task DotnetCompile (type:Exec, dependsOn: DotnetClean){ 6 | commandLine 'dotnet', 'build', '-c', 'Release', '-v', 'normal', project.solution 7 | } 8 | 9 | task DotnetRun (type:Exec, dependsOn: DotnetCompile){ 10 | workingDir './TrinityConsoleSample' 11 | commandLine 'dotnet', 'run', '-c', 'Release', '-v', 'normal', '--no-build' 12 | } 13 | 14 | task compileDotnet (dependsOn: DotnetCompile){ 15 | } 16 | 17 | task runDotnet (dependsOn: DotnetRun) { 18 | } 19 | -------------------------------------------------------------------------------- /examples/dotnet/gradle.properties: -------------------------------------------------------------------------------- 1 | solution=StardogDotNetSamples.sln 2 | 3 | -------------------------------------------------------------------------------- /examples/entity-resolution-databricks/Entity_Resolution_Blog_Data_Consumption.dbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/entity-resolution-databricks/Entity_Resolution_Blog_Data_Consumption.dbc -------------------------------------------------------------------------------- /examples/entity-resolution-databricks/Entity_Resolution_Blog_Data_Preparation.dbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/entity-resolution-databricks/Entity_Resolution_Blog_Data_Preparation.dbc -------------------------------------------------------------------------------- /examples/entity-resolution-databricks/er.properties: -------------------------------------------------------------------------------- 1 | stardog.er.dataset.partition=96 2 | stardog.er.similarity.threshold=.85 -------------------------------------------------------------------------------- /examples/entity-resolution-databricks/np_providers_vg.sms: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix rdf: 3 | prefix rdfs: 4 | prefix xsd: 5 | prefix owl: 6 | prefix so: 7 | prefix stardog: 8 | prefix provider: 9 | 10 | # national providers 11 | MAPPING 12 | FROM SQL { 13 | SELECT * 14 | FROM `main`.`entity_resolution_demo`.`nationalprovidersclean` 15 | } 16 | TO { 17 | ?Address_iri a provider:Address ; 18 | rdfs:label ?Full_Street_Address ; 19 | provider:street_address_line_one ?Line_1_Street_Address ; 20 | provider:street_address_line_two ?Line_2_Street_Address ; 21 | provider:full_address ?Full_Street_Address ; 22 | provider:city ?City ; 23 | provider:state ?State ; 24 | provider:zip_code ?Zip_Code . 25 | 26 | ?Physician_iri a provider:Physician ; 27 | rdfs:label ?Full_Name ; 28 | provider:first_name ?First_Name ; 29 | provider:last_name ?Last_Name ; 30 | provider:middle_initial ?Middle_Name ; 31 | provider:full_name ?Full_Name; 32 | provider:npi ?NPI . 33 | 34 | ?Source_iri a provider:Source ; 35 | rdfs:label ?source ; 36 | provider:source_name ?source . 37 | 38 | ?Specialty_iri a provider:Specialty ; 39 | rdfs:label ?Specialty ; 40 | provider:specialty_name ?Specialty . 41 | 42 | ?University_iri a provider:University ; 43 | rdfs:label ?Medical_School_Name ; 44 | provider:school_name ?Medical_School_Name . 45 | 46 | ?Physician_iri provider:attended_medical_school ?University_iri . 47 | 48 | ?Physician_iri provider:primary_practice_address ?Address_iri . 49 | 50 | ?Physician_iri provider:sourced_from ?Source_iri . 51 | 52 | ?Physician_iri provider:specializes_in ?Specialty_iri . 53 | } 54 | WHERE { 55 | BIND(TEMPLATE("urn:provider:data:Physician:NP_{NPI}") AS ?Physician_iri) 56 | BIND(TEMPLATE("urn:provider:data:Address:{Full_Street_Address}_{City}_{State}_{Zip_Code}") AS ?Address_iri) 57 | BIND(TEMPLATE("urn:provider:data:Specialty:{Specialty}") AS ?Specialty_iri) 58 | BIND(TEMPLATE("urn:provider:data:Source:{source}") AS ?Source_iri) 59 | BIND(TEMPLATE("urn:provider:data:University:{Medical_School_Name}") AS ?University_iri) 60 | } -------------------------------------------------------------------------------- /examples/entity-resolution-databricks/op_providers_vg.sms: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix rdf: 3 | prefix rdfs: 4 | prefix xsd: 5 | prefix owl: 6 | prefix so: 7 | prefix stardog: 8 | prefix provider: 9 | # open payment 10 | MAPPING 11 | FROM SQL { 12 | SELECT * 13 | FROM `main`.`entity_resolution_demo`.`openpaymentprovidersclean` 14 | } 15 | TO { 16 | ?Address_iri a provider:Address ; 17 | rdfs:label ?Full_Street_Address ; 18 | provider:street_address_line_one ?Physician_Profile_Address_Line_1 ; 19 | provider:street_address_line_two ?Physician_Profile_Address_Line_2 ; 20 | provider:full_address ?Full_Street_Address ; 21 | provider:city ?Physician_Profile_City ; 22 | provider:state ?Physician_Profile_State ; 23 | provider:zip_code ?Physician_Profile_Zipcode . 24 | 25 | ?Physician_iri a provider:Physician ; 26 | rdfs:label ?Full_Name ; 27 | provider:first_name ?Physician_Profile_First_Name ; 28 | provider:profile_id ?Physician_Profile_ID ; 29 | provider:last_name ?Physician_Profile_Last_Name ; 30 | provider:full_name ?Full_Name; 31 | provider:middle_initial ?Physician_Initial . 32 | 33 | ?Source_iri a provider:Source ; 34 | rdfs:label ?source ; 35 | provider:source_name ?source . 36 | 37 | ?Specialty_iri a provider:Specialty ; 38 | rdfs:label ?Physician_Specialty ; 39 | provider:specialty_name ?Physician_Specialty . 40 | 41 | 42 | ?Physician_iri provider:primary_practice_address ?Address_iri . 43 | 44 | ?Physician_iri provider:sourced_from ?Source_iri . 45 | 46 | ?Physician_iri provider:specializes_in ?Specialty_iri . 47 | 48 | } 49 | WHERE { 50 | BIND(TEMPLATE("urn:provider:data:Physician:OP_{Physician_Profile_ID}") AS ?Physician_iri) 51 | BIND(TEMPLATE("urn:provider:data:Specialty:{Physician_Specialty}") AS ?Specialty_iri) 52 | BIND(TEMPLATE("urn:provider:data:Address:{Full_Street_Address}_{Physician_Profile_City}_{Physician_Profile_State}_{Physician_Profile_Zipcode}") AS ?Address_iri) 53 | BIND(TEMPLATE("urn:provider:data:Source:{source}") AS ?Source_iri) 54 | } -------------------------------------------------------------------------------- /examples/function/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.complexible.stardog.examples.function" 2 | 3 | dependencies { 4 | // server core modules 5 | implementation platform("com.complexible.stardog:server:${stardogVersion}") 6 | } 7 | -------------------------------------------------------------------------------- /examples/function/main/resources/META-INF/services/com.complexible.stardog.plan.filter.functions.Function: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.functions.TitleCase 2 | com.complexible.stardog.plan.aggregates.GMean -------------------------------------------------------------------------------- /examples/grafana/img/All_Databases_-_Grafana_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/grafana/img/All_Databases_-_Grafana_1.png -------------------------------------------------------------------------------- /examples/grafana/img/All_Databases_-_Grafana_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/grafana/img/All_Databases_-_Grafana_2.png -------------------------------------------------------------------------------- /examples/grafana/img/Stardog_Overview_-_Grafana_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/grafana/img/Stardog_Overview_-_Grafana_1.png -------------------------------------------------------------------------------- /examples/grafana/img/Stardog_Overview_-_Grafana_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/grafana/img/Stardog_Overview_-_Grafana_2.png -------------------------------------------------------------------------------- /examples/grafana/img/stardog-import-grafana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/grafana/img/stardog-import-grafana.png -------------------------------------------------------------------------------- /examples/grafana/prometheus-stardog-values.yaml: -------------------------------------------------------------------------------- 1 | 2 | # extra scrape configuration for prometheus server to grab metrics from 3 | # stardog cluster kubenetes pods. 4 | # 5 | # The first scrape job `stardog` will gather stardog metrics from 6 | # pods with the label: 7 | # app.kubernetes.io/name=stardog 8 | # 9 | # The second scape job `stardog_legacy` will gather metrics from pods with the label: 10 | # stardog.com/resource-type=cluster-node 11 | # 12 | # which is a label from Stardog's earlier generation K8S deployments 13 | # 14 | extraScrapeConfigs: | 15 | - job_name: stardog 16 | metrics_path: /admin/status/prometheus 17 | scrape_interval: 15s 18 | kubernetes_sd_configs: 19 | - role: pod 20 | relabel_configs: 21 | - source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name] 22 | regex: stardog 23 | action: keep 24 | - action: labelmap 25 | regex: __meta_kubernetes_pod_label_(.+) 26 | - source_labels: [__meta_kubernetes_namespace] 27 | action: replace 28 | target_label: kubernetes_namespace 29 | - source_labels: [__meta_kubernetes_pod_name] 30 | action: replace 31 | target_label: kubernetes_pod_name 32 | basic_auth: 33 | username: monitor 34 | password: ******* 35 | - job_name: stardog_legacy 36 | metrics_path: /admin/status/prometheus 37 | scrape_interval: 15s 38 | kubernetes_sd_configs: 39 | - role: pod 40 | relabel_configs: 41 | - source_labels: [__meta_kubernetes_pod_label_stardog_com_resource_type] 42 | regex: cluster-node 43 | action: keep 44 | - action: labelmap 45 | regex: __meta_kubernetes_pod_label_(.+) 46 | - source_labels: [__meta_kubernetes_namespace] 47 | action: replace 48 | target_label: kubernetes_namespace 49 | - source_labels: [__meta_kubernetes_pod_name] 50 | action: replace 51 | target_label: kubernetes_pod_name 52 | basic_auth: 53 | username: monitor 54 | password: ******* -------------------------------------------------------------------------------- /examples/grafana/prometheus-static-config.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example file for configuring the scrape_config section of 3 | # of a prometheus server when not using kubernetes for discovery of the 4 | # endpoints. 5 | # 6 | # replace stardog_hostname below 7 | 8 | scrape_config: 9 | - job_name: stardog 10 | metrics_path: /admin/status/prometheus 11 | scrape_interval: 15s 12 | basic_auth: 13 | username: monitor 14 | password: '*******' 15 | static_config: 16 | targets: 17 | - '' 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/graph-analytics/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This demo illustrates the use of the Spark Connector to some some graph analytics algorithms against data queried from Stardog. In this demo, you will learn: 4 | 5 | 1. How to create different reasoning schemas in Stardog 6 | 2. How to run a graph algorithm from the command line with the selected schema 7 | 3. Why the default query should not be used 8 | 4. How to run GraphAnalytics from the Spark Connector in a Databricks notebook, or as a Databricks Job. 9 | 10 | Complete instructions are found in the [Stardog documentation](https://docs.stardog.com/graph-analytics/setup). -------------------------------------------------------------------------------- /examples/graph-analytics/RouterNotebook.scala: -------------------------------------------------------------------------------- 1 | // Databricks notebook source 2 | import com.stardog.spark.GraphAnalytics 3 | 4 | val sgServer = "https://solutions-demo.stardog.cloud:5820" 5 | val pw = dbutils.secrets.get("vgtest-databricks-secret-scope", "enterprise-demo-pw-cjd") 6 | val userName = dbutils.secrets.get("vgtest-databricks-secret-scope", "enterprise-demo-cjd") 7 | val dbName = "router" 8 | 9 | 10 | 11 | 12 | // COMMAND ---------- 13 | 14 | val q = "construct {?r1 ?p ?r2 .} where {?r1 a net:Router; ?p ?r2 . ?r2 a net:Router . }" 15 | 16 | // COMMAND ---------- 17 | 18 | val params = Array( 19 | "algorithm.name=StronglyConnectedComponents", 20 | "algorithm.iterations=5", 21 | "stardog.server=" + sgServer, 22 | "stardog.database=" + dbName, 23 | "stardog.username=" + userName, 24 | "stardog.password=" + pw, 25 | "stardog.query.timeout=10m", 26 | "stardog.reasoning.schema=onto", 27 | "stardog.query=" + q, 28 | "output.property=http://routers.stardog.com/symComp/component", 29 | "output.graph=http://routers.stardog.com/ontoComp", 30 | "spark.dataset.size=12000" 31 | ) 32 | 33 | // COMMAND ---------- 34 | 35 | GraphAnalytics.main(params) 36 | 37 | // COMMAND ---------- 38 | 39 | 40 | -------------------------------------------------------------------------------- /examples/graph-analytics/basic.ttl: -------------------------------------------------------------------------------- 1 | @prefix net: . 2 | 3 | net:Regional a owl:Class ; 4 | rdfs:label "Regional" . 5 | 6 | net:Local a owl:Class ; 7 | rdfs:label "Local" . 8 | 9 | net:connects a owl:ObjectProperty ; 10 | rdfs:label "connects" . 11 | -------------------------------------------------------------------------------- /examples/graph-analytics/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | stardog-admin db drop router 4 | stardog-admin db create -n router 5 | # stardog data remove --all router 6 | 7 | stardog namespace add --prefix net --uri http://routers.stardog.com/ router 8 | # stardog-admin virtual import router $sms_file routers.csv 9 | stardog-admin virtual import router scope.sms routers_scope.csv 10 | stardog-admin virtual import router routers.sms routers.csv 11 | 12 | stardog data add router -g net:basic basic.ttl 13 | stardog data add router -g net:onto onto.ttl 14 | stardog data add router -g net:sym onto_symmetric.ttl 15 | 16 | stardog reasoning schema --add basic --graphs net:basic -- router 17 | stardog reasoning schema --add onto --graphs net:onto -- router 18 | stardog reasoning schema --add sym --graphs net:sym -- router 19 | 20 | stardog query router "select (count(*) as ?n) {?s ?p ?o .}" 21 | 22 | 23 | echo 'stardog query --schema onto router "select * { net:r_465 net:connects ?o .}"' 24 | stardog query --schema basic router "select * { net:r_465 net:connects ?o .}" 25 | 26 | echo 'stardog query --schema sym router "select * { net:r_465 net:connects ?o .}"' 27 | stardog query --schema sym router "select * { net:r_465 net:connects ?o .}" 28 | 29 | -------------------------------------------------------------------------------- /examples/graph-analytics/databricks_job.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/graph-analytics/databricks_job.png -------------------------------------------------------------------------------- /examples/graph-analytics/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/graph-analytics/network.png -------------------------------------------------------------------------------- /examples/graph-analytics/network.properties: -------------------------------------------------------------------------------- 1 | # Algorithm parameters 2 | algorithm.name=ConnectedComponents 3 | # algorithm.name=LabelPropagation 4 | # algorithm.name=PageRank 5 | #algorithm.name=StronglyConnectedComponents 6 | # algorithm.name=TriangleCount 7 | algorithm.iterations=10 8 | 9 | # Stardog connection parameters 10 | stardog.server=http://localhost:5820 11 | stardog.database=network 12 | stardog.username=admin 13 | stardog.password=admin 14 | stardog.query.timeout=10m 15 | #stardog.reasoning=true 16 | #stardog.reasoning.schema=onto 17 | stardog.query=construct {?r1 ?p ?r2 .} where {?r1 a net:Router ; ?p ?r2 . ?r2 a net:Router . } 18 | 19 | # Output parameters 20 | output.property=http://routers.stardog.com/test2/component 21 | output.graph=http://routers.stardog.com/test2 22 | 23 | # Spark parameters 24 | 25 | spark.dataset.size=20 -------------------------------------------------------------------------------- /examples/graph-analytics/network.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | stardog-admin db drop network 4 | stardog-admin db create -n network 5 | 6 | stardog namespace add --prefix net --uri http://routers.stardog.com/ network 7 | stardog data add network network.ttl 8 | 9 | -------------------------------------------------------------------------------- /examples/graph-analytics/network.ttl: -------------------------------------------------------------------------------- 1 | @prefix net: . 2 | 3 | net:able a net:Router . 4 | net:baker a net:Router . 5 | net:charlie a net:Router . 6 | net:delta a net:Router . 7 | net:echo a net:Router . 8 | net:foxtrot a net:Router . 9 | 10 | net:able net:connects net:baker . 11 | net:baker net:connects net:charlie . 12 | net:charlie net:connects net:able . 13 | 14 | net:delta net:connects net:echo . 15 | net:echo net:connects net:delta . 16 | 17 | net:Router a owl:Class . 18 | net:connects a owl:ObjectProperty . 19 | -------------------------------------------------------------------------------- /examples/graph-analytics/network_spark.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # whoami 4 | date 5 | 6 | spark-submit --master local[*] --files network.properties stardog-spark-connector-2.0.0.jar network.properties 7 | 8 | date 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/graph-analytics/onto.ttl: -------------------------------------------------------------------------------- 1 | @prefix net: . 2 | 3 | net:Router a owl:Class ; 4 | rdfs:label "Router" . 5 | 6 | net:Regional rdfs:subClassOf net:Router ; 7 | rdfs:label "Regional" . 8 | net:Local rdfs:subClassOf net:Router ; 9 | rdfs:label "Local" . 10 | 11 | net:connects a owl:ObjectProperty ; 12 | rdfs:label "connects" ; 13 | rdfs:domain net:Router ; 14 | rdfs:range net:Router . 15 | 16 | -------------------------------------------------------------------------------- /examples/graph-analytics/onto_symmetric.ttl: -------------------------------------------------------------------------------- 1 | @prefix net: . 2 | @prefix rule: . 3 | 4 | net:Router a owl:Class ; 5 | rdfs:label "Router" . 6 | 7 | net:Regional rdfs:subClassOf net:Router ; 8 | rdfs:label "Regional" . 9 | net:Local rdfs:subClassOf net:Router ; 10 | rdfs:label "Local" . 11 | 12 | net:connects a owl:ObjectProperty ; 13 | rdfs:label "connects" ; 14 | rdfs:domain net:Router ; 15 | rdfs:range net:Router . 16 | 17 | IF { 18 | ?r1 net:connects ?r2 19 | } 20 | THEN { 21 | ?r2 net:connects ?r1 22 | } 23 | 24 | -------------------------------------------------------------------------------- /examples/graph-analytics/router.properties: -------------------------------------------------------------------------------- 1 | # Algorithm parameters 2 | # algorithm.name=ConnectedComponents 3 | # algorithm.name=LabelPropagation 4 | # algorithm.name=PageRank 5 | algorithm.name=StronglyConnectedComponents 6 | # algorithm.name=TriangleCount 7 | algorithm.iterations=10 8 | 9 | # Stardog connection parameters 10 | stardog.server=http://localhost:5820 11 | stardog.database=router 12 | stardog.username=admin 13 | stardog.password=admin 14 | stardog.query.timeout=10m 15 | #stardog.reasoning=true 16 | stardog.reasoning.schema=onto 17 | stardog.query=construct {?r1 ?p ?r2 .} where {?r1 a net:Router ; ?p ?r2 . ?r2 a net:Router . } 18 | 19 | # Output parameters 20 | output.property=http://routers.stardog.com/ontoComp/component 21 | output.graph=http://routers.stardog.com/ontoComp 22 | 23 | # Spark parameters 24 | 25 | spark.dataset.size=12000 -------------------------------------------------------------------------------- /examples/graph-analytics/routers.sms: -------------------------------------------------------------------------------- 1 | prefix net: 2 | 3 | Mapping 4 | from CSV { 5 | } 6 | to { 7 | ?from_iri net:connects ?to_iri . 8 | } 9 | where { 10 | bind(template("http://routers.stardog.com/r_{from}") as ?from_iri) 11 | bind(template("http://routers.stardog.com/r_{to}") as ?to_iri) 12 | } -------------------------------------------------------------------------------- /examples/graph-analytics/run_spark.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # whoami 4 | date 5 | 6 | spark-submit --master local[*] --files router.properties stardog-spark-connector-2.0.0.jar router.properties 7 | 8 | date 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/graph-analytics/scope.sms: -------------------------------------------------------------------------------- 1 | prefix net: 2 | 3 | Mapping 4 | from CSV { 5 | } 6 | to { 7 | ?router_iri rdf:type ?type ; 8 | rdfs:label ?name . 9 | } 10 | where { 11 | bind(template("http://routers.stardog.com/r_{name}") as ?router_iri) 12 | bind(template("http://routers.stardog.com/{scope}") as ?type) 13 | } -------------------------------------------------------------------------------- /examples/graph-analytics/solutions.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | stardog-admin db drop -u $U -p $P router 4 | stardog-admin db create -n router -u $U -p $P 5 | # stardog data remove --all router 6 | 7 | stardog namespace add -u $U -p $P --prefix net --uri http://routers.stardog.com/ router 8 | # stardog-admin virtual import router $sms_file routers.csv 9 | stardog-admin virtual import -u $U -p $P router scope.sms routers_scope.csv 10 | stardog-admin virtual import -u $U -p $P router routers.sms routers.csv 11 | 12 | stardog data add router -u $U -p $P -g net:basic basic.ttl 13 | stardog data add router -u $U -p $P -g net:onto onto.ttl 14 | stardog data add router -u $U -p $P -g net:sym onto_symmetric.ttl 15 | 16 | stardog reasoning schema -u $U -p $P --add basic --graphs net:basic -- router 17 | stardog reasoning schema -u $U -p $P --add onto --graphs net:onto -- router 18 | stardog reasoning schema -u $U -p $P --add sym --graphs net:sym -- router 19 | 20 | stardog query -u $U -p $P router "select (count(*) as ?n) {?s ?p ?o .}" 21 | 22 | 23 | echo 'stardog query --schema onto router "select * { net:r_465 net:connects ?o .}"' 24 | stardog query -u $U -p $P --schema basic router "select * { net:r_465 net:connects ?o .}" 25 | 26 | echo 'stardog query --schema sym router "select * { net:r_465 net:connects ?o .}"' 27 | stardog query -u $U -p $P --schema sym router "select * { net:r_465 net:connects ?o .}" 28 | 29 | -------------------------------------------------------------------------------- /examples/http_handler/README.md: -------------------------------------------------------------------------------- 1 | # Example Stardog Undertow HTTP Handler Extension 2 | 3 | This package is an example of how to create an extension point to the Stardog servers 4 | HTTP handlers. It allows end users to intercept server calls for monitoring, 5 | altering, doing admission control, etc. 6 | 7 | ## Build 8 | 9 | To build the example simply run: `./gradlew jar`. This will create the file: 10 | `./build/libs/handler-1.0.jar` which contains the handler extension and the 11 | `META-INF/services` definition that tells Stardog how to load this into the 12 | handler chain. 13 | 14 | ## Load into Stardog 15 | 16 | To load the module into Stardog set the environment variable `STARDOG_EXT` 17 | to the path that contains the jar referenced above or copy the jar file 18 | to a directory in Stardog's classpath, eg: `server/ext`. 19 | Then use `stardog-admin` to start the server in the typical manner. 20 | For example: 21 | ``` 22 | export STARDOG_EXT=/home/bresnaha/stardog-examples/examples/handler/build/libs 23 | stardog-admin server start 24 | ``` 25 | 26 | For more information see the documentation [here](https://www.stardog.com/docs/#_extending_stardog) 27 | -------------------------------------------------------------------------------- /examples/http_handler/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.complexible.stardog.examples.handler" 2 | 3 | dependencies { 4 | // server core modules 5 | implementation platform("com.complexible.stardog:server:${stardogVersion}") 6 | } 7 | -------------------------------------------------------------------------------- /examples/http_handler/main/resources/META-INF/services/io.undertow.server.HttpHandler: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.handler.ExtHttpHandler -------------------------------------------------------------------------------- /examples/http_handler/main/src/com/complexible/stardog/examples/handler/ExtHttpHandler.java: -------------------------------------------------------------------------------- 1 | package com.complexible.stardog.examples.handler; 2 | 3 | 4 | import com.stardog.http.server.undertow.HttpServiceLoader; 5 | import io.undertow.server.HttpHandler; 6 | import io.undertow.server.HttpServerExchange; 7 | import io.undertow.util.HttpString; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | public class ExtHttpHandler implements HttpHandler { 12 | 13 | private static final Logger LOGGER = LoggerFactory.getLogger(ExtHttpHandler.class); 14 | 15 | private final io.undertow.server.HttpHandler mNext; 16 | private final HttpServiceLoader.ServerContext mContext; 17 | 18 | 19 | public ExtHttpHandler(final HttpHandler theNext, final HttpServiceLoader.ServerContext theContext) { 20 | LOGGER.error("Loading ExtHttpHandler"); 21 | mNext = theNext; 22 | mContext = theContext; 23 | } 24 | 25 | public void handleRequest(HttpServerExchange theExchange) throws Exception { 26 | LOGGER.error("ExtHttpHandler.handleRequest called"); 27 | theExchange.getResponseHeaders().add(HttpString.tryFromString("TEST_HEADER"), "VALUE"); 28 | mNext.handleRequest(theExchange); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/http_handler/test/resources/META-INF/services/io.undertow.server.HttpHandler: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.handler.ExtHttpHandler -------------------------------------------------------------------------------- /examples/machinelearning/1-histogram.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | 3 | select ?rating (count(*) as ?count) 4 | where { 5 | ?movie :rating ?float 6 | bind(xsd:integer(?float) as ?rating) 7 | } 8 | group by ?rating 9 | order by desc(?rating) 10 | -------------------------------------------------------------------------------- /examples/machinelearning/2-simple_model.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | INSERT { 5 | graph spa:model { 6 | :r1 a spa:RegressionModel ; 7 | spa:arguments (?genres ?contentRating ?storyline ?metaCritic) ; 8 | spa:predict ?rating ; 9 | spa:crossValidation 100 ; 10 | spa:evaluation true ; 11 | spa:evaluationMetric spa:mae ; 12 | spa:overwrite True . 13 | } 14 | } 15 | WHERE { 16 | SELECT 17 | (spa:set(?genre) as ?genres) 18 | ?contentRating 19 | ?storyline 20 | ?metaCritic 21 | ?rating 22 | { 23 | ?movie :rating ?rating ; 24 | :genre ?genre ; 25 | :contentRating ?contentRating ; 26 | :storyline ?storyline . 27 | 28 | OPTIONAL { 29 | ?movie :metaCritic ?metaCritic . 30 | } 31 | } 32 | GROUP BY ?movie ?rating ?contentRating ?storyline ?metaCritic 33 | } 34 | -------------------------------------------------------------------------------- /examples/machinelearning/2.1-score.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | SELECT ?mean_absolute_error 5 | WHERE { 6 | graph spa:model { 7 | :r1 spa:evaluationScore ?mean_absolute_error 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/machinelearning/3-tweaked_parameters.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | INSERT { 5 | graph spa:model { 6 | :r2 a spa:RegressionModel ; 7 | spa:parameters [ 8 | spa:loss_function 'squared' ; 9 | spa:b 22 ; 10 | spa:l (0.01 0.08) ; 11 | spa:l1 (0.0000001 0.000001) ; 12 | spa:passes 2 ; 13 | spa:k True ; 14 | spa:c True ; 15 | spa:holdout_off True ; 16 | ] ; 17 | spa:arguments (?authors ?directors ?producers ?keywords ?contentRating ?year ?metaCritic) ; 18 | spa:predict ?rating ; 19 | spa:evaluation true ; 20 | spa:crossValidation 100 ; 21 | spa:evaluationMetric spa:mae ; 22 | spa:overwrite True . 23 | } 24 | } 25 | WHERE { 26 | SELECT 27 | (spa:set(?author) as ?authors) 28 | (spa:set(?director) as ?directors) 29 | (spa:set(?producer) as ?producers) 30 | (spa:set(?keyword) as ?keywords) 31 | ?contentRating 32 | ?year 33 | ?metaCritic 34 | ?rating 35 | { 36 | ?movie :rating ?rating ; 37 | :author ?author ; 38 | :director ?director ; 39 | :keyword ?keyword ; 40 | :contentRating ?contentRating ; 41 | :copyrightYear ?year . 42 | 43 | OPTIONAL { 44 | ?movie :productionCompany ?producer . 45 | } 46 | OPTIONAL { 47 | ?movie :metaCritic ?metaCritic . 48 | } 49 | } 50 | GROUP BY ?movie ?contentRating ?year ?metaCritic ?rating 51 | } 52 | -------------------------------------------------------------------------------- /examples/machinelearning/3.1-score.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | SELECT ?mean_absolute_error 5 | WHERE { 6 | graph spa:model { 7 | :r2 spa:evaluationScore ?mean_absolute_error 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/machinelearning/4-predicted_ratings.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | SELECT ?title ?rating ?predictedRating 5 | WHERE { 6 | graph spa:model { 7 | :r2 spa:arguments (?authors ?directors ?producers ?keywords ?contentRating ?year ?metaCritic) ; 8 | spa:predict ?predictedRating . 9 | } 10 | 11 | { 12 | SELECT 13 | (spa:set(?author) as ?authors) 14 | (spa:set(?director) as ?directors) 15 | (spa:set(?producer) as ?producers) 16 | (spa:set(?keyword) as ?keywords) 17 | ?contentRating 18 | ?year 19 | ?metaCritic 20 | ?rating 21 | ?title 22 | { 23 | ?movie rdfs:label ?title ; 24 | :rating ?rating ; 25 | :author ?author ; 26 | :director ?director ; 27 | :productionCompany ?producer ; 28 | :keyword ?keyword ; 29 | :contentRating ?contentRating ; 30 | :copyrightYear ?year ; 31 | :metaCritic ?metaCritic . 32 | } 33 | GROUP BY ?movie ?contentRating ?year ?metaCritic ?rating ?title 34 | ORDER BY rand() 35 | LIMIT 20 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/machinelearning/5-top_recommended_movies.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | 3 | SELECT ?rec 4 | WHERE { 5 | ?movie :recommendation ?rec . 6 | } 7 | GROUP BY ?rec 8 | ORDER BY desc(count(?rec) * rand()) 9 | LIMIT 100 10 | 11 | # t:tt0137523, t:tt1375666, t:tt0105236, t:tt1228705, t:tt0126029, t:tt1591095, t:tt1637725, t:tt0102926, t:tt0251127, t:tt0133093, t:tt0382932, t:tt1853728, t:tt0389860, t:tt1232829, t:tt1129442, t:tt1300854, t:tt0104431, t:tt0762107, t:tt0327084, t:tt0167260, t:tt0448157, t:tt0816711, t:tt0145487, t:tt0332280, t:tt0364725, t:tt0117060, t:tt0088763, t:tt1285016, t:tt0454876, t:tt2562232, t:tt1877832, t:tt0400717, t:tt0436697, t:tt0114369, t:tt0281358, t:tt0120611, t:tt0266697, t:tt0280590, t:tt0351283, t:tt1320253, t:tt0080684, t:tt0854678, t:tt1454468, t:tt1375670, t:tt0398165, t:tt0211915, t:tt0361862, t:tt0359013, t:tt0901476, t:tt0361748, t:tt0993846, t:tt1631867, t:tt0181689, t:tt0887883, t:tt1033643, t:tt0120737, t:tt0107290, t:tt1606389, t:tt0454848, t:tt0240772, t:tt0765429, t:tt0343818, t:tt0212720, t:tt1632708, t:tt0844471, t:tt3498820, t:tt0077651, t:tt0099685, t:tt0405422, t:tt0073486, t:tt0082971, t:tt0497465, t:tt0167404, t:tt0450278, t:tt1323594, t:tt0120783, t:tt0243155, t:tt1798709, t:tt1489889, t:tt1690953, t:tt1010048, t:tt0337563, t:tt0120660, t:tt0989757, t:tt1277953, t:tt0429591, t:tt0095016, t:tt0388789, t:tt1646987, t:tt0112508, t:tt0415306, t:tt0320691, t:tt0212338, t:tt0382628, t:tt0265086, t:tt0117438, t:tt1392190, t:tt0362227, t:tt0368933, t:tt1431045 12 | -------------------------------------------------------------------------------- /examples/machinelearning/6-recommender_model.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix t: 3 | prefix spa: 4 | 5 | INSERT { 6 | graph spa:model { 7 | :c1 a spa:ClassificationModel ; 8 | spa:parameters [ 9 | spa:b 22 ; 10 | spa:l 1 ; 11 | spa:l1 0.000001 12 | ] ; 13 | spa:arguments (?actors ?writers ?directors ?genres ?producers ?keywords ?languages ?contentRating ?year ?metaCritic ?rating) ; 14 | spa:predict ?rec ; 15 | spa:overwrite True . 16 | } 17 | } 18 | WHERE { 19 | SELECT 20 | (spa:set(?actor) as ?actors) 21 | (spa:set(?writer) as ?writers) 22 | (spa:set(?director) as ?directors) 23 | (spa:set(?genre) as ?genres) 24 | (spa:set(?producer) as ?producers) 25 | (spa:set(?keyword) as ?keywords) 26 | (spa:set(?language) as ?languages) 27 | ?contentRating 28 | ?year 29 | ?metaCritic 30 | ?storyline 31 | ?rating 32 | ?rec 33 | { 34 | ?movie :recommendation ?recommendation ; 35 | :actor ?actor ; 36 | :author ?writer ; 37 | :director ?director ; 38 | :genre ?genre ; 39 | :contentRating ?contentRating ; 40 | :copyrightYear ?year ; 41 | :keyword ?keyword ; 42 | :language ?language ; 43 | :storyline ?storyline ; 44 | :rating ?rating . 45 | ?recommendation rdfs:label ?rec . 46 | 47 | OPTIONAL { 48 | ?movie :productionCompany ?producer . 49 | } 50 | OPTIONAL { 51 | ?movie :metaCritic ?metaCritic . 52 | } 53 | 54 | FILTER (?recommendation in (t:tt0137523, t:tt1375666, t:tt0105236, t:tt1228705, t:tt0126029, t:tt1591095, t:tt1637725, t:tt0102926, t:tt0251127, t:tt0133093, t:tt0382932, t:tt1853728, t:tt0389860, t:tt1232829, t:tt1129442, t:tt1300854, t:tt0104431, t:tt0762107, t:tt0327084, t:tt0167260, t:tt0448157, t:tt0816711, t:tt0145487, t:tt0332280, t:tt0364725, t:tt0117060, t:tt0088763, t:tt1285016, t:tt0454876, t:tt2562232, t:tt1877832, t:tt0400717, t:tt0436697, t:tt0114369, t:tt0281358, t:tt0120611, t:tt0266697, t:tt0280590, t:tt0351283, t:tt1320253, t:tt0080684, t:tt0854678, t:tt1454468, t:tt1375670, t:tt0398165, t:tt0211915, t:tt0361862, t:tt0359013, t:tt0901476, t:tt0361748, t:tt0993846, t:tt1631867, t:tt0181689, t:tt0887883, t:tt1033643, t:tt0120737, t:tt0107290, t:tt1606389, t:tt0454848, t:tt0240772, t:tt0765429, t:tt0343818, t:tt0212720, t:tt1632708, t:tt0844471, t:tt3498820, t:tt0077651, t:tt0099685, t:tt0405422, t:tt0073486, t:tt0082971, t:tt0497465, t:tt0167404, t:tt0450278, t:tt1323594, t:tt0120783, t:tt0243155, t:tt1798709, t:tt1489889, t:tt1690953, t:tt1010048, t:tt0337563, t:tt0120660, t:tt0989757, t:tt1277953, t:tt0429591, t:tt0095016, t:tt0388789, t:tt1646987, t:tt0112508, t:tt0415306, t:tt0320691, t:tt0212338, t:tt0382628, t:tt0265086, t:tt0117438, t:tt1392190, t:tt0362227, t:tt0368933, t:tt1431045)) 55 | } 56 | GROUP BY ?movie ?year ?contentRating ?metaCritic ?storyline ?rating ?rec 57 | } 58 | -------------------------------------------------------------------------------- /examples/machinelearning/6.1.score.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | SELECT ?error 5 | WHERE { 6 | graph spa:model { 7 | :c1 spa:evaluationScore ?error 8 | } 9 | } -------------------------------------------------------------------------------- /examples/machinelearning/7-recommended_movies.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix t: 3 | prefix spa: 4 | 5 | SELECT ?recommendation ?confidence 6 | WHERE { 7 | 8 | graph spa:model { 9 | :c1 spa:arguments (?actors ?writers ?directors ?genres ?producers ?keywords ?languages ?contentRating ?year ?metaCritic ?rating) ; 10 | spa:confidence ?confidence ; 11 | spa:predict ?recommendation . 12 | } 13 | { 14 | SELECT 15 | (spa:set(?actor) as ?actors) 16 | (spa:set(?writer) as ?writers) 17 | (spa:set(?director) as ?directors) 18 | (spa:set(?genre) as ?genres) 19 | (spa:set(?producer) as ?producers) 20 | (spa:set(?keyword) as ?keywords) 21 | (spa:set(?language) as ?languages) 22 | ?contentRating 23 | ?year 24 | ?metaCritic 25 | ?storyline 26 | ?rating 27 | ?movie 28 | { 29 | ?movie :rating ?rating ; 30 | :actor ?actor ; 31 | :author ?writer ; 32 | :director ?director ; 33 | :genre ?genre ; 34 | :contentRating ?contentRating ; 35 | :copyrightYear ?year ; 36 | :productionCompany ?producer ; 37 | :keyword ?keyword ; 38 | :language ?language ; 39 | :storyline ?storyline ; 40 | :metaCritic ?metaCritic . 41 | 42 | FILTER(?movie in (t:tt0118715)) # The Big Lebowski 43 | } 44 | GROUP BY ?movie ?year ?contentRating ?metaCritic ?storyline ?rating 45 | } 46 | } 47 | ORDER BY DESC(?confidence) 48 | LIMIT 5 49 | -------------------------------------------------------------------------------- /examples/machinelearning/8-similarity_model.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | INSERT { 5 | graph spa:model { 6 | :s1 a spa:SimilarityModel ; 7 | spa:arguments (?genres ?directors ?authors ?producers ?metaCritic) ; 8 | spa:predict ?movie ; 9 | spa:overwrite True . 10 | } 11 | } 12 | WHERE { 13 | SELECT 14 | (spa:set(?genre) as ?genres) 15 | (spa:set(?director) as ?directors) 16 | (spa:set(?author) as ?authors) 17 | (spa:set(?producer) as ?producers) 18 | ?metaCritic 19 | ?movie 20 | { 21 | ?movie :genre ?genre ; 22 | :director ?director ; 23 | :author ?author . 24 | 25 | OPTIONAL { 26 | ?movie :productionCompany ?producer . 27 | } 28 | 29 | OPTIONAL { 30 | ?movie :metaCritic ?metaCritic . 31 | } 32 | } 33 | GROUP BY ?movie ?metaCritic 34 | } 35 | -------------------------------------------------------------------------------- /examples/machinelearning/9-similarity_search.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix t: 3 | prefix spa: 4 | 5 | SELECT ?similarMovieLabel ?confidence 6 | WHERE { 7 | graph spa:model { 8 | :s1 spa:arguments (?genres ?directors ?authors ?producers ?metaCritic) ; 9 | spa:confidence ?confidence ; 10 | spa:parameters [ spa:limit 5 ] ; 11 | spa:predict ?similarMovie . 12 | } 13 | 14 | { ?similarMovie rdfs:label ?similarMovieLabel } 15 | 16 | { 17 | SELECT 18 | (spa:set(?genre) as ?genres) 19 | (spa:set(?director) as ?directors) 20 | (spa:set(?author) as ?authors) 21 | (spa:set(?producer) as ?producers) 22 | ?metaCritic 23 | ?movie 24 | { 25 | ?movie :genre ?genre ; 26 | :director ?director ; 27 | :author ?author . 28 | 29 | OPTIONAL { 30 | ?movie :productionCompany ?producer . 31 | } 32 | OPTIONAL { 33 | ?movie :metaCritic ?metaCritic . 34 | } 35 | 36 | VALUES ?movie { t:tt0118715 } # The Big Lebowski 37 | } 38 | GROUP BY ?movie ?metaCritic 39 | } 40 | } 41 | 42 | ORDER BY DESC(?confidence) -------------------------------------------------------------------------------- /examples/machinelearning/delete_model.sparql: -------------------------------------------------------------------------------- 1 | prefix : 2 | prefix spa: 3 | 4 | DELETE DATA { 5 | graph spa:model { 6 | # change model IRI to delete existent model 7 | [] spa:deleteModel :c1 . 8 | } 9 | } -------------------------------------------------------------------------------- /examples/python-client/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | -------------------------------------------------------------------------------- /examples/python-client/requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2021.10.8 2 | charset-normalizer==2.0.7 3 | contextlib2==21.6.0 4 | idna==3.3 5 | pystardog==0.10.0 6 | requests==2.26.0 7 | requests-toolbelt==0.9.1 8 | urllib3==1.26.7 9 | -------------------------------------------------------------------------------- /examples/python-client/sdclient/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/examples/python-client/sdclient/__init__.py -------------------------------------------------------------------------------- /examples/python-client/sdclient/app.py: -------------------------------------------------------------------------------- 1 | import stardog 2 | from pathlib import Path 3 | import pprint 4 | 5 | pp = pprint.PrettyPrinter(indent=2) 6 | 7 | # specify our endpoint, username, and password 8 | # default values are provided, be sure to change if necessary 9 | conn_details = { 10 | 'endpoint': 'http://localhost:5820', 11 | 'username': 'admin', 12 | 'password': 'admin' 13 | } 14 | 15 | def main(): 16 | # create a new admin connection 17 | with stardog.Admin(**conn_details) as admin: 18 | # create a new database 19 | db = admin.new_database('pythondb') 20 | print('Created db') 21 | 22 | # create a connection to the db 23 | with stardog.Connection('pythondb', **conn_details) as conn: 24 | # begin transaction 25 | conn.begin() 26 | # add data to transaction from file 27 | path = str(Path(__file__).parent.resolve() / 'resources/GettingStarted_Music_Data.ttl') 28 | conn.add(stardog.content.File(path)) 29 | # commit the changes 30 | conn.commit() 31 | 32 | # SELECT some of the data we just inserted 33 | pp.pprint(conn.select('SELECT * {?s a :Person} LIMIT 5')) 34 | 35 | # another method of adding data 36 | conn.begin() 37 | conn.add(stardog.content.Raw(':Yo_Yo_Ma a :Person', 'text/turtle')) 38 | conn.commit() 39 | 40 | pp.pprint(conn.select('SELECT ?s { ?s a :Person }')) 41 | 42 | # delete all people from the db 43 | conn.begin() 44 | conn.update('DELETE WHERE { ?s ?p ?o }') 45 | conn.commit() 46 | 47 | pp.pprint(conn.select('SELECT * { ?s ?p ?o }')) 48 | 49 | # drop the db 50 | # (this is for demonstration purposes, you most likely don't want to do this) 51 | db.drop() 52 | print('Dropped db') 53 | 54 | if __name__ == '__main__': 55 | main() -------------------------------------------------------------------------------- /examples/service/build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.complexible.stardog.examples.service" 2 | 3 | dependencies { 4 | // server core modules 5 | implementation platform("com.complexible.stardog:server:${stardogVersion}") 6 | implementation "com.stardog.stark.query:stardog-stark-query-api:${stardogVersion}" 7 | implementation "com.stardog.stark.io:stardog-stark-io-api:${stardogVersion}" 8 | implementation "com.stardog.stark.query.io:stardog-stark-query-io:${stardogVersion}" 9 | } 10 | -------------------------------------------------------------------------------- /examples/service/main/resources/META-INF/services/com.complexible.stardog.StardogModule: -------------------------------------------------------------------------------- 1 | com.complexible.stardog.examples.service.ExampleServiceModule -------------------------------------------------------------------------------- /examples/service/main/src/com/complexible/stardog/examples/service/ExampleServiceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 - 2017, Stardog Union. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.complexible.stardog.examples.service; 17 | 18 | import com.complexible.stardog.AbstractStardogModule; 19 | import com.complexible.stardog.plan.eval.service.Service; 20 | import com.google.inject.Singleton; 21 | import com.google.inject.multibindings.Multibinder; 22 | 23 | /** 24 | * Guice module to register the example service 25 | * 26 | * @author Evren Sirin 27 | */ 28 | public final class ExampleServiceModule extends AbstractStardogModule { 29 | @Override 30 | protected void configure() { 31 | Multibinder.newSetBinder(binder(), Service.class) 32 | .addBinding() 33 | .to(ExampleService.class) 34 | .in(Singleton.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/stardog_free/readme.md: -------------------------------------------------------------------------------- 1 | # Stardog Free Examples 2 | 3 | ## Flight Planning 4 | 5 | The Flight Planning Knowledge Kit is an aviation focused dataset and flight planning demo and can be accessed from [Stardog Cloud](https://cloud.stardog.com/). The provided flights.csv can be used to expand the kit. Data provided was sourced from https://openflights.org/data.html#airline. 6 | -------------------------------------------------------------------------------- /examples/virtual/optimization/01uniquekeys.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :uniques 4 | FROM SQL { 5 | SELECT * FROM Bands 6 | } 7 | TO { 8 | ?band a :Band ; 9 | rdfs:label ?name ; 10 | :country ?country ; 11 | :yearFormed ?year_formed . 12 | } 13 | WHERE { 14 | BIND(TEMPLATE("urn:band:{id}") AS ?band) 15 | } 16 | -------------------------------------------------------------------------------- /examples/virtual/optimization/01uniquekeys.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS examples; 2 | USE examples; 3 | 4 | DROP TABLE IF EXISTS Bands; 5 | 6 | CREATE TABLE Bands(id INTEGER, -- note no primary key 7 | name VARCHAR(20), 8 | country VARCHAR(20), 9 | year_formed int); 10 | 11 | INSERT INTO Bands VALUES(1, 'Aerosmith', 'USA', 1970); 12 | INSERT INTO Bands VALUES(1, 'Errorsmith', 'USA', 2022); 13 | 14 | -- DELETE FROM Bands WHERE id=1 AND year_formed=2022; 15 | -------------------------------------------------------------------------------- /examples/virtual/optimization/02denormalized_songs.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS examples; 2 | USE examples; 3 | 4 | DROP TABLE IF EXISTS Songs; 5 | DROP TABLE IF EXISTS SongsNormalized; 6 | DROP TABLE IF EXISTS SongWriter; 7 | DROP TABLE IF EXISTS Artists; 8 | 9 | CREATE TABLE Songs(id INTEGER, 10 | band INTEGER, 11 | writer INTEGER, 12 | name VARCHAR(20)); 13 | 14 | CREATE TABLE SongsNormalized(id INTEGER PRIMARY KEY, 15 | name VARCHAR(20)); 16 | 17 | CREATE TABLE SongWriter(song INTEGER, 18 | artist INTEGER, 19 | PRIMARY KEY(song, artist)); 20 | 21 | 22 | CREATE TABLE Artists(id INTEGER PRIMARY KEY, 23 | name VARCHAR(20) NOT NULL); 24 | 25 | INSERT INTO Songs VALUES(1, 1, 1, 'Mr. Tambourine Man'); 26 | INSERT INTO Songs VALUES(1, 2, 1, 'Mr. Tambourine Man'); 27 | 28 | INSERT INTO SongsNormalized VALUES(1, 'Mr. Tambourine Man'); 29 | INSERT INTO SongsNormalized VALUES(2, 'Changes'); 30 | INSERT INTO SongsNormalized VALUES(3, 'Changes'); 31 | INSERT INTO SongsNormalized VALUES(4, 'Changes'); 32 | 33 | INSERT INTO SongWriter VALUES(1, 1); 34 | INSERT INTO SongWriter VALUES(2, 3); 35 | INSERT INTO SongWriter VALUES(3, 4); 36 | INSERT INTO SongWriter VALUES(3, 5); 37 | INSERT INTO SongWriter VALUES(3, 6); 38 | INSERT INTO SongWriter VALUES(4, 7); 39 | INSERT INTO SongWriter VALUES(4, 8); 40 | INSERT INTO SongWriter VALUES(4, 9); 41 | INSERT INTO SongWriter VALUES(4, 10); 42 | 43 | INSERT INTO Artists VALUES(1, 'Bob Dylan'); 44 | INSERT INTO Artists VALUES(2, 'The Byrds'); 45 | INSERT INTO Artists VALUES(3, 'David Bowie'); 46 | INSERT INTO Artists VALUES(4, 'Trevor Rabin'); 47 | INSERT INTO Artists VALUES(5, 'Jon Anderson'); 48 | INSERT INTO Artists VALUES(6, 'Alan White'); 49 | INSERT INTO Artists VALUES(7, 'Ozzy Osbourne'); 50 | INSERT INTO Artists VALUES(8, 'Tony Iommi'); 51 | INSERT INTO Artists VALUES(9, 'Geezer Butler'); 52 | INSERT INTO Artists VALUES(10, 'Bill Ward'); 53 | 54 | -------------------------------------------------------------------------------- /examples/virtual/optimization/02denormalized_songs_v1.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING 4 | FROM SQL { 5 | SELECT * FROM Songs 6 | } 7 | TO { 8 | ?song a :Song ; 9 | :performedBy ?performer ; 10 | :writtenBy ?writer ; 11 | rdfs:label ?name . 12 | } 13 | WHERE { 14 | BIND(TEMPLATE("urn:song:{id}") AS ?song) 15 | BIND(TEMPLATE("urn:artist:{band}") AS ?performer) 16 | BIND(TEMPLATE("urn:artist:{writer}") AS ?writer) 17 | } 18 | -------------------------------------------------------------------------------- /examples/virtual/optimization/02denormalized_songs_v2.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | # If we know each song has one name 4 | MAPPING 5 | FROM SQL { 6 | SELECT id, MIN(name) AS name FROM Songs GROUP BY id 7 | } 8 | TO { 9 | ?song a :Song ; 10 | rdfs:label ?name . 11 | } 12 | WHERE { 13 | BIND(TEMPLATE("urn:song:{id}") AS ?song) 14 | } 15 | 16 | ; 17 | 18 | MAPPING 19 | FROM SQL { 20 | SELECT id, band, writer FROM Songs 21 | } 22 | TO { 23 | ?song :performedBy ?performer ; 24 | :writtenBy ?writer . 25 | } 26 | WHERE { 27 | BIND(TEMPLATE("urn:song:{id}") AS ?song) 28 | BIND(TEMPLATE("urn:artist:{band}") AS ?performer) 29 | BIND(TEMPLATE("urn:artist:{writer}") AS ?writer) 30 | } 31 | -------------------------------------------------------------------------------- /examples/virtual/optimization/02denormalized_songs_v3.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING 4 | FROM SQL { 5 | SELECT * FROM Songs 6 | } 7 | TO { 8 | ?recording a :Recording ; 9 | :song ?song ; 10 | :performedBy ?performer . 11 | ?song a :Song ; 12 | :writtenBy ?writer ; 13 | rdfs:label ?name . 14 | } 15 | WHERE { 16 | BIND(TEMPLATE("urn:song:{id}") AS ?song) 17 | BIND(TEMPLATE("urn:recording:{id}:{band}") AS ?recording) 18 | BIND(TEMPLATE("urn:artist:{band}") AS ?performer) 19 | BIND(TEMPLATE("urn:artist:{writer}") AS ?writer) 20 | } 21 | -------------------------------------------------------------------------------- /examples/virtual/optimization/03denormalized.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS examples; 2 | USE examples; 3 | 4 | DROP TABLE IF EXISTS Roles; 5 | 6 | CREATE TABLE Roles(movie_id INTEGER NOT NULL, 7 | title VARCHAR(20) NOT NULL, 8 | year VARCHAR(20) NOT NULL, 9 | actor_id INTEGER NOT NULL, 10 | name VARCHAR(20) NOT NULL, 11 | char_name VARCHAR(20) NOT NULL, 12 | PRIMARY KEY (movie_id, actor_id)); 13 | 14 | INSERT INTO Roles VALUES(1, 'The Princess Bride', 1987, 1, 'Robin Wright', 'Buttercup'); 15 | INSERT INTO Roles VALUES(2, 'Unbreakable', 2000, 1, 'Robin Wright Penn', 'Audrey Dunn'); 16 | -------------------------------------------------------------------------------- /examples/virtual/optimization/03denormalized_v1.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :denormalized 4 | FROM SQL { 5 | SELECT * FROM Roles 6 | } 7 | TO { 8 | ?movie a :Movie ; 9 | rdfs:label ?title ; 10 | :releaseYear "?year"^^xsd:integer ; 11 | :actor ?actor . 12 | 13 | ?actor a :Actor ; 14 | rdfs:label ?name . 15 | } 16 | WHERE { 17 | BIND(TEMPLATE("urn:movie:{movie_id}") AS ?movie) 18 | BIND(TEMPLATE("urn:actor:{actor_id}") AS ?actor) 19 | } 20 | -------------------------------------------------------------------------------- /examples/virtual/optimization/03denormalized_v2.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :denormalized 4 | FROM SQL { 5 | SELECT * FROM Roles 6 | } 7 | TO { 8 | ?movie a :Movie ; 9 | rdfs:label ?title ; 10 | :releaseYear "?year"^^xsd:integer . 11 | 12 | ?role a :Role ; 13 | :movie ?movie ; 14 | :character ?char_name ; 15 | :actor ?actor ; 16 | :creditedAs ?name . 17 | } 18 | WHERE { 19 | BIND(TEMPLATE("urn:role:{movie_id}_{actor_id}") AS ?role) 20 | BIND(TEMPLATE("urn:movie:{movie_id}") AS ?movie) 21 | BIND(TEMPLATE("urn:actor:{actor_id}") AS ?actor) 22 | } 23 | 24 | ; 25 | 26 | # This is an act of desperation to get the actors latest name - avoid this if possible 27 | MAPPING :antipattern 28 | FROM SQL { 29 | SELECT t1.actor_id AS id, name 30 | FROM Roles AS t1 31 | JOIN ( 32 | -- year is a reserved word in Stardog's parser so quoting 33 | SELECT actor_id, max("year") AS maxyear 34 | FROM Roles 35 | GROUP BY actor_id) AS t2 36 | ON t1.actor_id = t2.actor_id AND t1."year" = t2.maxyear 37 | } 38 | TO { 39 | ?actor a :Actor ; 40 | rdfs:label ?name . 41 | } 42 | WHERE { 43 | BIND(TEMPLATE("urn:actor:{id}") AS ?actor) 44 | } 45 | -------------------------------------------------------------------------------- /examples/virtual/optimization/04rdftype.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS examples; 2 | USE examples; 3 | 4 | DROP TABLE IF EXISTS Roles; 5 | DROP TABLE IF EXISTS Actors; 6 | 7 | CREATE TABLE Roles(movie_id INTEGER NOT NULL, 8 | title VARCHAR(20) NOT NULL, 9 | year VARCHAR(20) NOT NULL, 10 | actor_id INTEGER NOT NULL, 11 | name VARCHAR(20) NOT NULL, 12 | char_name VARCHAR(20) NOT NULL, 13 | PRIMARY KEY (movie_id, actor_id)); 14 | 15 | INSERT INTO Roles VALUES(1, 'The Princess Bride', 1987, 1, 'Robin Wright', 'Buttercup'); 16 | INSERT INTO Roles VALUES(2, 'Unbreakable', 2000, 1, 'Robin Wright Penn', 'Audrey Dunn'); 17 | 18 | CREATE TABLE Actors(id INTEGER NOT NULL, 19 | name VARCHAR(20) NOT NULL, 20 | PRIMARY KEY (id)); 21 | 22 | INSERT INTO Actors VALUES(1, 'Robin Wright'); 23 | INSERT INTO Actors VALUES(2, 'Tom Hanks'); 24 | -------------------------------------------------------------------------------- /examples/virtual/optimization/04rdftype_v1.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :actor1_actors 4 | FROM SQL { 5 | SELECT * FROM Actors 6 | } 7 | TO { 8 | ?actor a :Actor ; 9 | rdfs:label ?name . 10 | } 11 | WHERE { 12 | BIND(TEMPLATE("urn:actor:{id}") AS ?actor) 13 | } 14 | 15 | ; 16 | 17 | MAPPING :actors1_roles 18 | FROM SQL { 19 | SELECT * FROM Roles 20 | } 21 | TO { 22 | ?movie a :Movie ; 23 | rdfs:label ?title ; 24 | :releaseYear "?year"^^xsd:integer . 25 | 26 | ?role a :Role ; 27 | :movie ?movie ; 28 | :character ?char_name ; 29 | :actor ?actor ; 30 | :creditedAs ?name . 31 | 32 | # Do we really want the Roles table to be an authoritative source for Actors? 33 | ?actor a :Actor . 34 | 35 | # If you really want to make a mess, give this actor an rdfs:label from the Roles table 36 | # ?actor rdfs:label ?name . 37 | } 38 | WHERE { 39 | BIND(TEMPLATE("urn:role:{movie_id}_{actor_id}") AS ?role) 40 | BIND(TEMPLATE("urn:movie:{movie_id}") AS ?movie) 41 | BIND(TEMPLATE("urn:actor:{actor_id}") AS ?actor) 42 | } 43 | -------------------------------------------------------------------------------- /examples/virtual/optimization/04rdftype_v2.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :actor2_actors 4 | FROM SQL { 5 | SELECT * FROM Actors 6 | } 7 | TO { 8 | ?actor a :Actor ; 9 | rdfs:label ?name . 10 | } 11 | WHERE { 12 | BIND(TEMPLATE("urn:actor:{id}") AS ?actor) 13 | } 14 | 15 | ; 16 | 17 | MAPPING :actor2_roles 18 | FROM SQL { 19 | SELECT * FROM Roles 20 | } 21 | TO { 22 | ?movie a :Movie ; 23 | rdfs:label ?title ; 24 | :releaseYear "?year"^^xsd:integer . 25 | 26 | ?role a :Role ; 27 | :movie ?movie ; 28 | :character ?char_name ; 29 | :actor ?actor ; 30 | :creditedAs ?name . 31 | } 32 | WHERE { 33 | BIND(TEMPLATE("urn:role:{movie_id}_{actor_id}") AS ?role) 34 | BIND(TEMPLATE("urn:movie:{movie_id}") AS ?movie) 35 | BIND(TEMPLATE("urn:actor:{actor_id}") AS ?actor) 36 | } 37 | -------------------------------------------------------------------------------- /examples/virtual/optimization/05dataset1_v1.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :datasets1 4 | FROM SQL { 5 | SELECT * FROM Actors 6 | } 7 | TO { 8 | ?actor a :Actor ; 9 | :name ?name ; 10 | rdfs:label ?name . 11 | } 12 | WHERE { 13 | BIND(TEMPLATE("urn:node:{id}") AS ?actor) 14 | } 15 | -------------------------------------------------------------------------------- /examples/virtual/optimization/05dataset1_v2.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :datasets1 4 | FROM SQL { 5 | SELECT * FROM Actors 6 | } 7 | TO { 8 | ?actor a :Actor ; 9 | :name ?name ; 10 | rdfs:label ?name . 11 | } 12 | WHERE { 13 | BIND(TEMPLATE("urn:actor:{id}") AS ?actor) 14 | } 15 | -------------------------------------------------------------------------------- /examples/virtual/optimization/05dataset2_v1.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :datasets2 4 | FROM SQL { 5 | SELECT * FROM Movies 6 | } 7 | TO { 8 | ?movie a :Movie ; 9 | :title ?title ; 10 | rdfs:label ?title ; 11 | :releaseYear "?year"^^xsd:integer . 12 | } 13 | WHERE { 14 | BIND(TEMPLATE("urn:node:{id}") AS ?movie) 15 | } 16 | -------------------------------------------------------------------------------- /examples/virtual/optimization/05dataset2_v2.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :datasets2 4 | FROM SQL { 5 | SELECT * FROM Movies 6 | } 7 | TO { 8 | ?movie a :Movie ; 9 | :title ?title ; 10 | rdfs:label ?title ; 11 | :releaseYear "?year"^^xsd:integer . 12 | } 13 | WHERE { 14 | BIND(TEMPLATE("urn:movie:{id}") AS ?movie) 15 | } 16 | -------------------------------------------------------------------------------- /examples/virtual/optimization/05predicates.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :predicates-actors 4 | FROM SQL { 5 | SELECT * FROM Actors 6 | } 7 | TO { 8 | ?actor a :Actor ; 9 | :name ?name ; 10 | rdfs:label ?name . 11 | } 12 | WHERE { 13 | BIND(TEMPLATE("urn:actor:{id}") AS ?actor) 14 | } 15 | 16 | ; 17 | 18 | MAPPING :predicates-movies 19 | FROM SQL { 20 | SELECT * FROM Movies 21 | } 22 | TO { 23 | ?movie a :Movie ; 24 | :title ?title ; 25 | rdfs:label ?title ; 26 | :releaseYear "?year"^^xsd:integer . 27 | } 28 | WHERE { 29 | BIND(TEMPLATE("urn:movie:{id}") AS ?movie) 30 | } 31 | -------------------------------------------------------------------------------- /examples/virtual/optimization/05predicates.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS examples; 2 | USE examples; 3 | 4 | DROP TABLE IF EXISTS Movies; 5 | DROP TABLE IF EXISTS Actors; 6 | 7 | CREATE TABLE Movies(id INTEGER NOT NULL, 8 | title VARCHAR(20) NOT NULL, 9 | year VARCHAR(20) NOT NULL, 10 | PRIMARY KEY (id)); 11 | 12 | INSERT INTO Movies VALUES(1, 'The Princess Bride', 1987); 13 | INSERT INTO Movies VALUES(2, 'Unbreakable', 2000); 14 | INSERT INTO Movies VALUES(3, 'Forest Gump', 1994); 15 | 16 | CREATE TABLE Actors(id INTEGER NOT NULL, 17 | name VARCHAR(20) NOT NULL, 18 | PRIMARY KEY (id)); 19 | 20 | INSERT INTO Actors VALUES(1, 'Robin Wright'); 21 | INSERT INTO Actors VALUES(2, 'Tom Hanks'); 22 | -------------------------------------------------------------------------------- /examples/virtual/optimization/05templates.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :templates-actors 4 | FROM SQL { 5 | SELECT * FROM Actors 6 | } 7 | TO { 8 | ?actor a :Actor ; 9 | :name ?name ; 10 | rdfs:label ?name . 11 | } 12 | WHERE { 13 | BIND(TEMPLATE("urn:node:{id}") AS ?actor) 14 | } 15 | 16 | ; 17 | 18 | MAPPING :templates-movies 19 | FROM SQL { 20 | SELECT * FROM Movies 21 | } 22 | TO { 23 | ?movie a :Movie ; 24 | :title ?title ; 25 | rdfs:label ?title ; 26 | :releaseYear "?year"^^xsd:integer . 27 | } 28 | WHERE { 29 | BIND(TEMPLATE("urn:node:{id}") AS ?movie) 30 | } 31 | -------------------------------------------------------------------------------- /examples/virtual/optimization/06functions.sms: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | 3 | MAPPING :remakes 4 | FROM SQL { 5 | -- Mixing * and specific fields is non-standard SQL but the Stardog SQL parser supports it 6 | SELECT *, title || ' (' || release_year || ')' AS label FROM Remakes 7 | } 8 | TO { 9 | ?movie a :Movie ; 10 | :title ?title ; 11 | :releaseYear "?release_year"^^xsd:integer ; 12 | rdfs:label ?label . 13 | } 14 | WHERE { 15 | BIND(TEMPLATE("urn:movie:{id}") AS ?movie) 16 | } 17 | -------------------------------------------------------------------------------- /examples/virtual/optimization/06functions.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS examples; 2 | USE examples; 3 | 4 | DROP TABLE IF EXISTS Remakes; 5 | 6 | CREATE TABLE Remakes(id INTEGER, 7 | title VARCHAR(40) NOT NULL, 8 | release_year INTEGER NOT NULL, 9 | PRIMARY KEY (id), 10 | KEY (title, release_year)); 11 | 12 | INSERT INTO Remakes VALUES(1, '3:10 to Yuma', 1957); 13 | INSERT INTO Remakes VALUES(2, '3:10 to Yuma', 2007); 14 | INSERT INTO Remakes VALUES(3, 'A Star Is Born', 1937); 15 | INSERT INTO Remakes VALUES(4, 'A Star Is Born', 1976); 16 | INSERT INTO Remakes VALUES(5, 'A Star Is Born', 2018); 17 | INSERT INTO Remakes VALUES(6, 'Ocean''s Eleven', 1960); 18 | INSERT INTO Remakes VALUES(7, 'Ocean''s Eleven', 2001); 19 | INSERT INTO Remakes VALUES(8, 'True Grit', 1969); 20 | INSERT INTO Remakes VALUES(9, 'True Grit', 2010); 21 | 22 | SELECT `title`, `release_year`, CONCAT(CONCAT(CONCAT(`title`, ' ('), CAST(`release_year` AS CHAR)), ')') AS `label` 23 | FROM `examples`.`Remakes` 24 | WHERE `id` = 5; 25 | 26 | SELECT `id`, CONCAT(CONCAT(CONCAT(`title`, ' ('), CAST(`release_year` AS CHAR)), ')') AS `label` 27 | FROM `examples`.`Remakes` 28 | WHERE `title` = 'A Star is Born' AND `release_year` = 2018; 29 | 30 | SELECT `id`, CONCAT(CONCAT(CONCAT(`title`, ' ('), CAST(`release_year` AS CHAR)), ')') AS `label` 31 | FROM `examples`.`Remakes` 32 | WHERE `title` = 'A Star is Born' AND `release_year` = 2018; 33 | -------------------------------------------------------------------------------- /examples/virtual/optimization/examples.properties: -------------------------------------------------------------------------------- 1 | jdbc.url=jdbc:mysql://localhost:3306/examples 2 | jdbc.username=root 3 | jdbc.password=pssword 4 | jdbc.driver=com.mysql.cj.jdbc.Driver 5 | parser.sql.quoting=ANSI 6 | testOnBorrow=true 7 | validationQuery=SELECT 1 8 | validationInterval=30000 9 | #unique.key.sets=(Bands.id) 10 | -------------------------------------------------------------------------------- /examples/virtual/optimization/examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | stardog-admin virtual add -o -f sms2 -n uniques examples.properties 01uniquekeys.sms 4 | 5 | stardog-admin virtual add -o -f sms2 -n denormalized1 examples.properties 03denormalized_v1.sms 6 | 7 | stardog-admin virtual add -o -f sms2 -n denormalized2 examples.properties 03denormalized_v2.sms 8 | 9 | stardog-admin virtual add -o -f sms2 -n actor1 examples.properties 04rdftype_v1.sms 10 | 11 | stardog-admin virtual add -o -f sms2 -n actor2 examples.properties 04rdftype_v2.sms 12 | 13 | stardog-admin virtual add -o -f sms2 -n predicates examples.properties 05predicates.sms 14 | 15 | stardog-admin virtual add -o -f sms2 -n templates examples.properties 05templates.sms 16 | 17 | stardog-admin virtual add -o -f sms2 -n remakes examples.properties 06functions.sms 18 | 19 | stardog-admin virtual add -o -f sms2 -n datasets1 examples.properties 05dataset1_v1.sms 20 | 21 | stardog-admin virtual add -o -f sms2 -n datasets2 examples.properties 05dataset2_v1.sms 22 | 23 | # stardog-admin virtual add -o -f sms2 -n datasets1 examples.properties 05dataset1_v2.sms 24 | 25 | # stardog-admin virtual add -o -f sms2 -n datasets2 examples.properties 05dataset2_v2.sms 26 | -------------------------------------------------------------------------------- /examples/virtual/optimization/readme.md: -------------------------------------------------------------------------------- 1 | # Optimizing Virtual Graphs 2 | 3 | These are the supporting files for the [Optimizing Virtual Graphs](https://docs.stardog.com/virtual-graphs/optimization) section of the online documentation. 4 | 5 | See [examples.sh](examples.sh) for CLI commands for creating the virtual graphs, [examples.rq](examples.rq) for the SPARQL queries. 6 | -------------------------------------------------------------------------------- /examples/workbook.sparql: -------------------------------------------------------------------------------- 1 | # # Overview 2 | # This is a simple Stardog Knowledge Graph workbook 3 | # 4 | # The following are a bunch of common namespace declarations 5 | # including the ones you'll need for Stardog. This makes 6 | # working with SPARQL a lot easier. 7 | 8 | prefix stardog: 9 | prefix catalog: 10 | prefix m: 11 | prefix kg: 12 | prefix sqs: 13 | prefix rule: 14 | prefix sd: 15 | prefix sql: 16 | prefix mp: 17 | prefix spa: 18 | 19 | prefix rdfs: 20 | prefix xsd: 21 | prefix owl: 22 | prefix rdf: 23 | prefix sh: 24 | 25 | prefix skos: 26 | prefix foaf: 27 | prefix dcat: 28 | prefix dct: 29 | prefix qudt: 30 | prefix unit: 31 | prefix void: 32 | prefix so: 33 | prefix prov: 34 | 35 | # Below you will find a number of example queries that you can use 36 | # to explore your knowledge graph. Simply place your cursor IN the query 37 | # you want to execute and hit the `Run` button. Make sure you've selected 38 | # any runtime configuration, such the database to execute against, prior to running. 39 | 40 | # Return a list of all sub-graphs in your knowledge graph 41 | select DISTINCT ?g { graph ?g {} } 42 | 43 | # Return the contents of specified graph as a table 44 | select distinct ?s ?p ?o where { bind( as ?g) graph ?g { ?s ?p ?o } } 45 | 46 | # Return the specified graph as a graph 47 | construct { ?s ?p ?o } where { bind( as ?g) graph ?g { ?s ?p ?o } } 48 | 49 | # Return all classes 50 | select DISTINCT ?cls from kg:local { { ?cls a owl:Class } union { ?cls a rdfs:Class } } order by ?cls 51 | 52 | # Return all defined properties 53 | select DISTINCT ?p from kg:local { { ?p a owl:DatatypeProperty } union {?p a owl:ObjectProperty} union { ?p a rdf:Property } } order by ?p 54 | 55 | # Return all properties in use, regardless of whether or not they've been defined 56 | select DISTINCT ?p from kg:local { ?s ?p ?o } order by ?p 57 | 58 | # return all instances of a particular classes 59 | select DISTINCT ?inst from kg:local { ?inst a } order by ?inst 60 | 61 | # Delete everything, use with caution 62 | DELETE WHERE { graph ?g { ?s ?p ?o } } 63 | 64 | # delete a specific graph 65 | clear silent graph -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include "examples:api", "examples:function", "examples:analyzer", "examples:foaf", "examples:docs", "examples:connectable", "examples:service", "examples:describe", "examples:http_handler","examples:dotnet" 2 | -------------------------------------------------------------------------------- /weblog/beaches.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/weblog/beaches.zip -------------------------------------------------------------------------------- /weblog/readme.md: -------------------------------------------------------------------------------- 1 | ## Downloads 2 | 3 | This folder contains scripts and data associated with Stardog blog posts. If you want the reader to be able to download a file, place it here and link to this content. 4 | -------------------------------------------------------------------------------- /weblog/stardog-client/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | 4 | group 'com.stardog.examples' 5 | version '1.0-SNAPSHOT' 6 | 7 | repositories { 8 | maven { url "http://maven.stardog.com" } 9 | mavenLocal() 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | // Core Dependencies 15 | compile ('com.complexible.stardog:client-http:6.1.0') 16 | compile ('com.stardog:stardog-spring:6.1.1') 17 | compile "com.complexible.stardog:server:6.1.0" 18 | 19 | compile ('org.springframework:spring-core:4.3.10.RELEASE') 20 | compile ('org.springframework:spring-beans:4.3.10.RELEASE') 21 | compile ('org.springframework:spring-context:4.3.10.RELEASE') 22 | compile ('org.springframework:spring-tx:4.3.10.RELEASE') 23 | compile ('org.slf4j:slf4j-api:1.6.1') 24 | } 25 | 26 | mainClassName = "com.stardog.examples.StardogSpringClient" 27 | -------------------------------------------------------------------------------- /weblog/stardog-client/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/weblog/stardog-client/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /weblog/stardog-client/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Mar 05 19:49:10 EST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip 7 | -------------------------------------------------------------------------------- /weblog/stardog-client/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /weblog/stardog-client/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'weblog' 2 | 3 | -------------------------------------------------------------------------------- /weblog/stardog-client/src/main/java/com/stardog/examples/StardogAdmin.java: -------------------------------------------------------------------------------- 1 | package com.stardog.examples; 2 | 3 | import com.complexible.stardog.api.admin.AdminConnection; 4 | import com.complexible.stardog.api.admin.AdminConnectionConfiguration; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.InitializingBean; 8 | import com.complexible.stardog.search.SearchOptions; 9 | 10 | public class StardogAdmin implements InitializingBean { 11 | 12 | final Logger log = LoggerFactory.getLogger(StardogAdmin.class); 13 | 14 | private String to; 15 | private String username; 16 | private String password; 17 | private String url; 18 | 19 | public String getTo() { 20 | return to; 21 | } 22 | 23 | public void setTo(String to) { 24 | this.to = to; 25 | } 26 | 27 | public String getUsername() { 28 | return username; 29 | } 30 | 31 | public void setUsername(String username) { 32 | this.username = username; 33 | } 34 | 35 | public String getPassword() { 36 | return password; 37 | } 38 | 39 | public void setPassword(String password) { 40 | this.password = password; 41 | } 42 | 43 | public String getUrl() { 44 | return url; 45 | } 46 | 47 | 48 | public void setUrl(String url) { 49 | this.url = url; 50 | } 51 | 52 | /** 53 | * Creates a connection to the DBMS itself so we can perform some administrative actions. 54 | */ 55 | public void afterPropertiesSet() { 56 | if (username == null || password == null || to == null || url == null) { 57 | log.error("Invalid parameters"); 58 | return; 59 | } 60 | 61 | try (final AdminConnection aConn = AdminConnectionConfiguration.toServer(url) 62 | .credentials(username, password) 63 | .connect()) { 64 | 65 | // A look at what databses are currently in Stardog - needed api and http 66 | aConn.list().forEach(item -> System.out.println(item)); 67 | 68 | // Checks to see if the 'myNewDB' is in Stardog. If it is, we are going to drop it so we are 69 | // starting fresh 70 | if (aConn.list().contains(to)) { 71 | aConn.drop(to); 72 | } 73 | 74 | // Convenience function for creating a non-persistent in-memory database with all the default settings. 75 | aConn.newDatabase(to).set(SearchOptions.SEARCHABLE, true).create(); 76 | aConn.close(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /weblog/stardog-client/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | classpath:foaf.rdf 42 | classpath:marvel.rdf 43 | classpath:marvel_v2.rdf 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /weblog/stardog-client/src/main/resources/marvel.rdf: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix foaf: . 3 | 4 | :incredibleHulk rdf:type foaf:Person ; 5 | foaf:name "Robert Bruce Banner"^^xsd:string ; 6 | foaf:title "Incredible Hulk"^^xsd:string ; 7 | foaf:givenname "Robert"^^xsd:string ; 8 | foaf:family_name "Banner"^^xsd:string ; 9 | foaf:knows :captainAmerica, :blackWidow, :thor, :ironMan . 10 | 11 | :captainAmerica rdf:type foaf:Person ; 12 | foaf:name "Steven Rogers"^^xsd:string ; 13 | foaf:title "Captian America"^^xsd:string ; 14 | foaf:givenname "Steven"^^xsd:string ; 15 | foaf:family_name "Rogers"^^xsd:string ; 16 | foaf:nick "Steve"^^xsd:string ; 17 | foaf:knows :incredibleHulk, :blackWidow, :thor, :ironMan . 18 | 19 | :thor rdf:type foaf:Person ; 20 | foaf:name "Thor Odinson"^^xsd:string ; 21 | foaf:title "Thor"^^xsd:string ; 22 | foaf:givenname "Thor"^^xsd:string ; 23 | foaf:family_name "Odinson"^^xsd:string ; 24 | foaf:knows :incredibleHulk, :blackWidow, :captainAmerica, :ironMan . 25 | 26 | :blackWidow rdf:type foaf:Person ; 27 | foaf:name "Natalia Alianovna Romanova"^^xsd:string ; 28 | foaf:title "Black Widow"^^xsd:string ; 29 | foaf:givenname "Natalia"^^xsd:string ; 30 | foaf:family_name "Romanova"^^xsd:string ; 31 | foaf:nick "Natasha"^^xsd:string ; 32 | foaf:knows :incredibleHulk, :thor, :captainAmerica, :ironMan . 33 | -------------------------------------------------------------------------------- /weblog/stardog-client/src/main/resources/marvel_v2.rdf: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix foaf: . 3 | @prefix owl: . 4 | 5 | :parentOf a owl:ObjectProperty ; 6 | owl:inverseOf :childOf . 7 | :childOf a owl:ObjectProperty ; 8 | owl:inverseOf :parentOf . 9 | 10 | :ironMan rdf:type foaf:Person ; 11 | foaf:name "Anthony Edward Stark" ; 12 | foaf:title "Iron Man" ; 13 | foaf:givenname "Anthony" ; 14 | foaf:family_name "Stark" ; 15 | foaf:nick "Tony" ; 16 | foaf:knows :blackWidow, :captainAmerica, :thor, :incredibleHulk . 17 | 18 | :spiderMan rdf:type foaf:Person ; 19 | foaf:name "Peter Parker" ; 20 | foaf:title "Spider-Man" ; 21 | foaf:givenname "Peter" ; 22 | foaf:family_name "Parker" ; 23 | foaf:knows :ironMan . 24 | 25 | :antMan rdf:type foaf:Person ; 26 | foaf:name "Scott Lang" ; 27 | foaf:title "Ant-Man" ; 28 | foaf:givenname "Scott" ; 29 | foaf:family_name "Lang" ; 30 | foaf:knows :captainAmerica . 31 | 32 | :maryParker rdf:type foaf:Person ; 33 | foaf:name "Mary Parker" ; 34 | foaf:title "Spider-Man's Mother" ; 35 | foaf:givenname "Mary" ; 36 | foaf:family_name "Parker" ; 37 | :parentOf :spiderMan . 38 | 39 | -------------------------------------------------------------------------------- /weblog/stardog-d3/images/Info_Simple.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /weblog/stardog-d3/images/stardog-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/weblog/stardog-d3/images/stardog-logo.png -------------------------------------------------------------------------------- /weblog/stardog-d3/images/stardog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stardog-union/stardog-examples/2af7f29132e76697ecfc53b5c8720f7ca8242e05/weblog/stardog-d3/images/stardog.png -------------------------------------------------------------------------------- /weblog/stardog-d3/js/Console2.js: -------------------------------------------------------------------------------- 1 | import React from 'js/react.min'; 2 | import { PropTypes } from 'prop-types'; 3 | 4 | class Console2 extends React.Component { 5 | constructor(props) { 6 | super(props); 7 | 8 | this.state = {tabIndex: 0}; 9 | } 10 | 11 | updateTabIndex(value) { 12 | this.setState({tabIndex: value}) 13 | }; 14 | 15 | render() { 16 | return ( 17 |
18 |
19 |
20 |
Add Person
21 |
Add Relationship
22 |
Query Editor
23 |
24 |
25 | Body 26 |
27 |
28 |
29 | ); 30 | } 31 | } 32 | 33 | Console2.propTypes = { }; 34 | Console2.defaultValue = { }; --------------------------------------------------------------------------------