Search in sources :

Example 1 with TableDisplayerSettingsBuilder

use of org.dashbuilder.displayer.TableDisplayerSettingsBuilder in project kie-wb-common by kiegroup.

the class DataManagementServiceImpl method getDisplayerSettings.

@Override
public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) {
    checkNotNull("dataSourceUuid", dataSourceUuid);
    checkNotNull("table", table);
    try {
        DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid);
        DataSetDef dataSetDef = DataSetDefBuilder.newBuilder().dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)).dataSetName(buildDataSetName(schema, table)).dataSourceUuid(deploymentInfo.getUuid()).schema(schema).table(buildDataSetTableName(dataSourceUuid, table)).isPublic(false).build();
        dataSetDefRegistry.registerDataSetDef(dataSetDef);
        DataSetLookup lookup = new DataSetLookup();
        lookup.setDataSetUUID(dataSetDef.getUUID());
        DataSet dataSet = dataSetManager.lookupDataSet(lookup);
        TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings().dataset(dataSetDef.getUUID()).title(table).titleVisible(true).tablePageSize(20).tableOrderEnabled(true);
        List<DataColumn> columns = dataSet.getColumns();
        for (DataColumn column : columns) {
            settingsBuilder.column(column.getId());
        }
        int tableWith = columns.size() * COLUMN_WIDTH;
        settingsBuilder.tableWidth(tableWith);
        settingsBuilder.renderer(DefaultRenderer.UUID);
        return settingsBuilder.buildSettings();
    } catch (Exception e) {
        throw new GenericPortableException(e.getMessage());
    }
}
Also used : DataSetDef(org.dashbuilder.dataset.def.DataSetDef) DataSet(org.dashbuilder.dataset.DataSet) DataColumn(org.dashbuilder.dataset.DataColumn) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) TableDisplayerSettingsBuilder(org.dashbuilder.displayer.TableDisplayerSettingsBuilder) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) DataSetLookup(org.dashbuilder.dataset.DataSetLookup) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException)

Aggregations

DataColumn (org.dashbuilder.dataset.DataColumn)1 DataSet (org.dashbuilder.dataset.DataSet)1 DataSetLookup (org.dashbuilder.dataset.DataSetLookup)1 DataSetDef (org.dashbuilder.dataset.def.DataSetDef)1 TableDisplayerSettingsBuilder (org.dashbuilder.displayer.TableDisplayerSettingsBuilder)1 GenericPortableException (org.guvnor.common.services.shared.exceptions.GenericPortableException)1 DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)1