Package org.apache.metamodel.data

Examples of org.apache.metamodel.data.DataSetHeader


                                final Object operand = whereItem.getOperand();
                                final Row row = executePrimaryKeyLookupQuery(table, selectItems, column, operand);
                                if (row == null) {
                                    logger.debug("DataContext did not return any primary key lookup query results. Proceeding with manual lookup.");
                                } else {
                                    final DataSetHeader header = new SimpleDataSetHeader(selectItems);
                                    return new InMemoryDataSet(header, row);
                                }
                            }
                        }
                    }
View Full Code Here


    public void testEvaluateBooleans() throws Exception {
        Column col1 = new MutableColumn("Col1", ColumnType.BIT);
        SelectItem s1 = new SelectItem(col1);
        SelectItem[] selectItems = new SelectItem[] { s1 };
        DataSetHeader header = new SimpleDataSetHeader(selectItems);

        FilterItem c = new FilterItem(s1, OperatorType.EQUALS_TO, true);

        Row row = new DefaultRow(header, new Object[] { true });
        assertTrue(c.evaluate(row));
View Full Code Here

        FilterItem c3 = new FilterItem(s1, OperatorType.EQUALS_TO, "foobar");

        FilterItem filter = new FilterItem(c1, c2, c3);
        assertEquals("(Col1 = 'foo' OR Col1 = 'bar' OR Col1 = 'foobar')", filter.toString());

        DataSetHeader header = new SimpleDataSetHeader(new SelectItem[] { s1 });

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

                assertEquals("column_number", columns[0].getName());
                assertEquals("name", columns[1].getName());
                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 }));
View Full Code Here

                null, false, null));
        Object operand = new String[] { "foo", "bar" };

        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

    @Override
    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));
View Full Code Here

                OperatorType.EQUALS_TO, item3) });

        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) });
View Full Code Here

        }

        final org.ektorp.ViewResult.Row row = _iterator.next();
        final JsonNode node = row.getDocAsNode();

        final DataSetHeader header = getHeader();
        _row = (DefaultRow) CouchDbUtils.jsonNodeToMetaModelRow(node, header);

        return true;
    }
View Full Code Here

                }
            }

            // convert the line's values into the row values that where
            // requested
            final DataSetHeader header = _dataSet.getHeader();
            final int size = header.size();
            final String[] rowValues = new String[size];

            for (int i = 0; i < size; i++) {
                final Column column = header.getSelectItem(i).getColumn();
                final int columnNumber = column.getColumnNumber();
                if (columnNumber < csvValues.length) {
                    rowValues[i] = csvValues[columnNumber];
                } else {
                    // Ticket #125: Missing values should be interpreted as
View Full Code Here

            throw new IllegalStateException("No such table name: '" + table.getName() + "'. Valid table names are: "
                    + _tableData.keySet());
        }

        final SelectItem[] selectItems = MetaModelHelper.createSelectItems(columns);
        final DataSetHeader header = new CachingDataSetHeader(selectItems);

        final List<Row> resultData = new ArrayList<Row>();
        for (Object[] tableDataRow : tableData) {
            if (maxRows == 0) {
                break;
View Full Code Here

TOP

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

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.