Search in sources :

Example 31 with DataSet

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

the class ProjectMetricsScreenTest method testTopAuthorSelector.

@Test
public void testTopAuthorSelector() {
    Displayer displayer = presenter.getTopAuthorSelectorDisplayer();
    DataSet dataSet = displayer.getDataSetHandler().getLastDataSet();
    assertDataSetValues(dataSet, new String[][] { { "user1", "2.00" }, { "user2", "2.00" } }, 0);
}
Also used : DataSet(org.dashbuilder.dataset.DataSet) RawDataSet(org.dashbuilder.dataset.RawDataSet) Displayer(org.dashbuilder.displayer.client.Displayer) AbstractDisplayer(org.dashbuilder.displayer.client.AbstractDisplayer) AbstractDisplayerTest(org.dashbuilder.displayer.client.AbstractDisplayerTest) Test(org.junit.Test)

Example 32 with DataSet

use of org.dashbuilder.dataset.DataSet 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)

Example 33 with DataSet

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

the class DataManagementServiceImplTest method testGetDisplayerSettings.

@Test
public void testGetDisplayerSettings() {
    expectedDataSetUUID = DATASOURCE_UUID + SEPARATOR + SCHEMA + SEPARATOR + TABLE;
    DataSetLookup expectedLookup = new DataSetLookup();
    expectedLookup.setDataSetUUID(expectedDataSetUUID);
    DataSet expectedSet = mock(DataSet.class);
    List<DataColumn> dataColumns = new ArrayList<>();
    for (int i = 0; i < COLUMNS_COUNT; i++) {
        DataColumn dataColumn = mock(DataColumn.class);
        when(dataColumn.getId()).thenReturn(DATA_COLUMN + String.valueOf(i));
        dataColumns.add(dataColumn);
    }
    when(expectedSet.getColumns()).thenReturn(dataColumns);
    when(dataSetManager.lookupDataSet(expectedLookup)).thenReturn(expectedSet);
    DisplayerSettings settings = dataManagementService.getDisplayerSettings(DATASOURCE_UUID, SCHEMA, TABLE);
    verify(dataSetDefRegistry, times(1)).registerDataSetDef(dataSetDefCaptor.capture());
    verifyDataSetDef(dataSetDefCaptor.getValue());
    verifySettings(settings);
}
Also used : DataSet(org.dashbuilder.dataset.DataSet) DataColumn(org.dashbuilder.dataset.DataColumn) ArrayList(java.util.ArrayList) DisplayerSettings(org.dashbuilder.displayer.DisplayerSettings) DataSetLookup(org.dashbuilder.dataset.DataSetLookup) Test(org.junit.Test)

Example 34 with DataSet

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

the class UserTaskInstanceWithPotOwnerQueryMapper method map.

@Override
public List<UserTaskInstanceWithPotOwnerDesc> map(Object result) {
    if (result instanceof DataSet) {
        DataSet dataSetResult = (DataSet) result;
        List<UserTaskInstanceWithPotOwnerDesc> mappedResult = new ArrayList<UserTaskInstanceWithPotOwnerDesc>();
        if (dataSetResult != null) {
            Map<Long, UserTaskInstanceWithPotOwnerDesc> tmp = new HashMap<Long, UserTaskInstanceWithPotOwnerDesc>();
            for (int i = 0; i < dataSetResult.getRowCount(); i++) {
                Long taskId = getColumnLongValue(dataSetResult, COLUMN_TASKID, i);
                UserTaskInstanceWithPotOwnerDesc ut = tmp.get(taskId);
                if (ut == null) {
                    ut = buildInstance(dataSetResult, i);
                    mappedResult.add(ut);
                    tmp.put(taskId, ut);
                } else if (getColumnStringValue(dataSetResult, COLUMN_POTOWNER, i) != null) {
                    ((org.jbpm.kie.services.impl.model.UserTaskInstanceWithPotOwnerDesc) ut).addPotOwner(getColumnStringValue(dataSetResult, COLUMN_POTOWNER, i));
                }
            }
        }
        return mappedResult;
    }
    throw new IllegalArgumentException("Unsupported result for mapping " + result);
}
Also used : UserTaskInstanceWithPotOwnerDesc(org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc) DataSet(org.dashbuilder.dataset.DataSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 35 with DataSet

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

the class UserTaskInstanceWithVarsQueryMapper method map.

@Override
public List<UserTaskInstanceWithVarsDesc> map(Object result) {
    if (result instanceof DataSet) {
        DataSet dataSetResult = (DataSet) result;
        List<UserTaskInstanceWithVarsDesc> mappedResult = new ArrayList<UserTaskInstanceWithVarsDesc>();
        if (dataSetResult != null) {
            Map<Long, UserTaskInstanceWithVarsDesc> tmp = new HashMap<Long, UserTaskInstanceWithVarsDesc>();
            for (int i = 0; i < dataSetResult.getRowCount(); i++) {
                Long taskId = getColumnLongValue(dataSetResult, COLUMN_TASKID, i);
                UserTaskInstanceWithVarsDesc ut = tmp.get(taskId);
                if (ut == null) {
                    ut = buildInstance(dataSetResult, i);
                    mappedResult.add(ut);
                    tmp.put(taskId, ut);
                }
                // now add variable
                String varName = getColumnStringValue(dataSetResult, COLUMN_TASK_VAR_NAME, i);
                String varValue = getColumnStringValue(dataSetResult, COLUMN_TASK_VAR_VALUE, i);
                ((org.jbpm.kie.services.impl.model.UserTaskInstanceWithVarsDesc) ut).addVariable(varName, varValue);
            }
        }
        return mappedResult;
    }
    throw new IllegalArgumentException("Unsupported result for mapping " + result);
}
Also used : DataSet(org.dashbuilder.dataset.DataSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserTaskInstanceWithVarsDesc(org.jbpm.services.api.model.UserTaskInstanceWithVarsDesc)

Aggregations

DataSet (org.dashbuilder.dataset.DataSet)41 Test (org.junit.Test)27 AbstractDisplayerTest (org.dashbuilder.displayer.client.AbstractDisplayerTest)25 AbstractDisplayer (org.dashbuilder.displayer.client.AbstractDisplayer)17 Displayer (org.dashbuilder.displayer.client.Displayer)13 ArrayList (java.util.ArrayList)12 RawDataSet (org.dashbuilder.dataset.RawDataSet)11 HashMap (java.util.HashMap)6 SelectorDisplayer (org.dashbuilder.renderer.client.selector.SelectorDisplayer)6 DataColumn (org.dashbuilder.dataset.DataColumn)3 DataSetLookup (org.dashbuilder.dataset.DataSetLookup)2 ProcessInstanceWithVarsDesc (org.jbpm.services.api.model.ProcessInstanceWithVarsDesc)2 UserTaskInstanceWithPotOwnerDesc (org.jbpm.services.api.model.UserTaskInstanceWithPotOwnerDesc)2 UserTaskInstanceWithVarsDesc (org.jbpm.services.api.model.UserTaskInstanceWithVarsDesc)2 Date (java.util.Date)1 List (java.util.List)1 DataSetBuilder (org.dashbuilder.dataset.DataSetBuilder)1 DataSetMetadata (org.dashbuilder.dataset.DataSetMetadata)1 DataColumnDef (org.dashbuilder.dataset.def.DataColumnDef)1 DataSetDef (org.dashbuilder.dataset.def.DataSetDef)1