Wednesday, April 30, 2008

MetWare, SKOS and Java Server Faces

The MetWare components are slowly coming together. The RAW data upload facility prototype went into beta stage, while the SKOS has proven really useful for various things.

Because of being compatible with various Java libraries and tools, we decided some time ago to use Java. We also wanted to start of with a HTML GUI to MetWare, which led us to Java Server Faces. Not being so fond of Tomcat (e.g. use by the NMRShiftDB), I was not sure how that would turn out, but Steffen was rather positive about it. And I like it :)

The source code for this screenshot is rather simple:
<tr valign="top">
<td><br/>Monoisotopic Mass:<br/>
min=<inputText id="monomassmin" value="#{metidMetaboliteQuery.monoisotopicMassMin}"/><br/>
max=<inputText id="monomassmax" value="#{metidMetaboliteQuery.monoisotopicMassMax}"/><br/>
<commandButton value="Search" id="submit" action="#{}"/>

<!-- search results -->
<p><dataTable value="#{metidMetaboliteQuery.results}" var="mbolite">
<facet name="caption">Search Results...</facet>
<facet name="header"><outputText value="Monoisotopic mass"/></facet>
<outputText value="#{mbolite.monoisotopicMass}"/>
<facet name="header"><outputText value="InChIKey"/></facet>
<outputText value="#{mbolite.inchikey}"/>
<td width="25%">
<b><outputText id="tabelName" value="#{metidMetabolite.prefLabel}"/>:</b>
<outputText id="tabelDef" value="#{metidMetabolite.definition}"/>
Key concept here is that JSF uses Java Beans, which are referred to in the above example with code like #{bean.field} for bean fields, and with #{bean.method}, assuming a bean exists with getField(), setField() and method(). The <h:outputText> stuff is JSF to work out bean details and will create HTML in the output. As really brief intro.

The Metware Beans
It is clear that java beans for Metware would be useful, and this is what I have been working on for the last few weeks. The relevant beans for the above example are automagically created from the SKOS, complemented with extra bits of RDF for the additional details, like field data type, mapping to SQL tables, and an example value. This all works very smoothly (the code to load() and save() into the SQL database is automatically generated too!) as you can see in the above example. The screenshot shows matches from a (local) live SQL metabolomics database. The text on the right side is directly taken from the SKOS.

Now, the bean library allows integration with other tools too, though this cannot be found in our current roadmap. But, for example, I have been thinking about a simple Bioclipse wrapper around these beans. What is on our roadmap involves workflows for metabolomics.


  1. A word of caution - I think it's nigh on impossible to create nice RESTful URLs when using JSF.

    As you point out, your javabeans will work with lots of other frameworks too...

  2. Hi Jim,

    easy machine access is actually not the goal. We'll use BioMart for that, possibly complemented with extra webservices, aimed at integration with workflow environments.

    That said, I'd say it should be possible to use rewrites to pass field properties via the URL... Will check that, and report on that.

  3. OK, I googled a bit, and it is possible. See commit r351 in SVN. This commit deals with adding GET support for the JSF page, /metid_metabolite_search.jsf?min=0.5,
    but using an Apache rewrites this can easily be translated into a REST URL scheme.

    BTW, I do not suggest to use it for filling search forms, but this would be rather useful for looking up metabolites, or other particular entities.

  4. Good stuff, Egon! JSF must have moved on since I looked last.

    Apache URL rewrite to the rescue again, eh? :-) btw, did you know that there's a Java equivalent?: