Search in sources :

Example 1 with WhereRuleChartDataEntity

use of org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity in project tdq-studio-se by Talend.

the class WhereRuleStatisticsTableState method getDataEntity.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.preview.model.states.table.AbstractTableTypeStates#getDataEntity()
     */
@Override
public ChartDataEntity[] getDataEntity() {
    List<WhereRuleChartDataEntity> dataEnities = new ArrayList<WhereRuleChartDataEntity>();
    for (TableIndicatorUnit unit : tableunits) {
        if (IndicatorEnum.WhereRuleIndicatorEnum.equals(unit.getType())) {
            double value = WhereRuleStatisticsStateUtil.getMatchValue(unit.getValue());
            WhereRuleChartDataEntity entity = WhereRuleStatisticsStateUtil.createRuleDataEntity(unit, unit.getIndicatorName(), value, WhereRuleStatisticsStateUtil.getNotMatchValue(unit.getValue(), value, unit.geIndicatorCount()));
            dataEnities.add(entity);
        }
    }
    return dataEnities.toArray(new WhereRuleChartDataEntity[dataEnities.size()]);
}
Also used : WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity) ArrayList(java.util.ArrayList) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)

Example 2 with WhereRuleChartDataEntity

use of org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity in project tdq-studio-se by Talend.

the class TableDynamicChartEventReceiver method clearValue.

@Override
public void clearValue() {
    if (IndicatorEnum.RowCountIndicatorEnum.equals(this.getIndicatorType())) {
        super.clearValue();
    } else {
        // clear the data before running.
        if (dataset != null) {
            TOPChartUtils.getInstance().setValue(dataset, 0.0, WhereRuleStatisticsStateTable.ROW_KEY_NOT_PASS, indicatorName);
            TOPChartUtils.getInstance().setValue(dataset, 0.0, WhereRuleStatisticsStateTable.ROW_KEY_PASS, indicatorName);
        }
        if (tableViewer != null) {
            TableWithData input = (TableWithData) tableViewer.getInput();
            if (input != null) {
                ChartDataEntity[] dataEntities = input.getEnity();
                ((WhereRuleChartDataEntity) dataEntities[this.getEntityIndex()]).setNumMatch(NAN_STRING);
                ((WhereRuleChartDataEntity) dataEntities[this.getEntityIndex()]).setNumNoMatch(NAN_STRING);
                tableViewer.getTable().clearAll();
                tableViewer.setInput(input);
            }
        }
    }
}
Also used : WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity) TableWithData(org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity)

Example 3 with WhereRuleChartDataEntity

use of org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity in project tdq-studio-se by Talend.

the class WhereRuleStatisticsStateUtil method createRuleDataEntity.

/**
 * DOC yyin Comment method "createRuleDataEntity".
 *
 * @param unit
 * @param columnKey
 * @param value
 * @param valueNotM
 * @return
 */
public static WhereRuleChartDataEntity createRuleDataEntity(TableIndicatorUnit unit, String columnKey, double value, double valueNotM) {
    WhereRuleChartDataEntity entity = new WhereRuleChartDataEntity();
    entity.setIndicator(unit.getIndicator());
    entity.setLabel(columnKey);
    entity.setNumMatch(String.valueOf(value));
    entity.setNumNoMatch(String.valueOf(valueNotM));
    // ADD xqliu 2010-03-10 feature 10834
    entity.setToolTip(WhereRuleStatisticsStateUtil.getUnitToolTip(unit));
    // ~
    return entity;
}
Also used : WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity)

Example 4 with WhereRuleChartDataEntity

use of org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method getAllColumnNodes.

/**
 * get All the Column level Nodes.
 *
 * @param selectedNodes
 * @return
 */
