@SuppressWarnings({"rawtypes"}) @Test public void testGetAttachemts() throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); // Date validAtDate = formatter.parse("8/26/2011"); Date validAtDate = new Date(); Date asOfDate = new Date(); System.out.println("TemporalReferenceGetAttachmentsTest.testGetAttachemts()"); System.out.println("--------------------------------------------------------"); portfolioBiz.setReference(true); AttachmentSet<String> as = new AttachmentSetFactory().createAttachmentSet(); HashSet<String> set = new HashSet<String>(); set.add("a"); set.add("ab"); as.setAttachments(set); long startTime = System.currentTimeMillis(); as.setGridPath("portfolio"); List<KeyMap> list = portfolioBiz.getAttachments(as, validAtDate.getTime()); long delta = System.currentTimeMillis() - startTime; for (KeyMap keyMap : list) { JsonLite jl = (JsonLite) keyMap; System.out.println(jl.toString(2, true, false)); } System.out.println(); System.out.println("Elapsed time (msec): " + delta); System.out.println(); }
@SuppressWarnings("unchecked") @Test public void testPQL_Lucene() throws PadoException, PadoLoginException, IOException { // Query Lucene String queryString = "portfolio?PortfolioId:MyPortfolio"; // String queryString = "portfolio?(PortfolioId:port_ab AND EndWrittenTime:[20121129 TO // 20141118])"; // String queryString = "portfolio?(Username:dpark AND EndWrittenTime:[20121129 TO 20141118])"; // String queryString = "spare/spare?(InvName:MSTEC AND EndWrittenTime:[20121129 TO // 20141118])"; // String queryString = "spare/spare?(InvName:MSTEC)"; // String orderBy = "EndWrittenTime"; String orderBy = "WrittenTime"; // String orderBy = "StartValidTime"; // String orderBy = "EndValidTime"; // String orderBy = "PortfolioId"; // String orderBy = "AccountId"; // String orderBy = "Description"; // String orderBy = "PortfolioName"; boolean isAscending = true; boolean isDate = orderBy.equals("WrittenTime") || orderBy.equals("EndWrittenTime") || orderBy.equals("StartValidTime") || orderBy.equals("EndValidTime"); imbiz.setAscending(isAscending); imbiz.setFetchSize(100); imbiz.setForceRebuildIndex(true); imbiz.setQueryType(QueryType.PQL); imbiz.setOrderByField(orderBy); int row = 1; IScrollableResultSet rs = imbiz.execute(queryString); int totalSize = rs.getTotalSize(); System.out.println(" total size = " + totalSize); do { List results = rs.toList(); Assert.assertNotNull(results); row = rs.getStartIndex() + 1; Object prevItem = null; JsonLite prevJl = null; for (int i = 0; i < results.size(); i++) { TemporalEntry entry = (TemporalEntry) results.get(i); ITemporalKey tk = entry.getTemporalKey(); ITemporalData data = entry.getTemporalData(); JsonLite jl = (JsonLite) data.getValue(); Comparable item = (Comparable) tk.getWrittenTime(); if (orderBy.equals("WrittenTime") || orderBy.equals("EndWrittenTime")) { item = (Comparable) tk.getWrittenTime(); } else if (orderBy.equals("StartValidTime")) { item = (Comparable) tk.getStartValidTime(); } else if (orderBy.equals("EndValidTime")) { item = (Comparable) tk.getEndValidTime(); } else if (orderBy.equals("Username")) { item = tk.getUsername(); } else { item = (Comparable) jl.get(orderBy); } if (item == null) { System.err.println(orderBy + " field not found."); Assert.fail(); } if (prevItem != null) { if (isAscending) { if (item.compareTo(prevItem) < 0) { printItems(row, jl, prevJl, item, prevItem, orderBy, isAscending, isDate); // Assert.fail(); } } else { if (item.compareTo(prevItem) > 0) { printItems(row, jl, prevJl, item, prevItem, orderBy, isAscending, isDate); // Assert.fail(); } } } row++; prevItem = item; prevJl = jl; } } while (rs.nextSet()); rs.close(); System.out.println("Complete"); }