You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(119) |
Oct
(111) |
Nov
(238) |
Dec
(395) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(239) |
Feb
(59) |
Mar
(354) |
Apr
(489) |
May
(23) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(5) |
Jun
(2) |
Jul
|
Aug
|
Sep
(3) |
Oct
(14) |
Nov
(17) |
Dec
(9) |
| 2007 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
(1) |
Oct
(2) |
Nov
(1) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(7) |
May
(3) |
Jun
(6) |
Jul
(4) |
Aug
(3) |
Sep
(15) |
Oct
(13) |
Nov
(35) |
Dec
(40) |
| 2009 |
Jan
(19) |
Feb
(21) |
Mar
(16) |
Apr
(18) |
May
(36) |
Jun
(20) |
Jul
(32) |
Aug
(11) |
Sep
(3) |
Oct
(2) |
Nov
(2) |
Dec
(13) |
| 2010 |
Jan
(5) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
(3) |
| 2012 |
Jan
(3) |
Feb
(3) |
Mar
(1) |
Apr
(4) |
May
(8) |
Jun
(4) |
Jul
(9) |
Aug
(2) |
Sep
(8) |
Oct
(3) |
Nov
(8) |
Dec
(4) |
| 2013 |
Jan
(2) |
Feb
(1) |
Mar
(5) |
Apr
(6) |
May
(10) |
Jun
(5) |
Jul
(6) |
Aug
(7) |
Sep
(5) |
Oct
(2) |
Nov
(4) |
Dec
(4) |
| 2014 |
Jan
(13) |
Feb
(4) |
Mar
(7) |
Apr
(9) |
May
(20) |
Jun
(13) |
Jul
(10) |
Aug
(3) |
Sep
(5) |
Oct
(2) |
Nov
(2) |
Dec
(2) |
| 2015 |
Jan
(3) |
Feb
(3) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2016 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(4) |
Sep
(3) |
Oct
(3) |
Nov
(4) |
Dec
(2) |
| 2017 |
Jan
|
Feb
(2) |
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <bug...@ve...> - 2004-03-29 20:24:51
|
Message:
The following issue has been closed.
Resolver: Pelle Braendgaard
Date: Mon, 29 Mar 2004 12:11 PM
This now works. It should work with any Ledger that implements LedgerBrowser.
---------------------------------------------------------------------
View the issue:
http://jira.neuclear.org//browse/GL-16
Here is an overview of the issue:
---------------------------------------------------------------------
Key: GL-16
Summary: Create LedgerBrowserServlet
Type: New Feature
Status: Closed
Priority: Major
Resolution: FIXED
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: NeuClear Ledger
Fix Fors:
r_0_4
Assignee: Pelle Braendgaard
Reporter: Pelle Braendgaard
Created: Wed, 19 Nov 2003 12:26 PM
Updated: Mon, 29 Mar 2004 12:11 PM
Description:
Create a LedgerBrowserServlet, which will format and page the items for a particular account a ledger.
The Servlet should be setup in its Init parameters with information about:
- The Ledger Instance to use
- The Ledger ID
The account in mention will be determined by a request parameter.
AccessControl should be done outside of this Servlet in a filter.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.neuclear.org//secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|
|
From: Pelle B. <pe...@us...> - 2004-03-29 20:24:28
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/servlets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6815/src/java/org/neuclear/ledger/servlets Modified Files: LedgerServlet.java Log Message: LedgerServlet works now at least for a straight non date restricted browse. Index: LedgerServlet.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/servlets/LedgerServlet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LedgerServlet.java 26 Mar 2004 23:36:34 -0000 1.6 --- LedgerServlet.java 29 Mar 2004 20:05:16 -0000 1.7 *************** *** 3,9 **** import org.neuclear.commons.Utility; import org.neuclear.commons.servlets.ServletTools; - import org.neuclear.commons.sql.JNDIConnectionSource; - import org.neuclear.commons.sql.statements.SimpleStatementFactory; - import org.neuclear.commons.sql.statements.StatementFactory; import org.neuclear.commons.time.TimeTools; import org.neuclear.id.InvalidNamedObjectException; --- 3,6 ---- *************** *** 12,15 **** --- 9,13 ---- import org.neuclear.ledger.browser.BookBrowser; import org.neuclear.ledger.browser.LedgerBrowser; + import org.neuclear.ledger.simple.PopulatedSimpleLedger; import javax.servlet.ServletConfig; *************** *** 18,25 **** import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import javax.sql.DataSource; import java.io.IOException; import java.io.PrintWriter; - import java.math.BigDecimal; import java.security.Principal; --- 16,21 ---- *************** *** 44,47 **** --- 40,46 ---- $Id$ $Log$ + Revision 1.7 2004/03/29 20:05:16 pelle + LedgerServlet works now at least for a straight non date restricted browse. + Revision 1.6 2004/03/26 23:36:34 pelle The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. *************** *** 72,85 **** public class LedgerServlet extends HttpServlet { public void init(ServletConfig config) throws ServletException { - datasource = ServletTools.getInitParam("datasource", config); serviceid = ServletTools.getInitParam("serviceid", config); try { ! fact = new SimpleStatementFactory(new JNDIConnectionSource(datasource)); ! // ledger= new SQLLedger( ! // fact, ! // serviceid ! // ); ! // if (!ledger.bookExists("neu://alice@test")) ! // PopulateLedger.main(null); } catch (Exception e) { throw new ServletException(e); --- 71,77 ---- public class LedgerServlet extends HttpServlet { public void init(ServletConfig config) throws ServletException { serviceid = ServletTools.getInitParam("serviceid", config); try { ! ledger = new PopulatedSimpleLedger(serviceid); } catch (Exception e) { throw new ServletException(e); *************** *** 99,103 **** book = serviceid; else ! book = "neu:/" + book; BookBrowser stmt = ledger.browse(book); out.println("<table><tr><th>Transaction ID</th><th>Time</th><th>Counterparty</th><th>Comment</th><th>Amount</th></tr>"); --- 91,96 ---- book = serviceid; else ! book = book.substring(1); ! System.out.println("Browsing: " + book); BookBrowser stmt = ledger.browse(book); out.println("<table><tr><th>Transaction ID</th><th>Time</th><th>Counterparty</th><th>Comment</th><th>Amount</th></tr>"); *************** *** 134,142 **** } - private DataSource ds; - private String datasource; private String serviceid; - private static final BigDecimal ZERO = new BigDecimal(0); private LedgerBrowser ledger; - private StatementFactory fact; } --- 127,131 ---- |
|
From: Pelle B. <pe...@us...> - 2004-03-29 20:24:28
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6815/src/java/org/neuclear/ledger/simple Modified Files: SimpleLedger.java Log Message: LedgerServlet works now at least for a straight non date restricted browse. Index: SimpleLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple/SimpleLedger.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SimpleLedger.java 29 Mar 2004 16:56:26 -0000 1.7 --- SimpleLedger.java 29 Mar 2004 20:05:17 -0000 1.8 *************** *** 4,7 **** --- 4,10 ---- * $Id$ * $Log$ + * Revision 1.8 2004/03/29 20:05:17 pelle + * LedgerServlet works now at least for a straight non date restricted browse. + * * Revision 1.7 2004/03/29 16:56:26 pelle * AbstractLedgerBrowserTest has been extended to test date ranges *************** *** 100,104 **** * thread safe or supportive of transactions. */ ! public final class SimpleLedger extends Ledger implements LedgerBrowser { public SimpleLedger(final String name) { --- 103,107 ---- * thread safe or supportive of transactions. */ ! public class SimpleLedger extends Ledger implements LedgerBrowser { public SimpleLedger(final String name) { |
|
From: Pelle B. <pe...@us...> - 2004-03-29 20:24:28
|
Update of /cvsroot/neuclear/neuclear-ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6815 Modified Files: project.xml Log Message: LedgerServlet works now at least for a straight non date restricted browse. Index: project.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/project.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** project.xml 23 Mar 2004 22:01:43 -0000 1.16 --- project.xml 29 Mar 2004 20:05:17 -0000 1.17 *************** *** 78,81 **** --- 78,84 ---- <id>picocontainer</id> <version>1.0-beta-1</version> + <properties> + <war.bundle>true</war.bundle> + </properties> </dependency> <dependency> |
|
From: Pelle B. <pe...@us...> - 2004-03-29 17:08:35
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30668/src/java/org/neuclear/ledger/hibernate Modified Files: HibernateLedger.java Log Message: AbstractLedgerBrowserTest has been extended to test date ranges SimpleLedger now passes all tests. HibernateLedger passes at times, which is mysterious. More research needed. Index: HibernateLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HibernateLedger.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** HibernateLedger.java 26 Mar 2004 23:36:50 -0000 1.10 --- HibernateLedger.java 29 Mar 2004 16:57:00 -0000 1.11 *************** *** 386,390 **** Query q = ses.createQuery("from HTransactionItem item where item.book=? and item.transaction.transactionTime>=?"); q.setString(0, book); ! q.setDate(1, from); Iterator iter = q.iterate(); return new HibernateBookBrowser(iter, book); --- 386,391 ---- Query q = ses.createQuery("from HTransactionItem item where item.book=? and item.transaction.transactionTime>=?"); q.setString(0, book); ! q.setTimestamp(1, from); ! System.out.println("from: " + from); Iterator iter = q.iterate(); return new HibernateBookBrowser(iter, book); *************** *** 400,405 **** Query q = ses.createQuery("from HTransactionItem item where item.book=? and item.transaction.transactionTime>=? and item.transaction.transactionTime<?"); q.setString(0, book); ! q.setDate(1, from); ! q.setDate(1, until); Iterator iter = q.iterate(); return new HibernateBookBrowser(iter, book); --- 401,409 ---- Query q = ses.createQuery("from HTransactionItem item where item.book=? and item.transaction.transactionTime>=? and item.transaction.transactionTime<?"); q.setString(0, book); ! q.setTimestamp(1, from); ! q.setTimestamp(2, until); ! System.out.println("from: " + from); ! System.out.println("until: " + until); ! System.out.println("range of " + (until.getTime() - from.getTime())); Iterator iter = q.iterate(); return new HibernateBookBrowser(iter, book); |
|
From: Pelle B. <pe...@us...> - 2004-03-29 17:08:35
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30668/src/java Modified Files: hibernate.properties Log Message: AbstractLedgerBrowserTest has been extended to test date ranges SimpleLedger now passes all tests. HibernateLedger passes at times, which is mysterious. More research needed. Index: hibernate.properties =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/hibernate.properties,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** hibernate.properties 26 Mar 2004 23:36:50 -0000 1.7 --- hibernate.properties 29 Mar 2004 16:57:00 -0000 1.8 *************** *** 299,303 **** ## print all generated SQL to the console ! #hibernate.show_sql true --- 299,303 ---- ## print all generated SQL to the console ! hibernate.show_sql true |
|
From: Pelle B. <pe...@us...> - 2004-03-29 17:07:55
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30575/src/java/org/neuclear/ledger/tests Modified Files: AbstractLedgerBrowserTest.java Log Message: AbstractLedgerBrowserTest has been extended to test date ranges SimpleLedger now passes all tests. HibernateLedger passes at times, which is mysterious. More research needed. Index: AbstractLedgerBrowserTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests/AbstractLedgerBrowserTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractLedgerBrowserTest.java 26 Mar 2004 23:36:34 -0000 1.2 --- AbstractLedgerBrowserTest.java 29 Mar 2004 16:56:26 -0000 1.3 *************** *** 13,16 **** --- 13,21 ---- $Id$ $Log$ + Revision 1.3 2004/03/29 16:56:26 pelle + AbstractLedgerBrowserTest has been extended to test date ranges + SimpleLedger now passes all tests. + HibernateLedger passes at times, which is mysterious. More research needed. + Revision 1.2 2004/03/26 23:36:34 pelle The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. *************** *** 44,47 **** --- 49,67 ---- } + public static Date getIsolatedTimeStamp() { + try { + Thread.currentThread().sleep(5); + } catch (InterruptedException e) { + ; + } + final Date t = new Date(); + try { + Thread.currentThread().sleep(5); + } catch (InterruptedException e) { + ; + } + return t; + } + public void testAmountOfEntries() throws LowlevelLedgerException, InvalidTransactionException { final String bob = getBobBook(); *************** *** 78,82 **** final String alice = getAliceBook(); ! Date t1 = new Date(); assertBookBrowserSize(bob, 0, browser.browse(bob)); assertBookBrowserSize(alice, 0, browser.browse(alice)); --- 98,102 ---- final String alice = getAliceBook(); ! Date t1 = getIsolatedTimeStamp(); assertBookBrowserSize(bob, 0, browser.browse(bob)); assertBookBrowserSize(alice, 0, browser.browse(alice)); *************** *** 88,92 **** assertBookBrowserSize(alice, i, browser.browse(alice)); ! Date t2 = new Date(); assertTrue(t2.after(t1)); --- 108,112 ---- assertBookBrowserSize(alice, i, browser.browse(alice)); ! Date t2 = getIsolatedTimeStamp(); assertTrue(t2.after(t1)); *************** *** 106,113 **** } ! public void testEntryContentFromTime() throws LowlevelLedgerException, InvalidTransactionException { final String bob = getBobBook(); final String alice = getAliceBook(); assertBookBrowserSize(bob, 0, browser.browse(bob)); assertBookBrowserSize(alice, 0, browser.browse(alice)); --- 126,134 ---- } ! public void testAmountOfEntriesInTimeRange() throws LowlevelLedgerException, InvalidTransactionException { final String bob = getBobBook(); final String alice = getAliceBook(); + Date t1 = getIsolatedTimeStamp(); assertBookBrowserSize(bob, 0, browser.browse(bob)); assertBookBrowserSize(alice, 0, browser.browse(alice)); *************** *** 116,125 **** ledger.transfer(bob, alice, 10, "test" + i); } ! assertVerifyBrowserContent(bob, alice, -10, i, browser.browse(bob)); ! assertVerifyBrowserContent(alice, bob, 10, i, browser.browse(alice)); ! } public void assertVerifyBrowserContent(final String book, final String counterparty, final double amount, final int count, final BookBrowser bb) throws LowlevelLedgerException { --- 137,176 ---- ledger.transfer(bob, alice, 10, "test" + i); } ! assertBookBrowserSize(bob, i, browser.browse(bob)); ! assertBookBrowserSize(alice, i, browser.browse(alice)); + Date t2 = getIsolatedTimeStamp(); ! for (i = 0; i < 10; i++) { ! ledger.transfer(bob, alice, 10, "test" + i); ! } ! assertBookBrowserSize(bob, 20, browser.browse(bob)); ! assertBookBrowserSize(alice, 20, browser.browse(alice)); ! Date t3 = getIsolatedTimeStamp(); ! ! for (i = 0; i < 10; i++) { ! ledger.transfer(bob, alice, 10, "test" + i); ! } ! Date t4 = getIsolatedTimeStamp(); ! assertBookBrowserSize(bob, 30, browser.browse(bob)); ! assertBookBrowserSize(alice, 30, browser.browse(alice)); + assertBookBrowserSize(bob, 10, browser.browseRange(bob, t3, t4)); + assertBookBrowserSize(alice, 10, browser.browseRange(alice, t3, t4)); + assertBookBrowserSize(bob, 10, browser.browseRange(bob, t2, t3)); + assertBookBrowserSize(alice, 10, browser.browseRange(alice, t2, t3)); + assertBookBrowserSize(bob, 10, browser.browseRange(bob, t1, t2)); + assertBookBrowserSize(alice, 10, browser.browseRange(alice, t1, t2)); + + + assertBookBrowserSize(bob, 20, browser.browseRange(bob, t1, t3)); + assertBookBrowserSize(alice, 20, browser.browseRange(alice, t1, t3)); + assertBookBrowserSize(bob, 20, browser.browseRange(bob, t2, t4)); + assertBookBrowserSize(alice, 20, browser.browseRange(alice, t2, t4)); + + assertBookBrowserSize(bob, 30, browser.browseRange(bob, t1, t4)); + assertBookBrowserSize(alice, 30, browser.browseRange(alice, t1, t4)); + + } public void assertVerifyBrowserContent(final String book, final String counterparty, final double amount, final int count, final BookBrowser bb) throws LowlevelLedgerException { |
|
From: Pelle B. <pe...@us...> - 2004-03-29 17:07:55
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30575/src/java/org/neuclear/ledger/simple Modified Files: SimpleLedger.java Log Message: AbstractLedgerBrowserTest has been extended to test date ranges SimpleLedger now passes all tests. HibernateLedger passes at times, which is mysterious. More research needed. Index: SimpleLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple/SimpleLedger.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SimpleLedger.java 26 Mar 2004 23:36:34 -0000 1.6 --- SimpleLedger.java 29 Mar 2004 16:56:26 -0000 1.7 *************** *** 4,7 **** --- 4,12 ---- * $Id$ * $Log$ + * Revision 1.7 2004/03/29 16:56:26 pelle + * AbstractLedgerBrowserTest has been extended to test date ranges + * SimpleLedger now passes all tests. + * HibernateLedger passes at times, which is mysterious. More research needed. + * * Revision 1.6 2004/03/26 23:36:34 pelle * The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. *************** *** 89,95 **** import org.neuclear.ledger.browser.LedgerBrowser; ! import java.util.Date; ! import java.util.HashMap; ! import java.util.Iterator; /** --- 94,98 ---- import org.neuclear.ledger.browser.LedgerBrowser; ! import java.util.*; /** *************** *** 105,108 **** --- 108,112 ---- held = new HashMap(); balances = new HashMap(); + books = new HashMap(); } *************** *** 121,129 **** throw new UnBalancedTransactionException(this, trans); final PostedTransaction posted = new PostedTransaction(trans, new Date()); ! ledger.put(id, posted); updateBalances(posted); return posted; } private void updateBalances(final PostedTransaction trans) { synchronized (balances) { --- 125,149 ---- throw new UnBalancedTransactionException(this, trans); final PostedTransaction posted = new PostedTransaction(trans, new Date()); ! return post(posted); ! } ! ! private PostedTransaction post(final PostedTransaction posted) { ! ledger.put(posted.getId(), posted); ! postToBook(posted); updateBalances(posted); return posted; } + private void postToBook(final PostedTransaction posted) { + Iterator iter = posted.getItems(); + while (iter.hasNext()) { + TransactionItem item = (TransactionItem) iter.next(); + if (!books.containsKey(item.getBook())) + books.put(item.getBook(), new LinkedList()); + List bookentries = (List) books.get(item.getBook()); + bookentries.add(posted); + } + } + private void updateBalances(final PostedTransaction trans) { synchronized (balances) { *************** *** 172,175 **** --- 192,196 ---- final PostedHeldTransaction posted = new PostedHeldTransaction(trans, new Date()); held.put(posted.getId(), posted); + postToBook(posted); return posted; } *************** *** 211,217 **** held.remove(hold.getId()); PostedTransaction posted = new PostedTransaction(hold, new Date(), amount, comment); ! ledger.put(posted.getId(), posted); ! updateBalances(posted); ! return posted; } --- 232,236 ---- held.remove(hold.getId()); PostedTransaction posted = new PostedTransaction(hold, new Date(), amount, comment); ! return post(posted); } *************** *** 324,332 **** public BookBrowser browseFrom(String book, Date from) throws LowlevelLedgerException { ! return null; } public BookBrowser browseRange(String book, Date from, Date until) throws LowlevelLedgerException { ! return null; } --- 343,351 ---- public BookBrowser browseFrom(String book, Date from) throws LowlevelLedgerException { ! return new SimpleBookBrowser(book, from); } public BookBrowser browseRange(String book, Date from, Date until) throws LowlevelLedgerException { ! return new SimpleBookBrowser(book, from, until); } *************** *** 335,344 **** private final String id; private final HashMap balances; private class SimpleBookBrowser extends BookBrowser { ! public SimpleBookBrowser(String book) { super(book); ! iter = ledger.keySet().iterator(); ! System.out.println("ledger contains: " + ledger.size()); } --- 354,391 ---- private final String id; private final HashMap balances; + private final HashMap books; private class SimpleBookBrowser extends BookBrowser { ! public SimpleBookBrowser(final String book) { ! this(book, null, null); ! } ! ! public SimpleBookBrowser(final String book, final Date from) { ! this(book, from, null); ! } ! ! public SimpleBookBrowser(final String book, final Date from, final Date to) { super(book); ! this.from = from; ! this.to = to; ! if (books.containsKey(book)) { ! iter = ((List) books.get(book)).iterator(); ! // System.out.println("book contains: " + ((List)books.get(book)).size()); ! } else { ! iter = new Iterator() { ! public void remove() { ! ! } ! ! public boolean hasNext() { ! return false; ! } ! ! public Object next() { ! return null; ! } ! ! }; ! } } *************** *** 346,355 **** if (!iter.hasNext()) return false; ! // PostedTransaction tran=(PostedTransaction) ledger.get((iter.next())); ! iter.next(); return true; } private final Iterator iter; } } --- 393,433 ---- if (!iter.hasNext()) return false; ! PostedTransaction tran = (PostedTransaction) iter.next(); ! if (!isValid(tran)) ! return next(); ! ! setRow(tran); return true; } + private boolean isValid(final PostedTransaction posted) { + if (from == null) + return true; + if (posted.getTransactionTime().after(from)) { + return (to == null) || posted.getTransactionTime().before(to); + } + return false; + } + + private void setRow(PostedTransaction tran) { + Iterator iter = tran.getItems(); + TransactionItem item = null; + String counterparty = null; + while (iter.hasNext()) { + TransactionItem party = (TransactionItem) iter.next(); + if (!party.getBook().equals(getBook())) { + counterparty = party.getBook(); + } else { + item = party; + } + } + + setRow(tran.getId(), tran.getRequestId(), counterparty, tran.getComment(), tran.getTransactionTime(), item.getAmount(), null, null, null); + } + private final Iterator iter; + private final Date from; + private final Date to; + // private int i=0; } } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 23:47:57
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25398/src/java/org/neuclear/ledger/hibernate Modified Files: HibernateBookBrowser.java HibernateLedger.java Log Message: The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. Index: HibernateLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HibernateLedger.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** HibernateLedger.java 26 Mar 2004 18:38:27 -0000 1.9 --- HibernateLedger.java 26 Mar 2004 23:36:50 -0000 1.10 *************** *** 381,390 **** } ! public BookBrowser browseFrom(String book, Timestamp from) throws LowlevelLedgerException { ! return null; } ! public BookBrowser browseRange(String book, Timestamp from, Timestamp until) throws LowlevelLedgerException { ! return null; } --- 381,411 ---- } ! public BookBrowser browseFrom(String book, Date from) throws LowlevelLedgerException { ! try { ! Session ses = factory.openSession(); ! Query q = ses.createQuery("from HTransactionItem item where item.book=? and item.transaction.transactionTime>=?"); ! q.setString(0, book); ! q.setDate(1, from); ! Iterator iter = q.iterate(); ! return new HibernateBookBrowser(iter, book); ! } catch (HibernateException e) { ! throw new LowlevelLedgerException(e); ! } ! } ! public BookBrowser browseRange(String book, Date from, Date until) throws LowlevelLedgerException { ! try { ! Session ses = factory.openSession(); ! Query q = ses.createQuery("from HTransactionItem item where item.book=? and item.transaction.transactionTime>=? and item.transaction.transactionTime<?"); ! q.setString(0, book); ! q.setDate(1, from); ! q.setDate(1, until); ! Iterator iter = q.iterate(); ! return new HibernateBookBrowser(iter, book); ! } catch (HibernateException e) { ! throw new LowlevelLedgerException(e); ! } ! } Index: HibernateBookBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HibernateBookBrowser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HibernateBookBrowser.java 25 Mar 2004 22:05:20 -0000 1.1 --- HibernateBookBrowser.java 26 Mar 2004 23:36:50 -0000 1.2 *************** *** 26,29 **** --- 26,32 ---- $Id$ $Log$ + Revision 1.2 2004/03/26 23:36:50 pelle + The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. + Revision 1.1 2004/03/25 22:05:20 pelle First shell of the HibernateBookBrowser *************** *** 43,47 **** public boolean next() throws LowlevelLedgerException { ! return false; } --- 46,63 ---- public boolean next() throws LowlevelLedgerException { ! if (!iter.hasNext()) ! return false; ! HTransactionItem item = (HTransactionItem) iter.next(); ! final HTransaction tran = item.getTransaction(); ! String counterparty = null; ! Iterator iter = tran.getItems().iterator(); ! while (iter.hasNext()) { ! HTransactionItem party = (HTransactionItem) iter.next(); ! if (!party.getBook().equals(item.getBook())) { ! counterparty = party.getBook(); ! } ! } ! setRow(tran.getId(), tran.getRequestId(), counterparty, tran.getComment(), tran.getTransactionTime(), item.getAmount(), null, null, null); ! return true; } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 23:47:57
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25398/src/java Modified Files: hibernate.properties Log Message: The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. Index: hibernate.properties =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/hibernate.properties,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** hibernate.properties 26 Mar 2004 18:38:27 -0000 1.6 --- hibernate.properties 26 Mar 2004 23:36:50 -0000 1.7 *************** *** 299,303 **** ## print all generated SQL to the console ! hibernate.show_sql true --- 299,303 ---- ## print all generated SQL to the console ! #hibernate.show_sql true |
|
From: Pelle B. <pe...@us...> - 2004-03-26 23:47:42
|
Update of /cvsroot/neuclear/neuclear-ledger-prevalent/src/test/org/neuclear/ledger/prevalent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25381/src/test/org/neuclear/ledger/prevalent Modified Files: PrevalentLedgerTest.java Log Message: The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. Index: PrevalentLedgerTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-prevalent/src/test/org/neuclear/ledger/prevalent/PrevalentLedgerTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PrevalentLedgerTest.java 22 Mar 2004 23:20:58 -0000 1.3 --- PrevalentLedgerTest.java 26 Mar 2004 23:36:40 -0000 1.4 *************** *** 1,13 **** package org.neuclear.ledger.prevalent; - import org.neuclear.commons.NeuClearException; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.LowlevelLedgerException; - import org.neuclear.ledger.UnknownLedgerException; import org.neuclear.ledger.tests.AbstractLedgerTest; - import javax.naming.NamingException; import java.io.IOException; - import java.sql.SQLException; /** --- 1,9 ---- *************** *** 19,23 **** */ public class PrevalentLedgerTest extends AbstractLedgerTest { ! public PrevalentLedgerTest(String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); } --- 15,19 ---- */ public class PrevalentLedgerTest extends AbstractLedgerTest { ! public PrevalentLedgerTest(String s) { super(s); } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 23:47:37
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25331/src/java/org/neuclear/ledger/browser Modified Files: BookBrowser.java LedgerBrowser.java Log Message: The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. Index: BookBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/BookBrowser.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BookBrowser.java 25 Mar 2004 22:04:45 -0000 1.3 --- BookBrowser.java 26 Mar 2004 23:36:34 -0000 1.4 *************** *** 3,8 **** import org.neuclear.ledger.LowlevelLedgerException; ! import java.math.BigDecimal; ! import java.sql.Timestamp; /* --- 3,7 ---- import org.neuclear.ledger.LowlevelLedgerException; ! import java.util.Date; /* *************** *** 26,29 **** --- 25,31 ---- $Id$ $Log$ + Revision 1.4 2004/03/26 23:36:34 pelle + The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. + Revision 1.3 2004/03/25 22:04:45 pelle The first shell for the HibernateBookBrowser *************** *** 54,58 **** ! protected final void setRow(String xid, String reqid, String counterparty, String comment, Timestamp valuetime, BigDecimal amount) { this.id = xid; this.reqid = reqid; --- 56,60 ---- ! protected final void setRow(String xid, String reqid, String counterparty, String comment, Date valuetime, double amount, Date expirytime, Date cancelled, String completedId) { this.id = xid; this.reqid = reqid; *************** *** 61,64 **** --- 63,69 ---- this.valuetime = valuetime; this.amount = amount; + this.cancelled = cancelled; + this.expirytime = expirytime; + this.completedId = completedId; } *************** *** 83,94 **** } ! public Timestamp getValuetime() { return valuetime; } ! public BigDecimal getAmount() { return amount; } private final String book; --- 88,115 ---- } ! public Date getValuetime() { return valuetime; } ! public double getAmount() { return amount; } + public Date getExpirytime() { + return expirytime; + } + + public Date getCancelled() { + return cancelled; + } + + public String getCompletedId() { + return completedId; + } + + boolean isHeld() { + return (expirytime != null); + } + private final String book; *************** *** 97,101 **** private String counterparty; private String comment; ! private Timestamp valuetime; ! private BigDecimal amount; } --- 118,125 ---- private String counterparty; private String comment; ! private Date valuetime; ! private Date expirytime; ! private Date cancelled; ! private String completedId; ! private double amount; } Index: LedgerBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/LedgerBrowser.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LedgerBrowser.java 21 Mar 2004 00:48:35 -0000 1.3 --- LedgerBrowser.java 26 Mar 2004 23:36:34 -0000 1.4 *************** *** 3,7 **** import org.neuclear.ledger.LowlevelLedgerException; ! import java.sql.Timestamp; /* --- 3,7 ---- import org.neuclear.ledger.LowlevelLedgerException; ! import java.util.Date; /* *************** *** 25,28 **** --- 25,31 ---- $Id$ $Log$ + Revision 1.4 2004/03/26 23:36:34 pelle + The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. + Revision 1.3 2004/03/21 00:48:35 pelle The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. *************** *** 45,50 **** public BookBrowser browse(String book) throws LowlevelLedgerException; ! public BookBrowser browseFrom(String book, Timestamp from) throws LowlevelLedgerException; // public BookBrowser browseUntil(Book book,Timestamp until); ! public BookBrowser browseRange(String book, Timestamp from, Timestamp until) throws LowlevelLedgerException; } --- 48,53 ---- public BookBrowser browse(String book) throws LowlevelLedgerException; ! public BookBrowser browseFrom(String book, Date from) throws LowlevelLedgerException; // public BookBrowser browseUntil(Book book,Timestamp until); ! public BookBrowser browseRange(String book, Date from, Date until) throws LowlevelLedgerException; } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 23:47:37
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25331/src/java/org/neuclear/ledger/tests Modified Files: AbstractLedgerBrowserTest.java Log Message: The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. Index: AbstractLedgerBrowserTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests/AbstractLedgerBrowserTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractLedgerBrowserTest.java 26 Mar 2004 18:37:56 -0000 1.1 --- AbstractLedgerBrowserTest.java 26 Mar 2004 23:36:34 -0000 1.2 *************** *** 8,14 **** --- 8,19 ---- import org.neuclear.ledger.browser.LedgerBrowser; + import java.util.Date; + /* $Id$ $Log$ + Revision 1.2 2004/03/26 23:36:34 pelle + The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. + Revision 1.1 2004/03/26 18:37:56 pelle More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. *************** *** 29,44 **** public abstract Ledger getLedger() throws LowlevelLedgerException; ! public void testIsBrowser() throws LowlevelLedgerException { ! final Ledger ledger = getLedger(); assertTrue("Ledger is instance of LedgerBrowser", ledger instanceof LedgerBrowser); ledger.close(); } public void testAmountOfEntries() throws LowlevelLedgerException, InvalidTransactionException { ! final Ledger ledger = getLedger(); ! assertTrue("Ledger is instance of LedgerBrowser", ledger instanceof LedgerBrowser); ! final LedgerBrowser browser = (LedgerBrowser) ledger; final String bob = getBobBook(); final String alice = getAliceBook(); --- 34,62 ---- public abstract Ledger getLedger() throws LowlevelLedgerException; ! protected void setUp() throws Exception { ! ledger = getLedger(); assertTrue("Ledger is instance of LedgerBrowser", ledger instanceof LedgerBrowser); + browser = (LedgerBrowser) ledger; + } + + protected void tearDown() throws Exception { ledger.close(); } public void testAmountOfEntries() throws LowlevelLedgerException, InvalidTransactionException { ! final String bob = getBobBook(); ! final String alice = getAliceBook(); ! assertBookBrowserSize(bob, 0, browser.browse(bob)); ! assertBookBrowserSize(alice, 0, browser.browse(alice)); ! int i; ! for (i = 0; i < 10; i++) { ! ledger.transfer(bob, alice, 10, "test" + i); ! } ! assertBookBrowserSize(bob, i, browser.browse(bob)); ! assertBookBrowserSize(alice, i, browser.browse(alice)); ! } + public void testEntryContent() throws LowlevelLedgerException, InvalidTransactionException { final String bob = getBobBook(); final String alice = getAliceBook(); *************** *** 50,58 **** ledger.transfer(bob, alice, 10, "test" + i); } assertBookBrowserSize(bob, i, browser.browse(bob)); assertBookBrowserSize(alice, i, browser.browse(alice)); - ledger.close(); } --- 68,144 ---- ledger.transfer(bob, alice, 10, "test" + i); } + assertVerifyBrowserContent(bob, alice, -10, i, browser.browse(bob)); + assertVerifyBrowserContent(alice, bob, 10, i, browser.browse(alice)); + + + } + + public void testAmountOfEntriesFromTime() throws LowlevelLedgerException, InvalidTransactionException { + final String bob = getBobBook(); + final String alice = getAliceBook(); + + Date t1 = new Date(); + assertBookBrowserSize(bob, 0, browser.browse(bob)); + assertBookBrowserSize(alice, 0, browser.browse(alice)); + int i; + for (i = 0; i < 10; i++) { + ledger.transfer(bob, alice, 10, "test" + i); + } assertBookBrowserSize(bob, i, browser.browse(bob)); assertBookBrowserSize(alice, i, browser.browse(alice)); + Date t2 = new Date(); + assertTrue(t2.after(t1)); + + for (i = 0; i < 10; i++) { + ledger.transfer(bob, alice, 10, "test" + i); + } + assertBookBrowserSize(bob, 20, browser.browse(bob)); + assertBookBrowserSize(alice, 20, browser.browse(alice)); + + assertBookBrowserSize(bob, 20, browser.browseFrom(bob, t1)); + assertBookBrowserSize(alice, 20, browser.browseFrom(alice, t1)); + + + assertBookBrowserSize(bob, i, browser.browseFrom(bob, t2)); + assertBookBrowserSize(alice, i, browser.browseFrom(alice, t2)); + + } + + public void testEntryContentFromTime() throws LowlevelLedgerException, InvalidTransactionException { + final String bob = getBobBook(); + final String alice = getAliceBook(); + + assertBookBrowserSize(bob, 0, browser.browse(bob)); + assertBookBrowserSize(alice, 0, browser.browse(alice)); + int i; + for (i = 0; i < 10; i++) { + ledger.transfer(bob, alice, 10, "test" + i); + } + assertVerifyBrowserContent(bob, alice, -10, i, browser.browse(bob)); + assertVerifyBrowserContent(alice, bob, 10, i, browser.browse(alice)); + + + } + + + public void assertVerifyBrowserContent(final String book, final String counterparty, final double amount, final int count, final BookBrowser bb) throws LowlevelLedgerException { + assertNotNull("null book browser for " + book, bb); + int total = 0; + while (bb.next()) { + assertEquals("book", book, bb.getBook()); + assertEquals("counterparty", counterparty, bb.getCounterparty()); + assertEquals("amount", amount, bb.getAmount(), 0); + assertEquals("comment", "test" + total, bb.getComment()); + assertNotNull("id", bb.getId()); + assertNotNull("reqid", bb.getRequestId()); + assertNotNull("valuetime", bb.getValuetime()); + assertNull("expiry", bb.getExpirytime()); + assertNull("cancelled", bb.getCancelled()); + assertNull("completed", bb.getCompletedId()); + total++; + } + assertEquals("The size doesnt match for: " + book, count, total); } *************** *** 78,80 **** --- 164,169 ---- } + protected Ledger ledger; + protected LedgerBrowser browser; + } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 23:47:37
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25331/src/java/org/neuclear/ledger/simple Modified Files: SimpleLedger.java Log Message: The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. Index: SimpleLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple/SimpleLedger.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SimpleLedger.java 26 Mar 2004 18:37:56 -0000 1.5 --- SimpleLedger.java 26 Mar 2004 23:36:34 -0000 1.6 *************** *** 4,7 **** --- 4,10 ---- * $Id$ * $Log$ + * Revision 1.6 2004/03/26 23:36:34 pelle + * The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. + * * Revision 1.5 2004/03/26 18:37:56 pelle * More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. *************** *** 86,90 **** import org.neuclear.ledger.browser.LedgerBrowser; - import java.sql.Timestamp; import java.util.Date; import java.util.HashMap; --- 89,92 ---- *************** *** 321,329 **** } ! public BookBrowser browseFrom(String book, Timestamp from) throws LowlevelLedgerException { return null; } ! public BookBrowser browseRange(String book, Timestamp from, Timestamp until) throws LowlevelLedgerException { return null; } --- 323,331 ---- } ! public BookBrowser browseFrom(String book, Date from) throws LowlevelLedgerException { return null; } ! public BookBrowser browseRange(String book, Date from, Date until) throws LowlevelLedgerException { return null; } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 23:47:35
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/servlets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25331/src/java/org/neuclear/ledger/servlets Modified Files: LedgerServlet.java Log Message: The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. Index: LedgerServlet.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/servlets/LedgerServlet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LedgerServlet.java 25 Mar 2004 22:04:46 -0000 1.5 --- LedgerServlet.java 26 Mar 2004 23:36:34 -0000 1.6 *************** *** 44,47 **** --- 44,50 ---- $Id$ $Log$ + Revision 1.6 2004/03/26 23:36:34 pelle + The simple browse(book) now works on hibernate, I have implemented the other two, which currently don not constrain the query correctly. + Revision 1.5 2004/03/25 22:04:46 pelle The first shell for the HibernateBookBrowser *************** *** 100,106 **** out.println("<table><tr><th>Transaction ID</th><th>Time</th><th>Counterparty</th><th>Comment</th><th>Amount</th></tr>"); while (stmt.next()) { ! final BigDecimal amount = stmt.getAmount(); out.print("<tr"); ! if (amount.compareTo(ZERO) < 0) out.print(" class=\"negative\""); out.print("><td style=\"size:small\">"); --- 103,109 ---- out.println("<table><tr><th>Transaction ID</th><th>Time</th><th>Counterparty</th><th>Comment</th><th>Amount</th></tr>"); while (stmt.next()) { ! final double amount = stmt.getAmount(); out.print("<tr"); ! if (amount < 0) out.print(" class=\"negative\""); out.print("><td style=\"size:small\">"); |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:50:04
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/java/org/neuclear/ledger/sql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28097/src/java/org/neuclear/ledger/sql Modified Files: SQLLedger.java Added Files: QueryBookBrowser.java Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. --- NEW FILE: QueryBookBrowser.java --- package org.neuclear.ledger.sql; import org.neuclear.commons.sql.statements.StatementFactory; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.browser.BookBrowser; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: QueryBookBrowser.java,v 1.1 2004/03/26 18:39:05 pelle Exp $ $Log: QueryBookBrowser.java,v $ Revision 1.1 2004/03/26 18:39:05 pelle More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. Revision 1.3 2004/03/25 22:04:46 pelle The first shell for the HibernateBookBrowser Revision 1.2 2004/03/21 00:48:35 pelle The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Revision 1.1 2004/01/02 23:18:34 pelle Added StatementFactory pattern and refactored the ledger to use it. Revision 1.1 2003/12/31 00:39:04 pelle Added Drivers for handling different Database dialects in the entity model. Added BookBrowser pattern to ledger, simplifying the statement writing process. */ /** * User: pelleb * Date: Dec 30, 2003 * Time: 4:30:19 PM */ public class QueryBookBrowser extends BookBrowser { public QueryBookBrowser(Ledger ledger, String book, StatementFactory fact) throws SQLException { this(ledger, book, executeQuery(fact, ledger.getId(), book)); } public QueryBookBrowser(Ledger ledger, String book, StatementFactory fact, Timestamp from, Timestamp until) throws SQLException { this(ledger, book, executeRangeQuery(fact, ledger.getId(), book, from, until)); } public QueryBookBrowser(Ledger ledger, String book, StatementFactory fact, Timestamp from) throws SQLException { this(ledger, book, executeFromQuery(fact, ledger.getId(), book, from)); } private QueryBookBrowser(Ledger ledger, String book, ResultSet rs) throws SQLException { super(book); this.rs = rs; next = rs.next(); this.ledger = ledger; } private static ResultSet executeRangeQuery(StatementFactory fact, String ledgerid, String book, Timestamp from, Timestamp until) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(RANGE_QUERY); stmt.setTimestamp(3, from); stmt.setTimestamp(4, until); return executeQuery(stmt, ledgerid, book); } private static ResultSet executeFromQuery(StatementFactory fact, String ledgerid, String book, Timestamp from) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(FROM_QUERY); stmt.setTimestamp(3, from); return executeQuery(stmt, ledgerid, book); } private static ResultSet executeUntilQuery(StatementFactory fact, String ledgerid, String book, Timestamp until) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(UNTIL_QUERY); stmt.setTimestamp(3, until); return executeQuery(stmt, ledgerid, book); } private static ResultSet executeQuery(StatementFactory fact, String ledgerid, String book) throws SQLException { return executeQuery(fact.prepareStatement(FULL_QUERY), ledgerid, book); } private static ResultSet executeQuery(PreparedStatement stmt, String ledgerid, String book) throws SQLException { stmt.setString(1, book); stmt.setString(2, ledgerid); return stmt.executeQuery(); } public boolean next() throws LowlevelLedgerException { try { if (!rs.next()) return false; setRow(rs.getString(1), rs.getString(2), rs.getString(4), rs.getString(5), rs.getTimestamp(3), rs.getBigDecimal(6)); return true; } catch (SQLException e) { throw new LowlevelLedgerException(ledger, e); } } private final ResultSet rs; private final Ledger ledger; private boolean next; private static final String BASE_QUERY = "select t.id,t.request_id, t.valuetime, r.bookid,t.comment,s.amount from entry s,entry r, transaction t where s.transactionid=t.id and r.transactionid=t.id and r.id<>s.id\nand s.bookid = ? and t.ledgerid=?"; private static final String UNTIL_CLAUSE = " AND t.valuetime<=?"; private static final String FROM_CLAUSE = " AND t.valuetime>?"; private static final String ORDERBY = " order by t.valuetime,t.id"; private static final String FULL_QUERY = BASE_QUERY + ORDERBY; private static final String RANGE_QUERY = BASE_QUERY + FROM_CLAUSE + UNTIL_CLAUSE + ORDERBY; private static final String FROM_QUERY = BASE_QUERY + FROM_CLAUSE + ORDERBY; private static final String UNTIL_QUERY = BASE_QUERY + UNTIL_CLAUSE + ORDERBY; } Index: SQLLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-sql/src/java/org/neuclear/ledger/sql/SQLLedger.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SQLLedger.java 25 Mar 2004 16:43:49 -0000 1.3 --- SQLLedger.java 26 Mar 2004 18:39:05 -0000 1.4 *************** *** 18,22 **** import org.neuclear.ledger.browser.BookBrowser; import org.neuclear.ledger.browser.LedgerBrowser; - import org.neuclear.ledger.browser.QueryBookBrowser; import javax.transaction.UserTransaction; --- 18,21 ---- |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:49:27
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27835/src/java Modified Files: hibernate.properties Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. Index: hibernate.properties =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/hibernate.properties,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hibernate.properties 25 Mar 2004 19:04:18 -0000 1.5 --- hibernate.properties 26 Mar 2004 18:38:27 -0000 1.6 *************** *** 27,31 **** #hibernate.connection.password #hibernate.connection.url jdbc:hsqldb:hsql://localhost ! #hibernate.connection.url jdbc:hsqldb:test #hibernate.connection.url jdbc:hsqldb:. --- 27,31 ---- #hibernate.connection.password #hibernate.connection.url jdbc:hsqldb:hsql://localhost ! #hibernate.connection.url jdbc:hsqldb:target/test-data/ledger #hibernate.connection.url jdbc:hsqldb:. |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:49:27
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/test/org/neuclear/ledger/hibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27835/src/test/org/neuclear/ledger/hibernate Added Files: HibernateBrowserTest.java Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. --- NEW FILE: HibernateBrowserTest.java --- package org.neuclear.ledger.hibernate; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.tests.AbstractLedgerBrowserTest; /* $Id: HibernateBrowserTest.java,v 1.1 2004/03/26 18:38:28 pelle Exp $ $Log: HibernateBrowserTest.java,v $ Revision 1.1 2004/03/26 18:38:28 pelle More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. */ /** * User: pelleb * Date: Mar 26, 2004 * Time: 1:00:05 PM */ public class HibernateBrowserTest extends AbstractLedgerBrowserTest { public HibernateBrowserTest(String name) { super(name); } public Ledger getLedger() throws LowlevelLedgerException { return new HibernateLedger("test"); } } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:49:26
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27835/src/java/org/neuclear/ledger/hibernate Modified Files: HibernateLedger.java Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. Index: HibernateLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HibernateLedger.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** HibernateLedger.java 25 Mar 2004 21:40:45 -0000 1.8 --- HibernateLedger.java 26 Mar 2004 18:38:27 -0000 1.9 *************** *** 28,36 **** public final class HibernateLedger extends Ledger implements LedgerBrowser { ! public HibernateLedger(final String id) throws UnknownLedgerException, LowlevelLedgerException { this(id, false); } ! public HibernateLedger(final String id, final boolean create) throws LowlevelLedgerException, UnknownLedgerException { super(id); --- 28,36 ---- public final class HibernateLedger extends Ledger implements LedgerBrowser { ! public HibernateLedger(final String id) throws LowlevelLedgerException { this(id, false); } ! public HibernateLedger(final String id, final boolean create) throws LowlevelLedgerException { super(id); *************** *** 369,373 **** public BookBrowser browse(String book) throws LowlevelLedgerException { ! return null; } --- 369,382 ---- public BookBrowser browse(String book) throws LowlevelLedgerException { ! try { ! Session ses = factory.openSession(); ! Query q = ses.createQuery("from HTransactionItem item where item.book=?"); ! q.setString(0, book); ! Iterator iter = q.iterate(); ! return new HibernateBookBrowser(iter, book); ! } catch (HibernateException e) { ! throw new LowlevelLedgerException(e); ! } ! } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:48:55
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27650/src/java/org/neuclear/ledger/simple Modified Files: SimpleLedger.java Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. Index: SimpleLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple/SimpleLedger.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleLedger.java 25 Mar 2004 16:44:21 -0000 1.4 --- SimpleLedger.java 26 Mar 2004 18:37:56 -0000 1.5 *************** *** 4,7 **** --- 4,10 ---- * $Id$ * $Log$ + * Revision 1.5 2004/03/26 18:37:56 pelle + * More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. + * * Revision 1.4 2004/03/25 16:44:21 pelle * Added getTestBalance() and isBalanced() to Ledger to see if ledger is balanced. *************** *** 80,88 **** import org.neuclear.ledger.*; import java.util.Date; import java.util.HashMap; import java.util.Iterator; - import java.util.LinkedHashMap; /** --- 83,93 ---- import org.neuclear.ledger.*; + import org.neuclear.ledger.browser.BookBrowser; + import org.neuclear.ledger.browser.LedgerBrowser; + import java.sql.Timestamp; import java.util.Date; import java.util.HashMap; import java.util.Iterator; /** *************** *** 90,100 **** * thread safe or supportive of transactions. */ ! public final class SimpleLedger extends Ledger { public SimpleLedger(final String name) { super(name); id = name; ! ledger = new LinkedHashMap(); ! held = new LinkedHashMap(); balances = new HashMap(); --- 95,105 ---- * thread safe or supportive of transactions. */ ! public final class SimpleLedger extends Ledger implements LedgerBrowser { public SimpleLedger(final String name) { super(name); id = name; ! ledger = new HashMap(); ! held = new HashMap(); balances = new HashMap(); *************** *** 312,320 **** } ! private final LinkedHashMap ledger; ! private final LinkedHashMap held; private final String id; private final HashMap balances; } --- 317,353 ---- } ! public BookBrowser browse(String book) throws LowlevelLedgerException { ! return new SimpleBookBrowser(book); ! } ! ! public BookBrowser browseFrom(String book, Timestamp from) throws LowlevelLedgerException { ! return null; ! } ! ! public BookBrowser browseRange(String book, Timestamp from, Timestamp until) throws LowlevelLedgerException { ! return null; ! } ! ! private final HashMap ledger; ! private final HashMap held; private final String id; private final HashMap balances; + private class SimpleBookBrowser extends BookBrowser { + public SimpleBookBrowser(String book) { + super(book); + iter = ledger.keySet().iterator(); + System.out.println("ledger contains: " + ledger.size()); + } + + public boolean next() throws LowlevelLedgerException { + if (!iter.hasNext()) + return false; + // PostedTransaction tran=(PostedTransaction) ledger.get((iter.next())); + iter.next(); + return true; + } + private final Iterator iter; + } } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:48:55
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/browser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27650/src/test/org/neuclear/ledger/browser Added Files: SimpleLedgerBrowserTest.java Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. --- NEW FILE: SimpleLedgerBrowserTest.java --- package org.neuclear.ledger.browser; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.simple.SimpleLedger; import org.neuclear.ledger.tests.AbstractLedgerBrowserTest; /* $Id: SimpleLedgerBrowserTest.java,v 1.1 2004/03/26 18:37:56 pelle Exp $ $Log: SimpleLedgerBrowserTest.java,v $ Revision 1.1 2004/03/26 18:37:56 pelle More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. */ /** * User: pelleb * Date: Mar 26, 2004 * Time: 12:17:25 PM */ public class SimpleLedgerBrowserTest extends AbstractLedgerBrowserTest { public SimpleLedgerBrowserTest(String name) { super(name); } public Ledger getLedger() { return new SimpleLedger("test browser"); } } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:48:55
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27650/src/java/org/neuclear/ledger/tests Added Files: AbstractLedgerBrowserTest.java Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. --- NEW FILE: AbstractLedgerBrowserTest.java --- package org.neuclear.ledger.tests; import junit.framework.TestCase; import org.neuclear.ledger.InvalidTransactionException; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.browser.BookBrowser; import org.neuclear.ledger.browser.LedgerBrowser; /* $Id: AbstractLedgerBrowserTest.java,v 1.1 2004/03/26 18:37:56 pelle Exp $ $Log: AbstractLedgerBrowserTest.java,v $ Revision 1.1 2004/03/26 18:37:56 pelle More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. */ /** * User: pelleb * Date: Mar 26, 2004 * Time: 12:19:26 PM */ public abstract class AbstractLedgerBrowserTest extends TestCase { public AbstractLedgerBrowserTest(String name) { super(name); } public abstract Ledger getLedger() throws LowlevelLedgerException; public void testIsBrowser() throws LowlevelLedgerException { final Ledger ledger = getLedger(); assertTrue("Ledger is instance of LedgerBrowser", ledger instanceof LedgerBrowser); ledger.close(); } public void testAmountOfEntries() throws LowlevelLedgerException, InvalidTransactionException { final Ledger ledger = getLedger(); assertTrue("Ledger is instance of LedgerBrowser", ledger instanceof LedgerBrowser); final LedgerBrowser browser = (LedgerBrowser) ledger; final String bob = getBobBook(); final String alice = getAliceBook(); assertBookBrowserSize(bob, 0, browser.browse(bob)); assertBookBrowserSize(alice, 0, browser.browse(alice)); int i; for (i = 0; i < 10; i++) { ledger.transfer(bob, alice, 10, "test" + i); } assertBookBrowserSize(bob, i, browser.browse(bob)); assertBookBrowserSize(alice, i, browser.browse(alice)); ledger.close(); } public void assertBookBrowserSize(final String book, final int count, final BookBrowser bb) throws LowlevelLedgerException { assertNotNull("null book browser for " + book, bb); int total = 0; while (bb.next()) { total++; } assertEquals("The size doesnt match for: " + book, count, total); } public String getNewBook(String root) { return root + System.currentTimeMillis(); } public String getBobBook() { return getNewBook("Roberto"); } public String getAliceBook() { return getNewBook("Alicia"); } } |
|
From: Pelle B. <pe...@us...> - 2004-03-26 18:48:54
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27650/src/java/org/neuclear/ledger/browser Removed Files: QueryBookBrowser.java Log Message: More work on browsers. Added an AbstractLedgerBrowserTest for unit testing LedgerBrowsers. --- QueryBookBrowser.java DELETED --- |
|
From: Pelle B. <pe...@us...> - 2004-03-26 17:16:33
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/browser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7803/src/test/org/neuclear/ledger/browser Log Message: Directory /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/browser added to the repository |
|
From: Pelle B. <pe...@us...> - 2004-03-25 22:16:11
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16357/src/java/org/neuclear/ledger/hibernate Added Files: HibernateBookBrowser.java Log Message: First shell of the HibernateBookBrowser --- NEW FILE: HibernateBookBrowser.java --- package org.neuclear.ledger.hibernate; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.browser.BookBrowser; import java.util.Iterator; /* NeuClear Distributed Transaction Clearing Platform (C) 2003 Pelle Braendgaard This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Id: HibernateBookBrowser.java,v 1.1 2004/03/25 22:05:20 pelle Exp $ $Log: HibernateBookBrowser.java,v $ Revision 1.1 2004/03/25 22:05:20 pelle First shell of the HibernateBookBrowser */ /** * User: pelleb * Date: Mar 25, 2004 * Time: 10:00:41 PM */ public class HibernateBookBrowser extends BookBrowser { public HibernateBookBrowser(Iterator iter, String book) { super(book); this.iter = iter; } public boolean next() throws LowlevelLedgerException { return false; } private final Iterator iter; } |