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);
}
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());
}
}
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);
}
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);
}
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);
}
Aggregations