On Mon, Feb 7, 2011 at 09:01, Andreas Truszkowski <[email protected]> wrote: > unfortunately my question was not answered yet. So what can I do that > when I use the "Add file location(s)" function of an input port that the > subsequent activity input port receives the file location data instead > of the file data. I can not imagine that I am the only one who needs > this feature.
as I said, there's not yet a local worker that can do the 'translation' for you, but individual activities can still do so. > So how have I to adapt programmatically my subsequent activity to > achieve the wanted behaviour? Yes, your activity would need to deliberately say it wants a FileReference instead of a value. See the example activity at https://github.com/stain/filepath-example-activity in particular from https://github.com/stain/filepath-example-activity/blob/master/example-activity/src/main/java/filepath/filepath/ExampleActivity.java notice: protected void configurePorts() { (..) // Expects File or HTTP Reference List<Class<? extends ExternalReferenceSPI>> expectedReferences = new ArrayList<Class<? extends ExternalReferenceSPI>>(); expectedReferences.add(HttpReference.class); expectedReferences.add(FileReference.class); addInput(IN_DATA, 0, false, expectedReferences, null); (..) } And a more low-level way to get the references (instead of renderIdentifier): T2Reference inputRef = inputs.get(IN_DATA); Identified identified = referenceService.resolveIdentifier(inputRef, null, context); if (identified instanceof ReferenceSet) { ReferenceSet referenceSet = (ReferenceSet) identified; Set<ExternalReferenceSPI> externalReferences = referenceSet .getExternalReferences(); for (ExternalReferenceSPI externalReference : externalReferences) { if (externalReference instanceof HttpReference) { HttpReference httpReference = (HttpReference) externalReference; url = httpReference.getHttpUrlString(); } if (externalReference instanceof FileReference) { FileReference fileReference = (FileReference) externalReference; file = fileReference.getFilePath(); } } } The rest of the activity deals with the edge case of 'what if it isn't a URL or File' - it depends on your service what you want to do then, to store the content passed to a temporary file, or to elect to parse the passed string as a File path or URL. now I agree this API could be improved a lot, perhaps something like renderIdentifier(t2ref, URL.class) would be good. -- Stian Soiland-Reyes, myGrid team School of Computer Science The University of Manchester ------------------------------------------------------------------------------ The modern datacenter depends on network connectivity to access resources and provide services. The best practices for maximizing a physical server's connectivity to a physical network are well understood - see how these rules translate into the virtual world? http://p.sf.net/sfu/oracle-sfdevnlfb _______________________________________________ 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/
