Search in sources :

Example 66 with MetadataColumn

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

the class MatchRuleTableViewer method getCellEditor.

/**
 * DOC zshen Comment method "getCellEditor".
 *
 * @param headers
 * @return
 */
@Override
protected CellEditor[] getCellEditor(List<String> headers, List<MetadataColumn> columnList) {
    CellEditor[] editors = new CellEditor[headers.size()];
    for (int i = 0; i < editors.length; ++i) {
        switch(i) {
            case // MatchAnalysisConstant.INPUT_COLUMN
            1:
                String[] cols = new String[columnList.size()];
                int idx = 0;
                for (MetadataColumn metaCol : columnList) {
                    cols[idx++] = metaCol.getName() == null ? "" : metaCol.getName();
                }
                editors[i] = new ComboBoxCellEditor(innerTable, cols, SWT.READ_ONLY);
                break;
            case // MatchAnalysisConstant.MATCHING_TYPE
            2:
                editors[i] = new ComboBoxCellEditor(innerTable, AttributeMatcherType.getAllTypes(), SWT.READ_ONLY);
                break;
            case // MatchAnalysisConstant.CUSTOM_MATCHER
            3:
                editors[i] = new jarFileCellEditor(innerTable, SWT.READ_ONLY);
                break;
            case // MatchAnalysisConstant.TOKENIZATION_TYPE
            4:
                editors[i] = new ComboBoxCellEditor(innerTable, TokenizedResolutionMethod.getAllTypes(), SWT.READ_ONLY);
                break;
            case // MatchAnalysisConstant.HANDLE_NULL
            6:
                editors[i] = new ComboBoxCellEditor(innerTable, HandleNullEnum.getAllTypes(), SWT.READ_ONLY);
                break;
            default:
                // MatchAnalysisConstant.MATCH_KEY_NAME and MatchAnalysisConstant.CONFIDENCE_WEIGHT
                editors[i] = new TextCellEditor(innerTable);
        }
    }
    return editors;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) CellEditor(org.eclipse.jface.viewers.CellEditor) org.talend.dataquality.record.linkage.ui.composite.tableviewer.cellEditor.jarFileCellEditor(org.talend.dataquality.record.linkage.ui.composite.tableviewer.cellEditor.jarFileCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) org.talend.dataquality.record.linkage.ui.composite.tableviewer.cellEditor.jarFileCellEditor(org.talend.dataquality.record.linkage.ui.composite.tableviewer.cellEditor.jarFileCellEditor)

Example 67 with MetadataColumn

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

the class ParticularDefaultSurvivorShipCellModifier method modify.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
     */
