On 29/04/2010 03:20, Alan Williams wrote:
> David Withers wrote:
> [snip]
> 
>> I've attached a very simple workflow.
> 
> Cheers.  That ran fine.  I was just choosing an inappropriate number to 
> test it with :-)
> 
> I can't save the output values though.  They just seem to be empty.  I 
> think that is probably due to Taverna not knowing how to serialize a 
> Jena literal.

I've had a look at the result saving code and I think it's using the
reference service incorrectly. It only handles String and byte[] (which
is fair enough) but it dereferences as an Object and then tests if that
Object is a String or byte[].

data = context.getReferenceService().renderIdentifier(resultReference,
Object.class, context);
...
if (data instanceof byte[]) {

} else if (data instanceof String) {

}

If the reference is a ValueCarryingExternalReference (which RDFReference
is) renderIdentifier() will just return the value (in this case RDFNode)
if it's assignable to the requested class (Object). So we get no output
saved.

Otherwise, renderIdentifier() will try and find a StreamToValueConverter
to convert the value. As we've asked to convert to Object, any (random)
StreamToValueConverter will match - with unpredictable results.

As we already have the mime type, I think a better way to do this is:

if (mineType.startsWith("text/") {
  data = (String) referenceService.renderIdentifier(resultReference,
String.class, context);
} else {
  data = (byte[]) referenceService.renderIdentifier(resultReference,
byte[].class, context);
}

or something like that.

David.
-- 
David Withers
School of Computer Science, University of Manchester,
Oxford Road, Manchester, M13 9PL, UK.
+44 (0)161 275 0683

------------------------------------------------------------------------------
_______________________________________________
taverna-hackers mailing list
[email protected]
Web site: http://www.taverna.org.uk
Mailing lists: http://www.taverna.org.uk/about/contact-us/
Developers Guide: http://www.taverna.org.uk/developers/

Reply via email to