[ome-users] Custom annotations absent in exported metadata
Josiah Johnston
siah at nih.gov
Fri Sep 16 23:13:25 BST 2005
I've had my head buried in the sand for the past several months in
attempts to be more productive with biology projects, supervision of a
summer student, classifier calibration, and classifier validation. Ilya
pointed me to your recent posting and asked me to respond. I'm very
excited to see that you are getting your hands dirty.
Completely unaware of your situation, last week I implemented an
"Export as OME XML" link in image detail. Clicking it gives you a File
download dialogue.
The url for the link looks like this:
http://localhost/perl2/serve.pl?Page=OME::Web::
XMLFileExport&images_to_export=1&filename=tinyTest.d3d.dv.ome&action=Exp
ort
The url is constructed in perl code and passed to the template. The
files to look at are
OME/src/perl2/OME/Web/DBObjRender/__OME_Image.pm
OME/src/perl2/OME/Web/XMLFileExport.pm
OME/src/html/Templates/System/Display/One/OME/Image/detail.tmpl
The template requests an export_url field in line 32. This gets
propagated to the specialized Image renderer (__OME_Image.pm) and ends
up on lines 95-100. The specialized renderer passes the buck to
XMLFileExport.pm and asks for a url. I figured XMLFileExport is the
only one with any business knowing about it's field names, so I wrote a
new method in it called getURLtoExport() one lines 143-150.
> Is there a template or module that constructs the menu bar at the
> left? (A grep on the source tree doesn't reveal, e.g., the string
> "serve.pl?Page=OME::Web::XMLFileExport", so I guess the menu is
> constructed more dynamically?)
Good guess with the grep, but you were just a tad too specific.
grepping for OME::Web::XMLFileExport would have led you to
OME/src/perl2/OME/Web/DefaultMenuBuilder.pm
If you copy and paste lines 162-166, and change XMLFileExport to
XMLFileExportDTGED, then you'll have another menu entry.
> Will the present logic allow a URI that directly obtains XML data for
> a single image? (The current logic uses a form button to initiate the
> export, so I'm guessing there's not a direct URI without adding some
> more logic.
If you pass the name of the form button as a url parameter, it's the
same as clicking the button.
> I suppose I'd need to pick up the image ID and use that to construct a
> link that invokes something like the "action eq 'export'" logic from
> the current OME::Web::XMLFileExport::getPageBody function, supplying
> the image id directly from the link. (Do the query components from
> the URI get passed in as CGI parameters? Do they show up as a Perl
> hash or array?)
Here's the reference you'll need
http://www.perldoc.com/perl5.6/lib/CGI.html#MIXING-POST-AND-URL-
PARAMETERS
CGI uses a different name for "query components". It calls them url
parameters.
Here's a code snippet that demonstrates retrieval of a single named url
parameter.
my $q = $self->CGI();
my $param_value = $q->param( 'param_name' );
If you want to strongly differentiate url and post parameters, then you
would use
my $param_value = $q->url_param( 'param_name' );
It won't make a difference for your simple use case.
In general, it can make a difference. If you have url parameters and a
post, then param() will ignore the url parameters. If you only have url
parameters, then param() will give you the url parameters.
CGI.pm has two significant idiosyncracies. You just learned one. The
other is "sticky" behavior. It's described as
"...As with all these methods, the field will be initialized with its
previous contents from earlier invocations of the script."
I won't go into more detail, because that only comes into play when you
repeatedly submit a form. That's not something you are doing now.
> It would also help to create a direct link here to create a specific
> type of annotation. I'm thinking a link with a target like:
>
> javascript: annotateImage(<TMPL_VAR Name='id'>,"DTGEDImageAnnotation");
>
> might do the trick. Is this right?
Yeah, you could construct an interface that looks like that. The
javascript function would need to know how to translate
"DTGEDImageAnnotation" to your annotator's url. I don't know if your
annotator is a perl package or an annotation template. But you could
get something going either way.
Good luck,
-Josiah
More information about the ome-users
mailing list