@Test public void testICDCodeLookup() throws Exception { String[] directives = new String[] { "catalog-lookup icd-10-2016 code", "catalog-lookup ICD-10-2017 code", }; List<Row> rows = Arrays.asList( new Row("code", "A0100"), new Row("code", "A0102"), new Row("code", "Z9989"), new Row("code", "Y36521S"), new Row("code", "ABC"), new Row("name", "Root") ); rows = TestingRig.execute(directives, rows); Assert.assertTrue(rows.size() == 6); Assert.assertEquals("code_icd_10_2016_description", rows.get(0).getColumn(1)); Assert.assertEquals("code_icd_10_2017_description", rows.get(0).getColumn(2)); for (int i = 0; i < 6; ++i) { Assert.assertEquals(3, rows.get(i).width()); } }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object != null && object instanceof String) { String code = (String) object; StaticCatalog.Entry value = catalog.lookup(code); if (value != null) { row.add(generatedColumn, value.getDescription()); } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } return rows; }
CatalogLookup implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object != null && object instanceof String) { String code = (String) object; StaticCatalog.Entry value = catalog.lookup(code); if (value != null) { row.add(generatedColumn, value.getDescription()); } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } return rows; } }
CatalogLookup implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object != null && object instanceof String) { String code = (String) object; StaticCatalog.Entry value = catalog.lookup(code); if (value != null) { row.add(generatedColumn, value.getDescription()); } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } return rows; }  }
CatalogLookup implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object != null && object instanceof String) { String code = (String) object; StaticCatalog.Entry value = catalog.lookup(code); if (value != null) { row.add(generatedColumn, value.getDescription()); } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); }
CatalogLookup implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = row.find(column); if (idx != -1) { Object object = row.getValue(idx); if (object != null && object instanceof String) { String code = (String) object; StaticCatalog.Entry value = catalog.lookup(code); if (value != null) { row.add(generatedColumn, value.getDescription()); } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } else { row.add(generatedColumn, null); } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); static final String NAME; }