use of org.talend.cwm.indicator.ColumnFilter in project tdq-studio-se by Talend.
the class DrillDownEditorInput method getDataSetForMapDB.
/**
* DataSet is used to be the input on the export wizard. unchecked is for the type of mapDB else will have a warning
*
* @param controller
* @return
*/
@SuppressWarnings("unchecked")
public Object getDataSetForMapDB(int pageSize) {
List<String> columnElementList = filterAdaptColumnHeader();
columnHeader = new String[columnElementList.size()];
int headerIndex = 0;
for (String columnElement : columnElementList) {
columnHeader[headerIndex++] = columnElement;
}
AbstractDB<?> mapDB = getMapDB();
if (mapDB == null) {
return null;
}
AnalysisType analysisType = analysis.getParameters().getAnalysisType();
if (AnalysisType.COLUMN_SET == analysisType) {
Long size = getCurrentIndicatorResultSize();
if (ColumnSetDBMap.class.isInstance(mapDB)) {
return SqlExplorerUtils.getDefault().createMapDBColumnSetDataSet(columnHeader, (ColumnSetDBMap) mapDB, size, IDataValidationFactory.INSTANCE.createValidation(currIndicator), pageSize);
}
}
if (DBSet.class.isInstance(mapDB)) {
return SqlExplorerUtils.getDefault().createMapDBSetDataSet(columnHeader, (DBSet<Object>) mapDB, pageSize);
} else {
ColumnFilter columnFilter = getColumnFilter();
Long itemSize = getItemSize(mapDB);
return SqlExplorerUtils.getDefault().createMapDBDataSet(columnHeader, (DBMap<Object, List<Object>>) mapDB, pageSize, columnFilter, itemSize);
}
}
use of org.talend.cwm.indicator.ColumnFilter in project tdq-studio-se by Talend.
the class DrillDownEditorInput method getColumnFilter.
/**
* Create columnFilter for current columnSet. It will be used when we can drill down both current column and whole
* of the row
*
* @return
*/
public ColumnFilter getColumnFilter() {
Integer[] columnIndexArray = getColumnIndexArray();
ColumnFilter filter = null;
if (columnIndexArray != null) {
filter = new ColumnFilter(columnIndexArray);
}
return filter;
}
use of org.talend.cwm.indicator.ColumnFilter in project tdq-studio-se by Talend.
the class DrillDownResultEditor method initTableViewerForMapDB.
/**
* DOC talend Comment method "initTableViewerForMapDB".
*
* @param parent
* @param table
* @param ddEditorInput
*/
@SuppressWarnings("unchecked")
private void initTableViewerForMapDB(final Composite parent, final Table table, DrillDownEditorInput ddEditorInput) {
table.setLinesVisible(true);
table.setHeaderVisible(true);
tableView.setLabelProvider(new DrillDownResultLabelProvider());
tableView.setContentProvider(new DrillDownResultContentProvider());
// set page size
final PageableController controller = new PageableController(MapDBPageConstant.NUMBER_PER_PAGE);
Object dataSetForMapDB = ddEditorInput.getDataSetForMapDB(controller.getPageSize());
if (dataSetForMapDB == null) {
log.error(DefaultMessagesImpl.getString("DrillDownResultEditor.drillDownError"), new RuntimeException(DefaultMessagesImpl.getString("DrillDownResultEditor.drillDownErrorMessage")));
} else {
table.setData(dataSetForMapDB);
}
// for columnSet analysis here only have one db file need to support drill down and data section
Analysis analysis = ddEditorInput.getAnalysis();
AnalysisType analysisType = analysis.getParameters().getAnalysisType();
IPageLoader<PageResult<Object[]>> pageLoader = null;
AbstractDB<Object> mapDB = ddEditorInput.getMapDB();
Indicator generateMapDBIndicator = ddEditorInput.getGenerateMapDBIndicator();
MapDBManager.getInstance().addDBRef(MapDBUtils.getMapDBFile(generateMapDBIndicator));
Long itemsSize = ddEditorInput.getItemSize(mapDB);
if (AnalysisType.COLUMN_SET == analysisType) {
pageLoader = new MapDBPageLoader<Object>(mapDB, IDataValidationFactory.INSTANCE.createValidation(ddEditorInput.getCurrIndicator()), itemsSize);
} else {
// ~
ColumnFilter filter = ddEditorInput.getColumnFilter();
pageLoader = new MapDBPageLoader<Object>(mapDB, null, itemsSize, filter);
}
controller.addPageChangedListener(PageLoaderStrategyHelper.createLoadPageAndReplaceItemsListener(controller, tableView, pageLoader, PageResultContentProvider.getInstance(), null));
controller.addPageChangedListener(new PageChangedAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.nebula.widgets.pagination.PageChangedAdapter#pageIndexChanged(int, int,
* org.eclipse.nebula.widgets.pagination.PageableController)
*/
@Override
public void pageIndexChanged(int oldPageIndex, int newPageIndex, PageableController controller) {
Object data = table.getData();
if (data != null && SqlExplorerUtils.getDefault().isInstanceofTalendDataSet(data)) {
long totalSize = controller.getTotalElements();
long pageSize = controller.getPageSize();
long pageIndex = controller.getPageOffset();
long fromIndex = pageIndex;
long toIndex = pageIndex + pageSize;
if (toIndex > totalSize) {
toIndex = totalSize;
}
SqlExplorerUtils.getDefault().resetTalendDataSetIndex(data, fromIndex, toIndex);
parent.layout();
}
}
});
// Create navigation page links
ResultAndNavigationPageGraphicsRenderer resultAndNavigationPageGraphicsRenderer = new ResultAndNavigationPageGraphicsRenderer(parent, SWT.NONE, controller);
resultAndNavigationPageGraphicsRenderer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
createColumns(tableView, controller, ((DrillDownEditorInput) this.getEditorInput()));
// Set current page to 0 to refresh the table
controller.setCurrentPage(0);
}
Aggregations