use of org.dashbuilder.dataset.DataSetLookup in project jbpm by kiegroup.
the class BusinessAdminTasksPreprocessorTest method testQueryByNoBusinessAdmin.
@Test
public void testQueryByNoBusinessAdmin() {
dataSetLookup = new DataSetLookup();
String role1 = "role1";
String role2 = "role2";
String userId = "userId";
when(identityProvider.getRoles()).thenReturn(Arrays.asList(role1, role2));
when(identityProvider.getName()).thenReturn(userId);
preprocessor.preprocess(dataSetLookup);
assertEquals("ID = role1, role2, userId", dataSetLookup.getFirstFilterOp().getColumnFilterList().get(0).toString());
}
use of org.dashbuilder.dataset.DataSetLookup 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.DataSetLookup 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.DataSetLookup in project jbpm by kiegroup.
the class BusinessAdminTasksPreprocessorTest method testSetUserWithoutRoles.
@Test
public void testSetUserWithoutRoles() {
dataSetLookup = new DataSetLookup();
String userId = "userId";
when(identityProvider.getRoles()).thenReturn(Collections.emptyList());
when(identityProvider.getName()).thenReturn(userId);
preprocessor.preprocess(dataSetLookup);
assertEquals("ID = userId", dataSetLookup.getFirstFilterOp().getColumnFilterList().get(0).toString());
}
use of org.dashbuilder.dataset.DataSetLookup in project jbpm by kiegroup.
the class BusinessAdminTasksPreprocessor method preprocess.
@SuppressWarnings("rawtypes")
@Override
public void preprocess(DataSetLookup lookup) {
if (identityProvider == null) {
return;
}
if (ADMIN_USER.equals(identityProvider.getName()) || identityProvider.getRoles().stream().filter(s -> s.equals(ADMIN_GROUP)).findFirst().isPresent()) {
return;
}
final List<Comparable> orgEntities = new ArrayList<Comparable>(identityProvider.getRoles());
orgEntities.add(identityProvider.getName());
final ColumnFilter columnFilter = equalsTo(COLUMN_ORGANIZATIONAL_ENTITY, orgEntities);
LOGGER.debug("Adding column filter: {}", columnFilter);
if (lookup.getFirstFilterOp() != null) {
lookup.getFirstFilterOp().addFilterColumn(columnFilter);
} else {
DataSetFilter filter = new DataSetFilter();
filter.addFilterColumn(columnFilter);
lookup.addOperation(filter);
}
super.preprocess(lookup);
}
Aggregations