use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisDetailsPage method validator.
private ReturnCode validator(List<RepositoryNode> columnASet, List<RepositoryNode> columnBSet) {
// MOD by gdbu 2011-3-21 bug 19179
ReturnCode canModRetCode = super.canSave();
if (!canModRetCode.isOk()) {
return canModRetCode;
}
if (columnASet.isEmpty() || columnBSet.isEmpty()) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnDependencyMasterDetailsPage.columnsBlankMessag"), false);
}
if (columnASet.size() != columnBSet.size()) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.columnsSameMessage"), false);
}
for (int i = 0; i < columnASet.size(); i++) {
RepositoryNode columnANode = columnASet.get(i);
RepositoryNode columnBNode = columnBSet.get(i);
TdColumn tdColumnA = ((DBColumnRepNode) columnANode).getTdColumn();
TdColumn tdColumnB = ((DBColumnRepNode) columnBNode).getTdColumn();
ColumnSet ownerA = ColumnHelper.getColumnOwnerAsColumnSet(tdColumnA);
ColumnSet ownerB = ColumnHelper.getColumnOwnerAsColumnSet(tdColumnB);
String uuidA = ResourceHelper.getUUID(ownerA);
String uuidB = ResourceHelper.getUUID(ownerB);
if (!uuidA.equals(uuidB)) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnDependencyMasterDetailsPage.tableMessage"), false);
}
}
return new ReturnCode(true);
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisDetailsPage method getSelectedColumns.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#getSelectedColumns()
*/
@Override
protected ModelElement[] getSelectedColumns() {
ColumnSet previewDataColumnOwner = anaColumnCompareViewer.getPreviewDataColumnOwner();
if (previewDataColumnOwner == null) {
return null;
}
List<TdColumn> columns = ColumnSetHelper.getColumns(previewDataColumnOwner);
return columns.toArray(new TdColumn[columns.size()]);
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class RedundancyAnalysisDetailsPage method canSave.
@Override
public ReturnCode canSave() {
// MOD by gdbu 2011-3-21 bug 19179
ReturnCode canModRetCode = super.canSave();
if (!canModRetCode.isOk()) {
return canModRetCode;
}
if (anaColumnCompareViewer.getColumnListA().size() != anaColumnCompareViewer.getColumnListB().size()) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.columnsSameMessage"), false);
}
List<TdColumn> columnAList = new ArrayList<TdColumn>();
List<TdColumn> columnBList = new ArrayList<TdColumn>();
for (RepositoryNode rd : anaColumnCompareViewer.getColumnListA()) {
columnAList.add((TdColumn) ((MetadataColumnRepositoryObject) rd.getObject()).getTdColumn());
}
for (RepositoryNode rd : anaColumnCompareViewer.getColumnListB()) {
columnBList.add((TdColumn) ((MetadataColumnRepositoryObject) rd.getObject()).getTdColumn());
}
if (anaColumnCompareViewer.getColumnListA().size() > 0) {
if (!ColumnHelper.isFromSameTable(columnAList) || !ColumnHelper.isFromSameTable(columnBList)) {
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.notSameElementMessage"), // $NON-NLS-1$
false);
}
for (int i = 0; i < anaColumnCompareViewer.getColumnListA().size(); i++) {
TdColumn columnA = columnAList.get(i);
TdColumn columnB = columnBList.get(i);
ColumnSet ownerA = ColumnHelper.getColumnOwnerAsColumnSet(columnA);
ColumnSet ownerB = ColumnHelper.getColumnOwnerAsColumnSet(columnB);
int typeA = columnA.getSqlDataType().getJavaDataType();
int typeB = columnB.getSqlDataType().getJavaDataType();
if (!Java2SqlType.isGenericSameType(typeA, typeB)) {
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.notSameColumnType"), // $NON-NLS-1$
false);
}
if (!ColumnSetHelper.isFromSamePackage(ownerA, ownerB)) {
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.schemaSameMessage"), // $NON-NLS-1$
false);
}
}
List<TdColumn> allColumns = new ArrayList<TdColumn>();
allColumns.addAll(columnAList);
allColumns.addAll(columnBList);
// MOD scorreia 2009-05-25 allow to compare elements from the same
// table
// if (ColumnHelper.isFromSameTable(allColumns)) {
// return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.TwoSideColumns"), false); //$NON-NLS-1$
// }
}
return new ReturnCode(true);
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class RedundancyAnalysisResultPage method createMenu.
/**
* DOC hcheng Comment method "createMenu".
*
* @param resultTable
* @param indicator
* @return
*/
private Menu createMenu(final Table resultTable, final RowMatchingIndicator indicator) {
if (indicator == null) {
return null;
}
final ColumnSet columnSet = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement());
getAnalysisHandler().getAnalyzedColumns();
if (columnSet == null) {
return null;
}
Menu menu = new Menu(resultTable);
MenuItem itemNotMatch = new MenuItem(menu, SWT.PUSH);
MenuItem itemRow = new MenuItem(menu, SWT.PUSH);
// MOD qiongli 2012-8-30 TDQ-5907 hide 'view match row' menue for hive connection.
final Connection provider = ConnectionHelper.getDataProvider(columnSet);
if (!ConnectionHelper.isHive(provider)) {
MenuItem itemMatch = new MenuItem(menu, SWT.PUSH);
itemMatch.setText(DataExplorer.MENU_VIEW_MATCH_ROWS);
itemMatch.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
itemMatch.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
RowMatchExplorer rowMatchExplorer = new RowMatchExplorer();
rowMatchExplorer.setAnalysis(masterPage.getCurrentModelElement());
// $NON-NLS-1$ //$NON-NLS-2$
rowMatchExplorer.setEnitty(new ChartDataEntity(indicator, "", ""));
String query = rowMatchExplorer.getRowsMatchStatement();
if (provider != null) {
SqlExplorerUtils.getDefault().runInDQViewer(provider, query, columnSet.getName());
}
}
});
}
itemNotMatch.setText(DataExplorer.MENU_VIEW_NOT_MATCH_ROWS);
itemNotMatch.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
itemRow.setText(DataExplorer.MENU_VIEW_ROWS);
itemRow.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
itemNotMatch.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
RowMatchExplorer rowMatchExplorer = new RowMatchExplorer();
rowMatchExplorer.setAnalysis(masterPage.getCurrentModelElement());
// $NON-NLS-1$ //$NON-NLS-2$
rowMatchExplorer.setEnitty(new ChartDataEntity(indicator, "", ""));
String query = rowMatchExplorer.getRowsNotMatchStatement();
if (provider != null) {
SqlExplorerUtils.getDefault().runInDQViewer(provider, query, columnSet.getName());
}
}
});
itemRow.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
// MOD 10913 zshen:unify the method that get sql query
RowMatchExplorer rowMatchExplorer = new RowMatchExplorer();
rowMatchExplorer.setAnalysis(masterPage.getCurrentModelElement());
// $NON-NLS-1$ //$NON-NLS-2$
rowMatchExplorer.setEnitty(new ChartDataEntity(indicator, "", ""));
String query = rowMatchExplorer.getAllRowsStatement();
if (provider != null) {
SqlExplorerUtils.getDefault().runInDQViewer(provider, query, columnSet.getName());
}
// ~10913
}
});
return menu;
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class ColumnFolderNode method loadChildren.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.model.nodes.AbstractFolderNode#loadChildren()
*/
@Override
public void loadChildren() {
// MOD xqliu 2009-04-27 bug 6507
// get columns from either tables or views.
ColumnSet columnSet = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch((EObject) getParent());
if (columnSet != null) {
List<TdColumn> columnList = null;
if (FILTER_FLAG) {
String columnFilter = ColumnHelper.getColumnFilter(columnSet);
columnList = filterColumns(ColumnSetHelper.getColumns(columnSet), columnFilter);
} else {
columnList = ColumnSetHelper.getColumns(columnSet);
}
if (columnList.size() > 0) {
if (columnList.size() > COLUMN_MAX) {
this.setChildren(null);
// $NON-NLS-1$
MessageUI.openWarning(DefaultMessagesImpl.getString("ColumnFolderNode.warnMsg", COLUMN_MAX));
} else {
this.setChildren(columnList.toArray());
}
return;
} else {
if (FILTER_FLAG) {
this.setChildren(null);
if (ColumnSetHelper.getColumns(columnSet).size() > 0) {
return;
}
}
}
if (columnSet.eIsProxy()) {
// resolve the proxy object.
columnSet = (ColumnSet) EObjectHelper.resolveObject(columnSet);
}
Package parentCatalogOrSchema = ColumnSetHelper.getParentCatalogOrSchema(columnSet);
if (parentCatalogOrSchema == null) {
return;
}
Connection conn = ConnectionHelper.getTdDataProvider(parentCatalogOrSchema);
if (conn == null) {
return;
}
try {
columnList = DqRepositoryViewService.getColumns(conn, columnSet, null, true);
if (columnList.size() > COLUMN_MAX) {
this.setChildren(null);
// $NON-NLS-1$
MessageUI.openWarning(DefaultMessagesImpl.getString("ColumnFolderNode.warnMsg", COLUMN_MAX));
return;
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
}
// store tables in catalog
// MOD scorreia 2009-01-29 columns are stored in the table
// ColumnSetHelper.addColumns(columnSet, columnList);
this.setChildren(columnList.toArray());
ElementWriterFactory.getInstance().createDataProviderWriter().save(conn);
}
super.loadChildren();
// ~
}
Aggregations