ProcessDefinitionDataSetProvider extends BeanDataSetProvider { @Override public DataSet lookupDataSet(DataSetDef def, DataSetLookup lookup) throws Exception { ProcessDefinitionDataSetDef processDefinitionDataSetDef = (ProcessDefinitionDataSetDef) def; final DataSetBuilder dsBuilder = DataSetFactory.newDataSetBuilder(); for (final DataColumnDef columnDef : processDefinitionDataSetDef.getColumns()) { dsBuilder.column(columnDef.getId(), columnDef.getColumnType()); } ConsoleDataSetLookup consoleDataSetLookup = (ConsoleDataSetLookup) lookup; processDefinitionDataSetDef.setServerTemplateId(consoleDataSetLookup.getServerTemplateId()); String defaultColumnSort = COL_ID_PROCESSNAME; boolean defaultSortOrder = false; DataSetSort dataSetSort = lookup.getFirstSortOp(); if (dataSetSort != null && dataSetSort.getColumnSortList().size() > 0) { defaultColumnSort = dataSetSort.getColumnSortList().get(0).getColumnId(); defaultSortOrder = dataSetSort.getColumnSortList().get(0).getOrder().equals(SortOrder.ASCENDING); } String searchText = ""; for (DataSetFilter filter : lookup.getOperationList(DataSetFilter.class)) { Optional coreFunctionFilter = filter.getColumnFilterList().stream() .filter(columnFilter -> columnFilter instanceof CoreFunctionFilter) .filter(columnFilter -> ((CoreFunctionFilter) columnFilter).getParameters().size() > 0).findFirst(); if (coreFunctionFilter.isPresent()) { searchText = ((CoreFunctionFilter) coreFunctionFilter.get()).getParameters().get(0).toString(); } } List<ProcessSummary> processSummaryList = processRuntimeDataService.getProcessesByFilter(consoleDataSetLookup.getServerTemplateId(), searchText, lookup.getRowOffset() / lookup.getNumberOfRows(), lookup.getNumberOfRows(), defaultColumnSort, defaultSortOrder); processSummaryList.forEach(processSummary -> dsBuilder.row(processSummary.getProcessDefName(), processSummary.getVersion(), processSummary.getDeploymentId(), processSummary.getProcessDefId(), processSummary.isDynamic()) ); DataSet dataSet = dsBuilder.buildDataSet(); dataSet.setUUID(PROCESS_DEFINITION_DATASET); return dataSet; }  @Override DataSetProviderType getType(); @Override DataSetMetadata getDataSetMetadata(DataSetDef def); @Override DataSet lookupDataSet(DataSetDef def, DataSetLookup lookup); @Override boolean isDataSetOutdated(DataSetDef def);  }
@Test public void testLookupDataSet() throws Exception { DataSetLookup lookup = new DataSetLookup(); lookup.setDataSetUUID(PROCESS_DEFINITION_DATASET); DataSetLookup consoleDataSetLookup = ConsoleDataSetLookup.fromInstance(lookup, SERVER_TEMPLATE_ID); CoreFunctionFilter coreFunctionFilter = new CoreFunctionFilter(SORT_COLUMN_NAME, CoreFunctionType.LIKE_TO, TEXT_SEARCH); DataSetFilter dataSetFilter = new DataSetFilter(); dataSetFilter.addFilterColumn(coreFunctionFilter); consoleDataSetLookup.addOperation(dataSetFilter); DataSet dataSet = processDefinitionDataSetProvider.lookupDataSet(dataSetdef, consoleDataSetLookup); assertEquals(PROCESS_DEFINITION_DATASET, dataSet.getUUID()); assertEquals(1, dataSet.getRowCount()); assertThat(dataSet.getColumns()).hasSize(5).extracting(dataColumn -> dataColumn.getId()).contains(COL_ID_PROCESSVERSION, COL_ID_PROCESSVERSION, COL_ID_PROJECT, COL_ID_PROCESSDEF, COL_DYNAMIC); }
@Test public void testLookupDataSetWithoutFilterColumn() throws Exception { DataSetLookup lookup = new DataSetLookup(); lookup.setDataSetUUID(PROCESS_DEFINITION_DATASET); DataSetLookup consoleDataSetLookup = ConsoleDataSetLookup.fromInstance(lookup, SERVER_TEMPLATE_ID); DataSetFilter dataSetFilter = new DataSetFilter(); consoleDataSetLookup.addOperation(dataSetFilter); DataSet dataSet = processDefinitionDataSetProvider.lookupDataSet(dataSetdef, consoleDataSetLookup); assertEquals(PROCESS_DEFINITION_DATASET, dataSet.getUUID()); assertEquals(3, dataSet.getRowCount()); assertThat(dataSet.getColumns()).hasSize(5).extracting(dataColumn -> dataColumn.getId()).contains(COL_ID_PROCESSVERSION, COL_ID_PROCESSVERSION, COL_ID_PROJECT, COL_ID_PROCESSDEF, COL_DYNAMIC); }