Skip to content

Commit

Permalink
chore(webapi): Add script for loading of a minimal set of data (#1267)
Browse files Browse the repository at this point in the history
resolves #1266
  • Loading branch information
subotic authored Mar 21, 2019
1 parent a081177 commit 7ed1425
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
28 changes: 28 additions & 0 deletions webapi/scripts/graphdb-knora-test-data-minimal.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/expect

set timeout 120
spawn openrdf-console/bin/console.sh --force --echo --serverURL [lindex $argv 0]
set prompt "> "
expect $prompt
send "open knora-test .\r"
expect $prompt
send "load ../../knora-ontologies/knora-base.ttl into http://www.knora.org/ontology/knora-base .\r"
expect $prompt
send "load ../../knora-ontologies/knora-admin.ttl into http://www.knora.org/ontology/knora-base .\r"
expect $prompt
send "load ../../knora-ontologies/standoff-onto.ttl into http://www.knora.org/ontology/standoff .\r"
expect $prompt
send "load ../../knora-ontologies/standoff-data.ttl into http://www.knora.org/data/standoff .\r"
expect $prompt
send "load ../../knora-ontologies/salsah-gui.ttl into http://www.knora.org/ontology/salsah-gui .\r"
expect $prompt
send "load ../_test_data/all_data/admin-data.ttl into http://www.knora.org/data/admin .\r"
expect $prompt
send "load ../_test_data/all_data/permissions-data.ttl into http://www.knora.org/data/permissions .\r"
expect $prompt
send "load ../_test_data/all_data/system-data.ttl into http://www.knora.org/data/0000/SystemProject .\r"
expect $prompt

send "close .\r"
expect $prompt
send "exit .\r"
44 changes: 44 additions & 0 deletions webapi/scripts/graphdb-se-docker-init-knora-test-minimal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

set -e

GRAPHDB="http://localhost:7200"
CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB"

GREEN='\033[0;32m'
RED='\033[0;31m'
NO_COLOUR='\033[0m'
DELIMITER="****************************************************************************************************\n* "

printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n"

cat graphdb-drop-knora-test-repository.ttl | $CONSOLE

printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n"

sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-se-knora-test-repository-config.ttl.tmpl > graphdb-se-knora-test-repository-config.ttl

curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test"

curl -X POST -H "Content-Type:text/turtle" -d "<http://www.knora.org/config-test> a <http://www.openrdf.org/config/repository#RepositoryContext>." $GRAPHDB/repositories/SYSTEM/statements

printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n"

STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test/statements)

if [ "$STATUS" == "204" ]
then
printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n"
else
printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n"
fi

printf "${GREEN}Loading Data${NO_COLOUR}\n\n"

./graphdb-knora-test-data-minimal.expect $GRAPHDB

printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n"

curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements

printf "${GREEN}Lucene Index Updated.${NO_COLOUR}"
2 changes: 1 addition & 1 deletion webapi/scripts/graphdb-se-docker-init-knora-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\

curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements

printf "${GREEN}Lucene Index Updated.${NO_COLOUR}"
printf "${GREEN}Lucene Index Updated.${NO_COLOUR}"

0 comments on commit 7ed1425

Please sign in to comment.