Search in sources :

Example 6 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class MetadataHelper method setDefaultDataminingType.

/**
 * Set the DataminingType according to the Column Type.
 *
 * @param modelElement
 */
public static void setDefaultDataminingType(ModelElement modelElement) {
    if (modelElement == null) {
        return;
    }
    DataminingType type = getDataminingType(modelElement);
    if (type == null) {
        type = getDefaultDataminingType(0);
    }
    TaggedValueHelper.setTaggedValue(modelElement, TaggedValueHelper.DATA_CONTENT_TYPE_TAGGED_VAL, type.getLiteral());
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType)

Example 7 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class ColumnSetMultiValueIndicatorImpl method isSameMiningType.

private Boolean isSameMiningType(ModelElement column, DataminingType type) {
    // MOD yyi 2011-02-25 16660: edit connection, save it will get error
    final MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(column);
    final TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(column);
    if (tdColumn == null && mdColumn == null) {
        if (column == null) {
            log.error("The list of analyzed column contains a null column");
        } else {
            log.error("Analyzed element should be a TdColumn instead of a Column. Analyzed element is " + column.getName());
        }
        // Column which is null is not a nominal type.
        return false;
    }
    // MOD qiongli 2011-3-8.fetature 19192,add mdColumn for MetadataColumn(delimited file)
    DataminingType dataminingType = MetadataHelper.getDataminingType(column);
    if (dataminingType != null && type == dataminingType) {
        return Boolean.TRUE;
    }
    return Boolean.FALSE;
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn)

Example 8 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class DbmsLanguage method castColumn4ColumnAnalysisSqlExecutor.

/**
 * Method "castColumn".
 *
 * @param indicator
 * @param tdColumn
 * @param colName the name of the given column (tdColumn.getName() ) (could contain quotes)
 * @return
 */
public String castColumn4ColumnAnalysisSqlExecutor(Indicator indicator, TdColumn tdColumn, String colName) {
    int javaType = tdColumn.getSqlDataType().getJavaDataType();
    boolean isText = Java2SqlType.isTextInSQL(javaType);
    String contentType = tdColumn.getContentType();
    DataminingType dataminingType = DataminingType.get(contentType);
    if (DataminingType.INTERVAL.equals(dataminingType) && (isText)) {
        // cast is needed
        // MOD qiongli 2011-4-18,bug 16723(data cleansing),handle date
        boolean isDate = Java2SqlType.isDateInSQL(javaType);
        if (isDate) {
            // $NON-NLS-1$//$NON-NLS-2$
            return "CAST(" + colName + " AS DATE)";
        }
        boolean isNumeric = Java2SqlType.isNumbericInSQL(javaType);
        if (isNumeric) {
            // $NON-NLS-1$ //$NON-NLS-2$
            return "CAST(" + colName + " AS DECIMAL)";
        }
    }
    return colName;
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType)

Example 9 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class IndicatorImpl method getDataminingType.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public DataminingType getDataminingType() {
    ModelElement elt = getAnalyzedElement();
    if (elt == null) {
        return getDataminingTypeGen();
    }
    TdColumn col = SwitchHelpers.COLUMN_SWITCH.doSwitch(elt);
    if (col == null) {
        return getDataminingTypeGen();
    }
    DataminingType type = MetadataHelper.getDataminingType(col);
    if (type == null) {
        // try the default code
        return getDataminingTypeGen();
    }
    return type;
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn)

Example 10 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class ColumnAnalysisDetailsPage method saveAnalysis.

/**
 * @param outputFolder
 * @throws DataprofilerCoreException
 */
@Override
public void saveAnalysis() throws DataprofilerCoreException {
    analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    analysisHandler.clearAnalysis();
    Analysis analysis = analysisHandler.getAnalysis();
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
    // save the number of connections per analysis
    this.saveNumberOfConnectionsPerAnalysis();
    try {
        // MOD zshen feature 12919 to save analysisParameter.
        analysis.getParameters().setMaxNumberRows(Integer.parseInt(maxNumText.getText()));
    } catch (NumberFormatException nfe) {
        // $NON-NLS-1$
        MessageDialogWithToggle.openError(// $NON-NLS-1$
        null, // $NON-NLS-1$
        DefaultMessagesImpl.getString("AbstractAnalysisMetadataPage.SaveAnalysis"), // $NON-NLS-1$
        DefaultMessagesImpl.getString(// $NON-NLS-1$
        "ColumnMasterDetailsPage.emptyField", // $NON-NLS-1$
        DefaultMessagesImpl.getString("ColumnMasterDetailsPage.maxNumberLabel")));
        maxNumText.setText(String.valueOf(analysis.getParameters().getMaxNumberRows()));
    }
    analysis.getParameters().setStoreData(drillDownCheck.getSelection());
    // ~12919
    ModelElementIndicator[] modelElementIndicators = this.getCurrentModelElementIndicators();
    if (modelElementIndicators != null && modelElementIndicators.length != 0) {
        Connection tdProvider = ModelElementIndicatorHelper.getTdDataProvider(modelElementIndicators[0]);
        if (tdProvider.eIsProxy()) {
            // Resolve the connection again
            tdProvider = (Connection) EObjectHelper.resolveObject(tdProvider);
        }
        analysis.getContext().setConnection(tdProvider);
        for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
            IRepositoryViewObject reposObject = modelElementIndicator.getModelElementRepositoryNode().getObject();
            ModelElement modelEle = null;
            if (reposObject instanceof MetadataColumnRepositoryObject) {
                modelEle = ((MetadataColumnRepositoryObject) reposObject).getTdColumn();
            }
            analysisHandler.addIndicator(modelEle, modelElementIndicator.getIndicators());
            DataminingType type = MetadataHelper.getDataminingType(modelEle);
            if (type == null) {
                type = MetadataHelper.getDefaultDataminingType(modelElementIndicator.getJavaType());
            }
            analysisHandler.setDatamingType(type.getLiteral(), modelEle);
        }
    } else {
        analysis.getContext().setConnection(null);
    }
    analysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
    // 2011.1.12 MOD by zshen to unify anlysis and connection id when saving.
    this.nameText.setText(analysisHandler.getName());
    TaggedValueHelper.setTaggedValue(getCurrentModelElement(), TaggedValueHelper.IS_USE_SAMPLE_DATA, isRunWithSampleData.toString());
    // TDQ-5581,if has removed emlements(patten/udi),should remove dependency each other before saving.
    // 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);
    treeViewer.setDirty(false);
    dataFilterComp.setDirty(false);
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) Domain(org.talend.dataquality.domain.Domain) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

DataminingType (org.talend.dataquality.indicators.DataminingType)19 TdColumn (org.talend.cwm.relational.TdColumn)8 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)8 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)6 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)5 Indicator (org.talend.dataquality.indicators.Indicator)4 Resource (org.eclipse.emf.ecore.resource.Resource)3 CCombo (org.eclipse.swt.custom.CCombo)3 TreeEditor (org.eclipse.swt.custom.TreeEditor)3 MouseAdapter (org.eclipse.swt.events.MouseAdapter)3 MouseEvent (org.eclipse.swt.events.MouseEvent)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Label (org.eclipse.swt.widgets.Label)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 ArrayList (java.util.ArrayList)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 ColumnsetFactory (org.talend.dataquality.indicators.columnset.ColumnsetFactory)2 IFolder (org.eclipse.core.resources.IFolder)1