use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.
the class MetadataHelper method setDefaultDataminingType.
/**
* Set the DataminingType according to the Column Type.
*
* @param modelElement
*/
public static void setDefaultDataminingType(ModelElement modelElement) {
if (modelElement == null) {
return;
}
DataminingType type = getDataminingType(modelElement);
if (type == null) {
type = getDefaultDataminingType(0);
}
TaggedValueHelper.setTaggedValue(modelElement, TaggedValueHelper.DATA_CONTENT_TYPE_TAGGED_VAL, type.getLiteral());
}
use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.
the class ColumnSetMultiValueIndicatorImpl method isSameMiningType.
private Boolean isSameMiningType(ModelElement column, DataminingType type) {
// MOD yyi 2011-02-25 16660: edit connection, save it will get error
final MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(column);
final TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(column);
if (tdColumn == null && mdColumn == null) {
if (column == null) {
log.error("The list of analyzed column contains a null column");
} else {
log.error("Analyzed element should be a TdColumn instead of a Column. Analyzed element is " + column.getName());
}
// Column which is null is not a nominal type.
return false;
}
// MOD qiongli 2011-3-8.fetature 19192,add mdColumn for MetadataColumn(delimited file)
DataminingType dataminingType = MetadataHelper.getDataminingType(column);
if (dataminingType != null && type == dataminingType) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.
the class DbmsLanguage method castColumn4ColumnAnalysisSqlExecutor.
/**
* Method "castColumn".
*
* @param indicator
* @param tdColumn
* @param colName the name of the given column (tdColumn.getName() ) (could contain quotes)
* @return
*/
public String castColumn4ColumnAnalysisSqlExecutor(Indicator indicator, TdColumn tdColumn, String colName) {
int javaType = tdColumn.getSqlDataType().getJavaDataType();
boolean isText = Java2SqlType.isTextInSQL(javaType);
String contentType = tdColumn.getContentType();
DataminingType dataminingType = DataminingType.get(contentType);
if (DataminingType.INTERVAL.equals(dataminingType) && (isText)) {
// cast is needed
// MOD qiongli 2011-4-18,bug 16723(data cleansing),handle date
boolean isDate = Java2SqlType.isDateInSQL(javaType);
if (isDate) {
// $NON-NLS-1$//$NON-NLS-2$
return "CAST(" + colName + " AS DATE)";
}
boolean isNumeric = Java2SqlType.isNumbericInSQL(javaType);
if (isNumeric) {
// $NON-NLS-1$ //$NON-NLS-2$
return "CAST(" + colName + " AS DECIMAL)";
}
}
return colName;
}
use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.
the class IndicatorImpl method getDataminingType.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public DataminingType getDataminingType() {
ModelElement elt = getAnalyzedElement();
if (elt == null) {
return getDataminingTypeGen();
}
TdColumn col = SwitchHelpers.COLUMN_SWITCH.doSwitch(elt);
if (col == null) {
return getDataminingTypeGen();
}
DataminingType type = MetadataHelper.getDataminingType(col);
if (type == null) {
// try the default code
return getDataminingTypeGen();
}
return type;
}
use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.
the class ColumnAnalysisDetailsPage method saveAnalysis.
/**
* @param outputFolder
* @throws DataprofilerCoreException
*/
@Override
public void saveAnalysis() throws DataprofilerCoreException {
analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
analysisHandler.clearAnalysis();
Analysis analysis = analysisHandler.getAnalysis();
for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
domain.setName(getCurrentModelElement().getName());
}
analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
// save the number of connections per analysis
this.saveNumberOfConnectionsPerAnalysis();
try {
// MOD zshen feature 12919 to save analysisParameter.
analysis.getParameters().setMaxNumberRows(Integer.parseInt(maxNumText.getText()));
} catch (NumberFormatException nfe) {
// $NON-NLS-1$
MessageDialogWithToggle.openError(// $NON-NLS-1$
null, // $NON-NLS-1$
DefaultMessagesImpl.getString("AbstractAnalysisMetadataPage.SaveAnalysis"), // $NON-NLS-1$
DefaultMessagesImpl.getString(// $NON-NLS-1$
"ColumnMasterDetailsPage.emptyField", // $NON-NLS-1$
DefaultMessagesImpl.getString("ColumnMasterDetailsPage.maxNumberLabel")));
maxNumText.setText(String.valueOf(analysis.getParameters().getMaxNumberRows()));
}
analysis.getParameters().setStoreData(drillDownCheck.getSelection());
// ~12919
ModelElementIndicator[] modelElementIndicators = this.getCurrentModelElementIndicators();
if (modelElementIndicators != null && modelElementIndicators.length != 0) {
Connection tdProvider = ModelElementIndicatorHelper.getTdDataProvider(modelElementIndicators[0]);
if (tdProvider.eIsProxy()) {
// Resolve the connection again
tdProvider = (Connection) EObjectHelper.resolveObject(tdProvider);
}
analysis.getContext().setConnection(tdProvider);
for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
IRepositoryViewObject reposObject = modelElementIndicator.getModelElementRepositoryNode().getObject();
ModelElement modelEle = null;
if (reposObject instanceof MetadataColumnRepositoryObject) {
modelEle = ((MetadataColumnRepositoryObject) reposObject).getTdColumn();
}
analysisHandler.addIndicator(modelEle, modelElementIndicator.getIndicators());
DataminingType type = MetadataHelper.getDataminingType(modelEle);
if (type == null) {
type = MetadataHelper.getDefaultDataminingType(modelElementIndicator.getJavaType());
}
analysisHandler.setDatamingType(type.getLiteral(), modelEle);
}
} else {
analysis.getContext().setConnection(null);
}
analysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
// 2011.1.12 MOD by zshen to unify anlysis and connection id when saving.
this.nameText.setText(analysisHandler.getName());
TaggedValueHelper.setTaggedValue(getCurrentModelElement(), TaggedValueHelper.IS_USE_SAMPLE_DATA, isRunWithSampleData.toString());
// TDQ-5581,if has removed emlements(patten/udi),should remove dependency each other before saving.
// MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(getCurrentRepNode().getObject().getProperty().getItem(), true);
// MOD yyi 2012-02-03 TDQ-3602:Avoid to rewriting all analyzes after saving, no reason to update all analyzes
// which is depended in the referred connection.
// Extract saving log function.
// @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#logSaved(ReturnCode)
logSaved(saved);
treeViewer.setDirty(false);
dataFilterComp.setDirty(false);
}
Aggregations