Search in sources :

Example 6 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class FunctionalDependencyAnalysisDetailsPage method saveAnalysis.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#saveAnalysis()
     */
@Override
protected void saveAnalysis() throws DataprofilerCoreException {
    analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    IRepositoryViewObject reposObject = null;
    getAnalysisHandler().clearAnalysis();
    List<RepositoryNode> columnListAANode = anaColumnCompareViewer.getColumnListA();
    List<RepositoryNode> columnListBBNode = anaColumnCompareViewer.getColumnListB();
    AnalysisBuilder anaBuilder = new AnalysisBuilder();
    anaBuilder.setAnalysis(getCurrentModelElement());
    Connection tdDataProvider = null;
    for (int i = 0; i < columnListAANode.size(); i++) {
        if (columnListBBNode.size() > i) {
            ColumnDependencyIndicator indicator = ColumnsetFactory.eINSTANCE.createColumnDependencyIndicator();
            TdColumn columnA = (TdColumn) ((MetadataColumnRepositoryObject) columnListAANode.get(i).getObject()).getTdColumn();
            TdColumn columnB = (TdColumn) ((MetadataColumnRepositoryObject) columnListBBNode.get(i).getObject()).getTdColumn();
            indicator.setColumnA(columnA);
            indicator.setColumnB(columnB);
            indicator.setIndicatorDefinition(DefinitionHandler.getInstance().getFDRuleDefaultIndicatorDefinition());
            getCurrentModelElement().getResults().getIndicators().add(indicator);
            anaBuilder.addElementToAnalyze(columnA, indicator);
            // ADD this line qiongli 2010-6-8
            anaBuilder.addElementToAnalyze(columnB, indicator);
        }
    }
    if (columnListAANode.size() > 0) {
        reposObject = columnListAANode.get(0).getObject();
        tdDataProvider = ((ConnectionItem) reposObject.getProperty().getItem()).getConnection();
        // MOD qiongli bug 14437:Add dependency
        getCurrentModelElement().getContext().setConnection(tdDataProvider);
        TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(getCurrentModelElement(), tdDataProvider);
        if (!rc.isOk()) {
            // $NON-NLS-1$
            log.info("fail to save dependency analysis:" + getCurrentModelElement().getFileName());
        }
    } else {
        getCurrentModelElement().getContext().setConnection(null);
    }
    // save the number of connections per analysis
    this.saveNumberOfConnectionsPerAnalysis();
    // 2011.1.12 MOD by zhsne to unify anlysis and connection id when saving.
    this.nameText.setText(getCurrentModelElement().getName());
    // MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
    ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(getCurrentRepNode().getObject().getProperty().getItem(), true);
    // MOD yyi 2012-02-03 TDQ-3602:Avoid to rewriting all analyzes after saving, no reason to update all analyzes
    // which is depended in the referred connection.
    // Extract saving log function.
    // @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#logSaved(ReturnCode)
    logSaved(saved);
    anaColumnCompareViewer.setDirty(false);
    dataFilterComp.setDirty(false);
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) TdColumn(org.talend.cwm.relational.TdColumn) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) AnalysisBuilder(org.talend.dq.analysis.AnalysisBuilder) Dependency(orgomg.cwm.objectmodel.core.Dependency) Domain(org.talend.dataquality.domain.Domain) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 7 with TdColumn

use of org.talend.cwm.relational.TdColumn 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 8 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class MatchAnalysisDetailsPage method createDataTableComposite.

/**
 * create DataTable Composite.
 *
 * @param dataparent
 */
