Package org.apache.metamodel.data

Examples of org.apache.metamodel.data.DefaultRow


                assertEquals("role", columns[2].getName());
                SelectItem[] selectItems = new SelectItem[] { new SelectItem(col1), new SelectItem(col2),
                        new SelectItem(col3) };
                DataSetHeader header = new CachingDataSetHeader(selectItems);
                List<Row> rows = new LinkedList<Row>();
                rows.add(new DefaultRow(header, new Object[] { "foo", "bar", 1 }));
                rows.add(new DefaultRow(header, new Object[] { "kasper", "developer", 2 }));
                rows.add(new DefaultRow(header, new Object[] { "admin", "admin", 3 }));
                rows.add(new DefaultRow(header, new Object[] { "elikeon", "user", 4 }));
                rows.add(new DefaultRow(header, new Object[] { "someuser", "user", 5 }));
                rows.add(new DefaultRow(header, new Object[] { "hmm", "what-the", 6 }));

                return new InMemoryDataSet(header, rows);
            }

            @Override
View Full Code Here


        FilterItem filterItem = new FilterItem(selectItem, OperatorType.IN, operand);
        SelectItem[] selectItems = new SelectItem[] { selectItem };
        DataSetHeader header = new CachingDataSetHeader(selectItems);

        assertTrue(filterItem.evaluate(new DefaultRow(header, new Object[] { "foo" })));
        assertTrue(filterItem.evaluate(new DefaultRow(header, new Object[] { "bar" })));
        assertFalse(filterItem.evaluate(new DefaultRow(header, new Object[] { "foobar" })));
    }
View Full Code Here

    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
        if (_tableName.equals(table.getName())) {
            final SelectItem[] allSelectItems = MetaModelHelper.createSelectItems(table.getColumns());
            final DataSetHeader header = new CachingDataSetHeader(allSelectItems);
            final List<Row> data = new ArrayList<Row>();
            data.add(new DefaultRow(header, new Object[] { "1", "hello", "world" }, null));
            data.add(new DefaultRow(header, new Object[] { "2", _value, "world" }, null));
            data.add(new DefaultRow(header, new Object[] { "3", "hi", _value }, null));
            data.add(new DefaultRow(header, new Object[] { "4", "yo", "world" }, null));

            final DataSet sourceDataSet = new InMemoryDataSet(header, data);

            final SelectItem[] columnSelectItems = MetaModelHelper.createSelectItems(columns);
            final DataSet selectionDataSet = MetaModelHelper.getSelection(columnSelectItems, sourceDataSet);
View Full Code Here

        SimpleDataSetHeader header = new SimpleDataSetHeader(selectItems);

        List<Row> rows = new ArrayList<Row>();
        for (Object[] objects : data) {
            rows.add(new DefaultRow(header, objects));
        }
        return new InMemoryDataSet(header, rows);
    }
View Full Code Here

            Object[] rowValues = new Object[columns.length];
            for (int i = 0; i < columns.length; i++) {
                int columnNumber = columns[i].getColumnNumber();
                rowValues[i] = values[columnNumber];
            }
            rows.add(new DefaultRow(header, rowValues));
        }

        if (rows.isEmpty()) {
            return new EmptyDataSet(items);
        }
View Full Code Here

    private void delete(List<FilterItem> whereItems) {
        final SelectItem[] selectItems = MetaModelHelper.createSelectItems(_table.getColumns());
        final CachingDataSetHeader header = new CachingDataSetHeader(selectItems);
        for (Iterator<Object[]> it = _values.iterator(); it.hasNext();) {
            Object[] values = (Object[]) it.next();
            DefaultRow row = new DefaultRow(header, values);
            boolean delete = true;
            for (FilterItem filterItem : whereItems) {
                if (!filterItem.evaluate(row)) {
                    delete = false;
                    break;
View Full Code Here

        assertEquals(SubSelectionDataSet.class, joinedDs.getClass());
        assertEquals("[foo AS f, bar AS b, baz AS z]", Arrays.toString(joinedDs.getSelectItems()));

        DataSetHeader header1 = new SimpleDataSetHeader(selectItems1);
        Row row = new DefaultRow(header1, new Object[] { 1, 2 }, null);
        ds1 = new InMemoryDataSet(header1, row);

        joinedDs = MetaModelHelper.getLeftJoin(ds1, ds2, new FilterItem[] { new FilterItem(item2,
                OperatorType.EQUALS_TO, item3) });
        assertEquals("[foo AS f, bar AS b, baz AS z]", Arrays.toString(joinedDs.getSelectItems()));
View Full Code Here

                value = valueNode;
            }
            values[i] = value;
        }

        DefaultRow finalRow = new DefaultRow(header, values);

        return finalRow;
    }
View Full Code Here

                    } catch (Exception e) {
                        logger.debug("Could not invoke wasNull() method on resultset, error message: {}",
                                e.getMessage());
                    }
                }
                _row = new DefaultRow(getHeader(), values);
            } else {
                _row = null;
            }
            return result;
        } catch (SQLException e) {
View Full Code Here

                logger.debug("Converted physical value {} to {}", value, virtualValue);
                value = virtualValue;
            }
            values[i] = value;
        }
        return new DefaultRow(getHeader(), values);
    }
View Full Code Here

TOP

Related Classes of org.apache.metamodel.data.DefaultRow

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.