save created relationships; fix relative paths in css
[scpubgit/stemmaweb.git] / lib / stemmaweb / Controller / Stexaminer.pm
index bdabcaa..46c0359 100644 (file)
@@ -30,17 +30,22 @@ sub index :Path :Args(1) {
     my( $self, $c, $textid ) = @_;
     my $m = $c->model('Directory');
        my $tradition = $m->tradition( $textid );
-       my $stemma = $tradition->stemma;
-       # TODO Think about caching the stemma in a session 
-       $c->stash->{svg} = $stemma->as_svg;
-       $c->stash->{text_title} = $tradition->name;
-       $c->stash->{template} = 'stexaminer.tt'; 
-       # TODO Run the analysis as AJAX from the loaded page.
-       my $t = run_analysis( $tradition );
-       $c->stash->{variants} = $t->{'variants'};
-       $c->stash->{total} = $t->{'variant_count'};
-       $c->stash->{genealogical} = $t->{'genealogical_count'};
-       $c->stash->{conflict} = $t->{'conflict_count'};
+       if( $tradition->stemma_count ) {
+               my $stemma = $tradition->stemma(0);
+               # TODO Think about caching the stemma in a session 
+               $c->stash->{svg} = $stemma->as_svg;
+               $c->stash->{text_title} = $tradition->name;
+               $c->stash->{template} = 'stexaminer.tt'; 
+               # TODO Run the analysis as AJAX from the loaded page.
+               my $t = run_analysis( $tradition );
+               $c->stash->{variants} = $t->{'variants'};
+               $c->stash->{total} = $t->{'variant_count'};
+               $c->stash->{genealogical} = $t->{'genealogical_count'};
+               $c->stash->{conflict} = $t->{'conflict_count'};
+       } else {
+               $c->stash->{error} = 'Tradition ' . $tradition->name 
+                       . 'has no stemma for analysis.';
+       }
 }
 
 =head2 end