Search in sources :

Example 1 with ColumnSet

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);
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 2 with ColumnSet

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()]);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

Example 3 with ColumnSet

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);
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 4 with ColumnSet

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;
}
Also used : MouseListener(org.eclipse.swt.events.MouseListener) Listener(org.eclipse.swt.widgets.Listener) Connection(org.talend.core.model.metadata.builder.connection.Connection) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) RowMatchExplorer(org.talend.dq.analysis.explore.RowMatchExplorer)

Example 5 with ColumnSet

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();
// ~
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Package(orgomg.cwm.objectmodel.core.Package)

Aggregations

ColumnSet (orgomg.cwm.resource.relational.ColumnSet)55 TdColumn (org.talend.cwm.relational.TdColumn)35 Package (orgomg.cwm.objectmodel.core.Package)14 ArrayList (java.util.ArrayList)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)11 Connection (org.talend.core.model.metadata.builder.connection.Connection)9 RepositoryNode (org.talend.repository.model.RepositoryNode)9 ReloadCompareException (org.talend.cwm.compare.exception.ReloadCompareException)7 TdTable (org.talend.cwm.relational.TdTable)7 Catalog (orgomg.cwm.resource.relational.Catalog)7 Schema (orgomg.cwm.resource.relational.Schema)7 Resource (org.eclipse.emf.ecore.resource.Resource)6 EObject (org.eclipse.emf.ecore.EObject)5 ReturnCode (org.talend.utils.sugars.ReturnCode)5 Indicator (org.talend.dataquality.indicators.Indicator)4 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 List (java.util.List)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)3 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)3