Package org.apache.metamodel.data

Examples of org.apache.metamodel.data.Row


        DataSet dataSet = dataContext.query().from(table)
                .select(CouchDbDataContext.FIELD_ID, CouchDbDataContext.FIELD_REV).where(whereItems).execute();
        try {
            while (dataSet.next()) {
                Row row = dataSet.getRow();
                String id = (String) row.getValue(0);
                String revision = (String) row.getValue(1);
                connector.delete(id, revision);
            }
        } finally {
            dataSet.close();
        }
View Full Code Here


    final CouchDbDataContext dc = _updateCallback.getDataContext();
    final DataSet dataSet = dc.query().from(table).select(table.getColumns()).where(getWhereItems()).execute();
    try {
      while (dataSet.next()) {
        final Map<String, Object> map = new HashMap<String, Object>(prototype);
        final Row row = dataSet.getRow();
        for (Column column : table.getColumns()) {
          if (!map.containsKey(column.getName())) {
            map.put(column.getName(), row.getValue(column));
          }
        }

        // copy the prototype and set the not-updated values
        connector.update(map);
View Full Code Here

        JdbcDataContext dc = new JdbcDataContext(connection);

        Table table = dc.getDefaultSchema().getTableByName("testtable");

        Query q = dc.query().from(table).selectCount().toQuery();
        Row row = MetaModelHelper.executeSingleRowQuery(dc, q);
        assertEquals(3, ((Number) row.getValue(0)).intValue());

        q = dc.query().from(table).selectCount().where("name").isEquals("m'jello").toQuery();

        assertEquals("SELECT COUNT(*) FROM PUBLIC.\"TESTTABLE\" WHERE \"TESTTABLE\".\"NAME\" = 'm'jello'", q.toSql());
        assertEquals("SELECT COUNT(*) FROM PUBLIC.\"TESTTABLE\" WHERE \"TESTTABLE\".\"NAME\" = 'm''jello'", dc.getQueryRewriter()
                .rewriteQuery(q));

        row = MetaModelHelper.executeSingleRowQuery(dc, q);
        assertEquals(1, ((Number) row.getValue(0)).intValue());
    }
View Full Code Here

        comparedDataSet = comparedDataContext
            .executeQuery(comparedQuery);
      }

      while (dataSet.next()) {
        Row row = dataSet.getRow();
        assertNotNull(row);
        Object[] values = row.getValues();

        assertEquals(values.length, table.getColumnCount());

        if (comparedDataSet != null) {
          boolean next = comparedDataSet.next();
          assertTrue("No comparable row exists for: " + row, next);
          Row comparedRow = comparedDataSet.getRow();
          assertNotNull(comparedRow);
          Object[] comparedValues = comparedRow.getValues();
          assertEquals(comparedValues.length, table.getColumnCount());

          for (int j = 0; j < comparedValues.length; j++) {
            assertEquals(comparedValues[j], values[j]);
          }

          // compare styles
          for (int j = 0; j < comparedValues.length; j++) {
            Style style1 = comparedRow.getStyle(j);
            Style style2 = row.getStyle(j);
            assertEquals("Diff in style on row: " + row
                + " (value index = " + j + ")\nStyle 1: "
                + style1 + "\nStyle 2: " + style2 + ". ",
                style1, style2);
View Full Code Here

    Table table = dc.getDefaultSchema().getTables()[0];

    DataSet dataSet = dc.query().from(table).select("Foo").and("Bar")
        .where("Foo").isEquals("7").execute();
    assertTrue(dataSet.next());
    Row row = dataSet.getRow();
    assertNotNull(row.getStyle(0));

    final String expectedStyling = "";

    assertEquals(expectedStyling, row.getStyle(0).toCSS());
    assertNotNull(row.getStyle(1));
    assertEquals(expectedStyling, row.getStyle(1).toCSS());
    assertFalse(dataSet.next());
    dataSet.close();

    dataSet = dc.query().from(table).select("Foo").and("Bar").execute();
    assertTrue(dataSet.next());
    row = dataSet.getRow();
    assertNotNull(row.getStyle(0));
    assertEquals(expectedStyling, row.getStyle(0).toCSS());
    assertNotNull(row.getStyle(1));
    assertEquals(expectedStyling, row.getStyle(1).toCSS());

    assertTrue(dataSet.next());
    assertEquals(expectedStyling, dataSet.getRow().getStyle(0).toCSS());
    assertTrue(dataSet.next());
    assertEquals(expectedStyling, dataSet.getRow().getStyle(0).toCSS());
View Full Code Here

            dc.executeUpdate(new InsertInto(table).value("id", 1).value("foo", exampleMap).value("bar", exampleList));

            DataSet ds = dc.query().from(table).select("id", "foo", "bar").execute();
            assertTrue(ds.next());
            Row row = ds.getRow();
            assertFalse(ds.next());
            ds.close();

            assertEquals("Row[values=[1, {hello=[world, welt, verden], foo=bar}, [{}, {meta=model, couch=db}]]]",
                    row.toString());
            assertTrue(row.getValue(0) instanceof Integer);
            assertTrue(row.getValue(1) instanceof Map);
            assertTrue(row.getValue(2) instanceof List);

        } finally {
            dc.executeUpdate(new DropTable(table));
        }
View Full Code Here

        assertTrue("Class: " + ds2.getClass().getName(), ds2 instanceof CouchDbDataSet);

        assertTrue(ds1.next());
        assertTrue(ds2.next());

        final Row row1 = ds1.getRow();
        final Row row2 = ds2.getRow();

        assertFalse(ds1.next());
        assertFalse(ds2.next());

        assertEquals("Row[values=[Jane Doe, null]]", row1.toString());
        assertEquals("Row[values=[John Doe, 30]]", row2.toString());

        ds1.close();
        ds2.close();
    }
View Full Code Here

        return _dataSet.next();
    }

    @Override
    public Row getRow() {
        Row sourceRow = _dataSet.getRow();
        Object[] values = new Object[_converters.length];
        for (int i = 0; i < values.length; i++) {
            Object value = sourceRow.getValue(i);

            @SuppressWarnings("unchecked")
            TypeConverter<Object, ?> converter = (TypeConverter<Object, ?>) _converters[i];

            if (converter != null) {
View Full Code Here

        final AtomicBoolean success = new AtomicBoolean(true);

        ExecutorService executorService = Executors.newFixedThreadPool(30);

        while (ds.next()) {
            final Row row = ds.getRow();
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    if (hugeFileCols != row.getValues().length) {
                        System.out.println("Weird row: " + row);
                        success.set(false);
                    }
                    countDown.countDown();
                }
View Full Code Here

            query.setMaxRows(sampleSize);
        }
        DataSet dataSet = dataContext.executeQuery(query);
        try {
            while (dataSet.next()) {
                Row row = dataSet.getRow();
                for (Column column : columns) {
                    String stringValue = (String) row.getValue(column);
                    ColumnTypeDetector detector = detectors.get(column);
                    detector.registerValue(stringValue);
                }
            }
        } finally {
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.