use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class ColumnDependencyExplorer method getStatement.
/**
* DOC xqliu Comment method "getStatement".
*
* @param genericSQL
* @return
*/
private String getStatement(String genericSQL) {
ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
TdColumn columnA = cdIndicator.getColumnA();
TdColumn columnB = cdIndicator.getColumnB();
GenericSQLHandler sqlHandler = new GenericSQLHandler(genericSQL);
sqlHandler.replaceColumnA(dbmsLanguage.quote(columnA.getName())).replaceColumnB(dbmsLanguage.quote(columnB.getName())).replaceTable(dbmsLanguage.quote(getFullyQualifiedTableName(columnA)));
String instantiatedSQL = sqlHandler.getSqlString();
List<String> whereClauses = new ArrayList<String>();
String dataFilter = ContextHelper.getDataFilterWithoutContext(this.analysis);
if (!StringUtils.isEmpty(dataFilter)) {
whereClauses.add(dataFilter);
}
instantiatedSQL = dbmsLanguage.addWhereToSqlStringStatement(instantiatedSQL, whereClauses);
return instantiatedSQL;
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class FunctionFrequencyStatExplorer method getInstantiatedClause.
@Override
protected String getInstantiatedClause() {
// get function which convert data into a pattern
String colName = columnName;
String function = null;
TdColumn column = (TdColumn) indicator.getAnalyzedElement();
int javaType = column.getSqlDataType().getJavaDataType();
if (!Java2SqlType.isNumbericInSQL(javaType)) {
function = getFunction();
} else {
colName = columnNameConvert();
}
// MOD mzhao bug 9681 2009-11-09
Object value = null;
if (Java2SqlType.isNumbericInSQL(javaType) && dbmsLanguage instanceof DB2DbmsLanguage) {
value = entity.getKey();
} else {
// $NON-NLS-1$//$NON-NLS-2$
value = "'" + entity.getKey() + "'";
}
String clause = entity.isLabelNull() ? columnName + dbmsLanguage.isNull() : ((function == null ? colName : function) + dbmsLanguage.equal() + value);
// ADD xqliu 2011-06-03 bug 20600's note 86482
if (dbmsLanguage instanceof InfomixDbmsLanguage) {
clause = clause.replaceAll(InfomixDbmsLanguage.AS_REPLACE_COLUMN, PluginConstant.EMPTY_STRING);
}
// ~ 20600
return clause;
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class FunctionFrequencyStatExplorer method getFreqRowsStatement.
/*
* (non-Javadoc)
*
* @see org.talend.dq.analysis.explore.FrequencyStatisticsExplorer#getFreqRowsStatement()
*/
@Override
protected String getFreqRowsStatement() {
// generate SELECT * FROM TABLE WHERE function(columnName) = labelToFind
TdColumn column = (TdColumn) indicator.getAnalyzedElement();
String clause = getInstantiatedClause();
return // $NON-NLS-1$
"SELECT * FROM " + getFullyQualifiedTableName(column) + dbmsLanguage.where() + inBrackets(clause) + andDataFilterClause();
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class FunctionFrequencyStatExplorer method columnNameConvert.
@SuppressWarnings("deprecation")
private String columnNameConvert() {
String colName = columnName;
TdColumn column = (TdColumn) indicator.getAnalyzedElement();
IndicatorDefinition indicatorDefinition;
String label = indicator.getIndicatorDefinition().getLabel();
if (label == null || PluginConstant.EMPTY_STRING.equals(label)) {
indicatorDefinition = indicator.getIndicatorDefinition();
} else {
indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(label);
}
if (indicator.eClass().equals(IndicatorsPackage.eINSTANCE.getPatternFreqIndicator()) || indicator.eClass().equals(IndicatorsPackage.eINSTANCE.getPatternLowFreqIndicator())) {
// MOD zshen for bug 12675 2010-05-12
if (Java2SqlType.isNumbericInSQL(column.getSqlDataType().getJavaDataType())) {
colName = addFunctionTypeConvert(colName);
}
// ~12675
final EList<CharactersMapping> charactersMapping = indicatorDefinition.getCharactersMapping();
colName = dbmsLanguage.getPatternFinderFunction(colName, charactersMapping);
if (columnName == null) {
// no replacement found, try the default one
colName = dbmsLanguage.getPatternFinderDefaultFunction(colName);
}
}
return colName;
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class AnalysisHandler method getColumnSetOwnerNames.
private String[] getColumnSetOwnerNames() {
List<String> existingTables = new ArrayList<String>();
for (ModelElement element : getAnalyzedColumns()) {
if (element instanceof TdColumn && element.eContainer() instanceof Table) {
String tableName = ColumnHelper.getTableFullName((TdColumn) element);
if (!existingTables.contains(tableName)) {
existingTables.add(tableName);
}
} else if (element instanceof Table) {
String tableName = ((Table) element).getName();
if (!existingTables.contains(tableName)) {
existingTables.add(tableName);
}
} else if (element instanceof MetadataColumn) {
// the result page
if (!(element instanceof TdColumn)) {
// MOD qiongli 2011-1-28,for delimited file
try {
MetadataTable table = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) element);
String tableName = table.getLabel();
if (!existingTables.contains(tableName)) {
existingTables.add(tableName);
}
} catch (java.lang.NullPointerException e) {
// $NON-NLS-1$
log.error(Messages.getString("AnalysisHandler.CanNotFindColumnParent", element.getName()), e);
}
}
}
}
return existingTables.toArray(new String[existingTables.size()]);
}
Aggregations