1 | #!/bin/bash
|
---|
2 |
|
---|
3 | tmp_cache="tmp-cache"
|
---|
4 |
|
---|
5 | cwd=`pwd`
|
---|
6 | cwd_without_prepare=${cwd%/*}
|
---|
7 | collection=${cwd_without_prepare##*/}
|
---|
8 |
|
---|
9 | echo ""
|
---|
10 |
|
---|
11 | if [ "x$GSDL3SRCHOME" = "x" ] ; then
|
---|
12 | echo "Environment variable GSDL3SRCHOME not set." 1>&2
|
---|
13 | echo "Have you sourced ./gs3-setup.sh?" 1>&2
|
---|
14 | exit 1
|
---|
15 | fi
|
---|
16 |
|
---|
17 | if [ ! -d $tmp_cache ] ; then
|
---|
18 | echo "Making temporary directory:"
|
---|
19 | echo " $tmp_cache"
|
---|
20 | mkdir $tmp_cache
|
---|
21 | else
|
---|
22 | echo "Removing existing content from:"
|
---|
23 | echo " $tmp_cache"
|
---|
24 | /bin/rm -rf $tmp_cache/*
|
---|
25 | fi
|
---|
26 |
|
---|
27 | echo "Copying to '$tmp_cache' then exploding:"
|
---|
28 |
|
---|
29 | f="local--esc-mir-gold.json"
|
---|
30 | echo " spotify-musicbrainz/$f -> $tmp_cache/sparqlresults-$f"
|
---|
31 | /bin/cp "spotify-musicbrainz/$f" "$tmp_cache/sparqlresults-$f"
|
---|
32 |
|
---|
33 | explode_metadata_database.pl \
|
---|
34 | -records_per_folder 2000 \
|
---|
35 | -collectdir $GSDL3SRCHOME/web/sites/eurovision-lod/collect \
|
---|
36 | -collection $collection \
|
---|
37 | -plugin_options "-metadata_merge_on_concat_fields Country,Year -OIDtype assigned -OIDmetadata Identifier" \
|
---|
38 | -plugin JSONSPARQLResultPlugin \
|
---|
39 | $tmp_cache/sparqlresults-$f
|
---|
40 |
|
---|
41 | if [ $? != 0 ] ; then
|
---|
42 | echo "Error encountered when exploding:" 1>&2
|
---|
43 | echo " $tmp_cache/sparqlresults-$f" 1>&2
|
---|
44 | exit 1
|
---|
45 | fi
|
---|
46 |
|
---|
47 |
|
---|
48 | echo ""
|
---|
49 | echo "Adding metadata_esc_mir_gold.xml to the sparqlresults-* directories in '../import' (from exploded results in '$tmp_cache')"
|
---|
50 | echo " Along with a manually assigned override file metadata_esc_mir_gold__override.xml"
|
---|
51 |
|
---|
52 | num_explode_subdirs=`ls -d $tmp_cache/sparqlresults-local--esc-mir-gold* | wc -l`
|
---|
53 |
|
---|
54 | if [ "x$num_explode_subdirs" != "x1" ] ; then
|
---|
55 | echo "Error: This script is designed for all the results results from exploding to be" 1>&2
|
---|
56 | echo " in a single subdirectory" 1>&2
|
---|
57 | echo " In $tmp_cache found: $num_explode_subdirs" 1>&2
|
---|
58 | exit 1
|
---|
59 | fi
|
---|
60 |
|
---|
61 | for d in ../import/sparqlresults-* ; do
|
---|
62 | cat $tmp_cache/sparqlresults-local--esc-mir-gold/metadata.xml \
|
---|
63 | | sed 's/mode="accumulate"/mode="override"/' > $d/metadata_esc_mir_gold.xml
|
---|
64 | # add to this a few manually overridden metadata values
|
---|
65 | /bin/cp metadata_esc_mir_gold__override.xml $d/.
|
---|
66 | done
|
---|
67 |
|
---|
68 | /bin/rm -rf $tmp_cache/sparqlresults-*
|
---|
69 |
|
---|
70 |
|
---|
71 | echo ""
|
---|