Hi David,

I presume you are talking about the SaveIndividualResult action in 
result-view module? We have also noticed there was a problem with saving 
individual results because it was rendering it as an Object and it was 
fixed last week (see T2-1280: Binary data not always loaded/saved 
correctly; http://www.mygrid.org.uk/dev/issues/browse/T2-1280).

The problem was that it was always saving binary data as a String (when 
rendering as Object, String seems to always be the first one to be 
returned by the Reference Service). So this worked on MAC but not on 
Windows, probably due to different string encoding.

Anyway, our fix was to use the first (least expensive) 
ExternalReferenceSPI returned for that T2Reference (which is actually a 
ReferenceSet) and just use its openStream(context) method and then save 
that stream to a file regardless of what the stream contained.

Alex


David Withers wrote:
> 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.
>   

------------------------------------------------------------------------------
_______________________________________________
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