Search in sources :

Example 6 with AnalysisEditor

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.

the class AnalyzeColumnCorrelationAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    hasDateColumn = false;
    hasNumberColumn = false;
    if (openStandardAnalysisDialog(AnalysisType.COLUMN_CORRELATION) == Window.OK) {
        AnalysisEditor editor = (AnalysisEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (editor != null) {
            CorrelationAnalysisDetailsPage page = (CorrelationAnalysisDetailsPage) editor.getMasterPage();
            if (!this.selection.isEmpty()) {
                DBColumnRepNode[] columns = new DBColumnRepNode[selection.size()];
                Iterator it = this.selection.iterator();
                int i = 0;
                while (it.hasNext()) {
                    columns[i] = (DBColumnRepNode) it.next();
                    i++;
                }
                if (page != null) {
                    page.getTreeViewer().setInput(columns);
                    page.doSave(null);
                }
            }
        }
    }
}
Also used : CorrelationAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.CorrelationAnalysisDetailsPage) Iterator(java.util.Iterator) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Example 7 with AnalysisEditor

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.

the class RunAnalysisAction 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 mzhao 2009-02-03 If there is no active editor opened, run
    // analysis action from cheat sheets will do nothing.
    IEditorPart activateEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activateEditor == null || !(activateEditor instanceof AnalysisEditor)) {
        return;
    }
    // MOD TDQ-8117 20131008 yyin: find the analysis item from the editor
    IEditorInput editorInput = activateEditor.getEditorInput();
    if (editorInput instanceof AnalysisItemEditorInput) {
        setAnalysisItems(new TDQAnalysisItem[] { ((TDQAnalysisItem) ((AnalysisItemEditorInput) editorInput).getItem()) });
    }
    AbstractAnalysisMetadataPage masterPage = ((AnalysisEditor) activateEditor).getMasterPage();
    listener = masterPage;
    // ~
    run();
}
Also used : AbstractAnalysisMetadataPage(org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage) IEditorPart(org.eclipse.ui.IEditorPart) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) IEditorInput(org.eclipse.ui.IEditorInput) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 8 with AnalysisEditor

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.

the class AnalyzeColumnAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    if (openStandardAnalysisDialog(AnalysisType.MULTIPLE_COLUMN) == Window.OK) {
        AnalysisEditor editor = (AnalysisEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (editor != null) {
            ColumnAnalysisDetailsPage page = (ColumnAnalysisDetailsPage) editor.getMasterPage();
            if (!this.selection.isEmpty()) {
                List<RepositoryNode> nodeList = new ArrayList<RepositoryNode>();
                Object[] objs = this.selection.toArray();
                for (Object obj : objs) {
                    if (obj instanceof RepositoryNode) {
                        nodeList.add((RepositoryNode) obj);
                    }
                }
                if (page != null) {
                    page.setTreeViewInput(objs);
                    page.doSave(null);
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) ColumnAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnAnalysisDetailsPage)

Example 9 with AnalysisEditor

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.

the class AnalyzeColumnSetAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    PackagesAnalyisParameter packaFilterParameter = new PackagesAnalyisParameter();
    if (nodeColumns != null) {
        DQRepositoryNode tFolder = (DQRepositoryNode) nodeColumns.getParent();
        if (tFolder != null) {
            IRepositoryNode node = tFolder.getParent();
            if (node instanceof DBCatalogRepNode) {
                IRepositoryNode connNode = ((DBCatalogRepNode) node).getParent();
                packaFilterParameter.setConnectionRepNode(connNode);
                catalogs.add(node);
                packaFilterParameter.setPackages(catalogs);
            } else if (node instanceof DBSchemaRepNode) {
                schemaNode = (DBSchemaRepNode) node;
                RepositoryNode parent = schemaNode.getParent();
                if (parent instanceof DBCatalogRepNode) {
                    catalogs.add(parent);
                    packaFilterParameter.setConnectionRepNode(parent);
                } else {
                    catalogs.add(schemaNode);
                    packaFilterParameter.setConnectionRepNode(schemaNode);
                }
                packaFilterParameter.setPackages(catalogs);
            }
        }
    }
    if (needselection) {
        IRepositoryNode firstElement = (RepositoryNode) this.selection.getFirstElement();
        IRepositoryViewObject viewObject = firstElement.getObject();
        Item item = viewObject.getProperty().getItem();
        ConnectionItem connectionItem = (ConnectionItem) item;
        Connection connection = connectionItem.getConnection();
        IRepositoryNode repositoryNode = RepositoryNodeHelper.recursiveFind(connection);
        packaFilterParameter.setConnectionRepNode(repositoryNode);
    }
    if (opencolumnSetAnalysisDialog(packaFilterParameter) == Window.OK) {
        AnalysisEditor editor = (AnalysisEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (editor != null) {
            ColumnSetAnalysisDetailsPage page = (ColumnSetAnalysisDetailsPage) editor.getMasterPage();
            if (this.needselection && !this.selection.isEmpty()) {
                IRepositoryNode[] nodeArray = new IRepositoryNode[selection.size()];
                Iterator it = this.selection.iterator();
                int i = 0;
                while (it.hasNext()) {
                    nodeArray[i] = (IRepositoryNode) it.next();
                    i++;
                }
                page.setTreeViewInput(nodeArray);
            } else if (!this.needselection && null != this.nodeColumns) {
                List<IRepositoryNode> column = new ArrayList<IRepositoryNode>();
                for (IRepositoryNode columnFolder : nodeColumns.getChildren()) {
                    if (columnFolder instanceof DBColumnFolderRepNode) {
                        column.addAll(columnFolder.getChildren());
                    }
                }
                page.setTreeViewInput(column.toArray());
            }
            page.doSave(null);
        }
    }
}
Also used : DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) PackagesAnalyisParameter(org.talend.dq.analysis.parameters.PackagesAnalyisParameter) ColumnSetAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnSetAnalysisDetailsPage) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Example 10 with AnalysisEditor

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.

the class PatternLabelProvider method createIndicatorUnit.

/**
 * DOC xqliu Comment method "createIndicatorUnit".
 *
 * @param pfile
 * @param modelElementIndicator
 * @param analysis
 * @param indicatorDefinition
 * @return
 */
public static TypedReturnCode<IndicatorUnit> createIndicatorUnit(Pattern pattern, ModelElementIndicator modelElementIndicator, Analysis analysis, IndicatorDefinition indicatorDefinition) {
    TypedReturnCode<IndicatorUnit> result = new TypedReturnCode<IndicatorUnit>();
    for (Indicator indicator : modelElementIndicator.getIndicators()) {
        // MOD xwang 2011-08-01 bug TDQ-2730
        if (UDIHelper.getMatchingIndicatorName(indicatorDefinition, pattern).equals(indicator.getName()) && indicator instanceof PatternMatchingIndicator) {
            result.setOk(false);
            // $NON-NLS-1$
            result.setMessage(DefaultMessagesImpl.getString("PatternUtilities.Selected"));
            return result;
        }
    // ~
    }
    // MOD scorreia 2009-01-06: when expression type is not set (version
    // TOP-1.1.x), then it's supposed to be a
    // regexp pattern. This could be false because expression type was not
    // set into SQL pattern neither in TOP-1.1.
    // This means that there could exist the need for a migration task to
    // set the expression type depending on the
    // folder where the pattern is stored. The method
    // DomainHelper.getExpressionType(pattern) tries to find the type
    // of pattern.
    Indicator patternMatchingIndicator = null;
    String expressionType = DomainHelper.getExpressionType(pattern);
    boolean isSQLPattern = (ExpressionType.SQL_LIKE.getLiteral().equals(expressionType));
    if (indicatorDefinition != null) {
        patternMatchingIndicator = UDIFactory.createUserDefIndicator(indicatorDefinition, pattern);
    } else {
        patternMatchingIndicator = isSQLPattern ? PatternIndicatorFactory.createSqlPatternMatchingIndicator(pattern) : PatternIndicatorFactory.createRegexpMatchingIndicator(pattern);
    }
    IEditorPart theEdit = CorePlugin.getDefault().getCurrentActiveEditor();
    if (theEdit != null && theEdit instanceof AnalysisEditor && analysis.getContext().getConnection() == null) {
        theEdit.doSave(null);
    }
    ExecutionLanguage executionLanguage = analysis.getParameters().getExecutionLanguage();
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(analysis);
    if (dbmsLanguage.isSql()) {
        // $NON-NLS-1$
        MessageUI.openWarning(DefaultMessagesImpl.getString("PatternUtilities.ConnectionError"));
        result.setOk(false);
        return result;
    }
    boolean isJavaEngin = ExecutionLanguage.JAVA.equals(executionLanguage);
    Expression returnExpression = dbmsLanguage.getRegexp(pattern);
    // MOD gdbu 2011-8-26 bug : TDQ-2169
    if ((ExpressionType.REGEXP.getLiteral().equals(expressionType) || ExpressionType.SQL_LIKE.getLiteral().equals(expressionType)) && returnExpression == null) {
        // ~TDQ-2169
        String executeType = isJavaEngin ? executionLanguage.getName() : dbmsLanguage.getDbmsName();
        boolean openPattern = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("PatternUtilities.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
        DefaultMessagesImpl.getString("PatternUtilities.NoExpression", executeType, pattern.getName()));
        if (openPattern) {
            RepositoryNode node = RepositoryNodeHelper.recursiveFind(pattern);
            if (RepositoryNodeHelper.canOpenEditor(node)) {
                new OpenItemEditorAction(new IRepositoryNode[] { node }).run();
            }
        }
        result.setOk(false);
        return result;
    }
    // a regular expression for the analyzed
    // database, but we probably test also whether the analyzed database
    // support the regular expressions (=> check
    // DB type, DB number version, existence of UDF)
    DataManager dm = analysis.getContext().getConnection();
    if (dm != null) {
        TypedReturnCode<java.sql.Connection> trc = JavaSqlFactory.createConnection((Connection) dm);
        // MOD qiongli 2011-1-10 feature 16796
        boolean isDelimitedFileConnection = ConnectionUtils.isDelimitedFileConnection((DataProvider) dm);
        if (trc != null) {
            // SoftwareSystem softwareSystem = DatabaseContentRetriever.getSoftwareSystem(conn);
            // MOD sizhaoliu TDQ-6316
            dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(dm);
        }
        // MOD xqliu 2010-08-12 bug 14601
        if (!(isSQLPattern || DefinitionHandler.getInstance().canRunRegularExpressionMatchingIndicator(dbmsLanguage, isJavaEngin, pattern) || isDelimitedFileConnection)) {
            // MessageDialogWithToggle.openInformation(null,
            // DefaultMessagesImpl.getString("PatternUtilities.Pattern"), DefaultMessagesImpl //$NON-NLS-1$
            // .getString("PatternUtilities.couldnotSetIndicator")); //$NON-NLS-1$
            result.setOk(false);
            // $NON-NLS-1$
            result.setMessage(DefaultMessagesImpl.getString("PatternUtilities.couldnotSetIndicator"));
            return result;
        }
    // ~ 14601
    }
    // when the indicator is created.
    if (indicatorDefinition == null) {
        if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(patternMatchingIndicator)) {
            // $NON-NLS-1$
            log.error(DefaultMessagesImpl.getString("PatternUtilities.SetFailed", patternMatchingIndicator.getName()));
        }
    } else {
        patternMatchingIndicator.setIndicatorDefinition(indicatorDefinition);
    }
    IndicatorEnum type = IndicatorEnum.findIndicatorEnum(patternMatchingIndicator.eClass());
    IndicatorUnit addIndicatorUnit = modelElementIndicator.addSpecialIndicator(type, patternMatchingIndicator);
    DependenciesHandler.getInstance().setUsageDependencyOn(analysis, pattern);
    result.setOk(true);
    // $NON-NLS-1$
    result.setMessage(DefaultMessagesImpl.getString("PatternUtilities.OK"));
    result.setObject(addIndicatorUnit);
    return result;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) Connection(org.talend.core.model.metadata.builder.connection.Connection) ExecutionLanguage(org.talend.dataquality.analysis.ExecutionLanguage) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) IEditorPart(org.eclipse.ui.IEditorPart) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) OpenItemEditorAction(org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction) ColumnIndicator(org.talend.dataprofiler.core.model.ColumnIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Expression(orgomg.cwm.objectmodel.core.Expression) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Aggregations

AnalysisEditor (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)13 IEditorPart (org.eclipse.ui.IEditorPart)6 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 RepositoryNode (org.talend.repository.model.RepositoryNode)6 ArrayList (java.util.ArrayList)4 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 Item (org.talend.core.model.properties.Item)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 AbstractAnalysisMetadataPage (org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage)3 ColumnAnalysisDetailsPage (org.talend.dataprofiler.core.ui.editor.analysis.ColumnAnalysisDetailsPage)3 ColumnSetAnalysisDetailsPage (org.talend.dataprofiler.core.ui.editor.analysis.ColumnSetAnalysisDetailsPage)3 Indicator (org.talend.dataquality.indicators.Indicator)3 DbmsLanguage (org.talend.dq.dbms.DbmsLanguage)3 Iterator (java.util.Iterator)2 List (java.util.List)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 OpenItemEditorAction (org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction)2 AnalysisItemEditorInput (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput)2