@Test public void testImportPropertiesMetadata() throws Exception { Properties props = new Properties(); props.put("importer.ColumnNamePattern", "{CQ}"); props.put("importer.ValueIn", "{ROWID}"); AccumuloConnection conn = Mockito.mock(AccumuloConnection.class); Mockito.stub(conn.getInstance()).toReturn(connector); Mockito.stub(conn.getAuthorizations()).toReturn(new Authorizations("public")); MetadataFactory mf = new MetadataFactory("vdb", 1, "accumulo", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null); AccumuloMetadataProcessor processor = new AccumuloMetadataProcessor(); PropertiesUtils.setBeanProperties(processor, mf.getModelProperties(), "importer"); processor.process(mf,conn); Schema schema = mf.getSchema(); Map<String, Table> tables = schema.getTables(); assertNotNull(tables); assertEquals(2, tables.size()); Table customer = tables.get("Customer"); assertNotNull(customer); List<Column> columns = customer.getColumns(); assertEquals(4, columns.size()); assertNotNull(customer.getColumnByName("rowid")); assertNotNull(customer.getColumnByName("CompanyName")); assertEquals("string",customer.getColumnByName("CompanyName").getDatatype().getName()); Column column = customer.getColumnByName("CompanyName"); assertEquals("Customer",column.getProperty(AccumuloMetadataProcessor.CF, false)); assertEquals("CompanyName",column.getProperty(AccumuloMetadataProcessor.CQ, false)); assertEquals("{ROWID}",column.getProperty(AccumuloMetadataProcessor.VALUE_IN, false)); assertEquals(SearchType.All_Except_Like, column.getSearchType()); column = customer.getColumnByName("rowid"); assertEquals(SearchType.All_Except_Like, column.getSearchType()); assertNotNull(customer.getPrimaryKey()); }
public void process(MetadataFactory mf, AccumuloConnection conn) { Connector connector = conn.getInstance(); Set<String> tableNames = connector.tableOperations().list(); for (String tableName:tableNames) { try { if (tableName.equals("!METADATA") || tableName.equals("trace") || tableName.startsWith("accumulo.")) { continue; } Text previousRow = null; Table table = null; Scanner scanner = connector.createScanner(tableName, conn.getAuthorizations()); for (Entry<Key, Value> entry : scanner) { Key key = entry.getKey(); Text cf = key.getColumnFamily(); Text cq = key.getColumnQualifier(); Text row = key.getRow(); if (previousRow == null || previousRow.equals(row)) { previousRow = row; if (mf.getSchema().getTable(tableName) == null) { table = mf.addTable(tableName); Column column = mf.addColumn(AccumuloMetadataProcessor.ROWID, TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); mf.addPrimaryKey("PK0", Arrays.asList(AccumuloMetadataProcessor.ROWID), table); column.setUpdatable(false); } else { table = mf.getSchema().getTable(tableName); } Column column = mf.addColumn(buildColumnName(cf, cq, row), TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); column.setProperty(CF, cf.toString()); column.setProperty(CQ, cq.toString()); column.setProperty(VALUE_IN, getValueIn()); column.setUpdatable(true); } else { break; } } scanner.close(); if (table != null) { table.setSupportsUpdate(true); } } catch (TableNotFoundException e) { continue; } } }
AccumuloMetadataProcessor implements MetadataProcessor<AccumuloConnection> { public void process(MetadataFactory mf, AccumuloConnection conn) { Connector connector = conn.getInstance(); Set<String> tableNames = connector.tableOperations().list(); for (String tableName:tableNames) { try { if (tableName.equals("!METADATA") || tableName.equals("trace") || tableName.startsWith("accumulo.")) { continue; } Text previousRow = null; Table table = null; Scanner scanner = connector.createScanner(tableName, conn.getAuthorizations()); for (Entry<Key, Value> entry : scanner) { Key key = entry.getKey(); Text cf = key.getColumnFamily(); Text cq = key.getColumnQualifier(); Text row = key.getRow(); if (previousRow == null || previousRow.equals(row)) { previousRow = row; if (mf.getSchema().getTable(tableName) == null) { table = mf.addTable(tableName); Column column = mf.addColumn(AccumuloMetadataProcessor.ROWID, TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); mf.addPrimaryKey("PK0", Arrays.asList(AccumuloMetadataProcessor.ROWID), table); column.setUpdatable(false); } else { table = mf.getSchema().getTable(tableName); } Column column = mf.addColumn(buildColumnName(cf, cq, row), TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); column.setProperty(CF, cf.toString()); column.setProperty(CQ, cq.toString()); column.setProperty(VALUE_IN, getValueIn()); column.setUpdatable(true); } else { break; } } scanner.close(); if (table != null) { table.setSupportsUpdate(true); } } catch (TableNotFoundException e) { continue; } } } }
AccumuloMetadataProcessor implements MetadataProcessor<AccumuloConnection> { public void process(MetadataFactory mf, AccumuloConnection conn) { Connector connector = conn.getInstance(); Set<String> tableNames = connector.tableOperations().list(); for (String tableName:tableNames) { try { if (tableName.equals("!METADATA") || tableName.equals("trace") || tableName.startsWith("accumulo.")) { continue; } Text previousRow = null; Table table = null; Scanner scanner = connector.createScanner(tableName, conn.getAuthorizations()); for (Entry<Key, Value> entry : scanner) { Key key = entry.getKey(); Text cf = key.getColumnFamily(); Text cq = key.getColumnQualifier(); Text row = key.getRow(); if (previousRow == null || previousRow.equals(row)) { previousRow = row; if (mf.getSchema().getTable(tableName) == null) { table = mf.addTable(tableName); Column column = mf.addColumn(AccumuloMetadataProcessor.ROWID, TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); mf.addPrimaryKey("PK0", Arrays.asList(AccumuloMetadataProcessor.ROWID), table); column.setUpdatable(false); } else { table = mf.getSchema().getTable(tableName); } Column column = mf.addColumn(buildColumnName(cf, cq, row), TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); column.setProperty(CF, cf.toString()); column.setProperty(CQ, cq.toString()); column.setProperty(VALUE_IN, getValueIn()); column.setUpdatable(true); } else { break; } } scanner.close(); if (table != null) { table.setSupportsUpdate(true); } } catch (TableNotFoundException e) { continue; } } }  }
AccumuloMetadataProcessor implements MetadataProcessor<AccumuloConnection> { public void process(MetadataFactory mf, AccumuloConnection conn) { Connector connector = conn.getInstance(); Set<String> tableNames = connector.tableOperations().list(); for (String tableName:tableNames) { try { if (tableName.equals("!METADATA") || tableName.equals("trace") || tableName.startsWith("accumulo.")) { continue; } Text previousRow = null; Table table = null; Scanner scanner = connector.createScanner(tableName, conn.getAuthorizations()); for (Entry<Key, Value> entry : scanner) { Key key = entry.getKey(); Text cf = key.getColumnFamily(); Text cq = key.getColumnQualifier(); Text row = key.getRow(); if (previousRow == null || previousRow.equals(row)) { previousRow = row; if (mf.getSchema().getTable(tableName) == null) { table = mf.addTable(tableName); Column column = mf.addColumn(AccumuloMetadataProcessor.ROWID, TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); mf.addPrimaryKey("PK0", Arrays.asList(AccumuloMetadataProcessor.ROWID), table); column.setUpdatable(false); } else { table = mf.getSchema().getTable(tableName); } Column column = mf.addColumn(buildColumnName(cf, cq, row), TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); column.setProperty(CF, cf.toString()); column.setProperty(CQ, cq.toString()); column.setProperty(VALUE_IN, getValueIn()); column.setUpdatable(true); } else { break; } } scanner.close(); if (table != null) { table.setSupportsUpdate(true); } } catch (TableNotFoundException e) { continue; } } }  void process(MetadataFactory mf, AccumuloConnection conn); @TranslatorProperty(display="Column Name Pattern", category=PropertyType.IMPORT, description="Pattern to derive column names from, available expressions to use({CF}, {CQ}, {ROW_ID}") String getColumnNamePattern(); void setColumnNamePattern(String columnNamePattern); @TranslatorProperty(display="Value In", category=PropertyType.IMPORT, description="Defines where the data value of property is in {VALUE} or {CQ}") String getValueIn(); void setValueIn(String valueIn); }
AccumuloMetadataProcessor implements MetadataProcessor<AccumuloConnection> { public void process(MetadataFactory mf, AccumuloConnection conn) { Connector connector = conn.getInstance(); Set<String> tableNames = connector.tableOperations().list(); for (String tableName:tableNames) { try { if (tableName.equals("!METADATA") || tableName.equals("trace") || tableName.startsWith("accumulo.")) { continue; } Text previousRow = null; Table table = null; Scanner scanner = connector.createScanner(tableName, conn.getAuthorizations()); for (Entry<Key, Value> entry : scanner) { Key key = entry.getKey(); Text cf = key.getColumnFamily(); Text cq = key.getColumnQualifier(); Text row = key.getRow(); if (previousRow == null || previousRow.equals(row)) { previousRow = row; if (mf.getSchema().getTable(tableName) == null) { table = mf.addTable(tableName); Column column = mf.addColumn(AccumuloMetadataProcessor.ROWID, TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); mf.addPrimaryKey("PK0", Arrays.asList(AccumuloMetadataProcessor.ROWID), table); column.setUpdatable(false); } else { table = mf.getSchema().getTable(tableName); } Column column = mf.addColumn(buildColumnName(cf, cq, row), TypeFacility.RUNTIME_NAMES.STRING, table); column.setSearchType(SearchType.All_Except_Like); column.setProperty(CF, cf.toString()); column.setProperty(CQ, cq.toString()); column.setProperty(VALUE_IN, getValueIn()); column.setUpdatable(true); } else { break; } } scanner.close(); if (table != null) { table.setSupportsUpdate(true); } } catch (TableNotFoundException e) { continue; } } }  void process(MetadataFactory mf, AccumuloConnection conn); @TranslatorProperty(display="Column Name Pattern", category=PropertyType.IMPORT, description="Pattern to derive column names from, available expressions to use({CF}, {CQ}, {ROW_ID}") String getColumnNamePattern(); void setColumnNamePattern(String columnNamePattern); @TranslatorProperty(display="Value In", category=PropertyType.IMPORT, description="Defines where the data value of property is in {VALUE} or {CQ}") String getValueIn(); void setValueIn(String valueIn); @ExtensionMetadataProperty(applicable=Column.class, datatype=String.class, display="Column Family", description="Column Familiy from the Key", required=true)
    static final String CF; @ExtensionMetadataProperty(applicable=Column.class, datatype=String.class, display="Column Qualifier", description="If Column Qualifier from key makes the key value unique, then this is required")
    static final String CQ; @ExtensionMetadataProperty(applicable=Column.class, datatype=String.class, display="Value In", description="The value of key exists in Column Qualifier or Value slot; Default is VALUE, if value is in CQ then this property is required", allowed= "CQ,VALUE")
    static final String VALUE_IN; static final String DEFAULT_COLUMN_NAME_PATTERN; static final String DEFAULT_VALUE_PATTERN; static final String ROWID; }