Search in sources :

Example 71 with Analysis

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

the class ColumnSetAnalysisDetailsPage method createPreviewSection.

void createPreviewSection(final ScrolledForm form, Composite parent) {
    previewSection = createSection(form, parent, DefaultMessagesImpl.getString("ColumnMasterDetailsPage.graphics"), // $NON-NLS-1$ //$NON-NLS-2$
    DefaultMessagesImpl.getString("ColumnMasterDetailsPage.space"));
    previewSection.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite sectionClient = toolkit.createComposite(previewSection);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setLayoutData(new GridData(GridData.FILL_BOTH));
    Button chartButton = new Button(sectionClient, SWT.NONE);
    // $NON-NLS-1$
    chartButton.setText(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.refreshGraphics"));
    final Label message = toolkit.createLabel(sectionClient, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ColumnMasterDetailsPage.spaceWhite"));
    message.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
    message.setVisible(false);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(sectionClient);
    chartComposite = toolkit.createComposite(sectionClient);
    chartComposite.setLayout(new GridLayout());
    chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    final Analysis analysis = columnSetAnalysisHandler.getAnalysis();
    chartButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            disposeChartComposite();
            boolean analysisStatue = analysis.getResults().getResultMetadata() != null && analysis.getResults().getResultMetadata().getExecutionDate() != null;
            if (!analysisStatue) {
                boolean returnCode = MessageDialog.openConfirm(null, // $NON-NLS-1$
                DefaultMessagesImpl.getString("ColumnMasterDetailsPage.ViewResult"), // $NON-NLS-1$
                DefaultMessagesImpl.getString("ColumnMasterDetailsPage.RunOrSeeSampleData"));
                if (returnCode) {
                    new RunAnalysisAction().run();
                    message.setVisible(false);
                } else {
                    createPreviewCharts(form, chartComposite, false);
                    // $NON-NLS-1$
                    message.setText(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.warning"));
                    message.setVisible(true);
                }
            } else {
                createPreviewCharts(form, chartComposite, true);
            }
            chartComposite.layout();
            form.reflow(true);
        }
    });
    previewSection.setClient(sectionClient);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Button(org.eclipse.swt.widgets.Button) Analysis(org.talend.dataquality.analysis.Analysis) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RunAnalysisAction(org.talend.dataprofiler.core.ui.action.actions.RunAnalysisAction)

Example 72 with Analysis

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

the class ColumnSetAnalysisDetailsPage method saveAnalysis.

/**
 * @param outputFolder
 * @throws DataprofilerCoreException
 */
@Override
public void saveAnalysis() throws DataprofilerCoreException {
    columnSetAnalysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    columnSetAnalysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    // columnSetAnalysisHandler.setName(columnSetAnalysisHandler.getName().replace(" ", ""));
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    // ~
    columnSetAnalysisHandler.clearAnalysis();
    simpleStatIndicator.getAnalyzedColumns().clear();
    allMatchIndicator.getAnalyzedColumns().clear();
    // set execute engine
    Analysis analysis = columnSetAnalysisHandler.getAnalysis();
    analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
    // set data filter
    columnSetAnalysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
    // save analysis
    List<IRepositoryNode> repositoryNodes = treeViewer.getColumnSetMultiValueList();
    Connection tdProvider = null;
    IRepositoryViewObject reposObject = null;
    if (repositoryNodes != null && repositoryNodes.size() != 0) {
        ConnectionItem item = (ConnectionItem) repositoryNodes.get(0).getObject().getProperty().getItem();
        tdProvider = item.getConnection();
        if (tdProvider.eIsProxy()) {
            // Resolve the connection again
            tdProvider = (Connection) EObjectHelper.resolveObject(tdProvider);
        }
        analysis.getContext().setConnection(tdProvider);
        List<ModelElement> columnList = new ArrayList<ModelElement>();
        for (IRepositoryNode rd : repositoryNodes) {
            reposObject = rd.getObject();
            columnList.add(((MetadataColumnRepositoryObject) reposObject).getTdColumn());
        }
        simpleStatIndicator.getAnalyzedColumns().addAll(columnList);
        columnSetAnalysisHandler.addIndicator(columnList, simpleStatIndicator);
        // ~ MOD mzhao feature 13040. 2010-05-21
        allMatchIndicator.getCompositeRegexMatchingIndicators().clear();
        ModelElementIndicator[] modelElementIndicator = treeViewer.getModelElementIndicator();
        if (modelElementIndicator != null) {
            for (ModelElementIndicator modelElementInd : modelElementIndicator) {
                Indicator[] inds = modelElementInd.getPatternIndicators();
                for (Indicator ind : inds) {
                    if (ind instanceof RegexpMatchingIndicator) {
                        // MOD yyi 2011-06-15 22419:column set pattern for MDM
                        IRepositoryViewObject obj = modelElementInd.getModelElementRepositoryNode().getObject();
                        ModelElement analyzedElt = ((MetadataColumnRepositoryObject) obj).getTdColumn();
                        ind.setAnalyzedElement(analyzedElt);
                        allMatchIndicator.getCompositeRegexMatchingIndicators().add((RegexpMatchingIndicator) ind);
                    }
                }
            }
        }
        if (allMatchIndicator.getCompositeRegexMatchingIndicators().size() > 0) {
            allMatchIndicator.getAnalyzedColumns().addAll(columnList);
            columnSetAnalysisHandler.addIndicator(columnList, allMatchIndicator);
        }
    // ~
    } else {
        analysis.getContext().setConnection(null);
    }
    TaggedValueHelper.setTaggedValue(getCurrentModelElement(), TaggedValueHelper.IS_USE_SAMPLE_DATA, isRunWithSampleData.toString());
    // 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(columnSetAnalysisHandler.getName());
    // TDQ-5581,if has removed emlements(patten),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);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) Domain(org.talend.dataquality.domain.Domain) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 73 with Analysis

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

the class CorrelationAnalysisDetailsPage method saveAnalysis.

/**
 * @param outputFolder
 * @throws DataprofilerCoreException
 */
@Override
public void saveAnalysis() throws DataprofilerCoreException {
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    IRepositoryViewObject reposObject = null;
    Connection tdProvider = null;
    correlationAnalysisHandler.clearAnalysis();
    columnSetMultiIndicator.getAnalyzedColumns().clear();
    // set execute engine
    Analysis analysis = correlationAnalysisHandler.getAnalysis();
    analysis.getParameters().setExecutionLanguage(ExecutionLanguage.get(execLang));
    // set data filter
    correlationAnalysisHandler.setStringDataFilter(dataFilterComp.getDataFilterString());
    // save analysis
    List<RepositoryNode> repositoryNodeList = treeViewer.getColumnSetMultiValueList();
    if (repositoryNodeList != null && !repositoryNodeList.isEmpty()) {
        reposObject = repositoryNodeList.get(0).getObject();
        tdProvider = ((ConnectionItem) reposObject.getProperty().getItem()).getConnection();
        analysis.getContext().setConnection(tdProvider);
        List<TdColumn> columnLst = new ArrayList<TdColumn>();
        for (RepositoryNode repNode : repositoryNodeList) {
            columnLst.add((TdColumn) ((MetadataColumnRepositoryObject) repNode.getObject()).getTdColumn());
        }
        columnSetMultiIndicator.getAnalyzedColumns().addAll(columnLst);
        correlationAnalysisHandler.addIndicator(columnLst, columnSetMultiIndicator);
    } else {
        analysis.getContext().setConnection(null);
        // MOD by zshen for bug 12042.
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        ColumnSetMultiValueIndicator columnSetMultiValueIndicator = null;
        if (ColumnsetPackage.eINSTANCE.getCountAvgNullIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiValueIndicator = columnsetFactory.createCountAvgNullIndicator();
        }
        if (ColumnsetPackage.eINSTANCE.getMinMaxDateIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiValueIndicator = columnsetFactory.createMinMaxDateIndicator();
        }
        if (ColumnsetPackage.eINSTANCE.getWeakCorrelationIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiValueIndicator = columnsetFactory.createWeakCorrelationIndicator();
        }
        fillSimpleIndicators(columnSetMultiValueIndicator);
        analysis.getResults().getIndicators().add(columnSetMultiValueIndicator);
    // ~12042
    }
    // 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(analysis.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);
    treeViewer.setDirty(false);
    dataFilterComp.setDirty(false);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) TdColumn(org.talend.cwm.relational.TdColumn) Analysis(org.talend.dataquality.analysis.Analysis) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) Domain(org.talend.dataquality.domain.Domain)

Example 74 with Analysis

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

the class AbstractAnalysisMetadataPage method getCurrentConnectionRepNode.

protected IRepositoryNode getCurrentConnectionRepNode() {
    // MOD klliu 2010-12-10
    IEditorInput editorInput = getEditor().getEditorInput();
    if (editorInput instanceof AnalysisItemEditorInput) {
        AnalysisItemEditorInput fileEditorInput = (AnalysisItemEditorInput) editorInput;
        return fileEditorInput.getConnectionNode();
    } else {
        // ADD TDQ-9613 msjian: when the user do something from the other views for example: from task view
        FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
        Analysis findAnalysis = AnaResourceFileHelper.getInstance().findAnalysis(fileEditorInput.getFile());
        DataManager connection = findAnalysis.getContext().getConnection();
        if (connection != null) {
            return RepositoryNodeHelper.recursiveFind(connection);
        }
    // TDQ-9613~
    }
    return null;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) FileEditorInput(org.eclipse.ui.part.FileEditorInput) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) IEditorInput(org.eclipse.ui.IEditorInput)

Example 75 with Analysis

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

the class AnalysisEditor method translateInput.

@Override
protected void translateInput(IEditorInput input) {
    // MOD klliu 2010-12-10
    Analysis findAnalysis = null;
    // $NON-NLS-1$
    String label = "";
    if (input instanceof AnalysisItemEditorInput) {
        AnalysisItemEditorInput fileEditorInput = (AnalysisItemEditorInput) input;
        findAnalysis = (Analysis) fileEditorInput.getModel();
        label = fileEditorInput.getName();
    } else if (input instanceof FileEditorInput) {
        FileEditorInput fileEditorInput = (FileEditorInput) input;
        IFile file = fileEditorInput.getFile();
        label = file.getFullPath().toString();
        if (FactoriesUtil.isAnalysisFile(file.getFileExtension())) {
            findAnalysis = AnaResourceFileHelper.getInstance().findAnalysis(file);
        }
    }
    if (findAnalysis != null) {
        analysisType = findAnalysis.getParameters().getAnalysisType();
    } else {
        // $NON-NLS-1$
        log.error("Could not find an analysis in file: " + label);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Analysis(org.talend.dataquality.analysis.Analysis) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

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