Package org.gdbms.engine.data

Examples of org.gdbms.engine.data.DataSource


     * DOCUMENT ME!
     *
     * @throws Exception DOCUMENT ME!
     */
    private void testNotGeomAsAField(String dsName) throws Exception {
        DataSource d = ds.getDataSource(dsName);

        d.start();

        int fieldCount = d.getDataSourceMetadata().getFieldCount();
        assertTrue(fieldCount == 2);

        d.stop();
    }
View Full Code Here


    return jButton1;
  }
 
  public static void main(String[] args) throws Exception {
      DataSourceFactory dsf = SetUp.setUp("/root/workspace/gdbms_drivers", new DataSourceFactory());
      final DataSource ds = dsf.getDataSource("persona");
      ds.start();
        final EditingFrame ef = new EditingFrame();
        ef.getEditingTable().setDataSource(ds);
        ef.getEditingTable().startEditing();
        ef.addWindowListener(new WindowAdapter () {
            public void windowClosing(WindowEvent e) {
                try {
                    ef.getEditingTable().commit();
                    ds.stop();
                    System.exit(0);
                } catch (DriverException e1) {
                    throw new RuntimeException(e1);
                } catch (FreeingResourcesException e1) {
                    throw new RuntimeException(e1);
View Full Code Here

        assertTrue(((BooleanValue)d.getFieldValue(0, 2).equals(ValueFactory.createValue(3))).getValue());
        d.stop();
    }
   
    public void testOrderByAsc() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from persona where id > 0 order by id asc;");
       
        d.start();
        assertTrue(d.getRowCount() == 2);
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(2))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 1).equals(ValueFactory.createValue("fernan"))).getValue());
        assertTrue(d.getFieldValue(1, 2) instanceof NullValue);
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 1).equals(ValueFactory.createValue("huracan"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 2).equals(ValueFactory.createValue("gonsales"))).getValue());
        d.stop();

        d = ds.executeSQL(
                "select * from persona order by id asc;");
       
        d.start();
        assertTrue(d.getRowCount() == 3);
        assertTrue(((BooleanValue)d.getFieldValue(2, 0).equals(ValueFactory.createValue(2))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 1).equals(ValueFactory.createValue("fernan"))).getValue());
        assertTrue(d.getFieldValue(2, 2) instanceof NullValue);
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 1).equals(ValueFactory.createValue("huracan"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 2).equals(ValueFactory.createValue("gonsales"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 1).equals(ValueFactory.createValue("fernando"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 2).equals(ValueFactory.createValue("gonzalez"))).getValue());
        d.stop();
    }
View Full Code Here

        assertTrue(((BooleanValue)d.getFieldValue(0, 2).equals(ValueFactory.createValue("gonzalez"))).getValue());
        d.stop();
    }
   
    public void testOrderByDesc() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from persona where id > 0 order by id desc;");
       
        d.start();
        assertTrue(d.getRowCount() == 2);
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(2))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 1).equals(ValueFactory.createValue("fernan"))).getValue());
        assertTrue(d.getFieldValue(0, 2) instanceof NullValue);
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 1).equals(ValueFactory.createValue("huracan"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 2).equals(ValueFactory.createValue("gonsales"))).getValue());
        d.stop();

        d = ds.executeSQL(
                "select * from persona order by id desc;");
       
        d.start();
        assertTrue(d.getRowCount() == 3);
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(2))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 1).equals(ValueFactory.createValue("fernan"))).getValue());
        assertTrue(d.getFieldValue(0, 2) instanceof NullValue);
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 1).equals(ValueFactory.createValue("huracan"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 2).equals(ValueFactory.createValue("gonsales"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 1).equals(ValueFactory.createValue("fernando"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 2).equals(ValueFactory.createValue("gonzalez"))).getValue());
        d.stop();
    }
View Full Code Here

        assertTrue(((BooleanValue)d.getFieldValue(2, 2).equals(ValueFactory.createValue("gonzalez"))).getValue());
        d.stop();
    }
   
    public void testOrderByWithNullValues() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from persona order by apellido;");
       
        d.start();
        assertTrue(d.getRowCount() == 3);
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(2))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 1).equals(ValueFactory.createValue("fernan"))).getValue());
        assertTrue(d.getFieldValue(0, 2) instanceof NullValue);
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 1).equals(ValueFactory.createValue("huracan"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 2).equals(ValueFactory.createValue("gonsales"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 1).equals(ValueFactory.createValue("fernando"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 2).equals(ValueFactory.createValue("gonzalez"))).getValue());
        d.stop();

        d = ds.executeSQL(
                "select * from persona order by apellido desc;");
       
        d.start();
        assertTrue(d.getRowCount() == 3);
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 1).equals(ValueFactory.createValue("fernando"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 2).equals(ValueFactory.createValue("gonzalez"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 1).equals(ValueFactory.createValue("huracan"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 2).equals(ValueFactory.createValue("gonsales"))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 0).equals(ValueFactory.createValue(2))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 1).equals(ValueFactory.createValue("fernan"))).getValue());
        assertTrue(d.getFieldValue(2, 2) instanceof NullValue);
        d.stop();
    }
