Search in sources :

Example 26 with ModelElementIndicator

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

the class IndicatorSelectDialog method isMatchCurrentIndicator.

public boolean isMatchCurrentIndicator(ModelElementIndicator currentIndicator, IIndicatorNode indicatorNode) {
    boolean returnValueForCurrentIndicator = true;
    IIndicatorNode parentNode = indicatorNode.getParent();
    boolean isParentPhoneStatistics = parentNode != null && parentNode.getIndicatorInstance() != null && parentNode.getIndicatorInstance() instanceof PhoneNumbStatisticsIndicator;
    if (!ModelElementIndicatorRule.match(indicatorNode, currentIndicator, this.language)) {
        returnValueForCurrentIndicator = false;
    }
    Indicator indicatorInstance = indicatorNode.getIndicatorInstance();
    if (null != indicatorInstance && !(indicatorInstance instanceof DatePatternFreqIndicator) && null != indicatorInstance.getIndicatorDefinition() && indicatorInstance.getIndicatorDefinition().getSqlGenericExpression().size() < 1 && ExecutionLanguage.SQL.equals(language) && !UDIHelper.isJavaUDI(indicatorInstance) && !indicatorNode.hasChildren() && !(currentIndicator instanceof DelimitedFileIndicator) && !isParentPhoneStatistics) {
        returnValueForCurrentIndicator = false;
    }
    return returnValueForCurrentIndicator;
}
Also used : DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) PhoneNumbStatisticsIndicator(org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) PhoneNumbStatisticsIndicator(org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator)

Example 27 with ModelElementIndicator

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

the class AbstractIndicatorSelectGrid method tickCell.

private void tickCell(Point cell, boolean tick) {
    if (!getItem(cell.y).getCheckable(cell.x)) {
        return;
    }
    if (cell.x == 1) {
        for (int i = 2; i < getColumnCount(); i++) {
            tickCell(new Point(i, cell.y), tick);
        }
    }
    getItem(cell.y).setChecked(cell.x, tick);
    getItem(cell.y).setGrayed(cell.x, false);
    IIndicatorNode indicatorNode = (IIndicatorNode) getItem(cell.y).getData();
    IndicatorEnum indicatorEnum = indicatorNode.getIndicatorEnum();
    ModelElementIndicator meIndicator = (ModelElementIndicator) getColumn(cell.x).getData();
    if (meIndicator != null && indicatorEnum != null) {
        if (tick) {
            if (IndicatorEnum.isSpecialIndicatorEnum(indicatorEnum)) {
                meIndicator.addTempSpecialIndicator(indicatorEnum, indicatorNode.createNewIndicatorInstance());
            } else {
                meIndicator.addTempIndicatorEnum(indicatorEnum);
            }
        } else {
            if (IndicatorEnum.isSpecialIndicatorEnum(indicatorEnum)) {
                meIndicator.removeTempSpecialIndicator(indicatorNode.getIndicatorInstance());
            } else {
                meIndicator.removeTempIndicatorEnum(indicatorEnum);
            }
        }
    }
    // select the entire indicator category
    if (getItem(cell.y).hasChildren()) {
        for (GridItem child : getItem(cell.y).getItems()) {
            tickCell(new Point(cell.x, indexOf(child)), tick);
        }
    }
}
Also used : TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 28 with ModelElementIndicator

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

the class AbstractIndicatorSelectGrid method createChildNodes.

/**
 * recursively create tree nodes and checked the existing indicators.
 *
 * @param grid
 * @param currentItem
 * @param indicatorNode
 */
void createChildNodes(GridItem parentItem, GridItem currentItem, IIndicatorNode indicatorNode) {
    Boolean[] hasCheckableInColumn = new Boolean[getColumnCount()];
    for (int j = 1; j < getColumnCount(); j++) {
        hasCheckableInColumn[j] = false;
    }
    for (int i = 0; i < indicatorNode.getChildren().length; i++) {
        IIndicatorNode childNode = indicatorNode.getChildren()[i];
        TalendGridItem childItem = new TalendGridItem(currentItem, SWT.NONE);
        childItem.setImage(ImageLib.getImage(childNode.getImageName()));
        if (childNode.hasChildren()) {
            createChildNodes(currentItem, childItem, childNode);
        }
        childItem.setText(childNode.getLabel());
        childItem.setData(childNode);
        if (parentItem == null) {
            childItem.setExpanded(true);
        }
        boolean hasCheckableInRow = false;
        for (int j = 2; j < getColumnCount(); j++) {
            // ignore indicator label column and row select column
            IndicatorEnum indicatorEnum = childNode.getIndicatorEnum();
            // DB columns
            ModelElementIndicator meIndicator = null;
            if (j - 2 < _modelElementIndicators.length) {
                meIndicator = _modelElementIndicators[j - 2];
            } else {
                meIndicator = _modelElementIndicators[0];
            }
            // Enable/disable the check box
            boolean isMatch = _dialog.isMatchCurrentIndicator(meIndicator, childNode);
            childItem.setCheckable(j, isMatch);
            if (isMatch) {
                hasCheckableInRow = true;
                hasCheckableInColumn[j] = true;
                // Check the box if it is already selected
                if (meIndicator != null && (meIndicator.tempContains(indicatorEnum) || meIndicator.specialTempContains(childNode.getIndicatorInstance()))) {
                    childItem.setChecked(j, true);
                }
            }
        }
        childItem.setCheckable(1, hasCheckableInRow);
    }
    boolean entireCategoryCheckable = false;
    for (int j = 2; j < getColumnCount(); j++) {
        if (hasCheckableInColumn[j]) {
            entireCategoryCheckable = true;
        } else {
            currentItem.setCheckable(j, false);
        }
    }
    currentItem.setCheckable(1, entireCategoryCheckable);
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) Point(org.eclipse.swt.graphics.Point) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 29 with ModelElementIndicator

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

