diff --git a/install/install_samples.sh b/install/install_samples.sh index 1ec2674..09a37fe 100755 --- a/install/install_samples.sh +++ b/install/install_samples.sh @@ -44,6 +44,14 @@ curl_call() { --data "$2" } +curl_file_upload_call() { + curl --location "$HOST:$PORT/api/v1/$1" \ + --header "Authorization: Bearer $TOKEN" \ + --fail \ + --silent \ + --form "file=@\"$2\"" +} + for INSTALL_DIR in $(ls $SAMPLE_PATH); do ENDPOINT=$(echo $INSTALL_DIR | cut -d'_' -f2) echo "Installing $ENDPOINT" @@ -51,8 +59,8 @@ for INSTALL_DIR in $(ls $SAMPLE_PATH); do ITEM_NAME=$(echo "$ITEM" | cut -d'.' -f1) ITEM_IDENTIFIER=${ENDPOINT}_"${ITEM_NAME}" - ID=$(cat $CACHE_FILE | grep $ITEM_IDENTIFIER | cut -d';' -f2) - if [ -z $ID ]; then + ID=$(cat $CACHE_FILE | grep "$ITEM_IDENTIFIER;" | cut -d';' -f2) + if [ -z "$ID" ]; then JSON=$(cat $SAMPLE_PATH/$INSTALL_DIR/$ITEM) # Replace ID placeholders @@ -72,8 +80,36 @@ for INSTALL_DIR in $(ls $SAMPLE_PATH); do ID=$(echo $RESULT | jq ".id") echo "$ITEM_IDENTIFIER;$ID" >> $CACHE_FILE echo -e "\tInstalled $ITEM_NAME with ID $ID" + + if [ $ENDPOINT = "schemas" ]; then + echo $RESULT | jq -r ".definitions[] | \"${ITEM_IDENTIFIER}_definitions_\(.name);\(.id)\"" >> $CACHE_FILE + fi else echo -e "\tSkipping $ITEM_NAME, already present with ID $ID" fi done + for ITEM in $(ls $SAMPLE_PATH/$INSTALL_DIR | grep ".csv"); do + VOCABULARY_NAME=$(echo "$ITEM" | cut -d'.' -f1) + VOCABULARY_IDENTIFIER=vocabularies_${VOCABULARY_NAME} + VOCABULARY_ID=$(cat $CACHE_FILE | grep $VOCABULARY_IDENTIFIER | cut -d';' -f2) + + if [ ! -z "$VOCABULARY_ID" ]; then + curl_file_upload_call "vocabularies/$VOCABULARY_ID/import/csv" "$SAMPLE_PATH/$INSTALL_DIR/$ITEM" + echo -e "\tImported \"$VOCABULARY_NAME\" vocabulary records" + else + echo -e "\tSkipping record imports into \"$VOCABULARY_NAME\" vocabulary, vocabulary not created beforehand!" + fi + done + for ITEM in $(ls $SAMPLE_PATH/$INSTALL_DIR | grep ".xlsx"); do + VOCABULARY_NAME=$(echo "$ITEM" | cut -d'.' -f1) + VOCABULARY_IDENTIFIER=vocabularies_${VOCABULARY_NAME} + VOCABULARY_ID=$(cat $CACHE_FILE | grep $VOCABULARY_IDENTIFIER | cut -d';' -f2) + + if [ ! -z "$VOCABULARY_ID" ]; then + curl_file_upload_call "vocabularies/$VOCABULARY_ID/import/excel" "$SAMPLE_PATH/$INSTALL_DIR/$ITEM" + echo -e "\tImported \"$VOCABULARY_NAME\" vocabulary records" + else + echo -e "\tSkipping record imports into \"$VOCABULARY_NAME\" vocabulary, vocabulary not created beforehand!" + fi + done done diff --git a/install/samples/books/3_schemas/Colors_Schema.json b/install/samples/books/3_schemas/Colors_Schema.json index 37cd558..1a04b65 100644 --- a/install/samples/books/3_schemas/Colors_Schema.json +++ b/install/samples/books/3_schemas/Colors_Schema.json @@ -26,7 +26,7 @@ ] }, { - "name": "Color Code", + "name": "Farbcode", "typeId": {{types_Hex_RGB}}, "required": false, "unique": true, diff --git a/install/samples/books/7_records/Authors.csv b/install/samples/books/7_records/Authors.csv new file mode 100644 index 0000000..34ea1f2 --- /dev/null +++ b/install/samples/books/7_records/Authors.csv @@ -0,0 +1,12 @@ +ID,Name (ger),Name (eng),Name (fre) +,Johann Wolfgang von Goethe,Johann Wolfgang von Goethe,Johann Wolfgang von Goethe +,William Shakespeare,William Shakespeare,William Shakespeare +,Ernest Hemingway,Ernest Hemingway,Ernest Hemingway +,Leo Tolstoy,Leo Tolstoy,Leo Tolstoï +,George Orwell,George Orwell,George Orwell +,Fyodor Dostoevsky,Fyodor Dostoevsky,Fyodor Dostoïevski +,Marcel Proust,Marcel Proust,Marcel Proust +,Franz Kafka,Franz Kafka,Franz Kafka +,Jane Austen,Jane Austen,Jane Austen +,Christopher Marlowe,Christopher Marlowe,Christopher Marlowe +,F. Scott Fitzgerald,Francis Scott Fitzgerald,Francis Scott Fitzgerald \ No newline at end of file diff --git a/install/samples/books/7_records/Colors.csv b/install/samples/books/7_records/Colors.csv new file mode 100644 index 0000000..04fd2b4 --- /dev/null +++ b/install/samples/books/7_records/Colors.csv @@ -0,0 +1,16 @@ +ID,Name (ger),Name (eng),Name (fre),Farbcode +,Schwarz,Black,Noir,#000000 +,Weiß,White,Blanc,#FFFFFF +,Rot,Red,Rouge,#FF0000 +,Grün,Green,Vert,#00FF00 +,Blau,Blue,Bleu,#0000FF +,Gelb,Yellow,Jaune,#FFFF00 +,Orange,Orange,Orange,#FFA500 +,Lila,Purple,Violet,#800080 +,Rosa,Pink,Rose,#FFC0CB +,Grau,Gray,Gris,#808080 +,Cyan,Cyan,Cyan,#00FFFF +,Magenta,Magenta,Magenta,#FF00FF +,Braun,Brown,Marron,#A52A2A +,Beige,Beige,Beige,#F5F5DC +,Olivgrün,Olive,Olive,#808000 \ No newline at end of file diff --git a/install/samples/books/7_records/Locations.csv b/install/samples/books/7_records/Locations.csv new file mode 100644 index 0000000..f741468 --- /dev/null +++ b/install/samples/books/7_records/Locations.csv @@ -0,0 +1,4 @@ +ID,Name (ger),Name (eng),Name (fre) +,Göttingen,Göttingen,Göttingen +,Hamburg,Hamburg,Hambourg +,Brüssel,Brussels,Bruxelles \ No newline at end of file diff --git a/install/samples/skos/4_vocabularies/SKOS.json b/install/samples/skos/4_vocabularies/Role.json similarity index 57% rename from install/samples/skos/4_vocabularies/SKOS.json rename to install/samples/skos/4_vocabularies/Role.json index 09e2b18..41eb5b8 100644 --- a/install/samples/skos/4_vocabularies/SKOS.json +++ b/install/samples/skos/4_vocabularies/Role.json @@ -1,6 +1,6 @@ { "schemaId": {{schemas_SKOS_Data}}, "metadataSchemaId": {{schemas_SKOS_Metadata}}, - "name": "SKOS", - "description": "SKOS example vocabulary." + "name": "Role", + "description": "An example SKOS vocabulary." } \ No newline at end of file diff --git a/install/samples/skos/5_records/Role.xlsx b/install/samples/skos/5_records/Role.xlsx new file mode 100644 index 0000000..67a3824 Binary files /dev/null and b/install/samples/skos/5_records/Role.xlsx differ