Search in sources :

Example 71 with MetadataColumn

use of org.talend.core.model.metadata.builder.connection.MetadataColumn 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 72 with MetadataColumn

use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.

the class ColumnSetMultiValueIndicatorImpl method getColumnHeaders.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<String> getColumnHeaders() {
    EList<String> headers = new BasicEList<String>();
    // shuold keep the order of the columns, when show the data in result page need to follow the order
    for (ModelElement column : analyzedColumns) {
        if (isSameMiningType(column, DataminingType.INTERVAL)) {
            // add numerical or date columns with formatted heander name if numeric or date functions defined in
            // indicator definition.
            final MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(column);
            final TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(column);
            if (tdColumn != null) {
                // For database items
                addDBColumnToHeaderList(headers, column, tdColumn);
            } else if (mdColumn != null) {
                // For file items.
                addFileColumnToHeaderList(headers, column, mdColumn);
            } else {
                // Never go here
                log.error("invalid data mining type for " + column);
            }
        } else {
            headers.add(column.getName());
        }
    }
    headers.add(this.getCountAll());
    return headers;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) BasicEList(org.eclipse.emf.common.util.BasicEList)

Example 73 with MetadataColumn

use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.

the class ColumnSetMultiValueIndicatorImpl method getNumericColumns.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<ModelElement> getNumericColumns() {
    // bug 10578 by zshen,fix the
    EList<ModelElement> computedColumns = new BasicElistExtend<ModelElement>();
    // correlation analysis to be move
    if (analyzedColumns != null) {
        for (ModelElement column : analyzedColumns) {
            // 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);
            // MOD qiongli 2011-3-8.fetature 19192,,add mdColumn for MetadataColumn(delimited file)
            if (tdColumn != null) {
                if (isSameMiningType(column, DataminingType.INTERVAL) && Java2SqlType.isNumbericInSQL(tdColumn.getSqlDataType().getJavaDataType())) {
                    computedColumns.add(column);
                }
            } else if (mdColumn != null) {
                int javaType = TalendTypeConvert.convertToJDBCType(mdColumn.getTalendType());
                if (isSameMiningType(column, DataminingType.INTERVAL) && Java2SqlType.isNumbericInSQL(javaType)) {
                    computedColumns.add(column);
                }
            }
        }
    }
    return computedColumns;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn)

Example 74 with MetadataColumn

use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.

the class ColumnSetMultiValueIndicatorImpl method getDateColumns.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<ModelElement> getDateColumns() {
    EList<ModelElement> dateColumns = new BasicEList<ModelElement>();
    if (analyzedColumns != null) {
        for (ModelElement column : analyzedColumns) {
            final MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(column);
            final TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(column);
            if (tdColumn != null) {
                if (isSameMiningType(column, DataminingType.INTERVAL) && Java2SqlType.isDateInSQL(tdColumn.getSqlDataType().getJavaDataType())) {
                    dateColumns.add(column);
                }
            } else if (mdColumn != null) {
                int javaType = TalendTypeConvert.convertToJDBCType(mdColumn.getTalendType());
                if (isSameMiningType(column, DataminingType.INTERVAL) && Java2SqlType.isDateInSQL(javaType)) {
                    dateColumns.add(column);
                }
            }
        }
    }
    return dateColumns;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) BasicEList(org.eclipse.emf.common.util.BasicEList)

Example 75 with MetadataColumn

use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method initColumns.

/**
 * init the file's related metadata table with columns: name, company, city,country, comment. and add all columns as
 * analyzed elements.
 *
 * @param context
 */
public MetadataColumn initColumns(AnalysisContext context, MetadataTable metadataTable) {
    List<ModelElement> anaElements = context.getAnalysedElements();
    // // Name
    MetadataColumn name = ConnectionPackage.eINSTANCE.getConnectionFactory().createMetadataColumn();
    // $NON-NLS-1$
    name.setName("name");
    // $NON-NLS-1$
    name.setLabel("name");
    anaElements.add(name);
    metadataTable.getColumns().add(name);
    // Company
    MetadataColumn company = ConnectionPackage.eINSTANCE.getConnectionFactory().createMetadataColumn();
    // $NON-NLS-1$
    company.setName("company");
    // $NON-NLS-1$
    company.setLabel("company");
    anaElements.add(company);
    metadataTable.getColumns().add(company);
    // City
    MetadataColumn city = ConnectionPackage.eINSTANCE.getConnectionFactory().createMetadataColumn();
    // $NON-NLS-1$
    city.setName("city");
    // $NON-NLS-1$
    city.setLabel("city");
    anaElements.add(city);
    metadataTable.getColumns().add(city);
    // Country
    MetadataColumn country = ConnectionPackage.eINSTANCE.getConnectionFactory().createMetadataColumn();
    // $NON-NLS-1$
    country.setName("country");
    // $NON-NLS-1$
    country.setLabel("country");
    anaElements.add(country);
    metadataTable.getColumns().add(country);
    // comment
    MetadataColumn comment = ConnectionPackage.eINSTANCE.getConnectionFactory().createMetadataColumn();
    // $NON-NLS-1$
    comment.setName("comment");
    // $NON-NLS-1$
    comment.setLabel("comment");
    anaElements.add(comment);
    metadataTable.getColumns().add(comment);
    return name;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn)

Aggregations

MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)203 ArrayList (java.util.ArrayList)98 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)51 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)37 TdColumn (org.talend.cwm.relational.TdColumn)28 List (java.util.List)24 HashMap (java.util.HashMap)20 Test (org.junit.Test)15 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)14 EList (org.eclipse.emf.common.util.EList)12 Indicator (org.talend.dataquality.indicators.Indicator)12 IRepositoryNode (org.talend.repository.model.IRepositoryNode)12 File (java.io.File)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 NoSQLExtractSchemaException (org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)10 Map (java.util.Map)9 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)9 RepositoryNode (org.talend.repository.model.RepositoryNode)9 Iterator (java.util.Iterator)8 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)8