Package org.conserve.select.discriminators

Examples of org.conserve.select.discriminators.Equal


    SimplestObject smallerOrEquals = new SimplestObject(3.0);
    SimplestObject largerOrEquals = new SimplestObject(3.0);

    And one = new And(new GreaterOrEqual(largerOrEquals), new LessOrEqual(smallerOrEquals));
    And two = new And(new Different(different), new Greater(larger));
    List<SimplestObject> list = persist.getObjects(SimplestObject.class, new Or(one, two, new Equal(equal)));
    assertEquals(3, list.size());
    list = persist.getObjects(SimplestObject.class, new Or(one, two, new Equal(equal)), new Ascending(different));
    assertEquals(3, list.size());
    assertEquals(3.0, (double) list.get(0).getFoo(), 0.0001);
    assertEquals(66.0, (double) list.get(1).getFoo(), 0.0001);
    assertEquals(99.0, (double) list.get(2).getFoo(), 0.0001);
View Full Code Here


    // find all books with the authors last name 'Asimov'.
    asimov = new Author();
    asimov.setLastName("Asimov");
    Book seekBook = new Book();
    seekBook.addAuthor(asimov);
    List<Book> asimovBooks = persist.getObjects(Book.class, new Equal(seekBook));
    assertEquals(2, asimovBooks.size());
    // print the title of the scifi books
    for (Book book : asimovBooks)
    {
      System.out.println(book.getTitle());
View Full Code Here

    PersistenceManager persist = new PersistenceManager(driver, database, login, password);

    // find all science fiction books
    Book seekBook = new Book();
    seekBook.addKeyWord("science fiction");
    List<Book> scifiBooks = persist.getObjects(Book.class, new Equal(seekBook));
    assertEquals(4, scifiBooks.size());
    // print the title of the scifi books
    for (Book book : scifiBooks)
    {
      System.out.println(book.getTitle());
    }

    // find all authors with the first name 'Isaac'.
    Author asimov = new Author();
    asimov.setFirstName("Isaac");
    List<Author> asimovAuthors = persist.getObjects(Author.class, new Equal(asimov));
    assertEquals(1, asimovAuthors.size());

    persist.close();
  }
View Full Code Here

    // object.
    ConcreteBar2 cbar2 = new ConcreteBar2();
    cbar2.setAbstractName("f");
    cbar2.setConcreteName("C");
    searchFoo.setBar(cbar2);
    List<Foo> foos = persist.getObjects(Foo.class, new Equal(searchFoo));
    assertEquals(1, foos.size());

    // assert that the Foo object can be retrieved with a ConcreteBar1
    // object.
    ConcreteBar1 cbar1 = new ConcreteBar1();
    cbar1.setAbstractName("f");
    cbar1.setConcreteName("C");
    cbar1.setFooProperty("foo");
    searchFoo.setBar(cbar1);
    foos = persist.getObjects(Foo.class, new Equal(searchFoo, false));
    assertEquals(1, foos.size());

    // assert that the Foo object can not be retrieved with incorrect values
    cbar1.setAbstractName("fail");
    searchFoo.setBar(cbar1);
    foos = persist.getObjects(Foo.class, new Equal(searchFoo, false));
    assertEquals(0, foos.size());

    persist.close();
  }
View Full Code Here

    // get the first foo based on strict search
    fooer = new MyFooContainer();
    fooer.setFoo("oneFooer");
    searchObject.setFooContainer(fooer);
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
    assertEquals(1, fooableowners.size());

    // get second foo based on strict search
    extfooer = new MyExtendedFooContainer();
    extfooer.setFoo("twoFooer");
    searchObject.setFooContainer(extfooer);
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
    assertEquals(1, fooableowners.size());

    // check that second foo can't be gotten by strict search
    fooer.setFoo("twoFooer");
    searchObject.setFooContainer(fooer);
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
    assertEquals(0, fooableowners.size());

    // get second foo based on non-strict search
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject, false));
    assertEquals(1, fooableowners.size());

    // check that the first foo can't be gotten by strict search
    extfooer.setFoo("oneFooer");
    searchObject.setFooContainer(extfooer);
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject));
    assertEquals(0, fooableowners.size());

    // get first foo based on non-strict search
    fooableowners = persist.getObjects(FooContainerOwner.class, new Equal(searchObject, false));
    assertEquals(1, fooableowners.size());

    persist.close();
  }
View Full Code Here

    pm.close();
    //check that objects exist/not exist
    pm = new PersistenceManager(driver, database, login, password);
    ObjectToSubclass src = new ObjectToSubclass();
    src.setValue(1);
    List<ObjectToSubclass>res = pm.getObjects(ObjectToSubclass.class, new Equal(src));
    assertEquals(1,res.size());
    ObjectToSubclass obj = res.get(0);
    assertTrue(obj.getName().equals(name));
    assertNull(obj.getOtherObject());
    src.setValue(2);
    res = pm.getObjects(ObjectToSubclass.class, new Equal(src));
    assertEquals(1,res.size());
    obj = res.get(0);
    assertTrue(obj.getName().equals(name));
    assertNotNull(obj.getOtherObject());
   
View Full Code Here

    // search all OriginalObject with name "foo", make sure SubClass
    // objects are returned.
    OriginalObject searchObject = new OriginalObject();
    searchObject.setName("foo");
    res3 = pm.getObjects(OriginalObject.class, new Equal(searchObject));
    assertEquals(1, res3.size());
    for (OriginalObject oo : res3)
    {
      assertTrue(oo instanceof SubClass);
    }

    // rename SubClass to to NotSubClass
    pm.changeName(SubClass.class, NotSubClass.class);
    // change the database schema
    pm.updateSchema(NotSubClass.class);

    // search all OriginalObject, make sure both objects are returned.
    res3 = pm.getObjects(OriginalObject.class, new All());
    assertEquals(2, res3.size());
    // search all NotSubClass, make sure both objects are returned
    List<NotSubClass> res1 = pm.getObjects(NotSubClass.class, new All());
    assertEquals(2, res1.size());
    // search NotSubClass, make sure only matchign object is returned
    NotSubClass searchObject2 = new NotSubClass();
    searchObject2.setName("foo");
    res1 = pm.getObjects(NotSubClass.class, new Equal(searchObject2));
    assertEquals(1, res1.size());

    pm.close();

    // TODO: Test changing inheritance of an object that is a property of
View Full Code Here

TOP

Related Classes of org.conserve.select.discriminators.Equal

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.