Search in sources :

Example 21 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method createTree.

/**
 * @param parent
 */
private Tree createTree(Composite parent) {
    final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION) {

        @Override
        protected boolean isValidItem(TreeItem item) {
            if (item == null) {
                return false;
            }
            Object itemData = item.getData(INDICATOR_UNIT_KEY);
            Object columnItemData = item.getData(MODELELEMENT_INDICATOR_KEY);
            if (itemData != null) {
                IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
                if (indicatorUnit != null && !(indicatorUnit.getIndicator() instanceof CompositeIndicator)) {
                    return true;
                }
                return false;
            } else {
                if (columnItemData != null) {
                    ModelElementIndicator modelElementIndicator = (ModelElementIndicator) columnItemData;
                    IRepositoryNode modelElementRepositoryNode = modelElementIndicator.getModelElementRepositoryNode();
                    return modelElementRepositoryNode == null ? false : true;
                }
                return false;
            }
        }

        @Override
        protected String getItemTooltipText(TreeItem item) {
            String expCont = isExpressionNull(item);
            if (expCont == null) {
                // $NON-NLS-1$
                return DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.queryNotGen");
            }
            return expCont;
        }
    };
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
    newTree.setHeaderVisible(true);
    // $NON-NLS-1$
    createTreeItem(newTree, 300, "AnalysisColumnTreeViewer.analyzedColumns");
    createTreeDataminingItem(newTree);
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.pattern");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.udi");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
    // TDQ-11622 : add a column here, let the width = 1 and text = EMPTY_STRING TODO need to find a better solution!
    TreeColumn blankColumn = new TreeColumn(newTree, SWT.CENTER);
    blankColumn.setWidth(1);
    // ~ TDQ-11622
    parent.layout();
    AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {

        @Override
        protected void handleRemove() {
            removeSelectedElements(newTree);
        }
    };
    parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
    ColumnViewerDND.installDND(newTree);
    this.addTreeListener(newTree);
    newTree.setData(this);
    return newTree;
}
Also used : AbstractAnalysisActionHandler(org.talend.dataprofiler.core.ui.editor.AbstractAnalysisActionHandler) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) Tree(org.eclipse.swt.widgets.Tree) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 22 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method openIndicatorSelectDialog.

/**
 * Open the dialog for select indicator
 *
 * @param shell
 * @return The array of ModelElementIndicator which selected by user if user click ok button. If cancel button be
 * clicked then the size of return array will be zero. If have a Where Clause is error will return null
 */
public ModelElementIndicator[] openIndicatorSelectDialog(Shell shell) {
    List<Object[]> previewData = masterPage.getSampleTable().getExistPreviewData();
    final IndicatorSelectDialog dialog = new IndicatorSelectDialog(shell, DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.indicatorSelection"), masterPage.getCurrentModelElementIndicators(), // $NON-NLS-1$
    previewData);
    dialog.setLimitNumber(this.masterPage.getPreviewLimit());
    dialog.create();
    if (!DQPreferenceManager.isBlockWeb()) {
        dialog.getShell().addShellListener(new ShellAdapter() {

            @Override
            public void shellActivated(ShellEvent e) {
                dialog.getShell().setFocus();
                IContext context = HelpSystem.getContext(HelpPlugin.getDefault().getIndicatorSelectorHelpContextID());
                PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
            }
        });
        dialog.getShell().addHelpListener(new HelpListener() {

            public void helpRequested(HelpEvent e) {
                IContext context = HelpSystem.getContext(HelpPlugin.getDefault().getIndicatorSelectorHelpContextID());
                PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
            }
        });
    }
    if (dialog.open() == Window.OK) {
        isGridPreviewColumnMoved = dialog.isGridPreviewColumnMoved();
        ModelElementIndicator[] result = dialog.getResult();
        for (ModelElementIndicator modelElementIndicator : result) {
            modelElementIndicator.storeTempIndicator();
        }
        return result;
    } else {
        ModelElementIndicator[] result = dialog.getResult();
        for (ModelElementIndicator modelElementIndicator : result) {
            modelElementIndicator.getTempIndicator().clear();
        }
        return null;
    }
}
Also used : HelpEvent(org.eclipse.swt.events.HelpEvent) HelpListener(org.eclipse.swt.events.HelpListener) ShellAdapter(org.eclipse.swt.events.ShellAdapter) IContext(org.eclipse.help.IContext) IndicatorSelectDialog(org.talend.dataprofiler.core.ui.grid.IndicatorSelectDialog) ShellEvent(org.eclipse.swt.events.ShellEvent) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 23 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method canDrop.

