From 7ba6844c6d663f67235e8da1e06f7f08c77ae8c2 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Thu, 21 Nov 2002 18:02:29 +0000 Subject: [PATCH] First version of the stuff to create the DB. --- helm/metadata/postgresql_V7_mowgli/.cvsignore | 6 ++ helm/metadata/postgresql_V7_mowgli/Makefile | 16 +++++ helm/metadata/postgresql_V7_mowgli/README | 27 +++++++++ .../postgresql_V7_mowgli/inserisci.pl | 24 ++++++++ .../postgresql_V7_mowgli/inserisci_names.pl | 13 ++++ .../metadata_for_names/.cvsignore | 1 + .../metadata_for_names/Makefile | 2 + .../postgresql_V7_mowgli/metainfo.xsl | 60 +++++++++++++++++++ .../postgresql_V7_mowgli/upload_rel.pl | 30 ++++++++++ .../postgresql_V7_mowgli/upload_sort.pl | 36 +++++++++++ 10 files changed, 215 insertions(+) create mode 100644 helm/metadata/postgresql_V7_mowgli/.cvsignore create mode 100644 helm/metadata/postgresql_V7_mowgli/Makefile create mode 100644 helm/metadata/postgresql_V7_mowgli/README create mode 100755 helm/metadata/postgresql_V7_mowgli/inserisci.pl create mode 100755 helm/metadata/postgresql_V7_mowgli/inserisci_names.pl create mode 100644 helm/metadata/postgresql_V7_mowgli/metadata_for_names/.cvsignore create mode 100644 helm/metadata/postgresql_V7_mowgli/metadata_for_names/Makefile create mode 100644 helm/metadata/postgresql_V7_mowgli/metainfo.xsl create mode 100755 helm/metadata/postgresql_V7_mowgli/upload_rel.pl create mode 100755 helm/metadata/postgresql_V7_mowgli/upload_sort.pl diff --git a/helm/metadata/postgresql_V7_mowgli/.cvsignore b/helm/metadata/postgresql_V7_mowgli/.cvsignore new file mode 100644 index 000000000..89ea3bfee --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/.cvsignore @@ -0,0 +1,6 @@ +forward +backward +forward_rel.xml +forward_sort.xml +txt +txt.saved diff --git a/helm/metadata/postgresql_V7_mowgli/Makefile b/helm/metadata/postgresql_V7_mowgli/Makefile new file mode 100644 index 000000000..c0814d7fb --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/Makefile @@ -0,0 +1,16 @@ +CWD=/projects/helm/metadata/postgresql_V7_mowgli_new_schema + +txt: + (cd forward && find . -type d -exec mkdir -p $(CWD)/txt/{} \;) + (cd forward && find . -name "*.xml" -exec xsltproc --param path '"{}"' -o $(CWD)/txt/{}.txt $(CWD)/metainfo.xsl {} \; -exec echo {} \;) + +upload: + (cd txt && find */* -name "*.txt" > index.txt) + (cd txt && cat index.txt | ../inserisci.pl) + ./upload_rel.pl forward_rel.xml | psql -h mowgli -U helm helm_mowgli_new_schema + ./upload_sort.pl forward_sort.xml | psql -h mowgli -U helm helm_mowgli_new_schema + +clean: + rm -rf txt/* + +.PHONY: txt diff --git a/helm/metadata/postgresql_V7_mowgli/README b/helm/metadata/postgresql_V7_mowgli/README new file mode 100644 index 000000000..c3729aa4c --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/README @@ -0,0 +1,27 @@ +* da utente postgres: + + $ createuser helm # con permessi minimi (i.e. no create altri database, + # no create altri utenti) + $ createdb helm + $ pg_passwd data/passwords + # settare una password + +* da un utente qualsiasi: + + $ psql -h mowgli -U helm helm_mowgli_new_schema + + create table registry (uri varchar, id int); + CREATE INDEX registry_index ON registry (uri); + + create table objectName (value varchar, uri varchar); + CREATE INDEX objectName_index ON objectName (value); + CREATE INDEX objectName_rev_index ON objectName (uri); + + create table hrefRel (uri varchar, position varchar, depth int); + create table hrefSort (uri varchar, position varchar, sort varchar, depth int); + +* svuotamento: + drop table tn; + delete from registry; +* svuotamento totale: + come postgres: dropdb helm diff --git a/helm/metadata/postgresql_V7_mowgli/inserisci.pl b/helm/metadata/postgresql_V7_mowgli/inserisci.pl new file mode 100755 index 000000000..17c882418 --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/inserisci.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +$max = 0; +open (OUT, "| psql -U helm helm_mowgli_new_schema"); +while () { + open (IN,$_); + $uri1 = ; + chomp($uri1); + print "$uri1:\n"; + $uri1 =~ s/'/\\'/g; + $max++; + print OUT "create table t$max (prop_id varchar, position varchar, uri varchar, depth int);"; + print OUT "insert into registry values ('$uri1', $max);"; + while () { + chomp; + ($dir,$context,$uri2,$depth) = split(/\|/); + print " Inserisco $dir#$context#$uri2#$depth\n"; + $uri2 =~ s/'/\\'/g; + print OUT "insert into t$max values ('$dir', '$context', '$uri2', $depth);"; + } + print "\n"; + close IN; +} +close OUT; diff --git a/helm/metadata/postgresql_V7_mowgli/inserisci_names.pl b/helm/metadata/postgresql_V7_mowgli/inserisci_names.pl new file mode 100755 index 000000000..68cc93eb7 --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/inserisci_names.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +open (OUT, "| psql -h mowgli -U helm helm_mowgli_new_schema"); +while () { + chomp; + ($name,$uri) = split(/\|/); + print " Inserisco $name#$uri\n"; + $name =~ s/'/\\'/g; + $uri =~ s/'/\\'/g; + print OUT "insert into objectName values ('$name', '$uri');"; + print "\n"; +} +close OUT; diff --git a/helm/metadata/postgresql_V7_mowgli/metadata_for_names/.cvsignore b/helm/metadata/postgresql_V7_mowgli/metadata_for_names/.cvsignore new file mode 100644 index 000000000..d873963bf --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/metadata_for_names/.cvsignore @@ -0,0 +1 @@ +objectName.txt diff --git a/helm/metadata/postgresql_V7_mowgli/metadata_for_names/Makefile b/helm/metadata/postgresql_V7_mowgli/metadata_for_names/Makefile new file mode 100644 index 000000000..cbde30733 --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/metadata_for_names/Makefile @@ -0,0 +1,2 @@ +upload: + cat objectName.txt | ../inserisci_names.pl diff --git a/helm/metadata/postgresql_V7_mowgli/metainfo.xsl b/helm/metadata/postgresql_V7_mowgli/metainfo.xsl new file mode 100644 index 000000000..472a35fd2 --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/metainfo.xsl @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + F| + + + B| + + + + | + + | + + + + + + null + + + + + + + diff --git a/helm/metadata/postgresql_V7_mowgli/upload_rel.pl b/helm/metadata/postgresql_V7_mowgli/upload_rel.pl new file mode 100755 index 000000000..6fece8441 --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/upload_rel.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +my $inputfile = $ARGV[0]; + +#print "Now splitting file $inputfile\n"; +open(IN, "<$inputfile") or die "Error opening file $inputfile"; +while(($skip = ) && not ($skip =~ /) && not ($line0 =~ /<\/rdf:RDF>/)) { # $/$1/; + $line1 = ; #; # + $position = $line2; + chomp($position); + $position =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/; + $position = "http://www.cs.unibo.it/helm/schemas/schema-helm#$position"; + $line3 = ; #([^<]*)<\/h:depth>$/$1/; + $line4 = ; # ; # + + $line0 =~ s/'/\\'/g; + $position =~ s/'/\\'/g; + $depth =~ s/'/\\'/g; + print "insert into hrefRel values ('$line0', '$position', $depth);\n\n"; +} +close(IN); diff --git a/helm/metadata/postgresql_V7_mowgli/upload_sort.pl b/helm/metadata/postgresql_V7_mowgli/upload_sort.pl new file mode 100755 index 000000000..1215ceb3a --- /dev/null +++ b/helm/metadata/postgresql_V7_mowgli/upload_sort.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl + +my $inputfile = $ARGV[0]; + +#print "Now splitting file $inputfile\n"; +open(IN, "<$inputfile") or die "Error opening file $inputfile"; +while(($skip = ) && not ($skip =~ /) && not ($line0 =~ /<\/rdf:RDF>/)) { # $/$1/; + $line1 = ; #; # + $position = $line2; + chomp($position); + $position =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/; + $position = "http://www.cs.unibo.it/helm/schemas/schema-helm#$position"; + $line3 = ;#/$1/; + $sort = "http://www.cs.unibo.it/helm/schemas/schema-helm#$sort"; + $line4 = ; #([^<]*)<\/h:depth>$/$1/; + $line5 = ; # ; # + + $line0 =~ s/'/\\'/g; + $position =~ s/'/\\'/g; + $depth =~ s/'/\\'/g; + $sort =~ s/'/\\'/g; + print "insert into hrefSort values ('$line0', '$position', '$sort', $depth);\n\n"; +} +close(IN); -- 2.39.2