fixing attribute rename
[scpubgit/stemmatology.git] / script / save_to_db.pl
index 936e6a9..2d734b3 100755 (executable)
@@ -11,11 +11,12 @@ use Text::Tradition::Directory;
 binmode( STDOUT, ':utf8' );
 binmode( STDERR, ':utf8' );
 
-my( $tfile, $sfile, $delete, $list, $dsn ) = 
-       ( undef, undef, undef, 0, 'dbi:SQLite:dbname=db/traditions.db' );
+my( $tfile, $format, $sfile, $delete, $list, $dsn ) = 
+       ( undef, 'Self', undef, undef, 0, 'dbi:SQLite:dbname=db/traditions.db' );
 
 GetOptions( 
        't|tradition=s' => \$tfile,
+       'f|format=s' => \$format,
        's|stemma=s' => \$sfile,
        'l|list' => \$list,
        'd|delete=s' => \$delete,
@@ -43,12 +44,12 @@ my( $tradition, $stemma );
 if( $tfile ) {
        print STDERR "Reading tradition from $tfile\n";
        $tradition = Text::Tradition->new( 
-               'input' => 'Self',
+               'input' => $format,
                'file' => $tfile,
                'linear' => 1,
                );
        if( $tradition && $sfile ) {
-               $stemma = $tradition->add_stemma( $sfile );
+               $stemma = $tradition->add_stemma( dotfile =>  $sfile );
                warn "Did not get stemma from $sfile\n" unless $stemma;
        }
     
@@ -69,7 +70,8 @@ if( $delete ) {
 
 # Now try reading the objects from the DB.
 if( $list ) {
-       foreach my $tid ( $kdb->tradition_ids ) {
+       foreach my $tref ( $kdb->traditionlist ) {
+               my $tid = $tref->{'id'};
                my $scope = $kdb->new_scope();
                my $t = $kdb->tradition( $tid );
                print STDERR "$tid: Tradition '" . $t->name . "'\n";
@@ -79,8 +81,7 @@ if( $list ) {
                print STDERR "...collation has " . scalar( $c->readings ) . " readings\n";
                print STDERR "...collation has " . scalar( $c->paths ) . " paths\n";
                print STDERR "...collation has " . scalar( $c->relationships ) . " relationship links\n";
-               my $s = $t->stemma;
-               if( $s ) {
+               foreach my $s ( $t->stemmata ) {
                        print STDERR "...associated stemma has graph " . $s->graph . "\n";
                }
        }