Merge list of errors to string
Created: 2011-09-13 14:04:50
Last updated: 2011-09-13 14:16:05
Based on http://myexperiment.elda.org/workflows/27/
The beanshell scripts collectively builds a temporary file of the merged string (by default using newline as separator). As each item is appended to the file separately by Write_text_append, this means it can handle occassional errors in the list, such as in the output from Sometimes_fails. Such items are not included in the merged string.
To use, merge with your workflow and delete "Create_Lots_if_Strings", "Sometimes_Fails" and "Merge_String_List_to_A_String". Note that Taverna can't provide promises to the order of the execution of Write_text_file_append.
Also see email discussion.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Marc Pochriera
Stian Soiland-Reyes |
Titles (1)
Merge list of errors to string |
Descriptions (1)
Based on http://myexperiment.elda.org/workflows/27/
The beanshell scripts collectively builds a temporary file of the merged string (by default using newline as separator). As each item is appended to the file separately by Write_text_append, this means it can handle occassional errors in the list, such as in the output from Sometimes_fails. Such items are not included in the merged string.
To use, *merge* with your workflow and delete "Create_Lots_if_Strings", "Sometimes_Fails" and "Merge_String_List_to_A_String".
Note that Taverna can't provide promises to the order of the execution of Write_text_file_append.
See http://taverna-users.markmail.org/search/?q=#query:+page:1+mid:cnfl53jbczhpf66b+state:results |
Dependencies (0)
Processors (6)
Name |
Type |
Description |
Sometimes_Fails |
localworker |
Scriptimport java.util.Random; Random r = new Random(); if ((r.nextInt() % 4) ==
0) { throw new RuntimeException("Fails every four runs!"); } out = in; |
Create_Lots_Of_Strings |
localworker |
ScriptList strings = new ArrayList(); for (int i = 0; i < 40; i++) {
strings.add("String" + i); } |
Merge_String_List_to_a_String |
localworker |
ScriptString seperatorString = "\n";
if (seperator != void) {
seperatorString = seperator;
}
StringBuffer sb = new StringBuffer();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append(seperatorString);
}
}
concatenated = sb.toString();
|
Create_temporary_file |
beanshell |
ScriptFile file = File.createTempFile("taverna", "txt");
file.deleteOnExit();
filepath = file.getCanonicalPath();
|
Write_text_file_append |
beanshell |
ScriptString separatorString = "\n";
if (separator != void) {
separatorString = separator;
}
outStream = new FileOutputStream(outputFile, true);
out = new BufferedWriter(new OutputStreamWriter(outStream, "utf-8"));
out.write(filecontents);
out.write(separatorString);
out.close();
|
Wait_for_completion |
beanshell |
Script// Not really needed as nested workflow
// would wait for all processors, but placed here
// for compatibility with older versions
// of Taverna, which would return as soon as all
// outputs were populated |
Beanshells (3)
Name |
Description |
Inputs |
Outputs |
Create_temporary_file |
|
|
filepath
file
|
Write_text_file_append |
|
outputFile
filecontents
separator
|
|
Wait_for_completion |
|
file
|
file
|
Outputs (3)
Name |
Description |
list_with_errors |
|
merged_output_fails |
|
merged_output_without_errors |
|
Datalinks (8)
Source |
Sink |
Create_Lots_Of_Strings:strings |
Sometimes_Fails:in |
Sometimes_Fails:out |
Merge_String_List_to_a_String:stringlist |
Create_temporary_file:filepath |
Write_text_file_append:outputFile |
Sometimes_Fails:out |
Write_text_file_append:filecontents |
Create_temporary_file:file |
Wait_for_completion:file |
Sometimes_Fails:out |
list_with_errors |
Merge_String_List_to_a_String:concatenated |
merged_output_fails |
Wait_for_completion:file |
merged_output_without_errors |
Coordinations (1)
Controller |
Target |
Write_text_file_append |
Wait_for_completion |
Uploader
License
All versions of this Workflow are
licensed under:
Version 2 (latest)
(of 2)
Credits (0)
(People/Groups)
None
Attributions (0)
(Workflows/Files)
None
Shared with Groups (1)
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment