Search in sources :

Example 6 with ColumnRepNode

use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.

the class RepNodeUtils method isSupportPatternFrequency.

/**
 * check whether the nodes can support pattern Frequency indicator for sql engine.
 *
 * @param nodes
 * @return
 */
public static boolean isSupportPatternFrequency(List<IRepositoryNode> nodes) {
    if (nodes != null && !nodes.isEmpty()) {
        Connection connection = null;
        if (nodes.get(0) instanceof ColumnRepNode) {
            MetadataColumn column = ((MetadataColumnRepositoryObject) nodes.get(0).getObject()).getTdColumn();
            connection = ConnectionHelper.getTdDataProvider(column);
        } else if (nodes.get(0) instanceof ColumnSetRepNode) {
            MetadataTable table = ((MetadataTableRepositoryObject) nodes.get(0).getObject()).getTable();
            connection = ConnectionHelper.getTdDataProvider(table);
        }
        if (connection != null && (ConnectionHelper.isTeradata(connection) || ConnectionHelper.isIngress(connection) || ConnectionHelper.isSybase(connection))) {
            return false;
        }
    }
    return true;
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) ColumnSetRepNode(org.talend.dq.nodes.ColumnSetRepNode) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 7 with ColumnRepNode

use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.

the class RepNodeUtils method isAllNumberalColumns.

/**
 * check is All the Columns are Numberal type.
 *
 * @param nodes
 * @return
 */
public static boolean isAllNumberalColumns(List<IRepositoryNode> nodes) {
    if (nodes != null && nodes.size() > 0) {
        for (int index = 0; index < nodes.size(); index++) {
            IRepositoryNode repositoryNode = nodes.get(index);
            if (!(repositoryNode instanceof ColumnRepNode)) {
                return false;
            }
            int javaType = getColumnJavaType(repositoryNode);
            if (!Java2SqlType.isNumbericInSQL(javaType)) {
                return false;
            }
        }
    }
    return Boolean.TRUE;
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 8 with ColumnRepNode

use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.

the class RepNodeUtils method isAllTextColumns.

/**
 * check is All the Columns are text type.
 *
 * @param nodes
 * @return
 */
public static boolean isAllTextColumns(List<IRepositoryNode> nodes) {
    if (nodes != null && nodes.size() > 0) {
        for (int index = 0; index < nodes.size(); index++) {
            IRepositoryNode repositoryNode = nodes.get(index);
            if (!(repositoryNode instanceof ColumnRepNode)) {
                return false;
            }
            int javaType = getColumnJavaType(repositoryNode);
            if (!Java2SqlType.isTextInSQL(javaType)) {
                return false;
            }
        }
    }
    return Boolean.TRUE;
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 9 with ColumnRepNode

use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis_4.

/**
 * Test:4) when the selected nodes are: multiple columns from one same table/view, will be valid.
 */
@Test
public void testIsValidSelectionForMatchAnalysis_4() {
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    DBTableRepNode table1 = mock(DBTableRepNode.class);
    DBViewRepNode view1 = mock(DBViewRepNode.class);
    DFTableRepNode dfTable = mock(DFTableRepNode.class);
    ColumnRepNode col1 = mock(ColumnRepNode.class);
    ColumnRepNode col2 = mock(ColumnRepNode.class);
    when(col1.getParent()).thenReturn(table1);
    when(col2.getParent()).thenReturn(table1);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    when(col1.getParent()).thenReturn(view1);
    when(col2.getParent()).thenReturn(view1);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    when(col1.getParent()).thenReturn(dfTable);
    when(col2.getParent()).thenReturn(dfTable);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with ColumnRepNode

use of org.talend.dq.nodes.ColumnRepNode in project tdq-studio-se by Talend.

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis_2.

/**
 * Test: 2) when the selected nodes are: multiple table/views, multiple columns from different table/view, will not
 * be valid;
 */
@Test
public void testIsValidSelectionForMatchAnalysis_2() {
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    DBTableRepNode table1 = mock(DBTableRepNode.class);
    DBTableRepNode table2 = mock(DBTableRepNode.class);
    nodes.clear();
    nodes.add(table1);
    nodes.add(table2);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBViewRepNode view1 = mock(DBViewRepNode.class);
    DBViewRepNode view2 = mock(DBViewRepNode.class);
    nodes.clear();
    nodes.add(view1);
    nodes.add(view2);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    ColumnRepNode col1 = mock(ColumnRepNode.class);
    ColumnRepNode col2 = mock(ColumnRepNode.class);
    when(col1.getParent()).thenReturn(table1);
    when(col2.getParent()).thenReturn(table2);
    nodes.clear();
    nodes.add(col1);
    nodes.add(col2);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ColumnRepNode (org.talend.dq.nodes.ColumnRepNode)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)8 ArrayList (java.util.ArrayList)6 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)5 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)5 List (java.util.List)3 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)3 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 ColumnSetRepNode (org.talend.dq.nodes.ColumnSetRepNode)2 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)2 HashSet (java.util.HashSet)1