gateway.pl - repository object-level web-database gateway
require "gateway.pl";
# Most common methods shown here. See METHODS for others.
# repo viewing
print repo_view($obj);
print repo_view($obj, &alternative_view)
print repo_view_label($obj);
print repo_view_row($obj);
$url = repo_vlink($obj);
$results = repo_query("Patient");
print repo_table($results);
# repo form elements
print repo_choice($results, "chosen_patient");
print repo_choice($results, "chosen_patient", "SCROLL", 5, "MULTIPLE");
# image handling
print repo_fullsize_jpeg($file);
print repo_thumbnail($file);
print repo_image_button($file, "button_1");
# misc
print repo_banner();
print repo_get_url("http://www.yahoo.com");
print repo_smart_prompt($paramname, $type);
print repo_attributes_prompt($r);
$r = repo_attributes_parse($r);
# built-in class defs
# (all standard methods for User, File, Annotation, plus:)
print File_view_icon($file);
print File_view_contents($file);
print File_view_image($file);
print Annotation_view_icon($subject);
print Annotation_view_icon_make($subject);
print Annotation_subject($subject);
CGI, repo.pl, html.pl, viz.pl, view definition file
The Gateway API provides a high-level interface for displaying repository
objects as web pages. There are generic methods for viewing objects as
labels, rows, and full pages.
The Gateway provides methods for generating HTML tables of objects, and for
generating form elements for choosing from a list of objects. There are
methods for creating jpeg versions of image files, and for creating
thumbnails and clickable image maps.
The Gateway is primarily used for developing scriplets for supporting
workflow, and for defining the View Classes of repository object types. For
each repository object type, the View Class consists of at least three
functions that declare how a subject should appear at three abstraction
levels: view_label (in the context of a string), view_row (in the context
of a collection of objects), and view_page (in the context of a single
focused object). The Label View returns a string (e.g. a patient's name),
the Row View returns a list of values (to be used in an HTML table), and
the Page View returns a full HTML page.
In addition, there are methods for managing the global context of the query
session, including the user class, subject, and view class.
- repo_view($subject, $function, $param)
-
repo_view is a type-independent function that emits an html string for
visualizing repository objects. This can be used in place of the specific
view functions for a given object type.
$subject may be a
reference to a single object or a group of objects to be visualized. The
optional $function specifies which view to use on the
subject(s). If $function is not specified, the
default views are used for the given object's class (view_page for a single
object, view_row for multiple objects). Third parameter ($parm) is an
optional parameter to be passed to the view function if it takes one.
- repo_view_label($obj)
-
repo_view_label is a type-independent function that emits a label for a
given object. This can be used in place of the specific view_label function
for a given object type.
- repo_view_row($obj)
-
repo_view_row is a type-independent function that emits a row-view for a
given object. This can be used in place of the specific view_row function
for a given object type.
- repo_table($obj_list, $view_class, $param)
-
Displays a group of objects in table form.
$obj_list should be
a ref to a list of objects (such as that returned by repo_query). The
objects must all be of the same type. The optional $view_class
parameter specifies which view function to use (the default will be
repo_view_row applied to the given object type). The optional
$param may be supplied to be passed to the
$view_class function.
- repo_vlink($subject, $view_class, $context)
-
repo_vlink generates a url to a view of the given $subject. Uses the WIRM
repo-viewer facility. The optional
$view_class parameter may
be used to specify a non-default view of the $subject. The optional
$context parameter may be used to pass a context to the view.
Note: $subject may be a ref to a repo, or an OID, or the
results of a query (a group of repos).
- repo_mlink($class)
-
generates a url to the Make Object wirmlet, using the given class.
- repo_elink($subject)
-
generates a url to the Edit Object wirmlet, using the given subject, which
may be an OID or a classname.
- repo_rlink($subject)
-
generates a url to the Remove Object wirmlet, using the given subject,
which may be an OID or a classname.
- repo_login_link($subject)
-
generates a url to the User Login wirmlet.
- repo_xlink($class, $filter, $order)
-
generates a url to the Explorer on the given class using the given filter.
- repo_fullsize_jpeg($file)
-
Takes a ref to a File object or a File OID. Returns an IMG tag to a
web-visible fullsize jpeg copy of the specified File. The image is
converted to jpeg and copied into the vizualization cache by the viz
facility.
- repo_thumbnail($file)
-
Takes a ref to a File object or a File OID. Returns an IMG tag to a
web-visible thumbnail sized jpeg copy of the specified File. The image is
converted to jpeg and copied into the vizualization cache by the viz
facility.
- repo_image_button($file, $button_name)
-
Creates a clickable image-button using the specified file as the source
image, to be used for server-side image maps. The specified
$button_name will be passed as a form variable when the button
is clicked, and the coordinates of the cursor can be retrieved using
$button_name.x and $button_name.y.
- repo_types_choice($param_name)
-
Generates a scrolling list of all possible repository object types and
simple types, using the specified parameter name.
- repo_types_choice_complex($param_name)
-
Generates a scrolling list of all possible repository object types
(excluding simple types), using the specified parameter name.
- repo_choice($obj_list, $param, $type, $size, $multiple)
-
Given a list of repository objects ($repolist), generates a popup menu
whose choices are labeled by the default labels of the objects. The OIDs of
the selected objects will be returned as results. The results will be named
using the given parameter name. The form element can be changed from popup
menu to scrollable list by passing the value ``SCROLL'' as the third
parameter. The viewable size may be set using the fourth parameter. By
default, multiple choices are not allowed, but they may be allowed by
passing the value ``MULTIPLE'' in the fifth parameter.
- repo_banner()
-
Emits a header to appear at the top of every web page. The banner should
also provide a navigation bar and identify the repository being accessed.
If the CGI programmer has created a function called ``custom_banner'' in
the view definition file, it will be used by repo_banner. Otherwise, a
default banner is emitted, which denotes the repository name and the user
level.
- repo_get_url($url)
-
Executes a remote query on the given
$url and returns the
results (text-only). This command only works if lynx is present on the
system. Can be re-implemented to use the perl URI module.
- repo_smart_prompt($paramname, $type)
-
Creates a form input element named
$paramname appropriate for
the attribute type given by $type.
- repo_attributes_prompt($r)
-
$r can be either a classname or a ref to a repo or a repo
template. Creates a table of form elements, one for each attribute of the
class. If $r is a repo or repo template, the form elements
will have default values using the attributes of $r. The form parameter
names will be prefixed by ``att_''. Use repo_attributes_parse to parse the
form.
- repo_attributes_parse($r)
-
$r can be either a classname or a ref to a repo or
repo_template. Parses the CGI parameters created by repo_attributes_prompt.
Stores the submitted results into the attributes of the repo and returns
it. Note: calling environment is responsible for committing the changes via
repo_update or repo_new.
Modeling multimedia knowledge can be simplified by recognizing multiple
types of context that affect how an object appears. Three kinds of context
are supported by the system: ViewClass context, which defines what kind of
object we are looking at, UserClass context, which identifies the point of
view from which the object is being observed, and Subject context, which
identifies the particular instance(s) that are being viewed.
To accommodate multiple user contexts, the UserClass of the query session
is accessible from within the ViewClass methods, to allow the ViewClass
designer to provide custom-tailored views. For example, to maintain patient
privacy, the patient's LabelView might display the patient's name for
privileged users, and only show a patient's research number for public
users. A simple switch statement can thus be used to enforce privacy at
every level of the system.
The context variables are stored in a hash called %CONTEXT, using keys
``subject'', ``view'', and ``user'', which are passed between cgi
invocations as parameters cx_subject, cx_view, and cx_user.
The following standard class definition methods are defined for every
built-in WIRM type (User, File, Annotation):
Class_view_label
Class_view_row_header
Class_view_row
Class_view_page
Class_make (and associated sub-methods)
In addition, the following methods are available:
- File_view_icon($file)
-
Display an icon view of the given file, which serves as a button that leads
to a page view of the file when clicked. If the file is a recognized image
type, the icon will be a thumbnail version of the file's contents.
Otherwise a generic icon will be shown.
- File_view_image($file)
-
Display a fullsize image of the given file, which serves as a button that
leads to a page view of the file when clicked. File must be an image type.
- File_view_contents($file)
-
Displays the contents of a file. If the file is an image, displays the
image using the viz service (the image will be copied as a jpeg into a
web-visible image cache, whose URL will be specified in an IMG tag). If the
file is a text type, the ASCII contents of the file will be emitted in
place. For all other types, the file will be copied to a web-visible
location and a URL to that file will be provided.
- Annotation_view_icon($subject)
-
If the given subject has an associated Annotation, returns a button which
can be clicked to read a annotation. If the given subject has no
annotation, a null string is returned.
- Annotation_view_icon_make($subject)
-
Displays a button which can be clicked to generate a annotation. Uses the
WIRM commet_add facility. The annotation will be associated with the given
$subject.
Rex Jakobovits, rex@cs.washington.edu
repo.pl