Search in sources :

Example 11 with Filter

use of com.orm.androrm.Filter in project androrm by androrm.

the class FieldResulutionTest method testManyToManyFieldResolutionInBetween.

public void testManyToManyFieldResolutionInBetween() {
    Filter filter = new Filter();
    filter.is("mBranches__mSuppliers__mName", "ACME");
    QuerySet<Product> products = Product.objects(getContext()).filter(filter);
    assertEquals(1, products.count());
    assertTrue(products.contains(mP1));
    filter = new Filter();
    filter.is("mBranches__mSuppliers__mName", "fail");
    products = Product.objects(getContext()).filter(filter);
    assertEquals(0, products.count());
}
Also used : Filter(com.orm.androrm.Filter) Product(com.orm.androrm.impl.Product)

Example 12 with Filter

use of com.orm.androrm.Filter in project androrm by androrm.

the class FieldResulutionTest method testForeignKeyResolutionInBetween.

public void testForeignKeyResolutionInBetween() {
    Filter filter = new Filter();
    filter.contains("mBranches__mBrand__mName", "cal");
    QuerySet<Supplier> suppliers = Supplier.objects(getContext()).filter(filter);
    assertEquals(1, suppliers.count());
    assertTrue(suppliers.contains(mS1));
    filter = new Filter();
    filter.is("mBranches__mBrand__mName", "false");
    suppliers = Supplier.objects(getContext()).filter(filter);
    assertEquals(0, suppliers.count());
}
Also used : Filter(com.orm.androrm.Filter) Supplier(com.orm.androrm.impl.Supplier)

Example 13 with Filter

use of com.orm.androrm.Filter in project androrm by androrm.

the class FieldResulutionTest method testForeignKeyResolutionOnlyField.

public void testForeignKeyResolutionOnlyField() {
    Filter filter = new Filter();
    filter.is("mBrand", mB);
    QuerySet<Branch> branches = Branch.objects(getContext()).filter(filter);
    assertEquals(3, branches.count());
    assertTrue(branches.contains(mB1));
    assertTrue(branches.contains(mB3));
}
Also used : Filter(com.orm.androrm.Filter) Branch(com.orm.androrm.impl.Branch)

Example 14 with Filter

use of com.orm.androrm.Filter in project androrm by androrm.

the class FieldResulutionTest method testForeignKeyResolutionLastField.

public void testForeignKeyResolutionLastField() {
    Filter filter = new Filter();
    filter.is("mBranches__mBrand", mB);
    QuerySet<Supplier> suppliers = Supplier.objects(getContext()).filter(filter);
    assertEquals(1, suppliers.count());
    assertTrue(suppliers.contains(mS1));
}
Also used : Filter(com.orm.androrm.Filter) Supplier(com.orm.androrm.impl.Supplier)

Example 15 with Filter

use of com.orm.androrm.Filter in project androrm by androrm.

the class OneToManyField method get.

@Override
public QuerySet<R> get(Context context, L origin) {
    String fieldName = Model.getBackLinkFieldName(mTargetClass, mOriginClass);
    Filter filter = new Filter();
    filter.is(fieldName, origin);
    QuerySet<R> querySet = new QuerySet<R>(context, mTargetClass);
    querySet.filter(filter);
    return querySet;
}
Also used : Filter(com.orm.androrm.Filter) QuerySet(com.orm.androrm.QuerySet)

Aggregations

Filter (com.orm.androrm.Filter)21 ArrayList (java.util.ArrayList)7 Supplier (com.orm.androrm.impl.Supplier)6 Branch (com.orm.androrm.impl.Branch)5 Product (com.orm.androrm.impl.Product)5 Rule (com.orm.androrm.Rule)3 InStatement (com.orm.androrm.statement.InStatement)3 LikeStatement (com.orm.androrm.statement.LikeStatement)3 Statement (com.orm.androrm.statement.Statement)3 Person (com.orm.androrm.impl.Person)2 EmptyModel (com.orm.androrm.impl.migration.EmptyModel)2 NewEmptyModel (com.orm.androrm.impl.migration.NewEmptyModel)2 Migrator (com.orm.androrm.migration.Migrator)2 QuerySet (com.orm.androrm.QuerySet)1 NoSuchFieldException (com.orm.androrm.field.NoSuchFieldException)1 Car (com.orm.androrm.impl.Car)1 ModelWithRelation (com.orm.androrm.impl.migration.ModelWithRelation)1 NewModelWithRelation (com.orm.androrm.impl.migration.NewModelWithRelation)1