Search in sources :

Example 6 with Analysis

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

the class ResultPaginationInfo method createChart.

/**
 * DOC bZhou Comment method "createChart".
 *
 * @param comp
 * @param chartType
 * @param units
 */
private void createChart(Composite comp, EIndicatorChartType chartType, List<IndicatorUnit> units) {
    DynamicIndicatorModel dyModel = new DynamicIndicatorModel();
    // MOD TDQ-8787 20140618 yyin: to let the chart and table use the same dataset
    Object chart = null;
    Object dataset = null;
    // Added TDQ-8787 20140722 yyin:(when first switch from master to result) if there is some dynamic event for the
    // current indicator, use its dataset directly (TDQ-9241)
    IEventReceiver event = EventManager.getInstance().findRegisteredEvent(units.get(0).getIndicator(), EventEnum.DQ_DYMANIC_CHART, 0);
    // get the dataset from the event
    if (event != null) {
        dataset = ((DynamicChartEventReceiver) event).getDataset();
    }
    // ~
    // Added TDQ-8787 2014-06-18 yyin: add the current units and dataset into the list
    List<Indicator> indicators = null;
    dyModel.setChartType(chartType);
    this.dynamicList.add(dyModel);
    if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
        // for the summary indicators, the table show 2 more than the bar chart
        dyModel.setSummaryIndicators(getIndicatorsForTable(units, true));
    }
    // create UI
    ExpandableComposite subComp = uiPagination.getToolkit().createExpandableComposite(comp, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
    subComp.setText(chartType.getLiteral());
    subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    // MOD xqliu 2009-06-23 bug 7481
    subComp.setExpanded(EditorPreferencePage.isUnfoldingIndicatorsResultPage());
    // ~
    final Composite composite = uiPagination.getToolkit().createComposite(subComp, SWT.NULL);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Analysis analysis = masterPage.getAnalysisHandler().getAnalysis();
    // create table viewer firstly
    ITableTypeStates tableTypeState = TableTypeStatesFactory.getInstance().getTableState(chartType, units);
    ChartDataEntity[] dataEntities = tableTypeState.getDataEntity();
    TableWithData chartData = new TableWithData(chartType, dataEntities);
    TableViewer tableviewer = tableTypeState.getTableForm(composite);
    tableviewer.setInput(chartData);
    tableviewer.getTable().pack();
    dyModel.setTableViewer(tableviewer);
    DataExplorer dataExplorer = tableTypeState.getDataExplorer();
    ChartTableFactory.addMenuAndTip(tableviewer, dataExplorer, analysis);
    if (EIndicatorChartType.TEXT_STATISTICS.equals(chartType) && dataEntities != null && dataEntities.length > 0) {
        // only text indicator need
        indicators = getIndicators(dataEntities);
    } else {
        indicators = getIndicators(units);
    }
    dyModel.setIndicatorList(indicators);
    // create chart
    try {
        if (!EditorPreferencePage.isHideGraphicsForResultPage() && TOPChartUtils.getInstance().isTOPChartInstalled()) {
            IChartTypeStates chartTypeState = ChartTypeStatesFactory.getChartState(chartType, units);
            boolean isPattern = chartTypeState instanceof PatternStatisticsState;
            if (event == null) {
                chart = chartTypeState.getChart();
                if (chart != null && isSQLMode) {
                    // chart is null for MODE. Get the dataset by this way for SQL mode
                    if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType)) {
                        dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 2);
                        if (dataset == null) {
                            dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
                        }
                        dyModel.setSecondDataset(TOPChartUtils.getInstance().getDatasetFromChart(chart, 0));
                    } else {
                        dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
                        if (dataset == null) {
                            dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, -1);
                        }
                    }
                }
            } else {
                chart = chartTypeState.getChart(dataset);
            }
            dyModel.setDataset(dataset);
            if (chart != null) {
                if (!isPattern) {
                    // need not to decorate the chart of Pattern(Regex/Sql/UdiMatch)
                    TOPChartUtils.getInstance().decorateChart(chart, false);
                } else {
                    TOPChartUtils.getInstance().decoratePatternMatching(chart);
                }
                Object chartComposite = TOPChartUtils.getInstance().createTalendChartComposite(composite, SWT.NONE, chart, true);
                dyModel.setBawParentChartComp(chartComposite);
                Map<String, Object> menuMap = createMenuForAllDataEntity((Composite) chartComposite, dataExplorer, analysis, ((ICustomerDataset) chartTypeState.getDataset()).getDataEntities());
                // call chart service to create related mouse listener
                if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType) || EIndicatorChartType.FREQUENCE_STATISTICS.equals(chartType)) {
                    TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, false);
                } else {
                    TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, true);
                }
            }
        }
    // TDQ-11886 add these 2 catches.make it continue to work even if encounter some problems.
    } catch (Error e) {
        // $NON-NLS-1$
        log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), e);
    } catch (Exception exp) {
        // $NON-NLS-1$
        log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), exp);
    }
    subComp.setClient(composite);
    subComp.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    masterPage.registerSection(subComp);
}
Also used : IEventReceiver(org.talend.dataprofiler.core.ui.events.IEventReceiver) DataExplorer(org.talend.dq.analysis.explore.DataExplorer) TableWithData(org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData) GridLayout(org.eclipse.swt.layout.GridLayout) DynamicIndicatorModel(org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataprofiler.core.ui.editor.preview.CompositeIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) IChartTypeStates(org.talend.dataprofiler.core.ui.editor.preview.model.states.IChartTypeStates) ITableTypeStates(org.talend.dataprofiler.core.ui.editor.preview.model.states.table.ITableTypeStates) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) PatternStatisticsState(org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticsState) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TableViewer(org.eclipse.jface.viewers.TableViewer) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 7 with Analysis

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

