use of org.talend.dataquality.indicators.schema.ViewIndicator in project tdq-studio-se by Talend.
the class AbstractSchemaEvaluator method createViewIndicator.
/**
* DOC scorreia Comment method "createViewIndicator".
*
* @param t
* @param schemaIndic
* @param rowCount
*/
private void createViewIndicator(NamedColumnSet t, SchemaIndicator schemaIndic, long rowCount) {
ViewIndicator viewIndicator = SchemaFactory.eINSTANCE.createViewIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(viewIndicator);
// t is not stored in xmi file. tableIndicator.setAnalyzedElement(t);
viewIndicator.setTableName(t.getName());
viewIndicator.setRowCount(rowCount);
schemaIndic.addViewIndicator(viewIndicator);
}
use of org.talend.dataquality.indicators.schema.ViewIndicator 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);
}
use of org.talend.dataquality.indicators.schema.ViewIndicator in project tdq-studio-se by Talend.
the class OverviewResultPage method wapperInput.
/**
* DOC zshen Comment method "wapperInput".
*
* @param indicatorViewList
* @param parentNode
* @return
*/
private List<OverviewIndUIElement> wapperInput(List<ViewIndicator> indicatorViewList, IRepositoryNode parentNode) {
List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
List<IRepositoryNode> children = parentNode.getChildren();
for (IRepositoryNode folderNode : children) {
if (folderNode instanceof DBViewFolderRepNode) {
List<IRepositoryNode> tableNodes = folderNode.getChildren();
// MOD 20120315 klliu&yyin TDQ-2391, avoid getting many times for table nodes.
for (ViewIndicator indicator : indicatorViewList) {
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.ViewIndicator in project tdq-studio-se by Talend.
the class SchemaViewSorter method compare.
public int compare(Viewer viewer, Object o1, Object o2) {
ViewIndicator viewIndicator1 = (ViewIndicator) o1;
ViewIndicator viewIndicator2 = (ViewIndicator) o2;
String tableName1;
String tableName2;
long rowCount1;
long rowCount2;
switch(sortType) {
case VIEW:
tableName1 = viewIndicator1.getTableName();
tableName2 = viewIndicator1.getTableName();
return tableName1.compareTo(tableName2);
case -VIEW:
tableName1 = viewIndicator1.getTableName();
tableName2 = viewIndicator2.getTableName();
return tableName2.compareTo(tableName1);
case ROWS:
rowCount1 = viewIndicator1.getRowCount();
rowCount2 = viewIndicator2.getRowCount();
return new Long(rowCount1).compareTo(new Long(rowCount2));
case -ROWS:
rowCount1 = viewIndicator1.getRowCount();
rowCount2 = viewIndicator2.getRowCount();
return new Long(rowCount2).compareTo(new Long(rowCount1));
default:
return 0;
}
}
Aggregations