private void createDataTableComposite(Composite dataparent) {
    dataTableComp = toolkit.createComposite(dataparent);
    GridLayout dataTableLayout = new GridLayout(1, Boolean.TRUE);
    dataTableComp.setLayout(dataTableLayout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 250;
    dataTableComp.setLayoutData(gridData);
    sampleTable = new DataSampleTable();
    // use handler to save selected columns
    ModelElement[] selectedColumns = getSelectedColumnsFromHandler();
    if (selectedColumns != null && selectedColumns.length > 0) {
        // use ModelElement instead of node to get the data source type directly.
        if (selectedColumns[0] instanceof MetadataColumn && !(selectedColumns[0] instanceof TdColumn)) {
            isDelimitedFile = true;
        }
        createNatTable(new ArrayList<Object[]>());
    }
    sampleTable.addPropertyChangeListener(this);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) GridLayout(org.eclipse.swt.layout.GridLayout) DataSampleTable(org.talend.dataquality.record.linkage.ui.composite.table.DataSampleTable) TdColumn(org.talend.cwm.relational.TdColumn) GridData(org.eclipse.swt.layout.GridData)

Example 9 with TdColumn

use of org.talend.cwm.relational.TdColumn 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 10 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class RedundancyAnalysisResultPage method createAnalyzedColumnSetsSection.

private void createAnalyzedColumnSetsSection(Composite parent) {
    columnSetSection = createSection(form, parent, DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.analyzedColumnSets"), // $NON-NLS-1$
    null);
    Composite sectionClient = toolkit.createComposite(columnSetSection);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    TableViewer elementsTableViewer = new TableViewer(sectionClient, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table table = elementsTableViewer.getTable();
    GridDataFactory.fillDefaults().applyTo(table);
    ((GridData) table.getLayoutData()).heightHint = 240;
    ((GridData) table.getLayoutData()).widthHint = 600;
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setDragDetect(true);
    // $NON-NLS-1$
    table.setToolTipText(DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.dragAndDropToolTip"));
    final TableColumn columnHeader1 = new TableColumn(table, SWT.LEAD);
    columnHeader1.setWidth(300);
    final TableColumn columnHeader2 = new TableColumn(table, SWT.LEAD);
    columnHeader2.setWidth(300);
    Analysis analysis = this.masterPage.getAnalysisHandler().getAnalysis();
    isHasDeactivatedIndicator = analysis.getParameters().getDeactivatedIndicators().size() != 0;
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    if (indicators.size() != 0) {
        rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
        rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
        TdColumn columnA = null;
        if (rowMatchingIndicatorA.getColumnSetA().size() > 0) {
            columnA = rowMatchingIndicatorA.getColumnSetA().get(0);
            if (columnA.eIsProxy()) {
                columnA = (TdColumn) EObjectHelper.resolveObject(columnA);
            }
        }
        String columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnA).getName() : PluginConstant.EMPTY_STRING;
        columnHeader1.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
        columnName));
        TdColumn columnB = null;
        if (rowMatchingIndicatorA.getColumnSetB().size() > 0) {
            columnB = rowMatchingIndicatorA.getColumnSetB().get(0);
            if (columnB.eIsProxy()) {
                columnB = (TdColumn) EObjectHelper.resolveObject(columnB);
            }
        }
        columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnB).getName() : PluginConstant.EMPTY_STRING;
        columnHeader2.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
        columnName));
    }
    ColumnPairsViewerProvider provider = new ColumnPairsViewerProvider();
    elementsTableViewer.setContentProvider(provider);
    elementsTableViewer.setLabelProvider(provider);
    elementsTableViewer.setInput(rowMatchingIndicatorA);
    columnSetSection.setClient(sectionClient);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) TdColumn(org.talend.cwm.relational.TdColumn) Composite(org.eclipse.swt.widgets.Composite) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) Indicator(org.talend.dataquality.indicators.Indicator) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator)

Aggregations

TdColumn (org.talend.cwm.relational.TdColumn)177 TdTable (org.talend.cwm.relational.TdTable)47 ArrayList (java.util.ArrayList)45 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)40 Test (org.junit.Test)37 ColumnSet (orgomg.cwm.resource.relational.ColumnSet)35 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)26 RepositoryNode (org.talend.repository.model.RepositoryNode)26 IRepositoryNode (org.talend.repository.model.IRepositoryNode)23 Indicator (org.talend.dataquality.indicators.Indicator)20 Connection (org.talend.core.model.metadata.builder.connection.Connection)17 Catalog (orgomg.cwm.resource.relational.Catalog)17 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)16 TdSqlDataType (org.talend.cwm.relational.TdSqlDataType)16 Analysis (org.talend.dataquality.analysis.Analysis)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)14 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)14 Package (orgomg.cwm.objectmodel.core.Package)14 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)13