/** * For testing */ TableModelerSource createTableModelerSource( DatabaseMeta database, String tableName, String schemaName, String datasourceName ) { return new TableModelerSource( database, tableName, schemaName, datasourceName ); }
public Domain generateDomain( String connectionName, String tableName, String dbType, String query, String datasourceName ) throws Exception { try { DatabaseMeta database = new DatabaseMeta(); database.setDatabaseInterface( new MySQLDatabaseMeta() ); database.setDatabaseType( "mysql" ); database.setUsername( "root" ); database.setPassword( "" ); database.setAccessType( DatabaseMeta.TYPE_ACCESS_NATIVE ); database.setHostname( "localhost" ); database.setDBName( "hibernate" ); database.setDBPort( "3306" ); TableModelerSource source = new TableModelerSource( database, tableName, null ); Domain d = null; try { d = source.generateDomain(); } catch ( ModelerException e ) { e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates. } return d; } catch ( Exception e ) { e.printStackTrace(); } return null; }
public Domain generateCSVDomain( ModelInfo modelInfo ) throws Exception { initKettle(); try { DatabaseMeta database = getDatabaseMeta(); final String tableName = modelInfo.getStageTableName(); final String datasourceName = modelInfo.getDatasourceName(); Column[] columns = toColumns( modelInfo.getColumns() ); PhysicalTableImporter.ImportStrategy importStrategy = new CsvDatasourceImportStrategy( columns ); TableModelerSource source = createTableModelerSource( database, tableName, null, datasourceName ); return source.generateDomain( importStrategy ); } catch ( Exception e ) { logger.error( e ); throw new Exception( e.getLocalizedMessage() ); } }
private ModelerWorkspace autoModelSharedDimension( final ModelerWorkspace workspace, final DataProvider dataProvider ) throws MetaStoreException, KettlePluginException, ModelerException { DatabaseMeta dbMeta = ( (ISpoonModelerSource) workspace.getModelSource() ).getDatabaseMeta(); TableModelerSource source = new TableModelerSource( dbMeta, dataProvider.getTableName(), dataProvider.getSchemaName() ); Domain domain = source.generateDomain( new SharedDimensionImportStrategy( dataProvider ) ); ModelerWorkspace model = new ModelerWorkspace( new ModelerWorkspaceHelper( workspace.getWorkspaceHelper().getLocale() ), workspace.getGeoContext() ); model.setModelSource( source ); model.setDomain( domain ); model.getWorkspaceHelper().autoModelFlat( model ); return model; }
/** * Use {@link ModelerService#generateCSVDomain(ModelInfo)} instead, * as ModelInfo object contains information about csv column names, * provided by user, that are not always the same as the names of columns, * stored in database. (see BISERVER-13026 for more info) * */ @Deprecated public Domain generateCSVDomain( String tableName, String datasourceName ) throws Exception { initKettle(); try { DatabaseMeta database = AgileHelper.getDatabaseMeta(); IModelerSource source = new TableModelerSource( database, tableName, null, datasourceName ); return source.generateDomain(); } catch ( Exception e ) { logger.error( e ); throw new Exception( e.getLocalizedMessage() ); } }
@Deprecated public Domain generateDomain( String connectionName, String tableName, String dbType, String query, String datasourceName ) throws Exception { initKettle(); try { DatabaseMeta database = AgileHelper.getDatabaseMeta(); IModelerSource source; if ( tableName != null ) { source = new TableModelerSource( database, tableName, null, datasourceName ); } else { source = new InlineSqlModelerSource( connectionName, dbType, query, datasourceName ); } return source.generateDomain(); } catch ( Exception e ) { logger.error( e ); throw new Exception( e.getLocalizedMessage() ); } }