[Bio] / FigWebServices / ErdbDocWidget.cgi Repository:
ViewVC logotype

View of /FigWebServices/ErdbDocWidget.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (annotate)
Tue Apr 24 20:33:51 2012 UTC (7 years, 9 months ago) by parrello
Branch: MAIN
CVS Tags: rast_rel_2014_0912, mgrast_version_3_2, rast_rel_2014_0729, HEAD
Changes since 1.4: +10 -2 lines
Support for CDMI as a special type of ERDB database.

#!/usr/bin/perl -w

#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
#
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License.
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

use strict;
use Tracer qw(:DEFAULT PrintLine);
use ERDB;
use ERDBPDocPage;
use ERDBExtras;

=head1 ErdbDocWidget Script

This is a small script that generates the documentation widget for an [[ErdbPm]]
database. It is designed to fit inside an embedded frame. The widget appears as
a two-column table with a scrolling select control on the left and the
documentation for the selected component on the right.

The following CGI parameters are used.

=over 4

=item database

Name of the database to document.

=item xmlFileName

Name of the XML file to document. If this option is specified, it overrides
B<database>. In this case, it is presumed the documentation is for a database
in development rather than a live database.

=item rows

The estimated number of rows to display in the select box in order to make the
widget fit comfortably inside the frame.

=back

=cut

# Get the CGI query object.
my $cgi = CGI->new();
# Start the output page.
print CGI::header();
print CGI::start_html(-title => 'ERDB Database Documenter',
                      -style =>  { src => "$ERDBExtras::css_dir/ERDB.css" },
                      -script => { src => "$ERDBExtras::js_dir/ERDB.js" });
# Insure we recover from errors.
eval {
    # Get the parameters.
    my $database = $cgi->param('database') || 'Sapling';
    my $height = $cgi->param('height') || 900;
    my $xmlFileName = $cgi->param('xmlFileName');
    # Get the datanase object.
    my $erdb;
    if ($xmlFileName) {
        # Yes, get a pseudo-database object for that XML file.
        $erdb = ERDB->new(undef, $xmlFileName);
    } else {
        # No, get the live database. Note that the CDMIs are special.
        if ($database eq 'CDMItest') {
            require Bio::KBase::CDMI::CDMI;
            $erdb = Bio::KBase::CDMI::CDMI->new(develop => 1);
        } elsif ($database eq 'CDMI') {
            require Bio::KBase::CDMI::CDMI;
            $erdb = Bio::KBase::CDMI::CDMI->new();
        } else {
            $erdb = ERDB::GetDatabase($database);
        }
    }
    # Get a page creator.
    my $page = ERDBPDocPage->new(dbObject => $erdb);
    # Create the body HTML.
    my $html = CGI::div({ class => 'doc' }, $page->DocPage(boxHeight => $height));
    # Output it.
    PrintLine($html);
};

if ($@) {
    # Here we have a fatal error. Save the message.
    my $errorText = "SCRIPT ERROR: $@";
    # Issue a feed event.
    Warn($errorText);
    # Output the error message.
    PrintLine CGI::pre($errorText);
}
# Close the page.
PrintLine CGI::end_html();

1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3