@Override
public boolean canDrop(IRepositoryNode metadataRepositoryNode) {
    IRepositoryViewObject metadataRepObject = metadataRepositoryNode.getObject();
    ConnectionItem connItem = (ConnectionItem) metadataRepObject.getProperty().getItem();
    // MOD qiongli 2010-8-19,bug 14436:could not come from diffrent connection
    Connection tdProvider = connItem.getConnection();
    if (tdProvider == null) {
        return false;
    } else if (this.getAnalysis().getContext().getConnection() != null && !ResourceHelper.areSame(tdProvider, this.getAnalysis().getContext().getConnection())) {
        return false;
    }
    // MOD mzhao, 2010-07-23 bug 14014: If the editor is dirty, save it firstly before drag and drop an elements.
    if (masterPage.isDirty()) {
        masterPage.doSave(new NullProgressMonitor());
        return false;
    }
    List<ModelElement> existModelElements = new ArrayList<ModelElement>();
    for (ModelElementIndicator modelElementIndicator : this.getAllTheElementIndicator()) {
        ModelElement me = RepositoryNodeHelper.getModelElementFromRepositoryNode(modelElementIndicator.getModelElementRepositoryNode());
        existModelElements.add(me);
    }
    // MOD mzhao 9848 2010-01-14, allowing to drag and drop table.
    if (metadataRepObject instanceof MetadataTableRepositoryObject) {
        MetadataTableRepositoryObject tableRepObject = (MetadataTableRepositoryObject) metadataRepObject;
        return !existModelElements.containsAll(ColumnSetHelper.getColumns((TdTable) tableRepObject.getTable()));
    }
    if (metadataRepObject instanceof MetadataColumnRepositoryObject) {
        if (existModelElements.contains(((MetadataColumnRepositoryObject) metadataRepObject).getTdColumn())) {
            return false;
        }
    }
    if (metadataRepObject instanceof MetadataXmlElementTypeRepositoryObject) {
        return !metadataRepositoryNode.hasChildren();
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 24 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class ModelElementTreeMenuProvider method previewSelectedElements.

/**
 * DOC Zqin Comment method "previewSelectedElements".
 *
 * @param newTree
 */
private void previewSelectedElements(Tree newTree) {
    TreeItem[] items = newTree.getSelection();
    ModelElement[] mes = new ModelElement[items.length];
    for (int i = 0; i < items.length; i++) {
        ModelElementIndicator meIndicator = (ModelElementIndicator) items[i].getData(AbstractColumnDropTree.MODELELEMENT_INDICATOR_KEY);
        ModelElement me = ((MetadataColumnRepositoryObject) meIndicator.getModelElementRepositoryNode().getObject()).getTdColumn();
        mes[i] = me;
    }
    new PreviewColumnAction(mes).run();
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TreeItem(org.eclipse.swt.widgets.TreeItem) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) PreviewColumnAction(org.talend.dataprofiler.core.ui.action.actions.predefined.PreviewColumnAction) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 25 with ModelElementIndicator

use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.

the class UDIUtils method createIndicatorUnit.

public static IndicatorUnit[] createIndicatorUnit(IndicatorDefinition udid, ModelElementIndicator meIndicator, Analysis analysis) throws Throwable {
    List<IndicatorUnit> addIndicatorUnits = new ArrayList<IndicatorUnit>();
    // can't add the same user defined indicator
    for (Indicator indicator : meIndicator.getIndicators()) {
        // MOD xwang 2011-08-01 bug TDQ-2730
        if (udid.getName().equals(indicator.getName()) && indicator instanceof UserDefIndicator) {
            // $NON-NLS-1$
            MessageUI.openWarning(DefaultMessagesImpl.getString("UDIUtils.UDISelected", udid.getName()));
            return null;
        }
    }
    Indicator udi = UDIFactory.createUserDefIndicator(udid);
    udi.setIndicatorDefinition(udid);
    // MOD mzhao feature 11128, Handle Java User Defined Indicator.
    Indicator judi = UDIHelper.adaptToJavaUDI(udi);
    if (judi != null) {
        udi = judi;
    }
    IEditorPart activeEditor = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor == null || !(activeEditor instanceof AnalysisEditor)) {
        return null;
    }
    ExecutionLanguage executionLanguage = ((AnalysisEditor) activeEditor).getUIExecuteEngin();
    boolean isJavaEngin = ExecutionLanguage.JAVA.equals(executionLanguage);
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(analysis, executionLanguage);
    Expression returnExpression = dbmsLanguage.getExpression(udi);
    String executeType = isJavaEngin ? executionLanguage.getName() : dbmsLanguage.getDbmsName();
    // MOD qiongli 2013.5.22 TDQ-7282.if don't find a valid java expression for JUDI,should also pop this dialog.
    boolean finddExpression = true;
    if (isJavaEngin && judi == null || !isJavaEngin && returnExpression == null) {
        finddExpression = false;
    }
    if (!finddExpression) {
        // open the editor
        boolean openUDI = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("PatternUtilities.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
        DefaultMessagesImpl.getString("UDIUtils.NoExpression", executeType));
        if (openUDI) {
            RepositoryNode node = RepositoryNodeHelper.recursiveFind(udid);
            if (RepositoryNodeHelper.canOpenEditor(node)) {
                new OpenItemEditorAction(new IRepositoryNode[] { node }).run();
            }
        }
        return null;
    }
    // dbmsLanguage
    IndicatorParameters parameters = udi.getParameters();
    if (parameters == null) {
        parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
        udi.setParameters(parameters);
    }
    Domain indicatorValidDomain = parameters.getIndicatorValidDomain();
    if (indicatorValidDomain == null) {
        // $NON-NLS-1$
        indicatorValidDomain = DomainHelper.createDomain("JAVA_UDI_PARAMETERS");
        parameters.setIndicatorValidDomain(indicatorValidDomain);
    }
    List<IndicatorDefinitionParameter> indicatorDefs = udid.getIndicatorDefinitionParameter();
    for (IndicatorDefinitionParameter idp : indicatorDefs) {
        JavaUDIIndicatorParameter judip = DomainHelper.createJavaUDIIndicatorParameter(idp.getKey(), idp.getValue());
        indicatorValidDomain.getJavaUDIIndicatorParameter().add(judip);
    }
    IndicatorEnum indicatorType = IndicatorEnum.findIndicatorEnum(udi.eClass());
    addIndicatorUnits.add(meIndicator.addSpecialIndicator(indicatorType, udi));
    DependenciesHandler.getInstance().setUsageDependencyOn(analysis, udid);
    return addIndicatorUnits.toArray(new IndicatorUnit[addIndicatorUnits.size()]);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ArrayList(java.util.ArrayList) JavaUDIIndicatorParameter(org.talend.dataquality.domain.JavaUDIIndicatorParameter) ExecutionLanguage(org.talend.dataquality.analysis.ExecutionLanguage) IEditorPart(org.eclipse.ui.IEditorPart) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) OpenItemEditorAction(org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) TdExpression(org.talend.cwm.relational.TdExpression) Expression(orgomg.cwm.objectmodel.core.Expression) IndicatorDefinitionParameter(org.talend.dataquality.indicators.definition.IndicatorDefinitionParameter) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) Domain(org.talend.dataquality.domain.Domain) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Aggregations

ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)58 IRepositoryNode (org.talend.repository.model.IRepositoryNode)22 ArrayList (java.util.ArrayList)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)16 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)15 Indicator (org.talend.dataquality.indicators.Indicator)13 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)12 TreeItem (org.eclipse.swt.widgets.TreeItem)11 RepositoryNode (org.talend.repository.model.RepositoryNode)10 IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)9 MetadataXmlElementTypeRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject)7 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)6 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)5 TreeEditor (org.eclipse.swt.custom.TreeEditor)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4