Package org.apache.metamodel.data

Examples of org.apache.metamodel.data.Row


                        if (!whereItem.isCompoundFilter() && selectItem != null && selectItem.getColumn() != null) {
                            final Column column = selectItem.getColumn();
                            if (column.isPrimaryKey() && whereItem.getOperator() == OperatorType.EQUALS_TO) {
                                logger.debug("Query is a primary key lookup query. Trying executePrimaryKeyLookupQuery(...)");
                                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


        Column col2 = new MutableColumn("Col2", ColumnType.VARCHAR);
        SelectItem s1 = new SelectItem(col1);
        SelectItem s2 = new SelectItem(col2);
        SelectItem[] selectItems = new SelectItem[] { s1, s2 };
        SimpleDataSetHeader header = new SimpleDataSetHeader(selectItems);
        Row row;
        FilterItem c;

        row = new DefaultRow(header, new Object[] { "foo", "bar" });
        c = new FilterItem(s1, OperatorType.DIFFERENT_FROM, s2);
        assertTrue(c.evaluate(row));
View Full Code Here

        SelectItem[] selectItems = new SelectItem[] { s1, s2 };
        CachingDataSetHeader header = new CachingDataSetHeader(selectItems);

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

        Row row = new DefaultRow(header, new Object[] { 1, 1 });
        assertFalse(c.evaluate(row));
        row = new DefaultRow(header, new Object[] { null, 1 });
        assertTrue(c.evaluate(row));

        c = new FilterItem(s1, OperatorType.EQUALS_TO, 1);
View Full Code Here

        CachingDataSetHeader header = new CachingDataSetHeader(selectItems);

        long currentTimeMillis = System.currentTimeMillis();
        FilterItem c = new FilterItem(s1, OperatorType.LESS_THAN, new java.sql.Date(currentTimeMillis));

        Row row = new DefaultRow(header, new Object[] { new java.sql.Date(currentTimeMillis) });
        assertFalse(c.evaluate(row));
        row = new DefaultRow(header, new Object[] { new java.sql.Date(currentTimeMillis + 10000000) });
        assertFalse(c.evaluate(row));
        row = new DefaultRow(header, new Object[] { new java.sql.Date(currentTimeMillis - 10000000) });
        assertTrue(c.evaluate(row));
View Full Code Here

        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));
        row = new DefaultRow(header, new Object[] { false });
        assertFalse(c.evaluate(row));

        c = new FilterItem(s1, OperatorType.EQUALS_TO, false);
View Full Code Here

        while (ds1next) {
            ds1next = ds1.next();
            boolean ds2next = ds2.next();
            assertEquals("DataSet 1 next=" + ds1next, ds1next, ds2next);
            if (ds1next) {
                Row row1 = ds1.getRow();
                Row row2 = ds2.getRow();
                assertEquals(row1, row2);
            }
        }
    }
View Full Code Here

        q.setMaxRows(1);

        final DataSet ds = dc.executeQuery(q);
        final SelectItem[] selectItems = ds.getSelectItems();
        while (ds.next()) {
            Row row = ds.getRow();

            for (SelectItem selectItem : selectItems) {
                Column column = selectItem.getColumn();
                Object value = row.getValue(column);
                if (value != null) {
                    ColumnType type = column.getType();
                    Class<?> expected = type.getJavaEquivalentClass();
                    Class<? extends Object> actual = value.getClass();
                    assertEquals("Unexpected type of value: " + value + ". Expected " + expected.getName()
View Full Code Here

        final List<String> ids = new ArrayList<String>();

        DataSet ds;
        ds = dc.query().from(tableName).select("id", "name").where("name").eq(insertedName).execute();
        assertTrue(ds.next());
        Row row = ds.getRow();
        assertNotNull(row.getValue(0));
        ids.add(row.getValue(0).toString());

        while (ds.next()) {
            row = ds.getRow();
            ids.add(row.getValue(0).toString());
            assertEquals("MetaModel TESTER contact", row.getValue(1));
        }

        ds.close();

        // UPDATE
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

                try {
                    for (int i = 0; i < noOfCallsPerThreads; i++) {
                        final DataSet dataSet = dataContext.executeQuery(compiledQuery, new Object[] { 103 });
                        try {
                            assertTrue(dataSet.next());
                            Row row = dataSet.getRow();
                            assertNotNull(row);
                            assertEquals("Atelier graphique", row.getValue(0).toString());
                            assertFalse(dataSet.next());
                        } finally {
                            dataSet.close();
                        }
                    }
View Full Code Here

TOP

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

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.