Search in sources :

Example 1 with DataColumn

use of org.dashbuilder.dataset.DataColumn in project kie-wb-common by kiegroup.

the class ContributorsManagerTest method testBuildDataSet.

@Test
public void testBuildDataSet() throws Exception {
    DataSet dataSet = contributorsManager.buildDataSet(null);
    assertEquals(68, dataSet.getRowCount());
    assertEquals(6, dataSet.getColumns().size());
    DataColumn column = dataSet.getColumns().get(0);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_ORG, column.getId());
    column = dataSet.getColumns().get(1);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_REPO, column.getId());
    column = dataSet.getColumns().get(2);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_PROJECT, column.getId());
    column = dataSet.getColumns().get(3);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_AUTHOR, column.getId());
    column = dataSet.getColumns().get(4);
    assertEquals(ColumnType.TEXT, column.getColumnType());
    assertEquals(COLUMN_MSG, column.getId());
    column = dataSet.getColumns().get(5);
    assertEquals(ColumnType.DATE, column.getColumnType());
    assertEquals(COLUMN_DATE, column.getId());
    DataSetMetadata metadata = dataSet.getMetadata();
    assertNotNull(metadata);
}
Also used : DataSet(org.dashbuilder.dataset.DataSet) DataColumn(org.dashbuilder.dataset.DataColumn) DataSetMetadata(org.dashbuilder.dataset.DataSetMetadata) Test(org.junit.Test)

Example 2 with DataColumn

use of org.dashbuilder.dataset.DataColumn in project jbpm by kiegroup.

the class AbstractQueryMapper method getColumnStringValue.

protected String getColumnStringValue(DataSet currentDataSet, String columnId, int index) {
    DataColumn column = currentDataSet.getColumnById(columnId);
    if (column == null) {
        return null;
    }
    Object value = column.getValues().get(index);
    return value != null ? value.toString() : null;
}
Also used : DataColumn(org.dashbuilder.dataset.DataColumn)

Example 3 with DataColumn

use of org.dashbuilder.dataset.DataColumn in project jbpm by kiegroup.

the class AbstractQueryMapper method getColumnLongValue.

protected Long getColumnLongValue(DataSet currentDataSet, String columnId, int index) {
    DataColumn column = currentDataSet.getColumnById(columnId);
    if (column == null) {
        return null;
    }
    Object value = column.getValues().get(index);
    if (value instanceof String) {
        value = Long.parseLong((String) value);
    }
    return value != null ? ((Number) value).longValue() : null;
}
Also used : DataColumn(org.dashbuilder.dataset.DataColumn)

Example 4 with DataColumn

use of org.dashbuilder.dataset.DataColumn in project jbpm by kiegroup.

the class AbstractQueryMapper method getColumnIntValue.

protected int getColumnIntValue(DataSet currentDataSet, String columnId, int index) {
    DataColumn column = currentDataSet.getColumnById(columnId);
    if (column == null) {
        return -1;
    }
    Object value = column.getValues().get(index);
    return value != null ? ((Number) value).intValue() : -1;
}
Also used : DataColumn(org.dashbuilder.dataset.DataColumn)

Example 5 with DataColumn

use of org.dashbuilder.dataset.DataColumn 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)7 DataSet (org.dashbuilder.dataset.DataSet)3 DataSetLookup (org.dashbuilder.dataset.DataSetLookup)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 DataSetMetadata (org.dashbuilder.dataset.DataSetMetadata)1 DataSetDef (org.dashbuilder.dataset.def.DataSetDef)1 DisplayerSettings (org.dashbuilder.displayer.DisplayerSettings)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