public Multimap < String , String > listCorpusAlias ( File databaseProperties ) { Multimap < String , String > result = TreeMultimap . create ( ) ; DataSource origDataSource = getDataSource ( ) . getInnerDataSource ( ) ; try { if ( databaseProperties != null ) { getDataSource ( ) . setInnerDataSource ( createDataSource ( databaseProperties ) ) ; } result = getJdbcTemplate ( ) . query ( "SELECT a.alias AS alias, c.name AS corpus\n" + "FROM corpus_alias AS a, corpus AS c\n" + "WHERE\n" + " a.corpus_ref = c.id" , new ResultSetExtractor < Multimap < String , String > > ( ) { @ Override public Multimap < String , String > extractData ( ResultSet rs ) throws SQLException , DataAccessException { Multimap < String , String > data = TreeMultimap . create ( ) ; while ( rs . next ( ) ) { // alias -> corpus name data . put ( rs . getString ( 1 ) , rs . getString ( 2 ) ) ; } return data ; } } ) ; } catch ( IOException | URISyntaxException | DataAccessException ex ) { if ( databaseProperties == null ) { log . error ( "Could not query corpus list" , ex ) ; } else { log . error ( "Could not query corpus list for the file " + databaseProperties . getAbsolutePath ( ) , ex ) ; } } finally { getDataSource ( ) . setInnerDataSource ( origDataSource ) ; } return result ; }
Provides a list where the keys are the aliases and the values are the corpus names .