Search in sources :

Example 16 with ModelElementIndicator

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

the class AnalysisColumnSetTreeViewer method moveElement.

/**
 * DOC zshen Comment method "moveElement".
 *
 * @param columnsElementViewer
 * @param step
 *
 * move the element of the columnList to up or down.
 */
private void moveElement(AnalysisColumnSetTreeViewer columnsElementViewer, int step) {
    Tree currentTree = columnsElementViewer.getTree();
    Object[] selectItem = currentTree.getSelection();
    List<IRepositoryNode> columnList = columnsElementViewer.getColumnSetMultiValueList();
    // get all the selected index list first which is used to check how to move
    List<Object> allSelectedItemList = new ArrayList<Object>();
    for (Object element : selectItem) {
        allSelectedItemList.add(element);
    }
    int index = 0;
    RepositoryNode moveElement = null;
    List<Integer> indexArray = new ArrayList<Integer>();
    for (Object element : selectItem) {
        index = currentTree.indexOf((TreeItem) element);
        int changeIndex = index + step;
        if (changeIndex > -1 && changeIndex < columnList.size()) {
            Object treeElement = ((TreeItem) element).getData(AnalysisColumnNominalIntervalTreeViewer.COLUMN_INDICATOR_KEY);
            // MOD by zshen for bug 15750 TODO 39 columnset analysis move up/down one column will get exception.
            if (treeElement instanceof ModelElement) {
                moveElement = RepositoryNodeHelper.recursiveFind((ModelElement) treeElement);
            } else if (treeElement instanceof RepositoryNode) {
                moveElement = (RepositoryNode) treeElement;
            }
            columnList.remove(moveElement);
            // when the changed one is the selected one too, get next one
            while (allSelectedItemList.contains(currentTree.getItem(changeIndex))) {
                ++changeIndex;
            }
            columnList.add(changeIndex, moveElement);
            indexArray.add(changeIndex);
            ModelElementIndicator tmpElement = modelElementIndicators[changeIndex];
            modelElementIndicators[changeIndex] = modelElementIndicators[index];
            modelElementIndicators[index] = tmpElement;
            allSelectedItemList.remove(element);
        } else {
            return;
        }
    }
    // columnsElementViewer.setInput(columnList.toArray());
    setElements(modelElementIndicators);
    currentTree = columnsElementViewer.getTree();
    for (int i = 0; i < indexArray.size(); i++) {
        currentTree.select(currentTree.getItem(indexArray.get(i)));
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) Tree(org.eclipse.swt.widgets.Tree) EObject(org.eclipse.emf.ecore.EObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 17 with ModelElementIndicator

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

the class AnalysisColumnSetTreeViewer method setInput.

@Override
public void setInput(Object[] objs) {
    if (objs != null && objs.length != 0) {
        List<DBColumnRepNode> columnList = new ArrayList<DBColumnRepNode>();
        for (Object obj : objs) {
            // default is should be sql engine.
            if (obj instanceof DBTableRepNode || obj instanceof DBViewRepNode) {
                columnList.addAll((Collection<? extends DBColumnRepNode>) ((ColumnSetRepNode) obj).getAllColumns());
            } else if (obj instanceof DBColumnRepNode) {
                columnList.add((DBColumnRepNode) obj);
            }
        }
        // MOD yyi 2010-05-13 12828
        Collections.reverse(columnList);
        // MOD qiongli 2011-3-15 set DataFilterText disabled except TdColumn.
        if (masterPage.getDataFilterComp() != null) {
            masterPage.getDataFilterComp().getDataFilterText().setEnabled(!columnList.isEmpty());
            if (columnList.isEmpty()) {
                // when the selected column is not DB type,will disable the execute engine
                // combobox.
                masterPage.changeExecuteLanguageToJava(true);
            } else {
                // when the selected column is back to DB type, should enable the execute engine combobox again.
                masterPage.enableExecuteLanguage();
            }
        }
        ModelElementIndicator[] newSelects = translateSelectedNodeIntoIndicator(objs);
        List<ModelElementIndicator> indicatorList = new ArrayList<ModelElementIndicator>();
        if (newSelects != null) {
            // indicator;
            for (ModelElementIndicator column : newSelects) {
                // if the modelElementIndicators contains selected column, add the column in modelElementIndicators
                // to ColumnIndicatorList
                boolean isOld = false;
                for (ModelElementIndicator oldColumn : modelElementIndicators) {
                    if (oldColumn.getModelElementRepositoryNode().equals(column.getModelElementRepositoryNode())) {
                        indicatorList.add(oldColumn);
                        isOld = true;
                        break;
                    }
                }
                // else add this column in filterInputData to ColumnIndicatorList
                if (!isOld) {
                    indicatorList.add(column);
                }
            }
            this.modelElementIndicators = indicatorList.toArray(new ModelElementIndicator[indicatorList.size()]);
            this.setElements(modelElementIndicators);
        }
    } else {
        TreeItem[] items = this.tree.getItems();
        for (TreeItem item : items) {
            this.removeItemBranch(item);
        }
        super.setInput(objs);
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ColumnSetRepNode(org.talend.dq.nodes.ColumnSetRepNode) EObject(org.eclipse.emf.ecore.EObject) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 18 with ModelElementIndicator

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

the class AnalysisColumnSetTreeViewer method addElements.

@Override
public void addElements(final ModelElementIndicator[] elements) {
    RepositoryNode[] columns = new RepositoryNode[elements.length];
    for (int i = 0; i < elements.length; i++) {
        columns[i] = (RepositoryNode) elements[i].getModelElementRepositoryNode();
    }
    List<IRepositoryNode> oriColumns = getColumnSetMultiValueList();
    for (RepositoryNode column : columns) {
        if (!RepositoryNodeHelper.containsModelElementNode(oriColumns, column)) {
            oriColumns.add(column);
        }
    }
    setInput(oriColumns.toArray());
    // MOD qiongli 2010-6-4,bug 0012766,after drag and drop a column from left view,update the connection state
    updateBindConnection(masterPage, tree);
    // ADD msjian TDQ-11606: refresh the datapreview part after add a new element
    ModelElementIndicator[] newsArray = new ModelElementIndicator[getAllTheElementIndicator().length + elements.length];
    System.arraycopy(getAllTheElementIndicator(), 0, newsArray, 0, getAllTheElementIndicator().length);
    for (int i = 0; i < elements.length; i++) {
        newsArray[getAllTheElementIndicator().length + i] = elements[i];
    }
    masterPage.refreshPreviewTable(newsArray, true);
// ADD msjian TDQ-11606~
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 19 with ModelElementIndicator

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

the class AnalysisColumnTreeViewer method isExpressionNull.

private String isExpressionNull(TreeItem item) {
    String expressContent = null;
    ModelElement me = null;
    IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
    ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
    if (indicatorUnit != null) {
        IRepositoryViewObject reposViewObj = meIndicator.getModelElementRepositoryNode().getObject();
        // MetadataXmlElementTypeRepositoryObject
        if (reposViewObj instanceof MetadataColumnRepositoryObject) {
            me = ((MetadataColumnRepositoryObject) reposViewObj).getTdColumn();
        }
        Connection dataprovider = ModelElementHelper.getTdDataProvider(me);
        DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
        Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
        if (expression != null) {
            expressContent = expression.getBody();
        }
    } else {
        IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
        expressContent = DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
        parentNodeForColumnNode.getObject().getLabel());
    }
    return expressContent;
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Expression(orgomg.cwm.objectmodel.core.Expression) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 20 with ModelElementIndicator

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

the class AnalysisColumnTreeViewer method getTheSuitedComposite.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.core.ui.editor.composite.AbstractColumnDropTree#getTheSuitedComposite(org.eclipse.swt
     * .events.SelectionEvent)
     */
@Override
public ExpandableComposite getTheSuitedComposite(SelectionEvent e) {
    Composite[] previewChartCompsites = masterPage.getPreviewChartCompsites();
    if (previewChartCompsites == null) {
        return null;
    }
    Object obj = e.item.getData(MODELELEMENT_INDICATOR_KEY);
    if (obj instanceof ModelElementIndicator) {
        ModelElementIndicator meIndicator = (ModelElementIndicator) obj;
        for (Composite comp : previewChartCompsites) {
            if (comp.getData() == meIndicator) {
                return (ExpandableComposite) comp;
            }
        }
    }
    return null;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) 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) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

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