the class AbstractAnalysisMetadataPage method getAnalysisRepNodeFromInput.

/**
 * get AnalysisRepNode From editorInput
 *
 * @param editorInput
 * @return
 */
private IRepositoryNode getAnalysisRepNodeFromInput(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
        IFile file = fileEditorInput.getFile();
        if (file != null) {
            Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(file);
            analysis = (Analysis) EObjectHelper.resolveObject(analysis);
            return RepositoryNodeHelper.recursiveFindAnalysis(analysis);
        }
    } else if (editorInput instanceof AnalysisItemEditorInput) {
        return ((AnalysisItemEditorInput) editorInput).getRepNode();
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) Analysis(org.talend.dataquality.analysis.Analysis) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 8 with Analysis

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

the class AbstractAnalysisMetadataPage method updateDQRuleDependency.

/**
 * ADD gdbu 2011-6-1 bug : 19833
 *
 * DOC gdbu Comment method "updateDQRuleDependency".
 *
 * @param dqRules
 */
protected void updateDQRuleDependency(List<DQRule> dqRules) {
    for (DQRule dqRule : dqRules) {
        List<Dependency> realSupplierDependency = new ArrayList<Dependency>();
        EList<Dependency> supplierDependency = dqRule.getSupplierDependency();
        for (Dependency dependency : supplierDependency) {
            EList<ModelElement> client = dependency.getClient();
            for (ModelElement modelElement : client) {
                if (modelElement instanceof Analysis) {
                    List<DQRule> dqRules2 = getDqRules((Analysis) modelElement);
                    if (dqRules2.contains(dqRule)) {
                        realSupplierDependency.add(dependency);
                    }
                }
            }
        }
        supplierDependency.clear();
        supplierDependency.addAll(realSupplierDependency);
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) Dependency(orgomg.cwm.objectmodel.core.Dependency) DQRule(org.talend.dataquality.rules.DQRule)

Example 9 with Analysis

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

the class AbstractAnalysisMetadataPage method saveContext.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.AbstractMetadataFormPage#saveContext()
     */
@Override
protected void saveContext() {
    // save contexts
    Analysis analysis = getCurrentModelElement();
    IContextManager contextManager = currentEditor.getContextManager();
    contextManager.saveToEmf(analysis.getContextType());
    analysis.setDefaultContext(getDefaultContextGroupName((SupportContextEditor) currentEditor));
    AnalysisHelper.setLastRunContext(currentEditor.getLastRunContextGroupName(), analysis);
}
Also used : SupportContextEditor(org.talend.dataprofiler.core.ui.editor.SupportContextEditor) Analysis(org.talend.dataquality.analysis.Analysis) IContextManager(org.talend.core.model.process.IContextManager)

Example 10 with Analysis

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

the class AbstractAnalysisMetadataPage method logSaved.

/**
 * log when analysis saved
 *
 * @param saved
 * @throws DataprofilerCoreException
 */
protected void logSaved(ReturnCode saved) throws DataprofilerCoreException {
    Analysis analysis = getCurrentModelElement();
    String urlString = analysis.eResource() != null ? (analysis.eResource().getURI().isFile() ? analysis.eResource().getURI().toFileString() : analysis.eResource().getURI().toString()) : PluginConstant.EMPTY_STRING;
    if (!saved.isOk()) {
        throw new DataprofilerCoreException(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.problem", analysis.getName(), urlString, // $NON-NLS-1$
        saved.getMessage()));
    } else if (log.isDebugEnabled()) {
        // MOD yyi 2012-02-06 TDQ-4581:avoid the instantiation of the strings to optimize the performances.
        // $NON-NLS-1$
        doLog(log, Level.INFO, DefaultMessagesImpl.getString("ColumnMasterDetailsPage.success", urlString));
    }
}
Also used : DataprofilerCoreException(org.talend.dataquality.exception.DataprofilerCoreException) Analysis(org.talend.dataquality.analysis.Analysis)

Aggregations

Analysis (org.talend.dataquality.analysis.Analysis)137 Test (org.junit.Test)36 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)36 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)30 ArrayList (java.util.ArrayList)28 Property (org.talend.core.model.properties.Property)28 Indicator (org.talend.dataquality.indicators.Indicator)27 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)27 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)26 PersistenceException (org.talend.commons.exception.PersistenceException)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)18 ReturnCode (org.talend.utils.sugars.ReturnCode)18 Dependency (orgomg.cwm.objectmodel.core.Dependency)18 TdColumn (org.talend.cwm.relational.TdColumn)16 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)16 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 Pattern (org.talend.dataquality.domain.pattern.Pattern)15 IFile (org.eclipse.core.resources.IFile)14 File (java.io.File)12 IPath (org.eclipse.core.runtime.IPath)12