@Test public void simple() throws Exception { List<Map<String, String>> flds = new ArrayList<Map<String, String>>(); Map<String, String> f = new HashMap<String, String>(); f.put(DataImporter.COLUMN, "dsc"); f.put(ClobTransformer.CLOB, "true"); f.put(DataImporter.NAME, "description"); flds.add(f); Context ctx = AbstractDataImportHandlerTest.getContext(null, new VariableResolverImpl(), null, Context.FULL_DUMP, flds, Collections.EMPTY_MAP); Transformer t = new ClobTransformer(); Map<String, Object> row = new HashMap<String, Object>(); Clob clob = (Clob) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{Clob.class}, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("getCharacterStream")) { return new StringReader("hello!"); } return null; } }); row.put("dsc", clob); t.transformRow(row, ctx); Assert.assertEquals("hello!", row.get("dsc")); }
public Object transformRow(Map<String, Object> aRow, Context context) { for (Map<String, String> map : context.getAllEntityFields()) { if (!TRUE.equals(map.get(CLOB))) continue; String column = map.get(DataImporter.COLUMN); String srcCol = map.get(RegexTransformer.SRC_COL_NAME); if (srcCol == null) srcCol = column; Object o = aRow.get(srcCol); if (o instanceof List) { List<Clob> inputs = (List<Clob>) o; List<String> results = new ArrayList<String>(); for (Object input : inputs) { if (input instanceof Clob) { Clob clob = (Clob) input; results.add(readFromClob(clob)); } } aRow.put(column, results); } else { if (o instanceof Clob) { Clob clob = (Clob) o; aRow.put(column, readFromClob(clob)); } } } return aRow; }
ClobTransformer extends Transformer { public Object transformRow(Map<String, Object> aRow, Context context) { for (Map<String, String> map : context.getAllEntityFields()) { if (!TRUE.equals(map.get(CLOB))) continue; String column = map.get(DataImporter.COLUMN); String srcCol = map.get(RegexTransformer.SRC_COL_NAME); if (srcCol == null) srcCol = column; Object o = aRow.get(srcCol); if (o instanceof List) { List<Clob> inputs = (List<Clob>) o; List<String> results = new ArrayList<String>(); for (Object input : inputs) { if (input instanceof Clob) { Clob clob = (Clob) input; results.add(readFromClob(clob)); } } aRow.put(column, results); } else { if (o instanceof Clob) { Clob clob = (Clob) o; aRow.put(column, readFromClob(clob)); } } } return aRow; } }
ClobTransformer extends Transformer { public Object transformRow(Map<String, Object> aRow, Context context) { for (Map<String, String> map : context.getAllEntityFields()) { if (!TRUE.equals(map.get(CLOB))) continue; String column = map.get(DataImporter.COLUMN); String srcCol = map.get(RegexTransformer.SRC_COL_NAME); if (srcCol == null) srcCol = column; Object o = aRow.get(srcCol); if (o instanceof List) { List<Clob> inputs = (List<Clob>) o; List<String> results = new ArrayList<String>(); for (Object input : inputs) { if (input instanceof Clob) { Clob clob = (Clob) input; results.add(readFromClob(clob)); } } aRow.put(column, results); } else { if (o instanceof Clob) { Clob clob = (Clob) o; aRow.put(column, readFromClob(clob)); } } } return aRow; }  }
ClobTransformer extends Transformer { public Object transformRow(Map<String, Object> aRow, Context context) { for (Map<String, String> map : context.getAllEntityFields()) { if (!TRUE.equals(map.get(CLOB))) continue; String column = map.get(DataImporter.COLUMN); String srcCol = map.get(RegexTransformer.SRC_COL_NAME); if (srcCol == null) srcCol = column; Object o = aRow.get(srcCol); if (o instanceof List) { List<Clob> inputs = (List<Clob>) o; List<String> results = new ArrayList<String>(); for (Object input : inputs) { if (input instanceof Clob) { Clob clob = (Clob) input; results.add(readFromClob(clob)); } } aRow.put(column, results); } else { if (o instanceof Clob) { Clob clob = (Clob) o; aRow.put(column, readFromClob(clob)); } } } return aRow; }  Object transformRow(Map<String, Object> aRow, Context context); }
ClobTransformer extends Transformer { public Object transformRow(Map<String, Object> aRow, Context context) { for (Map<String, String> map : context.getAllEntityFields()) { if (!TRUE.equals(map.get(CLOB))) continue; String column = map.get(DataImporter.COLUMN); String srcCol = map.get(RegexTransformer.SRC_COL_NAME); if (srcCol == null) srcCol = column; Object o = aRow.get(srcCol); if (o instanceof List) { List<Clob> inputs = (List<Clob>) o; List<String> results = new ArrayList<String>(); for (Object input : inputs) { if (input instanceof Clob) { Clob clob = (Clob) input; results.add(readFromClob(clob)); } } aRow.put(column, results); } else { if (o instanceof Clob) { Clob clob = (Clob) o; aRow.put(column, readFromClob(clob)); } } } return aRow; }  Object transformRow(Map<String, Object> aRow, Context context); static final String CLOB; }