Java Code Examples for com.gs.fw.common.mithra.finder.Operation#and()
The following examples show how to use
com.gs.fw.common.mithra.finder.Operation#and() .
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: TestCalculatedString.java From reladomo with Apache License 2.0 | 6 votes |
public void testIntegerToStringInMapper() { Mapper mapper = OrderFinder.orderId().convertToStringAttribute().constructEqualityMapper(OrderItemFinder.orderId().convertToStringAttribute()); mapper.setAnonymous(false); DoubleHashSet doubleSet = new DoubleHashSet(2000); for(int i = 0; i < 2000; i++) { doubleSet.add(i); } Operation op = new MappedOperation(mapper, OrderItemFinder.quantity().greaterThan(0)); op = op.and(new MappedOperation(mapper, OrderItemFinder.discountPrice().lessThan(10000))); op = op.and(new MappedOperation(mapper, OrderItemFinder.quantity().in(doubleSet))); assertEquals(3, OrderFinder.findMany(op).size()); }
Example 2
Source File: TestPeerToPeerMithraTestCase.java From reladomo with Apache License 2.0 | 6 votes |
public void testUpdateNotificationWithCompoundPrimaryKey() throws Exception { int updateClassCount = ExchangeRateFinder.getMithraObjectPortal().getPerClassUpdateCountHolder().getUpdateCount(); Timestamp ts = new Timestamp(timestampFormat.parse("2004-09-30 18:30:00.0").getTime()); Operation op = ExchangeRateFinder.acmapCode().eq("A"); op = op.and(ExchangeRateFinder.source().eq(10)); op = op.and(ExchangeRateFinder.currency().eq("USD")); op = op.and(ExchangeRateFinder.date().eq(ts)); ExchangeRate exchangeRate0 = ExchangeRateFinder.findOne(op); assertNotNull(exchangeRate0); assertEquals(1.0, exchangeRate0.getExchangeRate(), 0.0); this.getRemoteWorkerVm().executeMethod("peerUpdateExchangeRate", new Class[]{String.class, String.class, int.class, Timestamp.class, double.class}, new Object[]{"A", "USD", new Integer(10), ts, new Double(1.40)}); waitForMessages(updateClassCount, ExchangeRateFinder.getMithraObjectPortal()); ExchangeRate exchangeRate1 = ExchangeRateFinder.findOne(op); assertNotNull(exchangeRate1); assertEquals(1.40, exchangeRate1.getExchangeRate(), 0.0); }
Example 3
Source File: TestDatabaseReadPerformance.java From reladomo with Apache License 2.0 | 6 votes |
public void testLoadTimeForAll() { for(int i=0; i < 2; i++) { long now = System.currentTimeMillis(); Operation op = PositionQuantityFinder.businessDate().equalsEdgePoint(); op = op.and(PositionQuantityFinder.processingDate().equalsEdgePoint()); op = op.and(PositionQuantityFinder.acmapCode().eq(SOURCE_X)); PositionQuantityList positionQuantityList = new PositionQuantityList(op); positionQuantityList.setBypassCache(true); positionQuantityList.forceResolve(); long totalTime = (System.currentTimeMillis() - now); System.out.println("took "+totalTime +" ms "+" per object: "+((double)totalTime*1000)/positionQuantityList.size()+ " microseconds"); } }
Example 4
Source File: TestTempObject.java From reladomo with Apache License 2.0 | 6 votes |
public void testEnsureQueryCacheGetsCleanWhenDestroyContext() { TemporaryContext context = ParaProductDriverFinder.createTemporaryContext("A"); ParaProductDriverList drivers = new ParaProductDriverList(); drivers.add(createParaProductDriver("A","ABC123","12345")); drivers.insertAll(); Operation op = ParaProductDriverFinder.existsWithJoin(ParaProductFinder.acmapCode(), ParaProductFinder.gsn(), ParaProductFinder.cusip()); op = op.and(ParaProductFinder.acmapCode().eq("A")); ParaProductList products = new ParaProductList(op); assertEquals(0, products.size()); context.destroy(); TemporaryContext context2 = ParaProductDriverFinder.createTemporaryContext("A"); ParaProductDriverList drivers2 = new ParaProductDriverList(); drivers2.add(createParaProductDriver("A","ABC124","12346")); drivers2.insertAll(); Operation op2 = ParaProductDriverFinder.existsWithJoin(ParaProductFinder.acmapCode(), ParaProductFinder.gsn(), ParaProductFinder.cusip()); op2 = op2.and(ParaProductFinder.acmapCode().eq("A")); ParaProductList products2 = new ParaProductList(op2); assertEquals(1, products2.size()); context2.destroy(); }
Example 5
Source File: ProcessingDateMilestonedTopLevelLoaderFactory.java From reladomo with Apache License 2.0 | 6 votes |
@Override public List<TaskOperationDefinition> buildRefreshTaskDefinitions(CacheLoaderContext context, Operation loadOperation) { Timestamp start = context.getRefreshInterval().getStart(); Timestamp end = context.getRefreshInterval().getEnd(); final Operation inGreaterThenStart = this.getProcessingDateAttribute().getFromAttribute().greaterThanEquals(start); final Operation inLessThenEnd = this.getProcessingDateAttribute().getFromAttribute().lessThanEquals(end); final Operation loadChangedInZ = inGreaterThenStart.and(inLessThenEnd); final Operation outGreaterThenStart = this.getProcessingDateAttribute().getToAttribute().greaterThanEquals(start); final Operation outLessThenEnd = this.getProcessingDateAttribute().getToAttribute().lessThanEquals(end); final Operation loadChangedOutZ = outGreaterThenStart.and(outLessThenEnd); return FastList.newListWith( new TaskOperationDefinition(loadChangedInZ, true), new TaskOperationDefinition(loadChangedOutZ, false) ); }
Example 6
Source File: TestDb2GeneralTestCases.java From reladomo with Apache License 2.0 | 5 votes |
public void xtestDeleteObjectWithDateAsString() { Operation op = StringDatedOrderFinder.orderId().eq(1); op = op.and(StringDatedOrderFinder.processingDate().eq(Timestamp.valueOf("2004-01-12 00:00:00.0"))); StringDatedOrder order = StringDatedOrderFinder.findOne(op); assertNotNull(order); order.delete(); StringDatedOrder order2 = StringDatedOrderFinder.findOne(op); assertNull(order2); }
Example 7
Source File: TestConcurrentTransactions.java From reladomo with Apache License 2.0 | 5 votes |
private TinyBalance findTinyBalance(Timestamp businessDate) { Operation op = TinyBalanceFinder.acmapCode().eq("A"); op = op.and(TinyBalanceFinder.balanceId().eq(50)); op = op.and(TinyBalanceFinder.businessDate().eq(businessDate)); return TinyBalanceFinder.findOne(op); }
Example 8
Source File: TestMappedOperation.java From reladomo with Apache License 2.0 | 5 votes |
public void testEqualityAfterMapping() { Operation throughRel = OrderFinder.items().state().eq("x"); Operation mapped = new MappedOperation(OrderFinder.zGetOrderItemsReverseMapper(), OrderItemFinder.state().eq("x")); assertEquals(throughRel, mapped); throughRel = OrderFinder.items().discountPrice().absoluteValue().greaterThan(6); mapped = new MappedOperation(OrderFinder.zGetOrderItemsReverseMapper(), OrderItemFinder.discountPrice().absoluteValue().greaterThan(6)); assertEquals(throughRel, mapped); throughRel = OrderFinder.items().state().eq("x").and(OrderFinder.items().discountPrice().absoluteValue().greaterThan(6)); mapped = new MappedOperation(OrderFinder.zGetOrderItemsReverseMapper(), OrderItemFinder.state().eq("x").and(OrderItemFinder.discountPrice().absoluteValue().greaterThan(6))); assertEquals(throughRel, mapped); throughRel = UserFinder.groups().locations().city().eq("NY"); mapped = new MappedOperation(UserFinder.zGetUserGroupsReverseMapper(), new MappedOperation(GroupFinder.zGetGroupLocationsReverseMapper(), LocationFinder.city().eq("NY"))); assertEquals(throughRel, mapped); throughRel = UserFinder.groups().locations().city().eq("NY").and(UserFinder.groups().manager().id().eq(1)); mapped = new MappedOperation(UserFinder.zGetUserGroupsReverseMapper(), new MappedOperation(GroupFinder.zGetGroupLocationsReverseMapper(), LocationFinder.city().eq("NY"))); mapped = mapped.and(new MappedOperation(UserFinder.zGetUserGroupsReverseMapper(), new MappedOperation(GroupFinder.zGetGroupManagerReverseMapper(), UserFinder.id().eq(1)))); throughRel.equals(mapped); assertEquals(throughRel, mapped); new UserList(throughRel.and(UserFinder.sourceId().eq(0))).forceResolve(); }
Example 9
Source File: MultiThreadedBatchProcessor.java From reladomo with Apache License 2.0 | 5 votes |
protected void queueWithOp(final Object shardId, final LinkedBlockingQueue<TL> listQueue, final AtomicLong total) { Operation op = mainOperation; if (shardId != null) { op = op.and(finderInstance.getSourceAttribute().nonPrimitiveEq(shardId)); } Operation additionalOperation = additionalPerShardRetrievalOperations.get(shardId); if (additionalOperation != null) { op = op.and(additionalOperation); } final List accumulator = FastList.newList(batchSize); MithraList many = ((RelatedFinder)finderInstance).findMany(op); many.forEachWithCursor(new DoWhileProcedure() { @Override public boolean execute(Object obj) { T result = (T) obj; accumulator.add(result); if (accumulator.size() == batchSize) { queueResultsWithoutDeepFetch(accumulator, listQueue, shardId); total.addAndGet(accumulator.size()); accumulator.clear(); } return true; } }); if (!accumulator.isEmpty()) { queueResultsWithoutDeepFetch(accumulator, listQueue, shardId); total.addAndGet(accumulator.size()); } }
Example 10
Source File: TestRelationships.java From reladomo with Apache License 2.0 | 5 votes |
public void testSourceAttributeInheritancePreLoad() throws Exception { Timestamp buzDate = new Timestamp(timestampFormat.parse("2008-01-01 00:00:00.000").getTime()); Operation op = LewContractFinder.acctId().eq(7).and(LewContractFinder.instrumentId().eq(1)).and(LewContractFinder.region().eq("A")); op = op.and(LewContractFinder.businessDate().eq(buzDate)); LewContract contract = LewContractFinder.findOne(op); assertNotNull(contract); op = LewTransactionFinder.tranId().eq(23).and(LewTransactionFinder.region().eq("A")); op = op.and(LewTransactionFinder.businessDate().eq(buzDate)); assertNotNull(LewTransactionFinder.findOne(op)); int count = this.getRetrievalCount(); assertNotNull(contract.getLewTransaction()); assertEquals(count, this.getRetrievalCount()); }
Example 11
Source File: TestMithraTestResource.java From reladomo with Apache License 2.0 | 5 votes |
private void assertTestDatabaseForIntSourceAttribute() { Operation op = LocationFinder.all(); op = op.and(LocationFinder.sourceId().eq(1)); LocationList list = new LocationList(op); assertEquals(7, list.size()); }
Example 12
Source File: TestSybaseIqGeneralTestCases.java From reladomo with Apache License 2.0 | 5 votes |
public void testBatchDeleteWithDateAsString() { Operation op = StringDatedOrderFinder.processingDate().lessThan(new Timestamp(System.currentTimeMillis())); op = op.and(StringDatedOrderFinder.orderDate().lessThan(new java.util.Date())); StringDatedOrderList orderList = StringDatedOrderFinder.findMany(op); assertEquals(4, orderList.size()); StringDatedOrderFinder.clearQueryCache(); orderList.deleteAll(); StringDatedOrderList orderList2 = StringDatedOrderFinder.findMany(op); assertEquals(0, orderList2.size()); }
Example 13
Source File: TestMax.java From reladomo with Apache License 2.0 | 5 votes |
public void testMappedOperationWithDifferentMappersAndCalculatedAggregateAttributeWithToOneMapper() { Operation op = SalesLineItemFinder.productSpecs().originalPrice().greaterThan(20.00); op = op.and(SalesLineItemFinder.quantity().greaterThan(15)); MithraAggregateAttribute aggrAttr = SalesLineItemFinder.quantity().times(SalesLineItemFinder.productSpecs().originalPrice()).max(); AggregateList aggregateList = new AggregateList(op); aggregateList.addAggregateAttribute("MaxPrice", aggrAttr); aggregateList.addGroupBy("ManufacturerId", SalesLineItemFinder.manufacturerId()); assertEquals(2, aggregateList.size()); for (int i = 0; i < aggregateList.size(); i++) { AggregateData data = aggregateList.getAggregateDataAt(i); switch (data.getAttributeAsInt("ManufacturerId")) { case 1: assertEquals(600, data.getAttributeAsDouble("MaxPrice"), 2); break; case 2: assertEquals(425, data.getAttributeAsDouble("MaxPrice"), 0); break; default: fail("Invalid manufacturer id"); } } }
Example 14
Source File: SelfJoinTest.java From reladomo with Apache License 2.0 | 5 votes |
public void testDateOnRelatedObject() throws ParseException { Timestamp date1 = new Timestamp(timestampFormat.parse("2005-09-01 00:00:00").getTime()); Timestamp date2 = new Timestamp(timestampFormat.parse("2005-09-02 00:00:00").getTime()); Timestamp updateCutoffTime = new Timestamp(timestampFormat.parse("2005-09-03 00:00:00").getTime()); Operation priorLtdOp; priorLtdOp = TestEodAcctIfPnlFinder.businessDate().eq(date1); priorLtdOp = priorLtdOp.and(TestEodAcctIfPnlFinder.updatedBalancesOnOtherDate().processingDateFrom().greaterThan(updateCutoffTime)); priorLtdOp = priorLtdOp.and(TestEodAcctIfPnlFinder.updatedBalancesOnOtherDate().businessDate().eq(date2)); TestEodAcctIfPnlList list = new TestEodAcctIfPnlList(priorLtdOp); list.forceResolve(); assertEquals(1, list.size()); }
Example 15
Source File: TestOracleGeneralTestCases.java From reladomo with Apache License 2.0 | 5 votes |
public void xtestBatchDeleteWithDateAsString() { Operation op = StringDatedOrderFinder.processingDate().lessThan(new Timestamp(System.currentTimeMillis())); op = op.and(StringDatedOrderFinder.orderDate().lessThan(new Date())); StringDatedOrderList orderList = StringDatedOrderFinder.findMany(op); assertEquals(4, orderList.size()); StringDatedOrderFinder.clearQueryCache(); orderList.deleteAll(); StringDatedOrderList orderList2 = StringDatedOrderFinder.findMany(op); assertEquals(0, orderList2.size()); }
Example 16
Source File: TestDatedWithNotDatedJoin.java From reladomo with Apache License 2.0 | 5 votes |
public void testDatedNotDatedJoin() throws Exception { Operation op = DatedTableFinder.all(); op = op.and(DatedTableFinder.notDatedTable().id().eq(1)); DatedTableList dated = new DatedTableList(op); dated.deepFetch(DatedTableFinder.notDatedTable()); assertTrue(dated.size() == 1); }
Example 17
Source File: TestTransactionalList.java From reladomo with Apache License 2.0 | 5 votes |
private Operation getTinyBalanceDateOperation(Timestamp businessDateTo) { Operation tinyBalanceOp1 = TinyBalanceFinder.businessDateTo().lessThanEquals(businessDateTo); tinyBalanceOp1 = tinyBalanceOp1.and(TinyBalanceFinder.acmapCode().eq("A")); tinyBalanceOp1 = tinyBalanceOp1.and(TinyBalanceFinder.businessDate().equalsEdgePoint()); tinyBalanceOp1 = tinyBalanceOp1.and(TinyBalanceFinder.processingDate().equalsEdgePoint()); return tinyBalanceOp1; }
Example 18
Source File: TestDatedWithNotDatedJoin.java From reladomo with Apache License 2.0 | 5 votes |
public void testNonDatedWithBusinessDateToDatedTwoDeepNoDate() throws ParseException { int dbCount = this.getRetrievalCount(); Operation op = NotDatedWithBusinessDateFinder.quantity().greaterThan(0.5); op = op.and(NotDatedWithBusinessDateFinder.datedTable().datedEntityDescType().exists()); assertEquals(2, NotDatedWithBusinessDateFinder.findMany(op).size()); if (!NotDatedWithBusinessDateFinder.getMithraObjectPortal().isPartiallyCached()) { assertEquals(dbCount, this.getRetrievalCount()); } }
Example 19
Source File: TestSum.java From reladomo with Apache License 2.0 | 5 votes |
public void testAndOperationWithToOneOpAndRegularAggregateAttribute() { Operation op = SalesLineItemFinder.productSpecs().originalPrice().greaterThan(20.00); op = op.and(SalesLineItemFinder.quantity().greaterThan(15)); MithraAggregateAttribute aggrAttr = SalesLineItemFinder.quantity().sum(); AggregateList aggregateList = new AggregateList(op); aggregateList.addAggregateAttribute("TotalItems", aggrAttr); aggregateList.addGroupBy("SaleId", SalesLineItemFinder.saleId()); assertEquals(4, aggregateList.size()); for (int i = 0; i < aggregateList.size(); i++) { AggregateData data = aggregateList.get(i); switch (data.getAttributeAsInt("SaleId")) { case 5: assertEquals(17, data.getAttributeAsDouble("TotalItems"), 0); break; case 7: assertEquals(20, data.getAttributeAsDouble("TotalItems"), 0); break; case 8: assertEquals(20, data.getAttributeAsDouble("TotalItems"), 0); break; case 9: assertEquals(16, data.getAttributeAsDouble("TotalItems"), 0); break; default: fail("Invalid sale id"); } } }
Example 20
Source File: TestDifferentDataTypeOperations.java From reladomo with Apache License 2.0 | 4 votes |
public void testCharInOperation() throws SQLException { // test In Operation CharHashSet charSet = new CharHashSet(); charSet.add('A'); charSet.add('C'); Operation op = DifferentDataTypesFinder.charColumn().in(charSet); DifferentDataTypesList list = new DifferentDataTypesList(op); String sql = "select * from DIFFERENT_DATA_TYPES where CHAR_COLUMN in ('A', 'C')"; this.genericRetrievalTest(sql, list); op = DifferentDataTypesFinder.variousByCharColumn().charColumn().in(charSet); list = new DifferentDataTypesList(op); sql = "select D.* from DIFFERENT_DATA_TYPES D, VARIOUS_TYPES V where V.CHAR_COLUMN = D.CHAR_COLUMN and V.CHAR_COLUMN in ('A', 'C')"; this.genericRetrievalTest(sql, list); op = DifferentDataTypesFinder.charColumn().in(charSet); list = new DifferentDataTypesList(op); sql = "select * from DIFFERENT_DATA_TYPES where CHAR_COLUMN in ('A', 'C')"; this.genericRetrievalTest(sql, list); list = new DifferentDataTypesList(op.and(DifferentDataTypesFinder.charColumn().in(charSet))); sql = "select * from DIFFERENT_DATA_TYPES where CHAR_COLUMN in ('A', 'C')"; this.genericRetrievalTest(sql, list); charSet.add('B'); charSet.add('D'); charSet.add('E'); charSet.add('F'); ShortHashSet shortSet = new ShortHashSet(); shortSet.add((short)100); shortSet.add((short)120); op = DifferentDataTypesFinder.charColumn().in(charSet).and(DifferentDataTypesFinder.shortColumn().in(shortSet)); list = new DifferentDataTypesList(op); sql = "select * from DIFFERENT_DATA_TYPES where CHAR_COLUMN in ('A', 'C', 'B', 'D', 'E', 'F') and SHORT_COLUMN in (100, 120)"; this.genericRetrievalTest(sql, list); // test Not In Operation charSet.remove('A'); CharHashSet charSet1 = new CharHashSet(); charSet1.add('Z'); charSet1.add('Y'); op = DifferentDataTypesFinder.charColumn().notIn(charSet); list = new DifferentDataTypesList(op); sql = "select * from DIFFERENT_DATA_TYPES where CHAR_COLUMN not in ('C', 'B', 'D', 'E', 'F')"; this.genericRetrievalTest(sql, list); list = new DifferentDataTypesList(op.and(DifferentDataTypesFinder.charColumn().notIn(charSet)).and(DifferentDataTypesFinder.charColumn().notIn(charSet1))); sql = "select * from DIFFERENT_DATA_TYPES where CHAR_COLUMN not in ('C', 'B', 'D', 'E', 'F') and CHAR_COLUMN not in ('Z', 'Y')"; this.genericRetrievalTest(sql, list); }