Search in sources :

Example 91 with TdColumn

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

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

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

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

the class UnitTestBuildHelper method createRealTdColumn.

public static TdColumn createRealTdColumn(String columnName, String tdSqlName, int javaType) {
    TdTable table = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    table.setName("TDQ_CALENDAR");
    TdColumn column = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
    column.setName(columnName);
    TdSqlDataType tdsql = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdSqlDataType();
    tdsql.setName(tdSqlName);
    tdsql.setJavaDataType(javaType);
    column.setSqlDataType(tdsql);
    table.getOwnedElement().add(column);
    column.setOwner(table);
    return column;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) TdSqlDataType(org.talend.cwm.relational.TdSqlDataType)

Example 95 with TdColumn

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

the class TableNode method isNodeSameToColumn.

/**
     * Check if ColumnNode and Column are the same.
     * 
     * @param node ColumnNode
     * @param column MetadataColumnImpl
     * @return isNodeSameToColumn
     * @exception
     */
private boolean isNodeSameToColumn(ColumnNode node, MetadataColumnImpl column) {
    SessionTreeNode sessionTreeNode = node.getSession();
    TableColumnInfo[] tableColumnInfo = null;
    try {
        tableColumnInfo = sessionTreeNode.getMetaData().getColumnInfo(ptableInfo);
    } catch (SQLException e) {
        SqlBuilderPlugin.log(e.getMessage(), e);
        return false;
    }
    // Retrive metadataColumns from Database
    IMetadataConnection iMetadataConnection = ConvertionHelper.convert(connection);
    List<TdColumn> metadataColumns = new ArrayList<TdColumn>();
    metadataColumns = ExtractMetaDataFromDataBase.returnMetadataColumnsFormTable(iMetadataConnection, getLabelText());
    Iterator iterate = metadataColumns.iterator();
    while (iterate.hasNext()) {
        MetadataColumn metadataColumn = (MetadataColumn) iterate.next();
        for (TableColumnInfo info : tableColumnInfo) {
            if (metadataColumn.getLabel().equals(node.getLabelText()) && info.getColumnName().equals(node.getLabelText())) {
                boolean divergency = isEquivalent(metadataColumn, column);
                metadataColumn.setDivergency(divergency);
                return divergency;
            }
        }
    }
    return true;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) SQLException(java.sql.SQLException) SessionTreeNode(org.talend.sqlbuilder.sessiontree.model.SessionTreeNode) TableColumnInfo(net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection)

Aggregations

TdColumn (org.talend.cwm.relational.TdColumn)182 ArrayList (java.util.ArrayList)49 TdTable (org.talend.cwm.relational.TdTable)49 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)28 RepositoryNode (org.talend.repository.model.RepositoryNode)26 IRepositoryNode (org.talend.repository.model.IRepositoryNode)23 Indicator (org.talend.dataquality.indicators.Indicator)20 Catalog (orgomg.cwm.resource.relational.Catalog)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)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