the class AbstractIndicatorSelectGrid method initializeGrid.

protected void initializeGrid() {
    // first column is for indicator labels, it is hided from the cells but shown as row header.
    createIndicatorLabelColumn();
    // column
    // select all column
    createRowSelectColumn();
    // database columns
    for (int index = 0; index < _modelElementIndicators.length; index++) {
        ModelElementIndicator _modelElementIndicator = _modelElementIndicators[index];
        final GridColumn newCol = new TalendGridColumn(this, SWT.CHECK);
        AbstractColumnHerderRenderer headerRenderer = getColumnHeaderRenderer();
        headerRenderer.setRotation(COLUMN_HEADER_ROTATION);
        newCol.setHeaderRenderer(headerRenderer);
        newCol.setCellRenderer(getCellRenderer());
        newCol.setText(ModelElementIndicatorHelper.getModelElementDisplayName(_modelElementIndicator));
        newCol.setWidth(getPreferWidth(index));
        newCol.setData(_modelElementIndicator);
        newCol.setMoveable(true);
        newCol.setResizeable(true);
        newCol.setHeaderFont(headerFont);
        IRepositoryNode repNode = _modelElementIndicator.getModelElementRepositoryNode();
        if (repNode instanceof DBColumnRepNode && ((DBColumnRepNode) repNode).isKey()) {
            newCol.setImage(ImageLib.getImage(ImageLib.PK_ICON));
        }
        newCol.addListener(SWT.Resize, new Listener() {

            public void handleEvent(Event event) {
                notifyObservers(event);
            }
        });
        newCol.addListener(SWT.Move, new Listener() {

            public void handleEvent(Event event) {
                notifyObservers(event);
                isColumnMoved = true;
            }
        });
    }
    recalculateHeader();
    // initialize grid contents
    createTableContent();
    // show fixed column header
    setHeaderVisible(true);
    setTopLeftRenderer(new TdTopLeftRenderer());
    // setCellHeaderSelectionBackground(IndicatorSelectGrid.standardYellow);
    setEmptyColumnHeaderRenderer(new TdEmptyColumnHeaderRenderer());
    setEmptyRowHeaderRenderer(new TdEmptyCellRenderer());
    setEmptyCellRenderer(new TdEmptyCellRenderer());
    // show fixed row header
    TdRowHeaderRenderer rowHeaderRenderer = new TdRowHeaderRenderer();
    setRowHeaderRenderer(rowHeaderRenderer);
    rowHeaderRenderer.setTree(true);
    rowHeaderRenderer.setWordWrap(false);
    setRowHeaderVisible(true);
    setLinesVisible(true);
    setColumnScrolling(true);
    setSelectionEnabled(false);
    setCellSelectionEnabled(false);
    setRowsResizeable(false);
    setItemHeight(21);
    setLineColor(lineColor);
    setFont(itemFont);
    setFocusRenderer(null);
    for (GridItem gridItem : getItems()) {
        gridItem.setBackground(0, gray);
    }
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) Listener(org.eclipse.swt.widgets.Listener) MouseListener(org.eclipse.swt.events.MouseListener) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) Point(org.eclipse.swt.graphics.Point) TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) Event(org.eclipse.swt.widgets.Event) MouseEvent(org.eclipse.swt.events.MouseEvent) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 30 with ModelElementIndicator

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

the class ModelElementIndicatorHelper method getColumns.

/**
 * Get columns from modelElementIndicators
 *
 * @param modelElementIndicators
 * @return
 */
public static final List<MetadataColumn> getColumns(ModelElementIndicator[] modelElementIndicators) {
    List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
    for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
        ColumnIndicator switchColumnIndicator = switchColumnIndicator(modelElementIndicator);
        if (switchColumnIndicator == null) {
            continue;
        }
        columns.add(switchColumnIndicator.getTdColumn());
    }
    return columns;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ColumnIndicator(org.talend.dataprofiler.core.model.ColumnIndicator) ArrayList(java.util.ArrayList) 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