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;
}
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;
}
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;
}
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));
}
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));
}
Aggregations