use of org.pentaho.agilebi.modeler.util.TableModelerSource in project data-access by pentaho.
the class ModelerService method generateDomain.
// TODO: remove this method in favor so specific calls
@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());
}
}
use of org.pentaho.agilebi.modeler.util.TableModelerSource in project data-access by pentaho.
the class ModelerService method generateCSVDomain.
/**
* 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());
}
}
use of org.pentaho.agilebi.modeler.util.TableModelerSource in project data-access by pentaho.
the class SerializeServiceIT method generateModel.
private Domain generateModel() {
Domain domain = null;
try {
DatabaseMeta database = new DatabaseMeta();
// database.setDatabaseInterface(new HypersonicDatabaseMeta());
// $NON-NLS-1$
database.setDatabaseType("Hypersonic");
// database.setUsername("sa");//$NON-NLS-1$
// database.setPassword("");//$NON-NLS-1$
database.setAccessType(DatabaseMeta.TYPE_ACCESS_JNDI);
// database.setHostname(".");
// $NON-NLS-1$
database.setDBName("SampleData");
// database.setDBPort("9001");//$NON-NLS-1$
// $NON-NLS-1$
database.setName("SampleData");
System.out.println(database.testConnection());
// $NON-NLS-1$
TableModelerSource source = new TableModelerSource(database, "ORDERS", null);
domain = source.generateDomain();
List<OlapDimension> olapDimensions = new ArrayList<OlapDimension>();
OlapDimension dimension = new OlapDimension();
// $NON-NLS-1$
dimension.setName("test");
dimension.setTimeDimension(false);
olapDimensions.add(dimension);
// $NON-NLS-1$
domain.getLogicalModels().get(1).setProperty("olap_dimensions", olapDimensions);
} catch (Exception e) {
e.printStackTrace();
}
return domain;
}
use of org.pentaho.agilebi.modeler.util.TableModelerSource in project data-access by pentaho.
the class DatasourceResourceIT method generateModel.
private Domain generateModel() {
Domain domain = null;
try {
DatabaseMeta database = new DatabaseMeta();
// $NON-NLS-1$
database.setDatabaseType("Hypersonic");
database.setAccessType(DatabaseMeta.TYPE_ACCESS_JNDI);
// $NON-NLS-1$
database.setDBName("SampleData");
// $NON-NLS-1$
database.setName("SampleData");
System.out.println(database.testConnection());
// $NON-NLS-1$
TableModelerSource source = new TableModelerSource(database, "ORDERS", null);
domain = source.generateDomain();
List<OlapDimension> olapDimensions = new ArrayList<OlapDimension>();
OlapDimension dimension = new OlapDimension();
// $NON-NLS-1$
dimension.setName("test");
dimension.setTimeDimension(false);
olapDimensions.add(dimension);
// $NON-NLS-1$
domain.getLogicalModels().get(1).setProperty("olap_dimensions", olapDimensions);
} catch (Exception e) {
e.printStackTrace();
}
return domain;
}
use of org.pentaho.agilebi.modeler.util.TableModelerSource in project data-access by pentaho.
the class ModelerServiceIT method domainForCsvDatasource_GeneratedWithCsvDatasourceImportStrategy.
@Test
public void domainForCsvDatasource_GeneratedWithCsvDatasourceImportStrategy() throws Exception {
ModelInfo modelInfo = new ModelInfo();
ColumnInfo[] columnInfos = new ColumnInfo[] { createColumnInfo("id", "title") };
modelInfo.setColumns(columnInfos);
modelerService = spy(modelerService);
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
doReturn(dbMeta).when(modelerService).getDatabaseMeta();
TableModelerSource source = mock(TableModelerSource.class);
doReturn(source).when(modelerService).createTableModelerSource(any(DatabaseMeta.class), anyString(), anyString(), anyString());
modelerService.generateCSVDomain(modelInfo);
verify(modelerService).toColumns(columnInfos);
// most important thing here, is that domain is generated with CsvDatasourceImportStrategy
verify(source).generateDomain(any(CsvDatasourceImportStrategy.class));
}
Aggregations