Search in sources :

Example 11 with AnalysisType

use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.

the class PatternMouseAdapter method getPatternSelectDialogInputData.

/**
 * DOC msjian Comment method "getPatternSelectDialogInputData".
 *
 * @return
 */
private IRepositoryNode getPatternSelectDialogInputData() {
    IRepositoryNode patternFolderNode = null;
    // MOD qiongli 2011-6-16 bug 21768,pattern in columnset just support java engine.
    AnalysisType analysisType = analysis.getParameters().getAnalysisType();
    // MOD yyin 20131204 TDQ-8413, use the current selected value to judge, no need to save the analysis
    String executionLanguage = masterPage.getCurrentExecuteLanguage();
    if (AnalysisType.COLUMN_SET.equals(analysisType)) {
        if (ExecutionLanguage.SQL.getLiteral().equals(executionLanguage)) {
            // $NON-NLS-1$
            MessageUI.openWarning(DefaultMessagesImpl.getString("PatternMouseAdapter.noSupportForSqlEngine"));
            return patternFolderNode;
        } else if (ExecutionLanguage.JAVA.getLiteral().equals(executionLanguage)) {
            patternFolderNode = AnalysisUtils.getSelectDialogInputData(EResourceConstant.PATTERN_REGEX);
        }
    } else if (AnalysisType.MULTIPLE_COLUMN.equals(analysisType)) {
        if (ExecutionLanguage.JAVA.getLiteral().equals(executionLanguage)) {
            patternFolderNode = AnalysisUtils.getSelectDialogInputData(EResourceConstant.PATTERN_REGEX);
        }
    }
    if (null == patternFolderNode) {
        patternFolderNode = AnalysisUtils.getSelectDialogInputData(EResourceConstant.PATTERNS);
    }
    return patternFolderNode;
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 12 with AnalysisType

use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.

the class DrillDownResultEditor method initTableViewerForMapDB.

/**
 * DOC talend Comment method "initTableViewerForMapDB".
 *
 * @param parent
 * @param table
 * @param ddEditorInput
 */
@SuppressWarnings("unchecked")
private void initTableViewerForMapDB(final Composite parent, final Table table, DrillDownEditorInput ddEditorInput) {
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    tableView.setLabelProvider(new DrillDownResultLabelProvider());
    tableView.setContentProvider(new DrillDownResultContentProvider());
    // set page size
    final PageableController controller = new PageableController(MapDBPageConstant.NUMBER_PER_PAGE);
    Object dataSetForMapDB = ddEditorInput.getDataSetForMapDB(controller.getPageSize());
    if (dataSetForMapDB == null) {
        log.error(DefaultMessagesImpl.getString("DrillDownResultEditor.drillDownError"), new RuntimeException(DefaultMessagesImpl.getString("DrillDownResultEditor.drillDownErrorMessage")));
    } else {
        table.setData(dataSetForMapDB);
    }
    // for columnSet analysis here only have one db file need to support drill down and data section
    Analysis analysis = ddEditorInput.getAnalysis();
    AnalysisType analysisType = analysis.getParameters().getAnalysisType();
    IPageLoader<PageResult<Object[]>> pageLoader = null;
    AbstractDB<Object> mapDB = ddEditorInput.getMapDB();
    Indicator generateMapDBIndicator = ddEditorInput.getGenerateMapDBIndicator();
    MapDBManager.getInstance().addDBRef(MapDBUtils.getMapDBFile(generateMapDBIndicator));
    Long itemsSize = ddEditorInput.getItemSize(mapDB);
    if (AnalysisType.COLUMN_SET == analysisType) {
        pageLoader = new MapDBPageLoader<Object>(mapDB, IDataValidationFactory.INSTANCE.createValidation(ddEditorInput.getCurrIndicator()), itemsSize);
    } else {
        // ~
        ColumnFilter filter = ddEditorInput.getColumnFilter();
        pageLoader = new MapDBPageLoader<Object>(mapDB, null, itemsSize, filter);
    }
    controller.addPageChangedListener(PageLoaderStrategyHelper.createLoadPageAndReplaceItemsListener(controller, tableView, pageLoader, PageResultContentProvider.getInstance(), null));
    controller.addPageChangedListener(new PageChangedAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.nebula.widgets.pagination.PageChangedAdapter#pageIndexChanged(int, int,
             * org.eclipse.nebula.widgets.pagination.PageableController)
             */
        @Override
        public void pageIndexChanged(int oldPageIndex, int newPageIndex, PageableController controller) {
            Object data = table.getData();
            if (data != null && SqlExplorerUtils.getDefault().isInstanceofTalendDataSet(data)) {
                long totalSize = controller.getTotalElements();
                long pageSize = controller.getPageSize();
                long pageIndex = controller.getPageOffset();
                long fromIndex = pageIndex;
                long toIndex = pageIndex + pageSize;
                if (toIndex > totalSize) {
                    toIndex = totalSize;
                }
                SqlExplorerUtils.getDefault().resetTalendDataSetIndex(data, fromIndex, toIndex);
                parent.layout();
            }
        }
    });
    // Create navigation page links
    ResultAndNavigationPageGraphicsRenderer resultAndNavigationPageGraphicsRenderer = new ResultAndNavigationPageGraphicsRenderer(parent, SWT.NONE, controller);
    resultAndNavigationPageGraphicsRenderer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    createColumns(tableView, controller, ((DrillDownEditorInput) this.getEditorInput()));
    // Set current page to 0 to refresh the table
    controller.setCurrentPage(0);
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) ResultAndNavigationPageGraphicsRenderer(org.eclipse.nebula.widgets.pagination.renderers.navigation.ResultAndNavigationPageGraphicsRenderer) PageableController(org.eclipse.nebula.widgets.pagination.PageableController) ColumnFilter(org.talend.cwm.indicator.ColumnFilter) PageResult(org.eclipse.nebula.widgets.pagination.collections.PageResult) Indicator(org.talend.dataquality.indicators.Indicator) Point(org.eclipse.swt.graphics.Point) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) PageChangedAdapter(org.eclipse.nebula.widgets.pagination.PageChangedAdapter)

