use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class AddTdRelationalSwitch method casePrimaryKey.
@Override
public Boolean casePrimaryKey(PrimaryKey object) {
ColumnSet columnSet = null;
TdColumn tdColumn = null;
if (leftElement instanceof TdColumn) {
tdColumn = (TdColumn) leftElement;
columnSet = ColumnHelper.getColumnOwnerAsColumnSet(tdColumn);
}
if (columnSet == null) {
return Boolean.FALSE;
}
String pkName = object.getName();
PrimaryKey primaryKey = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createPrimaryKey();
primaryKey.setName(pkName);
if (columnSet instanceof Table) {
primaryKey = TableHelper.addPrimaryKey((TdTable) columnSet, primaryKey);
if (tdColumn != null) {
tdColumn.getUniqueKey().add(primaryKey);
}
}
return Boolean.TRUE;
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class UpdateTdRelationalSwitch method caseTdColumn.
@Override
public Boolean caseTdColumn(TdColumn object) {
if (recentElement instanceof TdColumn) {
TdColumn c = (TdColumn) recentElement;
object.setName(c.getName());
object.setLength(c.getLength());
// MOD klliu update the c.getJavaType()
object.getSqlDataType().setJavaDataType(c.getSqlDataType().getJavaDataType());
// ADD msjian TDQ-8546: fix the oracle nullable wrong after reload column list
object.setNullable(c.isNullable());
return true;
}
return false;
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class RowMatchingAnalysisExecutor method getTableName.
/**
* DOC scorreia Comment method "getTableName".
*
* @param columnSetA
* @return
*/
private String getTableName(EList<TdColumn> columnSetA) {
String tableName = null;
for (TdColumn column : columnSetA) {
if (column == null) {
continue;
}
if (column.eIsProxy()) {
column = (TdColumn) EObjectHelper.resolveObject(column);
}
if (belongToSameSchemata(column)) {
ColumnSet columnSetOwner = ColumnHelper.getColumnOwnerAsColumnSet(column);
if (columnSetOwner == null) {
// $NON-NLS-1$
log.error(Messages.getString("FunctionalDependencyExecutor.COLUMNSETOWNERISNULL", column.getName()));
continue;
} else {
tableName = dbms().getQueryColumnSetWithPrefix(column);
// ~11005
this.catalogOrSchema = getCatalogOrSchemaName(column);
// all columns should belong to the same table
break;
}
} else {
log.error(getErrorMessage());
}
}
return quote(tableName);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class MultiColumnAnalysisExecutor method instantiateQuery.
/**
* DOC scorreia Comment method "instantiateQuery".
*
* @param indicator
*/
private void instantiateQuery(Indicator indicator) {
if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
ColumnSetMultiValueIndicator colSetMultValIndicator = (ColumnSetMultiValueIndicator) indicator;
final EList<ModelElement> analyzedColumns = colSetMultValIndicator.getAnalyzedColumns();
final EList<String> numericFunctions = initializeNumericFunctions(colSetMultValIndicator);
final EList<String> dateFunctions = initializeDateFunctions(colSetMultValIndicator);
// ADD msjian 2011-5-30 17479: Excel Odbc connection can not run well on the correlation analysis
// note: this feature is not supported now, if support, delete this
// $NON-NLS-1$
final String caseStr = "SUM(CASE WHEN {0} IS NULL THEN 1 ELSE 0 END)";
if (// $NON-NLS-1$
"EXCEL".equals(dbms().getDbmsName()) && (dateFunctions.contains(caseStr) || numericFunctions.contains(caseStr))) {
// $NON-NLS-1$
setError(Messages.getString("MultiColumnAnalysisExecutor.errMessage"));
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("MultiColumnAnalysisExecutor.errTitle"), // $NON-NLS-1$
getErrorMessage());
return;
}
});
}
// ~
// get indicator definition
final Expression sqlGenericExpression = dbms().getSqlExpression(indicator.getIndicatorDefinition());
// separate nominal from numeric columns
List<String> nominalColumns = new ArrayList<String>();
for (ModelElement column : colSetMultValIndicator.getNominalColumns()) {
nominalColumns.add(getQuotedColumnName(column));
}
List<String> computedColumns = new ArrayList<String>();
for (ModelElement column : colSetMultValIndicator.getNumericColumns()) {
// call functions for each column
for (String f : numericFunctions) {
computedColumns.add(replaceVariablesLow(f, getQuotedColumnName(column)));
}
}
for (ModelElement column : colSetMultValIndicator.getDateColumns()) {
// call functions for each column
for (String f : dateFunctions) {
computedColumns.add(replaceVariablesLow(f, getQuotedColumnName(column)));
}
}
// add count(*)
computedColumns.add(colSetMultValIndicator.getCountAll());
// MOD msjian TDQ-7254: fix the columnset analysis run get error. the columnset analysis don't need to
// consider the datamining type.
List<String> columns = new ArrayList<String>();
// if the analysis type is columnset, use analyzed columns
if (AnalysisType.COLUMN_SET == cachedAnalysis.getParameters().getAnalysisType()) {
for (ModelElement column : analyzedColumns) {
columns.add(getQuotedColumnName(column));
}
} else {
columns = nominalColumns;
}
// TDQ-7254~
String selectItems = createSelect(columns, computedColumns);
String grpByClause = createGroupBy(columns);
// all columns must belong to the same table
TdColumn firstColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(analyzedColumns.get(0));
String tableName = dbms().getQueryColumnSetWithPrefix(firstColumn);
this.catalogOrSchema = dbms().getCatalogOrSchemaName(firstColumn);
// definition is SELECT <%=__COLUMN_NAMES__%> FROM <%=__TABLE_NAME__%> GROUP BY
// <%=__GROUP_BY_ALIAS__%>
String sqlExpr = dbms().fillGenericQueryWithColumnTableAndAlias(sqlGenericExpression.getBody(), selectItems, tableName, grpByClause);
// handle data filter
String stringDataFilter = ContextHelper.getDataFilterWithoutContext(cachedAnalysis);
if (stringDataFilter == null) {
stringDataFilter = PluginConstant.EMPTY_STRING;
}
sqlExpr = dbms().addWhereToStatement(sqlExpr, stringDataFilter);
indicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(sqlGenericExpression.getLanguage(), sqlExpr));
// MOD qiongli 2011-3-30 feature 19192.allow drill down for sql engine.
if (ColumnsetPackage.eINSTANCE.getSimpleStatIndicator().isSuperTypeOf(indicator.eClass())) {
SimpleStatIndicator simpleIndicator = (SimpleStatIndicator) indicator;
// MOD TDQ-7287 lost some columns(type!=norminal) when view values in column set ana. yyin 20130514
String columnsName = createSelect(columns, new ArrayList<String>());
for (Indicator leafIndicator : simpleIndicator.getLeafIndicators()) {
final Expression leafSqlGenericExpression = dbms().getSqlExpression(leafIndicator.getIndicatorDefinition());
String leafSqlExpr = dbms().fillGenericQueryWithColumnTableAndAlias(leafSqlGenericExpression.getBody(), columnsName, tableName, grpByClause);
leafSqlExpr = dbms().addWhereToStatement(leafSqlExpr, stringDataFilter);
leafIndicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(leafSqlGenericExpression.getLanguage(), leafSqlExpr));
}
}
}
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class AbstractComparisonLevel method upperCase.
private void upperCase(EObject eObject) {
Package pckg = SwitchHelpers.PACKAGE_SWITCH.doSwitch(eObject);
ColumnSet columnSet = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(eObject);
TdColumn column = SwitchHelpers.COLUMN_SWITCH.doSwitch(eObject);
if (column != null) {
// $NON-NLS-1$
column.setName(column.getName() == null ? "" : column.getName().toUpperCase());
// $NON-NLS-1$
column.setLabel(column.getLabel() == null ? "" : column.getLabel().toUpperCase());
column.getSqlDataType().setName(// $NON-NLS-1$
column.getSqlDataType().getName() == null ? "" : column.getSqlDataType().getName().toUpperCase());
// $NON-NLS-1$
column.setContentType(column.getContentType() == null ? "" : column.getContentType().toUpperCase());
// $NON-NLS-1$
column.setSourceType(column.getSourceType() == null ? "" : column.getSourceType().toUpperCase());
} else if (pckg != null) {
// $NON-NLS-1$
pckg.setName(pckg.getName() == null ? "" : pckg.getName().toUpperCase());
} else if (columnSet != null) {
// $NON-NLS-1$
columnSet.setName(columnSet.getName() == null ? "" : columnSet.getName().toUpperCase());
}
}
Aggregations