public static IRepositoryNode[] getAllColumnNodes(Object[] selectedNodes) {
    List<IRepositoryNode> list = new ArrayList<IRepositoryNode>();
    if (selectedNodes == null || selectedNodes.length == 0) {
        return list.toArray(new IRepositoryNode[list.size()]);
    }
    Object firstElement = selectedNodes[0];
    if (firstElement instanceof IRepositoryNode) {
        IRepositoryNode repNode = (IRepositoryNode) firstElement;
        IRepositoryViewObject repViewObject = repNode.getObject();
        if (repViewObject instanceof MetadataColumnRepositoryObject || repViewObject instanceof MetadataXmlElementType) {
            IRepositoryNode[] column = new IRepositoryNode[selectedNodes.length];
            for (int i = 0; i < selectedNodes.length; i++) {
                column[i] = (IRepositoryNode) selectedNodes[i];
            }
            return column;
        } else if (repViewObject instanceof MetadataTableRepositoryObject) {
            for (Object currentObj : selectedNodes) {
                IRepositoryNode columnSetNode = (IRepositoryNode) currentObj;
                List<IRepositoryNode> children = columnSetNode.getChildren();
                if (children.size() > 0) {
                    list.addAll(children.get(0).getChildren());
                }
            }
            return list.toArray(new IRepositoryNode[list.size()]);
        }
    } else if (firstElement instanceof TdTable) {
        TdTable table = (TdTable) firstElement;
        EList<MetadataColumn> columns = table.getColumns();
        for (MetadataColumn column : columns) {
            RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(column);
            list.add(recursiveFind);
        }
        return list.toArray(new IRepositoryNode[list.size()]);
    } else if (firstElement instanceof WhereRuleChartDataEntity) {
        // ADD msjian 2012-2-9 TDQ-4470: get columns from the join conditions
        EList<JoinElement> joinConditions = ((WhereRuleChartDataEntity) firstElement).getIndicator().getJoinConditions();
        if (joinConditions != null && joinConditions.size() > 0) {
            JoinElement joinElement = joinConditions.get(0);
            list.add(RepositoryNodeHelper.recursiveFind(joinElement.getColA()));
            list.add(RepositoryNodeHelper.recursiveFind(joinElement.getColB()));
            return list.toArray(new IRepositoryNode[list.size()]);
        }
    // TDQ-4470 ~
    } else if (firstElement instanceof TdView) {
        // Added yyin 20120522 TDQ-4945, support tdView
        TdView view = (TdView) firstElement;
        EList<MetadataColumn> columns = view.getColumns();
        for (MetadataColumn column : columns) {
            RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(column);
            list.add(recursiveFind);
        }
        return list.toArray(new IRepositoryNode[list.size()]);
    }
    // ~
    return null;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) JoinElement(org.talend.dataquality.rules.JoinElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) EList(org.eclipse.emf.common.util.EList) WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity) TdView(org.talend.cwm.relational.TdView) MetadataXmlElementType(org.talend.core.model.metadata.MetadataXmlElementType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISubRepositoryObject(org.talend.core.model.repository.ISubRepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) EObject(org.eclipse.emf.ecore.EObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList)

Example 5 with WhereRuleChartDataEntity

use of org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity in project tdq-studio-se by Talend.

the class TableDynamicChartEventReceiver method handle.

@Override
public boolean handle(Object value) {
    if (value == null) {
        return false;
    }
    if (IndicatorEnum.RowCountIndicatorEnum.equals(this.getIndicatorType())) {
        super.handle(value);
    } else {
        Long count = getIndicator().getCount();
        double valueMatch = WhereRuleStatisticsStateUtil.getMatchValue(value);
        double valueNotmatch = WhereRuleStatisticsStateUtil.getNotMatchValue(value, valueMatch, count);
        if (dataset != null) {
            TOPChartUtils.getInstance().setValue(dataset, valueNotmatch, WhereRuleStatisticsStateTable.ROW_KEY_NOT_PASS, indicatorName);
            TOPChartUtils.getInstance().setValue(dataset, valueMatch, WhereRuleStatisticsStateTable.ROW_KEY_PASS, indicatorName);
        }
        if (tableViewer != null) {
            TableWithData input = (TableWithData) tableViewer.getInput();
            if (input != null) {
                ChartDataEntity[] dataEntities = input.getEnity();
                ((WhereRuleChartDataEntity) dataEntities[this.getEntityIndex()]).setNumMatch(String.valueOf(valueMatch));
                ((WhereRuleChartDataEntity) dataEntities[this.getEntityIndex()]).setNumNoMatch(String.valueOf(valueNotmatch));
                tableViewer.getTable().clearAll();
                tableViewer.setInput(input);
            }
        }
    }
    return true;
}
Also used : WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity) TableWithData(org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) WhereRuleChartDataEntity(org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity)

Aggregations

WhereRuleChartDataEntity (org.talend.dq.indicators.preview.table.WhereRuleChartDataEntity)7 ArrayList (java.util.ArrayList)3 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)3 List (java.util.List)2 EList (org.eclipse.emf.common.util.EList)2 TdTable (org.talend.cwm.relational.TdTable)2 TableWithData (org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData)2 JoinElement (org.talend.dataquality.rules.JoinElement)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IFolder (org.eclipse.core.resources.IFolder)1 EObject (org.eclipse.emf.ecore.EObject)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1