Package org.apache.metamodel.data

Examples of org.apache.metamodel.data.DataSet.toObjectArrays()


                .execute();
        assertEquals(MongoDbDataSet.class, ds.getClass());
        assertFalse(((MongoDbDataSet) ds).isQueryPostProcessed());

        try {
            List<Object[]> objectArrays = ds.toObjectArrays();
            assertEquals(200, objectArrays.size());
            assertEquals("[0, record no. 0]", Arrays.toString(objectArrays.get(0)));
        } finally {
            ds.close();
        }
View Full Code Here


    public void doTicketFileTests(DataContext dc) {
        Table table = dc.getDefaultSchema().getTables()[0];
        Query q = dc.query().from(table).select(table.getColumns()).toQuery();

        DataSet dataSet = dc.executeQuery(q);
        List<Object[]> objectArrays = dataSet.toObjectArrays();
        assertEquals(13, objectArrays.get(0).length);
        assertEquals(36, objectArrays.size());
        assertEquals("2", objectArrays.get(0)[0].toString());

        Object description = objectArrays.get(0)[11];
View Full Code Here

                return schema;
            }
        };

        DataSet result = dc.executeQuery(q);
        List<Object[]> objectArrays = result.toObjectArrays();
        assertEquals(3, objectArrays.size());
        assertEquals(2, objectArrays.get(0)[0]);
        assertEquals(4, objectArrays.get(1)[0]);
        assertEquals(5, objectArrays.get(2)[0]);
    }
View Full Code Here

    assertSame(dc1.getDefaultSchema(), composite.getDefaultSchema());

    DataSet ds = composite.query()
        .from(dc1.getDefaultSchema().getTables()[0]).select("foo")
        .execute();
    List<Object[]> objectArrays = ds.toObjectArrays();
    assertEquals("1", objectArrays.get(0)[0]);
    assertEquals("2", objectArrays.get(1)[0]);
    assertEquals(4, objectArrays.size());
  }
View Full Code Here

          }
        });

    DataSet ds = dc.query().from(table).select("foo").execute();
    assertEquals(MaxRowsDataSet.class, ds.getClass());
    assertEquals(1, ds.toObjectArrays().size());
  }

  public void testInterceptQuery() throws Exception {

    DataContext dc = new InterceptableDataContext(delegateDataContext)
View Full Code Here

        assertEquals("[string, number, date]", Arrays.toString(table.getColumnNames()));

        Query q = dc.query().from(table).select(table.getColumns()).orderBy(table.getColumnByName("number")).toQuery();
        DataSet ds = dc.executeQuery(q);
        List<Object[]> objectArrays = ds.toObjectArrays();
        assertEquals(4, objectArrays.size());
        assertEquals("[hello, 1, 2010-01-01 00:00:00]", Arrays.toString(objectArrays.get(0)));
        assertEquals("[world, 2, 2010-01-02 00:00:00]", Arrays.toString(objectArrays.get(1)));
        assertEquals("[foo, 3, 2010-01-03 00:00:00]", Arrays.toString(objectArrays.get(2)));
        assertEquals("[bar, 4, 2010-01-04 00:00:00]", Arrays.toString(objectArrays.get(3)));
View Full Code Here

        DataSet ds2 = createDataSet(new SelectItem[] { si5, si6, si7 }, data2);
        FilterItem[] onConditions = new FilterItem[1];
        onConditions[0] = new FilterItem(si4, OperatorType.EQUALS_TO, si5);

        DataSet result = MetaModelHelper.getLeftJoin(ds1, ds2, onConditions);
        List<Object[]> objectArrays = result.toObjectArrays();
        assertEquals("[1, peter, 18, 1, 1, class president, clpr]", Arrays.toString(objectArrays.get(0)));
        assertEquals("[2, tom, 19, 2, 2, bad boy, bb]", Arrays.toString(objectArrays.get(1)));
        assertEquals("[3, betty, 19, null, null, null, null]", Arrays.toString(objectArrays.get(2)));
        assertEquals("[4, barbara, 17, 3, null, null, null]", Arrays.toString(objectArrays.get(3)));
        assertEquals("[5, susie, 18, 4, 4, trying harder, try]", Arrays.toString(objectArrays.get(4)));
View Full Code Here

        DataSet ds2 = createDataSet(new SelectItem[] { si5, si6, si7 }, data2);
        FilterItem[] onConditions = new FilterItem[1];
        onConditions[0] = new FilterItem(si4, OperatorType.EQUALS_TO, si5);

        DataSet result = MetaModelHelper.getRightJoin(ds1, ds2, onConditions);
        List<Object[]> objectArrays = result.toObjectArrays();
        assertEquals("[1, peter, 18, 1, 1, class president, clpr]", Arrays.toString(objectArrays.get(0)));
        assertEquals("[2, tom, 19, 2, 2, bad boy, bb]", Arrays.toString(objectArrays.get(1)));
        assertEquals("[null, null, null, null, 4, trying harder, try]", Arrays.toString(objectArrays.get(2)));
        assertEquals(3, objectArrays.size());
    }
View Full Code Here

        try {
            assertEquals(1, compiledQuery.getParameters().size());
            assertSame(param1, compiledQuery.getParameters().get(0));

            DataSet ds = dc.executeQuery(compiledQuery, "denmark");
            List<Object[]> objectArrays = ds.toObjectArrays();
            assertEquals(3, objectArrays.size());

        } finally {
            compiledQuery.close();
        }
View Full Code Here

        q.from(table1);
        q.from(table2);
        q.select(table1.getColumns());
        q.select(table2.getColumns());
        data = dc.executeQuery(q);
        assertEquals(48, data.toObjectArrays().size());

        q.setFirstRow(3);
        data = dc.executeQuery(q);
        assertEquals(46, data.toObjectArrays().size());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.