#!/bin/bash # Load sample RDF data into Oxigraph # # Usage: ./scripts/load-sample-data.sh set -e # Configuration OXIGRAPH_ENDPOINT="http://127.0.0.1:7878" DATA_DIR="$(pwd)/data/sample-rdf" echo "📥 Loading sample RDF data into Oxigraph..." echo "🌐 Endpoint: $OXIGRAPH_ENDPOINT" echo "📁 Data directory: $DATA_DIR" echo "" # Check if server is running if ! curl -s -f "$OXIGRAPH_ENDPOINT/" > /dev/null 2>&1; then echo "❌ Oxigraph server is not running!" echo "Start it with: ./scripts/start-oxigraph-memory.sh" exit 1 fi # Load each N-Triples file into DEFAULT GRAPH # Use PUT method with ?default parameter to load into default graph for file in "$DATA_DIR"/*.nt; do if [ -f "$file" ]; then filename=$(basename "$file") echo "📄 Loading: $filename" # Load into default graph using PUT method (replaces existing data) HTTP_CODE=$(curl -X PUT \ -H 'Content-Type: application/n-triples' \ --data-binary "@$file" \ "$OXIGRAPH_ENDPOINT/store?default" \ -w "%{http_code}" \ -o /dev/null -s 2>&1) if [ "$HTTP_CODE" = "204" ] || [ "$HTTP_CODE" = "201" ]; then echo " ✅ Success (HTTP $HTTP_CODE)" else echo " ❌ Failed (HTTP $HTTP_CODE)" fi echo "" fi done echo "🎉 Data loading complete!" echo "" echo "Test with a query:" echo " curl -X POST \\" echo " -H 'Content-Type: application/sparql-query' \\" echo " -H 'Accept: application/sparql-results+json' \\" echo " --data 'SELECT * WHERE { ?s ?p ?o } LIMIT 10' \\" echo " http://127.0.0.1:7878/query"