Java Code Examples for com.gs.fw.common.mithra.finder.Operation#or()

The following examples show how to use com.gs.fw.common.mithra.finder.Operation#or() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestExists.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testOrAndExistsWithSecondExists() throws Exception
{
    if (OrderStatusFinder.getMithraObjectPortal().isPartiallyCached())
    {
        Log4JRecordingAppender appender = this.setupRecordingAppender(OrderStatus.class);
        try
        {
            Operation op = OrderStatusFinder.order().items().otherInProgressItems().exists();
            Operation op2 = OrderStatusFinder.order().items().otherExpensiveItems().exists();
            Operation orOp = op.or(op2);
            OrderStatusFinder.findMany(orOp).forceResolve();
            LoggingEvent event = appender.getEvents().get(0);
            String msg = event.getMessage().toString();
            int start = 0;
            for(int i=0;i<3;i++)
            {
                start = msg.indexOf("left join", start);
                assertTrue(start >= 0);
            }
        }
        finally
        {
            tearDownRecordingAppender(OrderStatus.class);
        }
    }
}
 
Example 2
Source File: TestIn.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testMultipleIndenticalInWithLargeIn()
{
    IntHashSet set = new IntHashSet();
    for(int i=1;i<2000;i++)
    {
        set.add(i);
    }
    IntHashSet products = new IntHashSet();
    products.add(1);
    products.add(2);
    Operation repeatedInOp = OrderFinder.items().productId().in(products);
    Operation op1 = repeatedInOp.and(OrderFinder.items().quantity().greaterThan(2));
    Operation op2 = repeatedInOp.and(OrderFinder.items().state().eq("foo"));
    Operation op = op1.or(op2);
    op = op.and(OrderFinder.orderId().in(set));
    OrderList list = new OrderList(op);
    list.forceResolve();
}
 
Example 3
Source File: TestDatedAuditOnly.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testLastModifiedQuerying()
{
    Timestamp fromTime = Timestamp.valueOf("1999-12-31 22:00:00.0");
    Timestamp toTime = Timestamp.valueOf("2000-01-01 22:00:00.0");
    Operation op = AuditedOrderFinder.userId().eq(1);
    op = op.and(AuditedOrderFinder.processingDate().equalsEdgePoint());

    Operation auditedOrderProcDateOp = AuditedOrderFinder.processingDateFrom().greaterThan(fromTime);
    auditedOrderProcDateOp = auditedOrderProcDateOp.and(AuditedOrderFinder.processingDateFrom().lessThanEquals(toTime));

    Operation orderStatusProcDateOp = AuditedOrderFinder.orderStatus().processingDateFrom().greaterThan(fromTime);
    orderStatusProcDateOp = orderStatusProcDateOp.and(AuditedOrderFinder.orderStatus().processingDateFrom().lessThanEquals(toTime));

    auditedOrderProcDateOp = auditedOrderProcDateOp.or(orderStatusProcDateOp);

    op = op.and(auditedOrderProcDateOp);

    AuditedOrderList auditedOrderList = new AuditedOrderList(op);
    assertEquals("Changed AuditedOrders ", 4, auditedOrderList.size());
}
 
Example 4
Source File: EdgePointDeepFetchOnProcessingTemporalTest.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private ProjitoVersionList executeProjitoVersionQuery3()
{
    Operation authOp = ProjitoVersionFinder.versionedRoot().bvp().eq("bvp 2");
    authOp = authOp.or(ProjitoVersionFinder.versionedRoot().memberships().employee().kerberos().eq("tester2"));

    Operation op = ProjitoVersionFinder.processingDate().equalsEdgePoint();
    op = op.and(ProjitoVersionFinder.versionedRoot().id().eq(2L));
    op = op.and(authOp);

    ProjitoVersionList projitoVersions = new ProjitoVersionList(ProjitoVersionFinder.findMany(op));

    projitoVersions.deepFetch(ProjitoVersionFinder.versionedRoot().memberships().employee().addresses());
    projitoVersions.deepFetch(ProjitoVersionFinder.versionedRoot().measuresOfSuccess().accountableEmployee().addresses());

    projitoVersions.setOrderBy(ProjitoVersionFinder.number().descendingOrderBy());

    return projitoVersions;
}
 
Example 5
Source File: TestExists.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testToOneWithOrExistsNotExists()
{
    OrderStatus newStatus = new OrderStatus();
    newStatus.setOrderId(2);
    newStatus.setLastUser("Moh");
    newStatus.setLastUpdateTime(new Timestamp(System.currentTimeMillis()));
    newStatus.setStatus(17);
    newStatus.insert();
    Operation op = OrderFinder.orderStatus().notExists();
    op = op.or(OrderFinder.orderStatus().lastUser().eq("Fred"));
    assertEquals(6, OrderFinder.findMany(op).size());
}
 
