Package org.dashbuilder.dataset

Examples of org.dashbuilder.dataset.DataSetOp


    public T sum(String columnId, String newColumnId) {
        return function(columnId, newColumnId, AggregateFunctionType.SUM);
    }

    protected T function(String columnId, String newColumnId, AggregateFunctionType function) {
        DataSetOp op = getCurrentOp();
        if (op == null || !(op instanceof DataSetGroup)) {
            dataSetLookup.addOperation(new DataSetGroup());
        }
        DataSetGroup gOp = (DataSetGroup) getCurrentOp();
        gOp.addGroupFunction(new GroupFunction(columnId, newColumnId, function));
View Full Code Here


        gOp.addGroupFunction(new GroupFunction(columnId, newColumnId, function));
        return (T) this;
    }

    public T select(String... intervalNames) {
        DataSetOp op = getCurrentOp();
        if (op == null || !(op instanceof DataSetGroup)) {
            dataSetLookup.addOperation(new DataSetGroup());
        }
        DataSetGroup gOp = (DataSetGroup) getCurrentOp();
        gOp.addSelectedIntervalNames(intervalNames);
View Full Code Here

    public T filter(ColumnFilter... filters) {
        return filter(null, filters);
    }

    public T filter(String columnId, ColumnFilter... filters) {
        DataSetOp op = getCurrentOp();
        if (op == null || !(op instanceof DataSetFilter)) {
            dataSetLookup.addOperation(new DataSetFilter());
        }
        DataSetFilter fOp = (DataSetFilter) getCurrentOp();
        for (ColumnFilter filter : filters) {
View Full Code Here

    public T sort(String columnId, String order) {
        return sort(columnId, SortOrder.getByName(order));
    }

    public T sort(String columnId, SortOrder order) {
        DataSetOp op = getCurrentOp();
        if (op == null || !(op instanceof DataSetSort)) {
            dataSetLookup.addOperation(new DataSetSort());
        }
        DataSetSort sOp = (DataSetSort) getCurrentOp();
        sOp.addSortColumn(new ColumnSort(columnId, order));
View Full Code Here

            while (it1.hasNext()) {
                GroupOpFilter target = it1.next();

                Iterator<DataSetOp> it2 = lookupCurrent.getOperationList().iterator();
                while (it2.hasNext()) {
                    DataSetOp next = it2.next();
                    if (next == target.groupOp && target.drillDown == drillDown) {
                        it1.remove();
                        it2.remove();
                        opFound = true;
                    }
                }
            }
        }

        if (_groupOpsSelected.containsKey(columnId)) {

            Iterator<GroupOpFilter> it1 = _groupOpsSelected.get(columnId).iterator();
            while (it1.hasNext()) {
                GroupOpFilter target = it1.next();

                Iterator<DataSetGroup> it2 = lookupCurrent.getOperationList(DataSetGroup.class).iterator();
                while (it2.hasNext()) {
                    DataSetGroup next = it2.next();
                    if (next == target.groupOp && target.drillDown == drillDown) {
                        it1.remove();
                        next.getSelectedIntervalNames().clear();
                        next.getGroupFunctions().clear();
                        next.getSelectedIntervalNames().addAll(target.intervalNames);
                        next.getGroupFunctions().addAll(target.groupFunctions);
                        opFound = true;
                    }
                }
            }
        }
View Full Code Here

            boolean group = false;
            boolean calculations = false;
            boolean sort = false;

            for (int i=0; i<operationList.size(); i++) {
                DataSetOp op = operationList.get(i);

                if (DataSetOpType.GROUP.equals(op.getType())) {
                    if (calculations) throw new IllegalStateException("Group not permitted after a simple function calculation operation.");
                    if (sort) throw new IllegalStateException("Sort operations must be applied ALWAYS AFTER GROUP.");

                    DataSetGroup gOp = (DataSetGroup) op;
                    ColumnGroup columnGroup = gOp.getColumnGroup();
                    if (columnGroup == null) {
                        // No real group requested. Only function calculations on the data set.
                        calculations = true;
                        context.lastOperation = op;
                    } else {
                        if (group(gOp, context)) {
                            // The group will be required if is not an interval selection
                            group = context.lastGroupOp.getSelectedIntervalNames().isEmpty();
                            context.lastOperation = op;
                        }
                    }
                }
                else if (DataSetOpType.FILTER.equals(op.getType())) {
                    if (calculations) throw new IllegalStateException("Filter not permitted after a simple function calculation operation.");
                    if (group) throw new IllegalStateException("Filter operations must be applied ALWAYS BEFORE GROUP.");
                    if (sort) throw new IllegalStateException("Sort operations must be applied ALWAYS AFTER FILTER.");

                    filter((DataSetFilter) op, context);
                    context.lastOperation = op;
                }
                else if (DataSetOpType.SORT.equals(op.getType())) {
                    if (calculations) throw new IllegalStateException("Sort not permitted after a function calculation operation.");
                    if (sort) throw new IllegalStateException("Sort can only be executed once.");

                    if (group) {
                        buildDataSet(context);
                    }

                    sort = true;
                    sort((DataSetSort) op, context);
                    context.lastOperation = op;
                }
                else {
                    throw new IllegalArgumentException("Unsupported operation: " + op.getClass().getName());
                }
            }

            // Build the resulting data set
            buildDataSet(context);
View Full Code Here

            context.index = null;
            return result;
        }

        private DataSet _buildDataSet(InternalContext context) {
            DataSetOp lastOp = context.lastOperation;
            DataSetIndexNode index = context.index;
            DataSet dataSet = context.dataSet;

            if (lastOp instanceof DataSetGroup) {
                DataSetGroup gOp = (DataSetGroup) lastOp;
View Full Code Here

TOP

Related Classes of org.dashbuilder.dataset.DataSetOp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.