use of org.talend.dataquality.indicators.schema.TableIndicator in project tdq-studio-se by Talend.
the class OverviewResultPage method wapperInput.
/**
* DOC klliu Comment method "wapperInput". relations
*
* @param indicatorTableList
* @param parentNode
* @return
*/
private List<OverviewIndUIElement> wapperInput(EList<TableIndicator> indicatorTableList, IRepositoryNode parentNode) {
List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
List<IRepositoryNode> children = parentNode.getChildren();
for (IRepositoryNode folderNode : children) {
if (folderNode instanceof DBTableFolderRepNode) {
List<IRepositoryNode> tableNodes = folderNode.getChildren();
// MOD 20120315 klliu&yyin TDQ-2391, avoid getting many times for table nodes.
for (TableIndicator indicator : indicatorTableList) {
boolean equals = false;
for (IRepositoryNode tableNode : tableNodes) {
MetadataTable table = ((MetadataTableRepositoryObject) tableNode.getObject()).getTable();
String name = table.getName();
String tableName = indicator.getTableName();
// String connUuid = ResourceHelper.getUUID(table);
// String anaUuid = ResourceHelper.getUUID(indicator.getAnalyzedElement());
equals = name.equals(tableName);
if (equals) {
OverviewIndUIElement tableUIEle = new OverviewIndUIElement();
tableUIEle.setNode(tableNode);
tableUIEle.setOverviewIndicator(indicator);
if (DqRepositoryViewService.isComeFromRefrenceProject(getTdDataProvider()) && ColumnSetHelper.getColumns((ColumnSet) table).isEmpty()) {
tableUIEle.setVirtualNode(true);
}
cataUIEleList.add(tableUIEle);
break;
}
}
if (!equals) {
OverviewIndUIElement tableUIEle = new OverviewIndUIElement();
tableUIEle.setOverviewIndicator(indicator);
tableUIEle.setVirtualNode(true);
cataUIEleList.add(tableUIEle);
}
}
}
}
return cataUIEleList;
}
use of org.talend.dataquality.indicators.schema.TableIndicator in project tdq-studio-se by Talend.
the class SchemaTableSorter method compare.
public int compare(Viewer viewer, Object o1, Object o2) {
TableIndicator tableIndicator1 = (TableIndicator) ((OverviewIndUIElement) o1).getOverviewIndicator();
TableIndicator tableIndicator2 = (TableIndicator) ((OverviewIndUIElement) o2).getOverviewIndicator();
String value1;
String value2;
long number1;
long number2;
switch(sortType) {
case TABLE:
value1 = tableIndicator1.getTableName();
value2 = tableIndicator2.getTableName();
return value1.compareTo(value2);
case -TABLE:
value1 = tableIndicator1.getTableName();
value2 = tableIndicator2.getTableName();
return value2.compareTo(value1);
case ROWS:
number1 = tableIndicator1.getRowCount();
number2 = tableIndicator2.getRowCount();
return new Long(number1).compareTo(new Long(number2));
case -ROWS:
number1 = tableIndicator1.getRowCount();
number2 = tableIndicator2.getRowCount();
return new Long(number2).compareTo(new Long(number1));
case KEYS:
number1 = tableIndicator1.getKeyCount();
number2 = tableIndicator2.getKeyCount();
return new Long(number1).compareTo(new Long(number2));
case -KEYS:
number1 = tableIndicator1.getKeyCount();
number2 = tableIndicator2.getKeyCount();
return new Long(number2).compareTo(new Long(number1));
case INDEXES:
number1 = tableIndicator1.getIndexCount();
number2 = tableIndicator2.getIndexCount();
return new Long(number1).compareTo(new Long(number2));
case -INDEXES:
number1 = tableIndicator1.getIndexCount();
number2 = tableIndicator2.getIndexCount();
return new Long(number2).compareTo(new Long(number1));
default:
return 0;
}
}
use of org.talend.dataquality.indicators.schema.TableIndicator in project tdq-studio-se by Talend.
the class AbstractSchemaEvaluator method createTableIndicator.
/**
* DOC scorreia Comment method "createTableIndicator".
*
* @param t
* @param schemaIndic
* @param rowCount
* @param pkCount
* @param idxCount
*/
private void createTableIndicator(NamedColumnSet t, SchemaIndicator schemaIndic, long rowCount, int pkCount, int idxCount) {
TableIndicator tableIndicator = SchemaFactory.eINSTANCE.createTableIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(tableIndicator);
// t is not stored in xmi file. tableIndicator.setAnalyzedElement(t);
tableIndicator.setTableName(t.getName());
tableIndicator.setRowCount(rowCount);
tableIndicator.setKeyCount(pkCount);
tableIndicator.setIndexCount(idxCount);
schemaIndic.addTableIndicator(tableIndicator);
}
use of org.talend.dataquality.indicators.schema.TableIndicator in project tdq-studio-se by Talend.
the class OverviewResultPage method displayTableAndViewComp.
/**
* DOC klliu Comment method "displayTableAndViewComp".
*
* @param schemaIndicator
* @param parentNode
*/
protected void displayTableAndViewComp(final SchemaIndicator schemaIndicator, final IRepositoryNode parentNode) {
tableAndViewComposite.setVisible(true);
// DOC wapperInput retrun OverViewUIElement
EList<TableIndicator> indicatorTableList = schemaIndicator.getTableIndicators();
List<OverviewIndUIElement> tableElements = wapperInput(indicatorTableList, parentNode);
if (tableOfCatalogOrSchemaViewer == null || tableOfCatalogOrSchemaViewer.getTable().isDisposed()) {
tableOfCatalogOrSchemaViewer = new TableViewer(tableAndViewComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | // SWT.SINGLE);
SWT.FULL_SELECTION);
final Table catalogOrSchemaTable = tableOfCatalogOrSchemaViewer.getTable();
TableUtils.addActionTooltip(catalogOrSchemaTable);
catalogOrSchemaTable.setHeaderVisible(true);
catalogOrSchemaTable.setLinesVisible(true);
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutData.heightHint = 150;
catalogOrSchemaTable.setLayoutData(layoutData);
String[] columnTexts = new String[] { DefaultMessagesImpl.getString("AbstractFilterMetadataPage.Table"), DefaultMessagesImpl.getString("AbstractFilterMetadataPage.rows"), DefaultMessagesImpl.getString("AbstractFilterMetadataPage.keys"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
DefaultMessagesImpl.getString("AbstractFilterMetadataPage.indexes") };
createSorterColumns(tableOfCatalogOrSchemaViewer, columnTexts, tableSorters, COLUMN_TABLE_WIDTH);
TableOfCatalogOrSchemaProvider tableProvider = new TableOfCatalogOrSchemaProvider();
tableOfCatalogOrSchemaViewer.setLabelProvider(tableProvider);
tableOfCatalogOrSchemaViewer.setContentProvider(tableProvider);
catalogOrSchemaTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
if (e.button == 3) {
TableItem item = catalogOrSchemaTable.getItem(catalogOrSchemaTable.getSelectionIndex());
// TDQ-11430: show the menu only when there have data and have selected one.
if (catalogOrSchemaTable.getItemCount() > 0 && catalogOrSchemaTable.getSelectionIndex() != -1) {
final Menu menu = new Menu(catalogOrSchemaTable.getShell(), SWT.POP_UP);
catalogOrSchemaTable.setMenu(menu);
MenuItem viewKeyMenuItem = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
viewKeyMenuItem.setText(DefaultMessagesImpl.getString("AbstractFilterMetadataPage.ViewKeys"));
viewKeyMenuItem.setImage(ImageLib.getImage(ImageLib.PK_DECORATE));
viewKeyMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
runMenu(catalogOrSchemaTable, // $NON-NLS-1$
DefaultMessagesImpl.getString("DatabaseDetailView.Tab.PrimaryKeys"));
}
});
MenuItem viewIndexMenuItem = new MenuItem(menu, SWT.PUSH);
// $NON-NLS-1$
viewIndexMenuItem.setText(DefaultMessagesImpl.getString("AbstractFilterMetadataPage.ViewIndexes"));
viewIndexMenuItem.setImage(ImageLib.getImage(ImageLib.INDEX_VIEW));
viewIndexMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// $NON-NLS-1$
runMenu(catalogOrSchemaTable, DefaultMessagesImpl.getString("DatabaseDetailView.Tab.Indexes"));
}
});
TableItem tableItem = catalogOrSchemaTable.getItem(catalogOrSchemaTable.getSelectionIndex());
final OverviewIndUIElement data = (OverviewIndUIElement) tableItem.getData();
MenuItem tableAnalysisMenuItem = new MenuItem(menu, SWT.PUSH);
tableAnalysisMenuItem.setText(DefaultMessagesImpl.getString(// $NON-NLS-1$
"CreateTableAnalysisAction.tableAnalysis"));
tableAnalysisMenuItem.setImage(ImageLib.getImage(ImageLib.ACTION_NEW_ANALYSIS));
tableAnalysisMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
runTableAnalysis(data);
}
});
if (data.isVirtualNode()) {
tableAnalysisMenuItem.setEnabled(false);
}
} else {
// TDQ-11430: when there is no views will not show menu
catalogOrSchemaTable.setMenu(null);
}
}
}
});
viewOfCatalogOrSchemaViewer = new TableViewer(tableAndViewComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
final Table tableCatalogOrSchemaView = viewOfCatalogOrSchemaViewer.getTable();
TableUtils.addActionTooltip(tableCatalogOrSchemaView);
tableCatalogOrSchemaView.setHeaderVisible(true);
tableCatalogOrSchemaView.setLinesVisible(true);
layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutData.heightHint = 150;
tableCatalogOrSchemaView.setLayoutData(layoutData);
columnTexts = new String[] { DefaultMessagesImpl.getString("AbstractFilterMetadataPage.view"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("AbstractFilterMetadataPage.rows") };
createSorterColumns(viewOfCatalogOrSchemaViewer, columnTexts, viewSorters, COLUMN_VIEW_WIDTH);
ViewOfCatalogOrSchemaProvider viewProvider = new ViewOfCatalogOrSchemaProvider();
viewOfCatalogOrSchemaViewer.setLabelProvider(viewProvider);
viewOfCatalogOrSchemaViewer.setContentProvider(viewProvider);
// ADD msjian TDQ-4523 2013-1-22: Add "Table analysis" menu on the views
tableCatalogOrSchemaView.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
if (e.button == 3) {
// TDQ-11430: show the menu only when there have data and have selected one.
TableItem tableItem = tableCatalogOrSchemaView.getItem(tableCatalogOrSchemaView.getSelectionIndex());
final OverviewIndUIElement data = (OverviewIndUIElement) tableItem.getData();
if (tableCatalogOrSchemaView.getItemCount() > 0 && tableCatalogOrSchemaView.getSelectionIndex() != -1) {
final Menu menu = new Menu(tableCatalogOrSchemaView.getShell(), SWT.POP_UP);
tableCatalogOrSchemaView.setMenu(menu);
MenuItem tableAnalysisMenuItem = new MenuItem(menu, SWT.PUSH);
tableAnalysisMenuItem.setText(DefaultMessagesImpl.getString(// $NON-NLS-1$
"CreateTableAnalysisAction.tableAnalysis"));
tableAnalysisMenuItem.setImage(ImageLib.getImage(ImageLib.ACTION_NEW_ANALYSIS));
tableAnalysisMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ViewIndicator viewIndicator = (ViewIndicator) data.getOverviewIndicator();
runTableAnalysis(viewIndicator.getTableName());
}
});
if (data.isVirtualNode()) {
tableAnalysisMenuItem.setEnabled(false);
}
} else {
// TDQ-11430: when there is no views will not show menu
tableCatalogOrSchemaView.setMenu(null);
}
}
}
});
// TDQ-4523~
}
tableOfCatalogOrSchemaViewer.getTable().setMenu(null);
tableOfCatalogOrSchemaViewer.setInput(tableElements);
List<ViewIndicator> indicatorViewList = schemaIndicator.getViewIndicators();
List<OverviewIndUIElement> viewElements = wapperInput(indicatorViewList, parentNode);
viewOfCatalogOrSchemaViewer.setInput(viewElements);
viewOfCatalogOrSchemaViewer.getTable().setMenu(null);
// MOD xqliu 2009-11-05 bug 9521
tableAndViewComposite.pack();
statisticalSection.pack();
statisticalSection.layout();
// ~
form.reflow(true);
}
Aggregations