Example 6
Source File: TestExists.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testOrAndExistsWithSecondExistsWithOrAndAnd() throws Exception
{
    if (OrderStatusFinder.getMithraObjectPortal().isPartiallyCached())
    {
        Log4JRecordingAppender appender = this.setupRecordingAppender(OrderStatus.class);
        try
        {
            Operation op = OrderStatusFinder.order().items().otherInProgressItems().quantity().greaterThan(0.001);
            Operation op2 = OrderStatusFinder.order().items().otherExpensiveItems().exists();
            Operation orOp = op.or(op2);
            Operation op3 = OrderStatusFinder.order().items().otherInProgressItems().quantity().lessThan(1000000);
            Operation orAndOp = orOp.and(op3).and(OrderStatusFinder.status().notEq(-10));
            OrderStatusFinder.findMany(orAndOp).forceResolve();
            LoggingEvent event = appender.getEvents().get(0);
            String msg = event.getMessage().toString();
            int start = 0;
            for(int i=0;i<3;i++)
            {
                start = msg.indexOf("left join", start);
                assertTrue(start >= 0);
            }
        }
        finally
        {
            tearDownRecordingAppender(OrderStatus.class);
        }
    }
}
 
Example 7
Source File: TestExists.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testMultiOrExists()
{
    Operation op = OrderFinder.items().quantity().greaterThan(0);
    op = op.or(OrderFinder.items().exists().and(OrderFinder.expensiveItems(1.0).quantity().greaterThan(1)));

    assertEquals(3, OrderFinder.findMany(op).size());
}
 
Example 8
Source File: TestDatedAuditOnly.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testMultipleOrOperations()
{
    Operation op = AuditedOrderFinder.orderId().eq(1);
    op = op.or(AuditedOrderFinder.orderId().eq(2));
    op = op.or(AuditedOrderFinder.orderId().eq(3));
    AuditedOrderList orderList = AuditedOrderFinder.findMany(op);
    orderList.setOrderBy(AuditedOrderFinder.processingDateFrom().ascendingOrderBy());
    assertEquals(3, orderList.size());
}
 
Example 9
Source File: TestOtherOperationsToString.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testExistsWithOr()
{
    Operation op1 = ChildTypeFinder.id().eq(102).and(ChildTypeFinder.pets().exists());
    Operation op2 = ChildTypeFinder.id().eq(101).and(ChildTypeFinder.pets().exists());
    Operation op = op1.or(op2);
    assertEquals(" ( ( ChildType.id = 102 & ChildType.pets(ChildType.isAlive = true).ownerId = 102 ) | ( ChildType.id = 101 & ChildType.pets(ChildType.isAlive = true).ownerId = 101 ) )", op.toString());
}
 
Example 10
Source File: TestOtherOperationsToString.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testNotExistsWithOr()
{
    Operation op1 = ChildTypeFinder.id().eq(102).and(ChildTypeFinder.pets().notExists());
    Operation op2 = ChildTypeFinder.id().eq(101).and(ChildTypeFinder.pets().notExists(PetTypeFinder.genome().eq("foo")));
    Operation op = op1.or(op2);
    assertEquals(" ( ( ChildType.id = 102 & ChildType.pets(ChildType.isAlive = true) not exists ) | ( ChildType.id = 101 & ChildType.pets(ChildType.isAlive = true) { PetType.genome = \"foo\" } not exists ) )", op.toString());
    ChildTypeList ct = ChildTypeFinder.findMany(op);
    assertEquals(" ( ( PetType.[ -> ChildType: ownerId = id](ChildType.isAlive = true).id = 102 " +
            "& PetType.[ -> ChildType: ownerId = id](ChildType.isAlive = true).pets(ChildType.isAlive = true) not exists ) " +
            "| ( PetType.[ -> ChildType: ownerId = id](ChildType.isAlive = true).id = 101 " +
            "& PetType.[ -> ChildType: ownerId = id](ChildType.isAlive = true).pets(ChildType.isAlive = true) { PetType.genome = \"foo\" } not exists ) )", ct.getPets().getOperation().toString());
}
 
Example 11
Source File: TestNullPrimaryKeyColumn.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testRetrieval() throws Exception
{
    Operation dateCondition = SynonymFinder.synonymEndDate().isNull();
    dateCondition = dateCondition.or(SynonymFinder.synonymEndDate().greaterThan(Timestamp.valueOf("2005-01-01 00:00:00")));

    Operation op = SynonymFinder.productId().eq(1234);
    op = op.and(dateCondition);

    List fakeList = new SynonymList(op);

    String sql = "select * from SYNONYM where PRODUCT_ID = 1234 and (EXPIRY_DATE is null or EXPIRY_DATE > '2005-01-01 00:00:00')";
    this.genericRetrievalTest(sql, fakeList, 1);
}
 
Example 12
Source File: TestAndOperationToString.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testAndWithOr()
{
    Operation op1 = UserFinder.sourceId().greaterThan(0);
    op1 = op1.and(UserFinder.id().eq(1));
    Operation op2 = UserFinder.sourceId().eq(0);
    op2 = op2.and(UserFinder.id().eq(2));
    Operation op = op1.or(op2);
    assertEquals(" ( ( User.sourceId > 0 & User.id = 1 ) | ( User.id = 2 & User.sourceId = 0 ) )", op.toString());
}
 
Example 13
Source File: TestOrOperationToString.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testOrWithDuplicates()
{
    Operation op = UserFinder.sourceId().eq(0);
    op = op.or(UserFinder.id().eq(1));
    op = op.or(UserFinder.id().eq(1));
    op = op.or(UserFinder.sourceId().eq(0));
    assertEquals(" ( ( User.sourceId = 0 ) | ( User.id = 1 ) | ( User.id = 1 ) | ( User.sourceId = 0 ) )", op.toString());
}