View Full Code Here

        assertTrue(d.getFieldValue(2, 2) instanceof NullValue);
        d.stop();
    }
   
    public void testOrderWithRepeatedValues() throws Exception {
        DataSource d = ds.executeSQL(
                "select id2 from sort order by id2 asc;");
       
        d.start();
        assertTrue(d.getRowCount() == 5);
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(3, 0).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(4, 0).equals(ValueFactory.createValue(3))).getValue());
        d.stop();
    }
View Full Code Here

        assertTrue(((BooleanValue)d.getFieldValue(4, 0).equals(ValueFactory.createValue(3))).getValue());
        d.stop();
    }
   
    public void testOrderByMultipleCriteria() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from sort order by id1 desc, id2 asc;");
       
        d.start();
        assertTrue(d.getRowCount() == 5);
        assertTrue(((BooleanValue)d.getFieldValue(0, 0).equals(ValueFactory.createValue(2))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(0, 1).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(1, 1).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(2, 1).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(3, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(3, 1).equals(ValueFactory.createValue(1))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(4, 0).equals(ValueFactory.createValue(0))).getValue());
        assertTrue(((BooleanValue)d.getFieldValue(4, 1).equals(ValueFactory.createValue(3))).getValue());
        d.stop();
    }
View Full Code Here

     * @throws IOException DOCUMENT ME!
     */
    public void testCustomQuery()
      throws Exception,
        SemanticException, IOException {
      DataSource d = ds.executeSQL("custom sumquery tables persona values (id);");
   
      d.start();
      assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(ValueFactory.createValue(
            3))).getValue());
      d.stop();
    }
View Full Code Here

/**
* @author Fernando Gonz�lez Cort�s
*/
public class SQLTest extends DataSourceTestCase {
    public void testIsClause() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from persona where apellido is null;");
        d.start();
        Value v0 = ValueFactory.createValue(2);
        Value v1 = ValueFactory.createValue("fernan");
        Value v2 = ValueFactory.createNullValue();
        assertTrue(d.getRowCount() == 1);
        assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(v0)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 1).equals(v1)).getValue());
        assertTrue(d.getFieldValue(0, 2) instanceof NullValue);
        d.stop();

        d = ds.executeSQL("select * from persona where apellido is not null;");
        d.start();
        v0 = ValueFactory.createValue(0);
        v1 = ValueFactory.createValue("fernando");
        v2 = ValueFactory.createValue("gonzalez");
        Value v3 = ValueFactory.createValue(1);
        Value v4 = ValueFactory.createValue("huracan");
        Value v5 = ValueFactory.createValue("gonsales");
        assertTrue(d.getRowCount() == 2);
        assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(v0)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 1).equals(v1)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 2).equals(v2)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(1, 0).equals(v3)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(1, 1).equals(v4)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(1, 2).equals(v5)).getValue());
        d.stop();
    }
View Full Code Here

        assertTrue(((BooleanValue) d.getFieldValue(1, 2).equals(v5)).getValue());
        d.stop();
    }
   
    public void testBetweenClause() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from persona where id between 0 and 2;");
        d.start();
        Value v0 = ValueFactory.createValue(1);
        Value v1 = ValueFactory.createValue("huracan");
        Value v2 = ValueFactory.createValue("gonsales");
        assertTrue(d.getRowCount() == 1);
        assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(v0)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 1).equals(v1)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 2).equals(v2)).getValue());
        d.stop();

        d = ds.executeSQL("select * from persona where id not between 0 and 2;");
        d.start();
        v0 = ValueFactory.createValue(0);
        v1 = ValueFactory.createValue("fernando");
        v2 = ValueFactory.createValue("gonzalez");
        Value v3 = ValueFactory.createValue(2);
        Value v4 = ValueFactory.createValue("fernan");
        assertTrue(d.getRowCount() == 2);
        assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(v0)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 1).equals(v1)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 2).equals(v2)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(1, 0).equals(v3)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(1, 1).equals(v4)).getValue());
        assertTrue(d.getFieldValue(1, 2) instanceof NullValue);
        d.stop();
    }
View Full Code Here

TOP

Related Classes of org.gdbms.engine.data.DataSource

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.