]> matita.cs.unibo.it Git - helm.git/commitdiff
First version of the stuff to create the DB.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Thu, 21 Nov 2002 18:02:29 +0000 (18:02 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Thu, 21 Nov 2002 18:02:29 +0000 (18:02 +0000)
helm/metadata/postgresql_V7_mowgli/.cvsignore [new file with mode: 0644]
helm/metadata/postgresql_V7_mowgli/Makefile [new file with mode: 0644]
helm/metadata/postgresql_V7_mowgli/README [new file with mode: 0644]
helm/metadata/postgresql_V7_mowgli/inserisci.pl [new file with mode: 0755]
helm/metadata/postgresql_V7_mowgli/inserisci_names.pl [new file with mode: 0755]
helm/metadata/postgresql_V7_mowgli/metadata_for_names/.cvsignore [new file with mode: 0644]
helm/metadata/postgresql_V7_mowgli/metadata_for_names/Makefile [new file with mode: 0644]
helm/metadata/postgresql_V7_mowgli/metainfo.xsl [new file with mode: 0644]
helm/metadata/postgresql_V7_mowgli/upload_rel.pl [new file with mode: 0755]
helm/metadata/postgresql_V7_mowgli/upload_sort.pl [new file with mode: 0755]

diff --git a/helm/metadata/postgresql_V7_mowgli/.cvsignore b/helm/metadata/postgresql_V7_mowgli/.cvsignore
new file mode 100644 (file)
index 0000000..89ea3bf
--- /dev/null
@@ -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 (file)
index 0000000..c0814d7
--- /dev/null
@@ -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 (file)
index 0000000..c3729aa
--- /dev/null
@@ -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 (executable)
index 0000000..17c8824
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+$max = 0;
+open (OUT, "| psql -U helm helm_mowgli_new_schema");
+while (<STDIN>) {
+ open (IN,$_);
+ $uri1 = <IN>;
+ 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 (<IN>) {
+  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 (executable)
index 0000000..68cc93e
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+
+open (OUT, "| psql -h mowgli -U helm helm_mowgli_new_schema");
+while (<STDIN>) {
+ 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 (file)
index 0000000..d873963
--- /dev/null
@@ -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 (file)
index 0000000..cbde307
--- /dev/null
@@ -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 (file)
index 0000000..472a35f
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+
+<!--******************************************************************--> 
+<!-- XSLT version 0.1 generating metadata content of pointers         -->
+<!-- (backward and forward)                                           -->
+<!-- First draft: May 24 2002, Irene Schena                           -->
+<!--******************************************************************-->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                             xmlns:h="http://www.cs.unibo.it/helm/schemas/schema-helm#"
+                             xmlns:hth="http://www.cs.unibo.it/helm/schemas/schema-helmth#">
+
+<xsl:output method="text"/>
+
+<xsl:param name="path"/>
+
+<xsl:template match="/">
+  <xsl:apply-templates select="*"/>
+  <xsl:apply-templates select="document(concat('backward/',$path))/rdf:RDF/h:Object/*"/>
+</xsl:template>
+
+<!-- to skip blanks -->
+<xsl:template match="*">
+ <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<xsl:template match="h:Object">
+  <xsl:value-of select="@rdf:about"/>
+  <xsl:text>
+</xsl:text>
+  <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<xsl:template match="h:refObj|h:backPointer">
+  <xsl:choose>
+  <xsl:when test="name(.)='h:refObj'">
+   <xsl:text>F|</xsl:text>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:text>B|</xsl:text>
+  </xsl:otherwise>
+  </xsl:choose>
+  <xsl:value-of select="h:position/@rdf:resource"/>
+  <xsl:text>|</xsl:text>
+  <xsl:value-of select="h:occurrence/h:Object/@rdf:about"/>
+  <xsl:text>|</xsl:text>
+  <xsl:choose>
+   <xsl:when test="h:depth">
+    <xsl:value-of select="h:depth"/>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:text>null</xsl:text>
+   </xsl:otherwise>
+  </xsl:choose>
+  <xsl:text>
+</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/helm/metadata/postgresql_V7_mowgli/upload_rel.pl b/helm/metadata/postgresql_V7_mowgli/upload_rel.pl
new file mode 100755 (executable)
index 0000000..6fece84
--- /dev/null
@@ -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 = <IN>) && not ($skip =~ /<rdf:RDF/)) {}
+while(($line0 = <IN>) && not ($line0 =~ /<\/rdf:RDF>/)) { # <h:Object
+  chomp($line0);
+  $line0 =~ s/^[^"]*"([^"]*)">$/$1/;
+  $line1 = <IN>; #<h:refRel..
+  $obj = $line1;
+  $line2 = <IN>; # <h:position rdf:resource="&hns;value"/>
+  $position = $line2;
+  chomp($position);
+  $position =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
+  $position = "http://www.cs.unibo.it/helm/schemas/schema-helm#$position";
+  $line3 = <IN>; #<h:depth..
+  $depth = $line3;
+  chomp($depth);
+  $depth =~ s/^[ \t]*<h:depth>([^<]*)<\/h:depth>$/$1/;
+  $line4 = <IN>; # </h:refRel
+  $line5 = <IN>; # </h:Object>
+   
+  $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 (executable)
index 0000000..1215ceb
--- /dev/null
@@ -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 = <IN>) && not ($skip =~ /<rdf:RDF/)) {}
+while(($line0 = <IN>) && not ($line0 =~ /<\/rdf:RDF>/)) { # <h:Object
+  chomp($line0);
+  $line0 =~ s/^[^"]*"([^"]*)">$/$1/;
+  $line1 = <IN>; #<h:refRel..
+  $obj = $line1;
+  $line2 = <IN>; # <h:position rdf:resource="&hns;value"/>
+  $position = $line2;
+  chomp($position);
+  $position =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
+  $position = "http://www.cs.unibo.it/helm/schemas/schema-helm#$position";
+  $line3 = <IN>;#<h:sort..
+  $sort = $line3; 
+  chomp($sort);
+  $sort =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
+  $sort = "http://www.cs.unibo.it/helm/schemas/schema-helm#$sort";
+  $line4 = <IN>; #<h:depth..
+  $depth = $line4;
+  chomp($depth);
+  $depth =~ s/^[ \t]*<h:depth>([^<]*)<\/h:depth>$/$1/;
+  $line5 = <IN>; # </h:refRel
+  $line6 = <IN>; # </h:Object>
+   
+  $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);