@Override
public void modify(Object element, String property, Object value) {
    if (element instanceof TableItem) {
        ParticularDefaultSurvivorshipDefinitions pdskd = (ParticularDefaultSurvivorshipDefinitions) ((TableItem) element).getData();
        String newValue = String.valueOf(value);
        if (MatchAnalysisConstant.PRECOLUMN.equalsIgnoreCase(property)) {
            if (Integer.parseInt(newValue) == -1) {
                return;
            }
            MetadataColumn metadataColumn = columnList.get(Integer.parseInt(newValue));
            String columnName = metadataColumn.getName();
            if (StringUtils.equals(pdskd.getColumn(), columnName)) {
                return;
            }
            pdskd.setColumn(columnName);
            pdskd.setDataType(metadataColumn.getTalendType());
            if (isFunctionInvalid(pdskd, metadataColumn.getTalendType())) {
                resetFunction(pdskd);
            }
        } else if (MatchAnalysisConstant.FUNCTION.equalsIgnoreCase(property)) {
            SurvivorShipAlgorithmEnum valueByIndex = SurvivorShipAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
            if (StringUtils.equals(pdskd.getFunction().getAlgorithmType(), valueByIndex.getComponentValueName())) {
                return;
            }
            setFunction(pdskd, valueByIndex);
        } else if (MatchAnalysisConstant.PARAMETER.equalsIgnoreCase(property)) {
            pdskd.getFunction().setAlgorithmParameters(newValue);
        } else {
            return;
        }
        tableViewer.update(pdskd, null);
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) TableItem(org.eclipse.swt.widgets.TableItem) SurvivorShipAlgorithmEnum(org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)

Example 68 with MetadataColumn

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

the class AbstractMatchAnaysisTableSection method setColumnValueIfMatch.

/**
 * When import:1) use key's name & key's column to compare, 2) set it empty when no match. If the key's column =
 * some column name, keep it; when key's name and key's column both no match, set it empty
 *
 * @param keyDefinition
 */
protected void setColumnValueIfMatch(KeyDefinition keyDefinition) {
    String columnName = StringUtils.EMPTY;
    if (this.columnMap != null) {
        for (MetadataColumn column : columnMap.keySet()) {
            if (StringUtils.equalsIgnoreCase(getColumnName(column), getMappingName(keyDefinition))) {
                columnName = column.getLabel();
                break;
            }
        }
    }
    keyDefinition.setColumn(columnName);
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn)

Example 69 with MetadataColumn

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

the class CreateDateAnalysisAction method isTimeType.

// Added yyin2012-05-14 TDQ-5241
private boolean isTimeType() {
    for (IRepositoryNode repositoryNode : getColumns()) {
        MetadataColumn column = ((MetadataColumnRepositoryObject) repositoryNode.getObject()).getTdColumn();
        int javaSQLType = ((TdColumn) column).getSqlDataType().getJavaDataType();
        if (Java2SqlType.isTimeSQL(javaSQLType)) {
            return true;
        }
    }
    return false;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 70 with MetadataColumn

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

the class SemanticDiscoveryActionProvider method fillContextMenu.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
     */
@Override
public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
    Object firstElement = currentSelection.getFirstElement();
    boolean selectedMoreThanOne = currentSelection.size() > 1;
    // keep all of columns belong to same one table and create SemanticDiscoveryAction.
    if (selectedMoreThanOne || firstElement instanceof ColumnRepNode) {
        Set<String> currentTableSet = new HashSet<String>();
        MetadataTable createTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        List<String> filterNames = new ArrayList<String>();
        Iterator<Object> columnIterator = currentSelection.iterator();
        while (columnIterator.hasNext()) {
            Object columnNode = columnIterator.next();
            MetadataColumn metadataColumn = null;
            if (DBColumnRepNode.class.isInstance(columnNode)) {
                metadataColumn = ((DBColumnRepNode) columnNode).getTdColumn();
                createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
            } else if (DFColumnRepNode.class.isInstance(columnNode)) {
                metadataColumn = ((DFColumnRepNode) columnNode).getMetadataColumn();
                createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
            } else {
                // If not all of elements which be selected is columns
                return;
            }
            currentTableSet.add(ResourceHelper.getUUID(createTable));
            // all of columns should come from same table
            if (currentTableSet.size() > 1) {
                return;
            }
            filterNames.add(metadataColumn.getName());
        }
        MetadataTable metadataTableWithFilter = new MetadataTableWithFilter(filterNames, createTable);
        semanticDiscoveryAction = new SemanticDiscoveryAction(metadataTableWithFilter);
    } else {
        // otherwise the selection is valid, only two possible status: only one columnset is select.
        if (firstElement instanceof DBTableRepNode) {
            DBTableRepNode node = (DBTableRepNode) firstElement;
            semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdTable());
        } else if (firstElement instanceof DBViewRepNode) {
            DBViewRepNode node = (DBViewRepNode) firstElement;
            semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdView());
        } else if (firstElement instanceof DFTableRepNode) {
            DFTableRepNode node = (DFTableRepNode) firstElement;
            semanticDiscoveryAction = new SemanticDiscoveryAction(node.getMetadataTable());
        }
    }
    menu.add(semanticDiscoveryAction);
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) ArrayList(java.util.ArrayList) SemanticDiscoveryAction(org.talend.dataprofiler.core.ui.action.actions.predefined.SemanticDiscoveryAction) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) MetadataTableWithFilter(org.talend.dataprofiler.core.model.MetadataTableWithFilter) HashSet(java.util.HashSet)

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