Search in sources :

Example 11 with TdColumn

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

the class ColumnSetAnalysisDetailsPage method recomputeIndicators.

public void recomputeIndicators() {
    columnSetAnalysisHandler = new ColumnSetAnalysisHandler();
    columnSetAnalysisHandler.setAnalysis(getCurrentModelElement());
    stringDataFilter = columnSetAnalysisHandler.getStringDataFilter();
    analyzedColumns = columnSetAnalysisHandler.getAnalyzedColumns();
    if (columnSetAnalysisHandler.getSimpleStatIndicator() == null || columnSetAnalysisHandler.getSimpleStatIndicator().eIsProxy()) {
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        simpleStatIndicator = columnsetFactory.createSimpleStatIndicator();
        simpleStatIndicator.setRowCountIndicator(IndicatorsFactory.eINSTANCE.createRowCountIndicator());
        simpleStatIndicator.setDistinctCountIndicator(IndicatorsFactory.eINSTANCE.createDistinctCountIndicator());
        simpleStatIndicator.setDuplicateCountIndicator(IndicatorsFactory.eINSTANCE.createDuplicateCountIndicator());
        simpleStatIndicator.setUniqueCountIndicator(IndicatorsFactory.eINSTANCE.createUniqueCountIndicator());
    } else {
        simpleStatIndicator = (SimpleStatIndicator) columnSetAnalysisHandler.getSimpleStatIndicator();
    }
    if (columnSetAnalysisHandler.getAllmatchIndicator() == null) {
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        allMatchIndicator = columnsetFactory.createAllMatchIndicator();
        DefinitionHandler.getInstance().setDefaultIndicatorDefinition(allMatchIndicator);
    } else {
        allMatchIndicator = (AllMatchIndicator) columnSetAnalysisHandler.getAllmatchIndicator();
    }
    initializeIndicator(simpleStatIndicator);
    List<ModelElementIndicator> meIndicatorList = new ArrayList<ModelElementIndicator>();
    ModelElementIndicator currentIndicator = null;
    for (ModelElement element : analyzedColumns) {
        // MOD yyi 2011-02-16 17871:delimitefile
        MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(element);
        TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
        if (tdColumn == null && mdColumn == null) {
            continue;
        }
        if (tdColumn == null && mdColumn != null) {
            currentIndicator = ModelElementIndicatorHelper.createDFColumnIndicator(RepositoryNodeHelper.recursiveFind(mdColumn));
        } else if (tdColumn != null) {
            RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(tdColumn);
            if (recursiveFind == null) {
                recursiveFind = RepositoryNodeHelper.createRepositoryNode(tdColumn);
            }
            currentIndicator = ModelElementIndicatorHelper.createModelElementIndicator(recursiveFind);
        }
        DataminingType dataminingType = MetadataHelper.getDataminingType(element);
        MetadataHelper.setDataminingType(dataminingType == null ? DataminingType.NOMINAL : dataminingType, element);
        Collection<Indicator> indicatorList = columnSetAnalysisHandler.getRegexMathingIndicators(element);
        if (null != currentIndicator) {
            currentIndicator.setIndicators(indicatorList.toArray(new Indicator[indicatorList.size()]));
            meIndicatorList.add(currentIndicator);
        }
    }
    currentModelElementIndicators = meIndicatorList.toArray(new ModelElementIndicator[meIndicatorList.size()]);
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ColumnSetAnalysisHandler(org.talend.dq.analysis.ColumnSetAnalysisHandler) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 12 with TdColumn

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

the class ColumnSetAnalysisDetailsPage method canSave.

@Override
public ReturnCode canSave() {
    // MOD by gdbu 2011-3-21 bug 19179
    ReturnCode canModRetCode = super.canSave();
    if (!canModRetCode.isOk()) {
        return canModRetCode;
    }
    // ~19179
    String message = null;
    List<IRepositoryNode> columnSetMultiValueList = this.treeViewer.getColumnSetMultiValueList();
    // MOD yyi 2011-02-16 17871:delimitefile
    List<ModelElement> columnList = new ArrayList<ModelElement>();
    // MOD klliu 2001-03-28 19464 filter column from same table
    Set<EObject> nodeTypeName = new HashSet<EObject>();
    for (IRepositoryNode rd : columnSetMultiValueList) {
        ModelElement modelElementFromRepositoryNode = RepositoryNodeHelper.getModelElementFromRepositoryNode(rd);
        EObject eContainer = modelElementFromRepositoryNode.eContainer();
        nodeTypeName.add(eContainer);
        columnList.add(RepositoryNodeHelper.getModelElementFromRepositoryNode(rd));
    }
    if (nodeTypeName.size() > 1) {
        // $NON-NLS-1$
        return new ReturnCode(DefaultMessagesImpl.getString("ColumnSetMasterPage.CannotCreateAnalysis"), false);
    }
    if (!columnSetMultiValueList.isEmpty()) {
        // MOD klliu bug 19464,file delimit connection does not need to check from one table.
        if (columnList.get(0) instanceof TdColumn) {
            if (!ModelElementHelper.isFromSameTable(columnList)) {
                // $NON-NLS-1$
                message = DefaultMessagesImpl.getString("ColumnSetMasterPage.CannotCreateAnalysis");
            }
        } else if (columnList.get(0) instanceof MetadataColumn) {
            if (!isFromSameTableByDFColumn(columnSetMultiValueList)) {
                // $NON-NLS-1$
                message = DefaultMessagesImpl.getString("ColumnSetMasterPage.CannotCreateAnalysis");
            }
        }
    }
    if (message == null) {
        resetResultPageData();
        return new ReturnCode(true);
    }
    return new ReturnCode(message, false);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ReturnCode(org.talend.utils.sugars.ReturnCode) TdColumn(org.talend.cwm.relational.TdColumn) IRepositoryNode(org.talend.repository.model.IRepositoryNode) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 13 with TdColumn

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

the class AbstractAnalysisMetadataPage method createExecuteEngineSection.

/**
 * Extracted from the column and column set master page, to create the execution language selection section
 *
 * @param form1
 * @param anasisDataComp
 * @param analyzedColumns
 * @param anaParameters
 * @return
 */
protected Composite createExecuteEngineSection(final ScrolledForm form1, Composite anasisDataComp, EList<ModelElement> analyzedColumns, AnalysisParameters anaParameters) {
    analysisParamSection = createSection(form1, anasisDataComp, DefaultMessagesImpl.getString("ColumnMasterDetailsPage.AnalysisParameter"), // $NON-NLS-1$
    null);
    Composite sectionClient = toolkit.createComposite(analysisParamSection);
    sectionClient.setLayout(new GridLayout(1, false));
    Composite comp1 = new Composite(sectionClient, SWT.NONE);
    this.createAnalysisLimitComposite(comp1);
    Composite comp2 = new Composite(sectionClient, SWT.NONE);
    comp2.setLayout(new GridLayout(2, false));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(comp2);
    // $NON-NLS-1$
    toolkit.createLabel(comp2, DefaultMessagesImpl.getString("ColumnMasterDetailsPage.ExecutionEngine"));
    // MOD zshen:need to use the component with finish indicator Selection.
    execCombo = new CCombo(comp2, SWT.BORDER);
    // ~
    execCombo.setEditable(false);
    // run with sample data mode only used by java engin
    if (this.isRunWithSampleData) {
        execCombo.setEnabled(false);
    }
    for (ExecutionLanguage language : ExecutionLanguage.VALUES) {
        String temp = language.getLiteral();
        execCombo.add(temp);
    }
    // MOD qiongli 2011-3-17 set DataFilterText disabled except TdColumn.
    if (analyzedColumns != null && !analyzedColumns.isEmpty()) {
        ModelElement mod = analyzedColumns.get(0);
        TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(mod);
        dataFilterComp.getDataFilterText().setEnabled((tdColumn != null) ? true : false);
        if (tdColumn == null) {
            dataFilterComp.getDataFilterText().setEnabled(false);
            changeExecuteLanguageToJava(true);
        }
    }
    ExecutionLanguage executionLanguage = getCurrentModelElement().getParameters().getExecutionLanguage();
    execLang = executionLanguage.getLiteral();
    execCombo.setText(execLang);
    // ADD xqliu 2009-08-24 bug 8776
    setLanguageToTreeViewer(ExecutionLanguage.get(execLang));
    // ~
    // MOD msjian TDQ-9467: this part is only for column analysis
    createDrillDownPart(anaParameters, comp2, executionLanguage);
    analysisParamSection.setClient(sectionClient);
    return comp2;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) GridLayout(org.eclipse.swt.layout.GridLayout) CCombo(org.eclipse.swt.custom.CCombo) TdColumn(org.talend.cwm.relational.TdColumn) Composite(org.eclipse.swt.widgets.Composite) ExecutionLanguage(org.talend.dataquality.analysis.ExecutionLanguage)

Example 14 with TdColumn

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

the class MultiColAnalysisCreationTest method getColumns.

/**
 * DOC scorreia Comment method "getColumn".
 *
 * @param dataManager
 * @return
 * @throws Exception
 */
private List<TdColumn> getColumns(Connection dataManager) throws Exception {
    List<Catalog> tdCatalogs = CatalogHelper.getCatalogs(dataManager.getDataPackage());
    Catalog catalog = null;
    for (Catalog tdCatalog : tdCatalogs) {
        if (CATALOG.equals(tdCatalog.getName())) {
            catalog = tdCatalog;
            break;
        }
    }
    Assert.assertNotNull(catalog);
    Assert.assertFalse(tdCatalogs.isEmpty());
    // $NON-NLS-1$
    System.out.println("analysed Catalog: " + catalog.getName());
    List<TdTable> tables = DqRepositoryViewService.getTables(dataManager, catalog, TABLE, true, false);
    // store tables in catalog
    CatalogHelper.addTables(tables, catalog);
    Assert.assertFalse(tables.isEmpty());
    TdTable tdTable = tables.get(0);
    // $NON-NLS-1$
    System.out.println("analyzed Table: " + tdTable.getName());
    List<TdColumn> columns;
    columns = DqRepositoryViewService.getColumns(dataManager, tdTable, null, true);
    // MOD scorreia 2009-01-29 columns are stored in the table
    // TableHelper.addColumns(tdTable, columns);
    Assert.assertFalse(columns.isEmpty());
    List<TdColumn> usedCols = new ArrayList<TdColumn>();
    for (TdColumn tdColumn : columns) {
        for (String c : COLUMNS) {
            if (tdColumn.getName().equals(c)) {
                usedCols.add(tdColumn);
            }
        }
    }
    // set DM type for each used column
    for (TdColumn tdColumn : usedCols) {
        final int javaType = tdColumn.getJavaType();
        if (Java2SqlType.isNumbericInSQL(javaType)) {
            MetadataHelper.setDataminingType(DataminingType.INTERVAL, tdColumn);
        } else if (Java2SqlType.isTextInSQL(javaType)) {
            MetadataHelper.setDataminingType(DataminingType.NOMINAL, tdColumn);
        }
    }
    return usedCols;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) Catalog(orgomg.cwm.resource.relational.Catalog)

Example 15 with TdColumn

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

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