add support for direct SQL query of directory
[scpubgit/stemmatology.git] / stemmaweb / lib / stemmaweb / Controller / Root.pm
index 4b4e5e8..c33b9f0 100644 (file)
@@ -49,12 +49,7 @@ sub directory :Local :Args(0) {
     my $m = $c->model('Directory');
     # TODO not used yet, will load user texts later
     my $user = $c->request->param( 'user' ) || 'ALL';
-    my @textlist;
-    $m->scan( sub { 
-       push( @textlist, {
-               'id' => $m->object_to_id( @_ ),
-               'name' => $_[0]->name } ) 
-       } );    
+    my @textlist = $m->traditionlist();
     $c->stash->{texts} = \@textlist;
        $c->stash->{template} = 'directory.tt';
 }
@@ -70,9 +65,11 @@ Returns the variant graph for the text specified at $textid, in SVG form.
 sub variantgraph :Local :Args(1) {
        my( $self, $c, $textid ) = @_;
        my $m = $c->model('Directory');
-       my $collation = $m->tradition( $textid )->collation;
-
+       my $tradition = $m->tradition( $textid );
+       my $collation = $tradition->collation;
+       my $needsave = !$collation->has_cached_svg;
        $c->stash->{'result'} = $collation->as_svg;
+       $m->save( $tradition );
        $c->forward('View::SVG');
 }
        
@@ -88,7 +85,7 @@ sub alignment :Local :Args(1) {
        my( $self, $c, $textid ) = @_;
        my $m = $c->model('Directory');
        my $collation = $m->tradition( $textid )->collation;
-       my $alignment = $collation->make_alignment_table;
+       my $alignment = $collation->alignment_table;
        
        # Turn the table, so that witnesses are by column and the rows
        # are by rank.
@@ -128,8 +125,8 @@ sub stemma :Local :Args(1) {
                $m->store( $tradition );
        }
        
-       $c->stash->{'result'} = $tradition->stemma
-               ? $tradition->stemma->as_svg
+       $c->stash->{'result'} = $tradition->stemma_count
+               ? $tradition->stemma(0)->as_svg
                : '';
        $c->forward('View::SVG');
 }