public Map execute(Map inputs) throws TaskExecutionException { try { Map outputs = new HashMap(); outputs.put("replacelsid", new DataThing("replacelsid:input")); return outputs; } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } } }
/** * For String arrays convert the array to a List and store that. */ public static DataThing bake(String[] theStringArray) { return new DataThing(convertObject(theStringArray)); /** * List theList = new ArrayList(); for (int i = 0; i < * theStringArray.length; i++) { theList.add(theStringArray[i]); } * return new DataThing(theList); */ }
/** * For arrays of byte arrays store each byte array in a List */ public static DataThing bake(byte[][] theByteArrayArray) { return new DataThing(convertObject(theByteArrayArray)); /** * List theList = new ArrayList(); for (int i = 0; i < * theByteArrayArray.length; i++) { theList.add(theByteArrayArray[i]); } * return new DataThing(theList); */ }
/** * For byte arrays store the byte array as is */ public static DataThing bake(byte[] theByteArray) { return new DataThing(convertObject(theByteArray)); }
public Map execute(Map inputs) throws TaskExecutionException { try { Map outputs = new HashMap(); byte[] bytes = (byte[]) ((DataThing) inputs.get("bytes")).getDataObject(); outputs.put("string", new DataThing(new String(bytes))); return outputs; } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } }
/** * Easy for String objects, everything already recognizes them so no custom * code required. */ public static DataThing bake(String theString) { return new DataThing(convertObject(theString)); }
public Map execute(Map inputs) throws TaskExecutionException { try { String firstString = (String) ((DataThing) inputs.get("string1")).getDataObject(); String secondString = (String) ((DataThing) inputs.get("string2")).getDataObject(); Map outputs = new HashMap(); outputs.put("output", new DataThing(firstString + secondString)); return outputs; } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } }
public Map execute(Map inputs) throws TaskExecutionException { Map results = new HashMap(); byte[] bytes = (byte[]) ((DataThing) inputs.get("bytes")).getDataObject(); String base64 = Base64.encodeBytes(bytes); results.put("base64", new DataThing(base64)); return results; }
public Map execute(java.util.Map workflowInputMap, IProcessorTask parentTask) throws TaskExecutionException { try{ StringConstantProcessor theProcessor = (StringConstantProcessor)proc; // Get the output port, there is always only a single child for this task Map outputMap = new HashMap(); outputMap.put("value",new DataThing(theProcessor.getStringValue())); return outputMap; } catch(Exception ex) { throw new TaskExecutionException("Couldn't create string constant!"); } }
public static DataThing fetchFromURL(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.connect(); String contentType = conn.getContentType(); Object content = conn.getContent(); DataThing dt = new DataThing(content); dt.getMetadata().setMIMETypes( Arrays.asList(new String[] { contentType })); return dt; }
DataThing makeSimple(String extra) { List<List<String>> values = new ArrayList<List<String>>(); values.add(Arrays.asList("1", "2", "3")); values.add(Arrays.asList("4", "5", "6")); if (extra != null) { values.add(Arrays.asList(extra)); } return new DataThing(values); }
private List runSlicer(SliceList slicer, List list, String fromString, String toString) throws TaskExecutionException { Map<String, DataThing> inputs = new HashMap<String, DataThing>(); inputs.put("inputlist", new DataThing(list)); inputs.put("fromindex", new DataThing(fromString)); inputs.put("toindex", new DataThing(toString)); Map out = slicer.execute(inputs); DataThing thing = (DataThing) out.get("outputlist"); List result = (List) thing.getDataObject(); return result; }
private List runFlattener(FlattenList flattener, List list) throws TaskExecutionException { Map<String, DataThing> inputs = new HashMap<String, DataThing>(); inputs.put("inputlist", new DataThing(list)); Map out = flattener.execute(inputs); DataThing thing = (DataThing) out.get("outputlist"); List result = (List) thing.getDataObject(); return result; }
public void testPadding() throws Exception { Map inputs = new HashMap(); inputs.put("input",new DataThing("12345")); inputs.put("targetlength",new DataThing("15")); Map output = new PadNumber().execute(inputs); DataThing thing = (DataThing)output.get("padded"); assertNotNull("no result found",thing); String result = (String)thing.getDataObject(); assertEquals("incorrect result","000000000012345",result); }
public void testConcat() throws Exception { Map inputs=new HashMap(); inputs.put("string1",new DataThing("bob ")); inputs.put("string2",new DataThing("monkhouse")); Map out = new StringConcat().execute(inputs); assertEquals("there should only be 1 output",1,out.size()); DataThing thing = (DataThing)out.get("output"); String result=(String)thing.getDataObject(); assertEquals("output is wrong","bob monkhouse",result); }
private void triggerIterationEvent(String input, Map lsidMap, Processor processor, List<ProcessCompletionEvent> assocCompletionEvents, Map<String, DataThing> inputMap, Map<String, DataThing> outputMap) { DataThing inputDataThing = new DataThing(input); inputDataThing.setLSID(input, (String) lsidMap.get(input)); triggerIterationEvent(inputDataThing, processor, assocCompletionEvents, outputMap); }
public void testPadding2() throws Exception { Map inputs = new HashMap(); inputs.put("input",new DataThing("123456789")); inputs.put("targetlength",new DataThing("12")); Map output = new PadNumber().execute(inputs); DataThing thing = (DataThing)output.get("padded"); assertNotNull("no result found",thing); String result = (String)thing.getDataObject(); assertEquals("incorrect result","000123456789",result); }
public JComponent getComponent(RendererRegistry renderers, DataThing dataThing) throws RendererException { DataThing copy = new DataThing(dataThing); copy.getMetadata().setMIMETypes( Arrays.asList(strip(dataThing.getMetadata().getMIMETypes()))); try { return new XMLTree((String) dataThing.getDataObject()); } catch (Exception ex) { throw new RendererException(ex); } } }
public void testDefault() throws Exception { Map inputs = new HashMap(); inputs.put("input",new DataThing("123")); Map output = new PadNumber().execute(inputs); DataThing thing = (DataThing)output.get("padded"); assertNotNull("no result found",thing); String result = (String)thing.getDataObject(); assertEquals("incorrect result","0000123",result); }
public void testByteToArray() throws Exception { byte [] bytes = { '1', '2', '3', '4', '5'}; Map inputs = new HashMap(); inputs.put("bytes",new DataThing(bytes)); Map outputs = new ByteArrayToString().execute(inputs); assertEquals("outputs should contain 1 element",1,outputs.size()); Object result=outputs.get("string"); assertNotNull("element in map for 'string' should not be null",result); assertTrue("element in map should be of type DataThing",result instanceof DataThing); assertEquals("value of string is incorrect","12345",((DataThing)result).getDataObject()); }