Search in sources :

Example 1 with TableModelerSource

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());
    }
}
Also used : TableModelerSource(org.pentaho.agilebi.modeler.util.TableModelerSource) InlineSqlModelerSource(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.utils.InlineSqlModelerSource) IModelerSource(org.pentaho.agilebi.modeler.IModelerSource) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) KettleException(org.pentaho.di.core.exception.KettleException)

Example 2 with TableModelerSource

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());
    }
}
Also used : TableModelerSource(org.pentaho.agilebi.modeler.util.TableModelerSource) IModelerSource(org.pentaho.agilebi.modeler.IModelerSource) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) KettleException(org.pentaho.di.core.exception.KettleException)

Example 3 with TableModelerSource

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;
}
Also used : TableModelerSource(org.pentaho.agilebi.modeler.util.TableModelerSource) ArrayList(java.util.ArrayList) Domain(org.pentaho.metadata.model.Domain) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) OlapDimension(org.pentaho.metadata.model.olap.OlapDimension) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) DatasourceMgmtServiceException(org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException) DataAccessException(org.springframework.dao.DataAccessException) DuplicateDatasourceException(org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException) NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException)

Example 4 with TableModelerSource

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;
}
Also used : TableModelerSource(org.pentaho.agilebi.modeler.util.TableModelerSource) ArrayList(java.util.ArrayList) Domain(org.pentaho.metadata.model.Domain) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) OlapDimension(org.pentaho.metadata.model.olap.OlapDimension) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) DatasourceMgmtServiceException(org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException) PlatformImportException(org.pentaho.platform.plugin.services.importer.PlatformImportException) DataAccessException(org.springframework.dao.DataAccessException) DuplicateDatasourceException(org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException) IOException(java.io.IOException) NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException)

Example 5 with TableModelerSource

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));
}
Also used : TableModelerSource(org.pentaho.agilebi.modeler.util.TableModelerSource) ModelInfo(org.pentaho.platform.dataaccess.datasource.wizard.models.ModelInfo) CsvDatasourceImportStrategy(org.pentaho.metadata.automodel.importing.strategy.CsvDatasourceImportStrategy) ColumnInfo(org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Aggregations

TableModelerSource (org.pentaho.agilebi.modeler.util.TableModelerSource)6 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)6 KettleException (org.pentaho.di.core.exception.KettleException)3 ArrayList (java.util.ArrayList)2 IModelerSource (org.pentaho.agilebi.modeler.IModelerSource)2 CsvDatasourceImportStrategy (org.pentaho.metadata.automodel.importing.strategy.CsvDatasourceImportStrategy)2 Domain (org.pentaho.metadata.model.Domain)2 OlapDimension (org.pentaho.metadata.model.olap.OlapDimension)2 DatasourceMgmtServiceException (org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException)2 DuplicateDatasourceException (org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException)2 NonExistingDatasourceException (org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException)2 DataAccessException (org.springframework.dao.DataAccessException)2 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)2 IOException (java.io.IOException)1 Test (org.junit.Test)1 PhysicalTableImporter (org.pentaho.metadata.automodel.PhysicalTableImporter)1 Column (org.pentaho.metadata.model.thin.Column)1 ColumnInfo (org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo)1 ModelInfo (org.pentaho.platform.dataaccess.datasource.wizard.models.ModelInfo)1 InlineSqlModelerSource (org.pentaho.platform.dataaccess.datasource.wizard.service.impl.utils.InlineSqlModelerSource)1