Example 13 with AnalysisType

use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.

the class CreateNewAnalysisAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.cheatsheets.ICheatSheetAction#run(java.lang.String[],
     * org.eclipse.ui.cheatsheets.ICheatSheetManager)
     */
public void run(String[] params, ICheatSheetManager manager) {
    // ADD xqliu TDQ-4285 2011-12-27
    if (!CheatSheetActionHelper.canRun()) {
        return;
    }
    // passed parameter.
    if (params == null || params.length == 0) {
        return;
    }
    Integer analysisCatigory = null;
    if (NumberUtils.isNumber(params[0])) {
        analysisCatigory = NumberUtils.toInt(params[0]);
    }
    AnalysisType analysisType = null;
    Wizard wizard = null;
    if (analysisCatigory != null) {
        switch(analysisCatigory) {
            case AnalysisType.BUSINESS_RULE_VALUE:
                analysisType = AnalysisType.TABLE;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            case AnalysisType.TABLE_FUNCTIONAL_DEPENDENCY_VALUE:
                analysisType = AnalysisType.TABLE_FUNCTIONAL_DEPENDENCY;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            case AnalysisType.COLUMN_SET_VALUE:
                analysisType = AnalysisType.COLUMN_SET;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            case AnalysisType.MULTIPLE_COLUMN_VALUE:
                analysisType = AnalysisType.MULTIPLE_COLUMN;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            case AnalysisType.CATALOG_VALUE:
                analysisType = AnalysisType.CATALOG;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            case AnalysisType.SCHEMA_VALUE:
                analysisType = AnalysisType.SCHEMA;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            case AnalysisType.COLUMNS_COMPARISON_VALUE:
                analysisType = AnalysisType.COLUMNS_COMPARISON;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            case AnalysisType.COLUMN_CORRELATION_VALUE:
                analysisType = AnalysisType.COLUMN_CORRELATION;
                if (params[1] != null) {
                    if (NumberUtils.isNumber(params[1])) {
                        AnalysisLabelParameter parameter = new AnalysisLabelParameter();
                        parameter.setAnalysisTypeName(analysisType.getLiteral());
                        int correAnaType = NumberUtils.toInt(params[1]);
                        if (correAnaType == 0) {
                            parameter.setCategoryLabel(AnalysisLabelParameter.NUMBERIC_CORRELATION);
                        } else if (correAnaType == 1) {
                            parameter.setCategoryLabel(AnalysisLabelParameter.NOMINAL_CORRELATION);
                        } else {
                            parameter.setCategoryLabel(AnalysisLabelParameter.DATE_CORRELATION);
                        }
                        wizard = WizardFactory.createAnalysisWizard(analysisType, parameter);
                    }
                }
                break;
            case AnalysisType.MATCH_ANALYSIS_VALUE:
                analysisType = AnalysisType.MATCH_ANALYSIS;
                wizard = WizardFactory.createAnalysisWizard(analysisType);
                break;
            default:
                break;
        }
    }
    if (analysisType == null || wizard == null) {
        return;
    }
    wizard.setForcePreviousAndNextButtons(true);
    WizardDialog dialog = new WizardDialog(null, wizard);
    dialog.setPageSize(500, 340);
    if (WizardDialog.OK == dialog.open()) {
        ProxyRepositoryManager.getInstance().save();
    }
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) CreateNewAnalysisWizard(org.talend.dataprofiler.core.ui.wizard.analysis.CreateNewAnalysisWizard) Wizard(org.eclipse.jface.wizard.Wizard) OpeningHelpWizardDialog(org.talend.dataprofiler.core.ui.utils.OpeningHelpWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AnalysisLabelParameter(org.talend.dq.analysis.parameters.AnalysisLabelParameter)

Example 14 with AnalysisType

use of org.talend.dataquality.analysis.AnalysisType 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;
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) ColumnsCompareIndicator(org.talend.dataquality.indicators.columnset.ColumnsCompareIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) ColumnsCompareIndicator(org.talend.dataquality.indicators.columnset.ColumnsCompareIndicator) AnalysisBuilder(org.talend.dq.analysis.AnalysisBuilder)

Example 15 with AnalysisType

use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.

the class AnalysisCategoryImpl method unsetAnalysisType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void unsetAnalysisType() {
    AnalysisType oldAnalysisType = analysisType;
    boolean oldAnalysisTypeESet = analysisTypeESet;
    analysisType = ANALYSIS_TYPE_EDEFAULT;
    analysisTypeESet = false;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.UNSET, CategoryPackage.ANALYSIS_CATEGORY__ANALYSIS_TYPE, oldAnalysisType, ANALYSIS_TYPE_EDEFAULT, oldAnalysisTypeESet));
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

AnalysisType (org.talend.dataquality.analysis.AnalysisType)16 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3 Indicator (org.talend.dataquality.indicators.Indicator)3 ColumnFilter (org.talend.cwm.indicator.ColumnFilter)2 OpeningHelpWizardDialog (org.talend.dataprofiler.core.ui.utils.OpeningHelpWizardDialog)2 Analysis (org.talend.dataquality.analysis.Analysis)2 AnalysisLabelParameter (org.talend.dq.analysis.parameters.AnalysisLabelParameter)2 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 EObject (org.eclipse.emf.ecore.EObject)1 IContext (org.eclipse.help.IContext)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1