use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisDetailsPage method saveAnalysis.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#saveAnalysis()
*/
@Override
protected void saveAnalysis() throws DataprofilerCoreException {
analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
domain.setName(getCurrentModelElement().getName());
}
IRepositoryViewObject reposObject = null;
getAnalysisHandler().clearAnalysis();
List<RepositoryNode> columnListAANode = anaColumnCompareViewer.getColumnListA();
List<RepositoryNode> columnListBBNode = anaColumnCompareViewer.getColumnListB();
AnalysisBuilder anaBuilder = new AnalysisBuilder();
anaBuilder.setAnalysis(getCurrentModelElement());
Connection tdDataProvider = null;
for (int i = 0; i < columnListAANode.size(); i++) {
if (columnListBBNode.size() > i) {
ColumnDependencyIndicator indicator = ColumnsetFactory.eINSTANCE.createColumnDependencyIndicator();
TdColumn columnA = (TdColumn) ((MetadataColumnRepositoryObject) columnListAANode.get(i).getObject()).getTdColumn();
TdColumn columnB = (TdColumn) ((MetadataColumnRepositoryObject) columnListBBNode.get(i).getObject()).getTdColumn();
indicator.setColumnA(columnA);
indicator.setColumnB(columnB);
indicator.setIndicatorDefinition(DefinitionHandler.getInstance().getFDRuleDefaultIndicatorDefinition());
getCurrentModelElement().getResults().getIndicators().add(indicator);
anaBuilder.addElementToAnalyze(columnA, indicator);
// ADD this line qiongli 2010-6-8
anaBuilder.addElementToAnalyze(columnB, indicator);
}
}
if (columnListAANode.size() > 0) {
reposObject = columnListAANode.get(0).getObject();
tdDataProvider = ((ConnectionItem) reposObject.getProperty().getItem()).getConnection();
// MOD qiongli bug 14437:Add dependency
getCurrentModelElement().getContext().setConnection(tdDataProvider);
TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(getCurrentModelElement(), tdDataProvider);
if (!rc.isOk()) {
// $NON-NLS-1$
log.info("fail to save dependency analysis:" + getCurrentModelElement().getFileName());
}
} else {
getCurrentModelElement().getContext().setConnection(null);
}
// save the number of connections per analysis
this.saveNumberOfConnectionsPerAnalysis();
// 2011.1.12 MOD by zhsne to unify anlysis and connection id when saving.
this.nameText.setText(getCurrentModelElement().getName());
// 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);
anaColumnCompareViewer.setDirty(false);
dataFilterComp.setDirty(false);
}
use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisResultPage method initCustomerDataset.
/**
* DOC xqliu Comment method "initCustomerDataset".
*
* @return
*/
private CustomerDefaultCategoryDataset initCustomerDataset() {
CustomerDefaultCategoryDataset dataset = new CustomerDefaultCategoryDataset();
Analysis analysis = this.getAnalysisHandler().getAnalysis();
for (Indicator indicator2 : analysis.getResults().getIndicators()) {
ColumnDependencyIndicator indicator = (ColumnDependencyIndicator) indicator2;
String label = ColumnDependencyHelper.getIndicatorName(indicator);
if (getAnalysisHandler().getResultMetadata().getExecutionNumber() > 0) {
Long matchCount = indicator.getDistinctACount() == null ? 0 : indicator.getDistinctACount();
Long notMatchCount = indicator.getACount() == null ? 0 : indicator.getACount() - matchCount;
// $NON-NLS-1$
dataset.addValue(matchCount, DefaultMessagesImpl.getString("ColumnDependencyResultPage.Match"), label);
// $NON-NLS-1$
dataset.addValue(notMatchCount, DefaultMessagesImpl.getString("ColumnDependencyResultPage.NotMatch"), label);
PatternChartDataEntity dataEntity = new PatternChartDataEntity();
dataEntity.setLabel(label);
dataEntity.setIndicator(indicator);
dataEntity.setNumMatch(matchCount.toString());
dataEntity.setNumNoMatch(notMatchCount.toString());
dataset.addDataEntity(dataEntity);
}
}
return dataset;
}
use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class ColumnDependencyExplorer method getDetailedInvalidValuesStatement.
private String getDetailedInvalidValuesStatement() {
// MOD by zshen fixed 12039 to distinguish the same name of column.
String genericSQL = dbmsLanguage.getFDGenericInvalidDetailedValues();
ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
TdColumn columnA = cdIndicator.getColumnA();
TdColumn columnB = cdIndicator.getColumnB();
if (columnA.getName().equals(columnB.getName())) {
genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_A, // $NON-NLS-1$
dbmsLanguage.quote(columnA.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
"_A");
genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_B, // $NON-NLS-1$
dbmsLanguage.quote(columnB.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
"_B");
}
return getStatement(genericSQL);
}
use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class ColumnDependencyExplorer method getDetailedValidValuesStatement.
private String getDetailedValidValuesStatement() {
// MOD by zshen fixed 12039 to distinguish the same name of column.
String genericSQL = dbmsLanguage.getFDGenericValidDetailedValues();
ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
TdColumn columnA = cdIndicator.getColumnA();
TdColumn columnB = cdIndicator.getColumnB();
if (columnA.getName().equals(columnB.getName())) {
genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_A, // $NON-NLS-1$
dbmsLanguage.quote(columnA.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
"_A");
genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_B, // $NON-NLS-1$
dbmsLanguage.quote(columnB.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
"_B");
}
return getStatement(genericSQL);
}
use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator 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;
}
Aggregations