use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisResultPage method createResultSection.
@Override
protected void createResultSection(Composite parent) {
resultSection = createSection(form, parent, DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.analysisResults"), // $NON-NLS-1$ //$NON-NLS-2$
"");
Composite sectionClient = toolkit.createComposite(resultSection);
sectionClient.setLayout(new GridLayout(2, false));
sectionClient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
resultSection.setClient(sectionClient);
Analysis analysis = this.masterPage.getAnalysisHandler().getAnalysis();
EList<Indicator> indicators = analysis.getResults().getIndicators();
if (indicators.size() > 0) {
columnDependencyIndicator = (ColumnDependencyIndicator) indicators.get(0);
}
createTable(sectionClient);
if (canShowChartForResultPage()) {
createChart(sectionClient, analysis);
}
resultSection.layout();
}
use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class FunctionalDependencyExecutor method instantiateQuery.
private boolean instantiateQuery(Indicator indicator, DbmsLanguage dbmsLanguage) {
if (ColumnsetPackage.eINSTANCE.getColumnDependencyIndicator().equals(indicator.eClass())) {
ColumnDependencyIndicator rowMatchingIndicator = (ColumnDependencyIndicator) indicator;
TdColumn columnA = rowMatchingIndicator.getColumnA();
TdColumn columnB = rowMatchingIndicator.getColumnB();
IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
// SystemIndicator),the IndicatorDefinition maybe a proxy,should reset it.
if (indicatorDefinition == null || indicatorDefinition.eIsProxy()) {
// $NON-NLS-1$
indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition("Functional Dependency");
indicator.setIndicatorDefinition(indicatorDefinition);
}
Expression sqlGenericExpression = dbms().getSqlExpression(indicatorDefinition);
Expression instantiatedSqlExpression = createInstantiatedSqlExpression(sqlGenericExpression, columnA, columnB, dbmsLanguage);
indicator.setInstantiatedExpression(instantiatedSqlExpression);
return true;
}
traceError(Messages.getString("FunctionalDependencyExecutor.UNHANDLEDGIVENINDICATOR", // $NON-NLS-1$
AnalysisExecutorHelper.getIndicatorName(indicator)));
return Boolean.FALSE;
}
use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnCompareTreeViewer method updateModelViewer.
@Override
public void updateModelViewer() {
if (analysis.getResults().getIndicators().size() != 0) {
EList<Indicator> indicators = analysis.getResults().getIndicators();
// ColumnDependencyIndicator and update view
if (indicators.get(0) instanceof ColumnDependencyIndicator) {
columnListA.clear();
columnListB.clear();
ColumnDependencyIndicator cdi = null;
for (int i = 0; i < indicators.size(); i++) {
cdi = (ColumnDependencyIndicator) indicators.get(i);
columnListA.add(RepositoryNodeHelper.recursiveFind(cdi.getColumnA()));
columnListB.add(RepositoryNodeHelper.recursiveFind(cdi.getColumnB()));
}
tableViewerPosStack.get(0).setInput(columnListA);
tableViewerPosStack.get(1).setInput(columnListB);
} else {
RowMatchingIndicator rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
columnListA.clear();
for (TdColumn tdColumn : rowMatchingIndicatorA.getColumnSetA()) {
columnListA.add(RepositoryNodeHelper.recursiveFind(tdColumn));
}
tableViewerPosStack.get(0).setInput(columnListA);
columnListB.clear();
// columnListB.addAll(rowMatchingIndicatorA.getColumnSetB());
for (TdColumn tdColumn : rowMatchingIndicatorA.getColumnSetB()) {
columnListB.add(RepositoryNodeHelper.recursiveFind(tdColumn));
}
tableViewerPosStack.get(1).setInput(columnListB);
}
} else {
// MOD mzhao bug 12766, 2010-04-22 refresh the viewer.
columnListA.clear();
columnListB.clear();
// MOD qiongli 2010-6-8, bug 13595
// tableViewerPosStack.get(0).setInput(null);
// tableViewerPosStack.get(1).setInput(null);
tableViewerPosStack.get(0).setInput(columnListA);
tableViewerPosStack.get(1).setInput(columnListB);
// ~
}
}
use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator in project tdq-studio-se by Talend.
the class ChangeConnectionAction method synAnalyzedElements.
private boolean synAnalyzedElements(AnalyzedElementSynDialog anaEleSynDialog, Analysis synAnalysis, Connection oldDataProvider, Connection newDataProv) {
// Change connection uuid.
Map<ModelElement, ModelElement> synEleMap = anaEleSynDialog == null ? null : anaEleSynDialog.getSynedEleMap();
AnalysisBuilder anaBuilder = new AnalysisBuilder();
anaBuilder.setAnalysis(synAnalysis);
// Remove old dependencies.
boolean isRemovedDependency = DependenciesHandler.getInstance().removeConnDependencyAndSave(analysisItem);
if (!isRemovedDependency) {
return false;
}
synAnalysis.getContext().setConnection(newDataProv);
// Synchronize analysis result.
EList<Indicator> indcList = synAnalysis.getResults().getIndicators();
Indicator[] copiedIndArray = new Indicator[indcList.size()];
System.arraycopy(indcList.toArray(), 0, copiedIndArray, 0, indcList.size());
// MOD qiongli 2010-6-13,bug 12766:To column analysis, which has same
// construct connection with before and maybe have not indicator
boolean isExistSynedElement = false;
AnalysisType analysisType = synAnalysis.getParameters().getAnalysisType();
if (analysisType == AnalysisType.MULTIPLE_COLUMN) {
EList<ModelElement> meLs = synAnalysis.getContext().getAnalysedElements();
ModelElement[] mes = new ModelElement[meLs.size()];
System.arraycopy(meLs.toArray(), 0, mes, 0, meLs.size());
synAnalysis.getContext().getAnalysedElements().clear();
for (ModelElement me : mes) {
if (synEleMap != null && synEleMap.get(me) != null) {
TdColumn newColumn = (TdColumn) synEleMap.get(me);
synAnalysis.getContext().getAnalysedElements().add(newColumn);
isExistSynedElement = true;
}
}
}
if (!isExistSynedElement) {
synAnalysis.getContext().getAnalysedElements().clear();
}
// ~
synAnalysis.getResults().getIndicators().clear();
for (Indicator indicator : copiedIndArray) {
// connection.
if (indicator instanceof ColumnSetMultiValueIndicator) {
ColumnSetMultiValueIndicator compositeInd = (ColumnSetMultiValueIndicator) indicator;
ModelElement[] mes = new ModelElement[compositeInd.getAnalyzedColumns().size()];
((ColumnSetMultiValueIndicator) indicator).getAnalyzedColumns().toArray(mes);
compositeInd.getAnalyzedColumns().clear();
for (ModelElement me : mes) {
if (synEleMap != null && synEleMap.get(me) != null) {
TdColumn newColumn = (TdColumn) synEleMap.get(me);
DataminingType dataminingType = MetadataHelper.getDataminingType((TdColumn) me);
if (dataminingType == null) {
dataminingType = MetadataHelper.getDefaultDataminingType(((TdColumn) me).getSqlDataType().getJavaDataType());
}
MetadataHelper.setDataminingType(dataminingType, newColumn);
compositeInd.getAnalyzedColumns().add(newColumn);
anaBuilder.addElementToAnalyze(newColumn, indicator);
isExistSynedElement = true;
}
}
} else if (indicator instanceof ColumnsCompareIndicator) {
// Correlation compare
ColumnsCompareIndicator compInd = (ColumnsCompareIndicator) indicator;
if ((compInd.getColumnSetA() == null || compInd.getColumnSetA().size() == 0) || (compInd.getColumnSetB() == null || compInd.getColumnSetB().size() == 0)) {
return false;
}
// Column set(Columns)
ModelElement[] mesA = new ModelElement[compInd.getColumnSetA().size()];
compInd.getColumnSetA().toArray(mesA);
compInd.getColumnSetA().clear();
for (ModelElement me : mesA) {
if (synEleMap != null && synEleMap.get(me) != null) {
TdColumn newColumn = (TdColumn) synEleMap.get(me);
compInd.getColumnSetA().add(newColumn);
anaBuilder.addElementToAnalyze(newColumn, indicator);
isExistSynedElement = true;
}
}
ModelElement[] mesB = new ModelElement[compInd.getColumnSetB().size()];
compInd.getColumnSetB().toArray(mesB);
compInd.getColumnSetB().clear();
for (ModelElement me : mesB) {
if (synEleMap != null && synEleMap.get(me) != null) {
TdColumn newColumn = (TdColumn) synEleMap.get(me);
compInd.getColumnSetB().add(newColumn);
anaBuilder.addElementToAnalyze(newColumn, indicator);
isExistSynedElement = true;
}
}
// Analyzed element(Table)
ModelElement oldAnaEle = compInd.getAnalyzedElement();
compInd.setAnalyzedElement(null);
ColumnSet oldColSetA = ColumnHelper.getColumnOwnerAsColumnSet(mesA[0]);
ColumnSet oldColSetB = ColumnHelper.getColumnOwnerAsColumnSet(mesB[0]);
if (oldColSetA == oldAnaEle) {
if (synEleMap != null && synEleMap.get(mesA[0]) != null) {
compInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(mesA[0])));
}
}
if (oldColSetB == oldAnaEle) {
if (synEleMap != null && synEleMap.get(mesB[0]) != null) {
compInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(mesB[0])));
}
}
} else if (indicator instanceof ColumnDependencyIndicator) {
// ADD qiongli bug 0012766
// Functional Dependency indicator
ColumnDependencyIndicator funDepInd = (ColumnDependencyIndicator) indicator;
if (funDepInd.getColumnA() == null || funDepInd.getColumnB() == null) {
return false;
}
// Column A
if (synEleMap != null && synEleMap.get(funDepInd.getColumnA()) != null) {
TdColumn newColumn = (TdColumn) synEleMap.get(funDepInd.getColumnA());
funDepInd.setColumnA(newColumn);
anaBuilder.addElementToAnalyze(newColumn, indicator);
isExistSynedElement = true;
}
// Column B
if (synEleMap != null && synEleMap.get(funDepInd.getColumnB()) != null) {
TdColumn newColumn = (TdColumn) synEleMap.get(funDepInd.getColumnB());
funDepInd.setColumnB(newColumn);
anaBuilder.addElementToAnalyze(newColumn, indicator);
isExistSynedElement = true;
}
// Analyzed element(Table)
ModelElement oldAnaEle = funDepInd.getAnalyzedElement();
funDepInd.setAnalyzedElement(null);
ColumnSet oldColSetA = ColumnHelper.getColumnOwnerAsColumnSet(funDepInd.getColumnA());
ColumnSet oldColSetB = ColumnHelper.getColumnOwnerAsColumnSet(funDepInd.getColumnB());
if (oldColSetA == oldAnaEle) {
if (synEleMap != null && synEleMap.get(funDepInd.getColumnA()) != null) {
funDepInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(funDepInd.getColumnA())));
}
}
if (oldColSetB == oldAnaEle) {
if (synEleMap != null && synEleMap.get(funDepInd.getColumnB()) != null) {
funDepInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(funDepInd.getColumnB())));
}
}
} else {
ModelElement me = indicator.getAnalyzedElement();
if (synEleMap != null && synEleMap.get(me) != null) {
indicator.setAnalyzedElement(synEleMap.get(me));
if (analysisType == AnalysisType.MULTIPLE_COLUMN) {
synAnalysis.getResults().getIndicators().add(indicator);
} else {
anaBuilder.addElementToAnalyze(synEleMap.get(me), indicator);
}
isExistSynedElement = true;
}
}
}
return isExistSynedElement;
}
Aggregations