@Test public void testFunkyDatasource() throws Exception { Map<String, Datasource> nameToDatasource = new HashMap<>(); nameToDatasource.put("mock", new MockDatasource("mock", List.of("column"), List.of(new MockDataset("ds", Map.of("column", "value")), new MockDataset("ds2", Map.of("column", "value2"))))); Datasource ds = new FunkyDatasource(nameToDatasource, new ConfigThingy("", "NAME \"funky\" SOURCE \"mock\" Spaltenumsetzung(column2(CAT(\"neu_\" VALUE(\"column\"))))")); assertEquals("funky", ds.getName()); assertEquals(List.of("column2", "column"), ds.getSchema()); QueryResults results = ds.getContents(); assertEquals(2, results.size()); results = ds.getDatasetsByKey(List.of("ds")); assertEquals(1, results.size()); results = ds.find(List.of(new QueryPart("column", "value2"))); assertEquals(1, results.size()); assertEquals("neu_value2", results.iterator().next().get("column2")); }
public FunkyDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc) throws ConfigurationErrorException { try { name = sourceDesc.get("NAME", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m("NAME der Datenquelle fehlt")); } String sourceName; try { sourceName = sourceDesc.get("SOURCE", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m( "SOURCE der Datenquelle \"%1\" fehlt", name)); } source = nameToDatasource.get(sourceName); if (source == null) throw new ConfigurationErrorException( L.m( "Fehler bei Initialisierung von Datenquelle \"%1\": Referenzierte Datenquelle \"%2\" nicht (oder fehlerhaft) definiert", name, sourceName)); FunctionLibrary funcLib = new FunctionLibrary(); DialogLibrary dialogLib = new DialogLibrary(); Map<Object, Object> context = new HashMap<Object, Object>(); columnTransformer = new ColumnTransformer(FunctionFactory.parseTrafos(sourceDesc, "Spaltenumsetzung", funcLib, dialogLib, context)); schema = columnTransformer.getSchema(); schema.addAll(source.getSchema()); }
FunkyDatasource extends Datasource { public FunkyDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc) throws ConfigurationErrorException { try { name = sourceDesc.get("NAME", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m("NAME der Datenquelle fehlt")); } String sourceName; try { sourceName = sourceDesc.get("SOURCE", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m( "SOURCE der Datenquelle \"%1\" fehlt", name)); } source = nameToDatasource.get(sourceName); if (source == null) throw new ConfigurationErrorException( L.m( "Fehler bei Initialisierung von Datenquelle \"%1\": Referenzierte Datenquelle \"%2\" nicht (oder fehlerhaft) definiert", name, sourceName)); FunctionLibrary funcLib = new FunctionLibrary(); DialogLibrary dialogLib = new DialogLibrary(); Map<Object, Object> context = new HashMap<Object, Object>(); columnTransformer = new ColumnTransformer(FunctionFactory.parseTrafos(sourceDesc, "Spaltenumsetzung", funcLib, dialogLib, context)); schema = columnTransformer.getSchema(); schema.addAll(source.getSchema()); } }
FunkyDatasource extends Datasource { public FunkyDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc) throws ConfigurationErrorException { try { name = sourceDesc.get("NAME", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m("NAME der Datenquelle fehlt")); } String sourceName; try { sourceName = sourceDesc.get("SOURCE", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m( "SOURCE der Datenquelle \"%1\" fehlt", name)); } source = nameToDatasource.get(sourceName); if (source == null) throw new ConfigurationErrorException( L.m( "Fehler bei Initialisierung von Datenquelle \"%1\": Referenzierte Datenquelle \"%2\" nicht (oder fehlerhaft) definiert", name, sourceName)); FunctionLibrary funcLib = new FunctionLibrary(); DialogLibrary dialogLib = new DialogLibrary(); Map<Object, Object> context = new HashMap<Object, Object>(); columnTransformer = new ColumnTransformer(FunctionFactory.parseTrafos(sourceDesc, "Spaltenumsetzung", funcLib, dialogLib, context)); schema = columnTransformer.getSchema(); schema.addAll(source.getSchema()); } FunkyDatasource(Map<String, Datasource> nameToDatasource,
      ConfigThingy sourceDesc); }
FunkyDatasource extends Datasource { public FunkyDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc) throws ConfigurationErrorException { try { name = sourceDesc.get("NAME", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m("NAME der Datenquelle fehlt")); } String sourceName; try { sourceName = sourceDesc.get("SOURCE", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m( "SOURCE der Datenquelle \"%1\" fehlt", name)); } source = nameToDatasource.get(sourceName); if (source == null) throw new ConfigurationErrorException( L.m( "Fehler bei Initialisierung von Datenquelle \"%1\": Referenzierte Datenquelle \"%2\" nicht (oder fehlerhaft) definiert", name, sourceName)); FunctionLibrary funcLib = new FunctionLibrary(); DialogLibrary dialogLib = new DialogLibrary(); Map<Object, Object> context = new HashMap<Object, Object>(); columnTransformer = new ColumnTransformer(FunctionFactory.parseTrafos(sourceDesc, "Spaltenumsetzung", funcLib, dialogLib, context)); schema = columnTransformer.getSchema(); schema.addAll(source.getSchema()); } FunkyDatasource(Map<String, Datasource> nameToDatasource,
      ConfigThingy sourceDesc); @Override List<String> getSchema(); @Override QueryResults getDatasetsByKey(Collection<String> keys); @Override QueryResults getContents(); @Override QueryResults find(List<QueryPart> query); @Override String getName(); }
FunkyDatasource extends Datasource { public FunkyDatasource(Map<String, Datasource> nameToDatasource, ConfigThingy sourceDesc) throws ConfigurationErrorException { try { name = sourceDesc.get("NAME", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m("NAME der Datenquelle fehlt")); } String sourceName; try { sourceName = sourceDesc.get("SOURCE", 1).toString(); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException(L.m( "SOURCE der Datenquelle \"%1\" fehlt", name)); } source = nameToDatasource.get(sourceName); if (source == null) throw new ConfigurationErrorException( L.m( "Fehler bei Initialisierung von Datenquelle \"%1\": Referenzierte Datenquelle \"%2\" nicht (oder fehlerhaft) definiert", name, sourceName)); FunctionLibrary funcLib = new FunctionLibrary(); DialogLibrary dialogLib = new DialogLibrary(); Map<Object, Object> context = new HashMap<Object, Object>(); columnTransformer = new ColumnTransformer(FunctionFactory.parseTrafos(sourceDesc, "Spaltenumsetzung", funcLib, dialogLib, context)); schema = columnTransformer.getSchema(); schema.addAll(source.getSchema()); } FunkyDatasource(Map<String, Datasource> nameToDatasource,
      ConfigThingy sourceDesc); @Override List<String> getSchema(); @Override QueryResults getDatasetsByKey(Collection<String> keys); @Override QueryResults getContents(); @Override QueryResults find(List<QueryPart> query); @Override String getName();  }