--- /dev/null
+forward
+backward
+forward_rel.xml
+forward_sort.xml
+txt
+txt.saved
--- /dev/null
+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
--- /dev/null
+* 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
--- /dev/null
+#!/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;
--- /dev/null
+#!/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;
--- /dev/null
+objectName.txt
--- /dev/null
+upload:
+ cat objectName.txt | ../inserisci_names.pl
--- /dev/null
+<?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>
--- /dev/null
+#!/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);
--- /dev/null
+#!/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);