|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:40
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2857/src/java/org/neuclear/ledger/browser Modified Files: BookBrowser.java LedgerBrowser.java LedgerConfiguration.java QueryBookBrowser.java Log Message: 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. Index: QueryBookBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/QueryBookBrowser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryBookBrowser.java 2 Jan 2004 23:18:34 -0000 1.1 --- QueryBookBrowser.java 21 Mar 2004 00:48:35 -0000 1.2 *************** *** 1,11 **** package org.neuclear.ledger.browser; - import org.neuclear.ledger.Book; - import org.neuclear.ledger.LowlevelLedgerException; - import org.neuclear.commons.Utility; import org.neuclear.commons.sql.statements.StatementFactory; ! import java.sql.*; ! import java.security.Principal; /* --- 1,12 ---- package org.neuclear.ledger.browser; import org.neuclear.commons.sql.statements.StatementFactory; + import org.neuclear.ledger.Ledger; + import org.neuclear.ledger.LowlevelLedgerException; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Timestamp; /* *************** *** 29,32 **** --- 30,36 ---- $Id$ $Log$ + 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. *************** *** 44,84 **** */ public class QueryBookBrowser extends BookBrowser { ! public QueryBookBrowser(Book book,StatementFactory fact) throws SQLException { ! this(book,executeQuery(fact,book)); } ! public QueryBookBrowser(Book book,StatementFactory fact,Timestamp from, Timestamp until) throws SQLException { ! this(book,executeRangeQuery(fact,book,from,until)); } ! public QueryBookBrowser(Book book,StatementFactory fact,Timestamp from) throws SQLException { ! this(book,executeFromQuery(fact,book,from)); } ! private QueryBookBrowser(Book book,ResultSet rs) throws SQLException { super(book); ! this.rs=rs; ! next=rs.next(); } ! private static ResultSet executeRangeQuery(StatementFactory fact,Book 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,book); } ! private static ResultSet executeFromQuery(StatementFactory fact,Book book,Timestamp from) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(FROM_QUERY); ! stmt.setTimestamp(3,from); ! return executeQuery(stmt,book); } ! private static ResultSet executeUntilQuery(StatementFactory fact,Book book, Timestamp until) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(UNTIL_QUERY); ! stmt.setTimestamp(3,until); ! return executeQuery(stmt,book); } ! private static ResultSet executeQuery(StatementFactory fact,Book book) throws SQLException { ! return executeQuery(fact.prepareStatement(FULL_QUERY),book); } ! private static ResultSet executeQuery(PreparedStatement stmt,Book book) throws SQLException { ! stmt.setString(1,book.getBookID()); ! stmt.setString(2,book.getLedger().getId()); return stmt.executeQuery(); --- 48,96 ---- */ 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(); *************** *** 89,99 **** if (!rs.next()) return false; ! setRow(rs.getString(1),rs.getString(3),rs.getString(4),rs.getTimestamp(2),rs.getBigDecimal(5)); return true; } catch (SQLException e) { ! throw new LowlevelLedgerException(getBook().getLedger(),e); } } private final ResultSet rs; private boolean next; private static final String BASE_QUERY = "select t.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=?"; --- 101,113 ---- if (!rs.next()) return false; ! setRow(rs.getString(1), rs.getString(3), rs.getString(4), rs.getTimestamp(2), rs.getBigDecimal(5)); 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.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=?"; *************** *** 102,109 **** 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; } --- 116,123 ---- 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: BookBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/BookBrowser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BookBrowser.java 2 Jan 2004 23:18:34 -0000 1.1 --- BookBrowser.java 21 Mar 2004 00:48:35 -0000 1.2 *************** *** 1,10 **** package org.neuclear.ledger.browser; - import org.neuclear.ledger.Book; import org.neuclear.ledger.LowlevelLedgerException; - import java.util.Iterator; - import java.sql.Timestamp; import java.math.BigDecimal; /* --- 1,8 ---- package org.neuclear.ledger.browser; import org.neuclear.ledger.LowlevelLedgerException; import java.math.BigDecimal; + import java.sql.Timestamp; /* *************** *** 28,31 **** --- 26,32 ---- $Id$ $Log$ + 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. *************** *** 43,48 **** */ public abstract class BookBrowser { ! public BookBrowser(Book book){ ! this.book=book; } --- 44,49 ---- */ public abstract class BookBrowser { ! public BookBrowser(String book) { ! this.book = book; } *************** *** 50,61 **** ! protected final void setRow(String xid,String counterparty,String comment,Timestamp valuetime, BigDecimal amount) { ! this.xid=xid; ! this.counterparty=counterparty; ! this.comment=comment; ! this.valuetime=valuetime; ! this.amount=amount; } ! public Book getBook() { return book; } --- 51,63 ---- ! protected final void setRow(String xid, String counterparty, String comment, Timestamp valuetime, BigDecimal amount) { ! this.xid = xid; ! this.counterparty = counterparty; ! this.comment = comment; ! this.valuetime = valuetime; ! this.amount = amount; } ! ! public String getBook() { return book; } *************** *** 81,85 **** } ! private final Book book; private String xid; --- 83,87 ---- } ! private final String book; private String xid; Index: LedgerConfiguration.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/LedgerConfiguration.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LedgerConfiguration.java 2 Jan 2004 23:18:34 -0000 1.1 --- LedgerConfiguration.java 21 Mar 2004 00:48:35 -0000 1.2 *************** *** 2,14 **** import org.neuclear.commons.configuration.Configuration; - import org.neuclear.commons.sql.statements.StatementFactory; - import org.neuclear.commons.sql.statements.SimpleStatementFactory; import org.neuclear.commons.sql.ConnectionSource; - import org.neuclear.commons.sql.DefaultXAConnectionSource; import org.neuclear.commons.sql.TestCaseXAConnectionSource; ! import org.neuclear.ledger.implementations.SQLLedger; ! import org.neuclear.ledger.Ledger; ! import org.picocontainer.Parameter; ! import org.picocontainer.defaults.ConstantParameter; /* --- 2,9 ---- import org.neuclear.commons.configuration.Configuration; import org.neuclear.commons.sql.ConnectionSource; import org.neuclear.commons.sql.TestCaseXAConnectionSource; ! import org.neuclear.commons.sql.statements.SimpleStatementFactory; ! import org.neuclear.commons.sql.statements.StatementFactory; /* *************** *** 32,35 **** --- 27,33 ---- $Id$ $Log$ + 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. *************** *** 44,50 **** public class LedgerConfiguration implements Configuration { public void configure(org.picocontainer.MutablePicoContainer pico) { ! pico.registerComponentImplementation(ConnectionSource.class,TestCaseXAConnectionSource.class); ! pico.registerComponentImplementation(StatementFactory.class,SimpleStatementFactory.class); ! pico.registerComponentImplementation(Ledger.class,SQLLedger.class,new Parameter[] {new ConstantParameter("neu://test/bux")}); } --- 42,48 ---- public class LedgerConfiguration implements Configuration { public void configure(org.picocontainer.MutablePicoContainer pico) { ! pico.registerComponentImplementation(ConnectionSource.class, TestCaseXAConnectionSource.class); ! pico.registerComponentImplementation(StatementFactory.class, SimpleStatementFactory.class); ! // pico.registerComponentImplementation(Ledger.class,SQLLedger.class,new Parameter[] {new ConstantParameter("neu://test/bux")}); } Index: LedgerBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/LedgerBrowser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LedgerBrowser.java 2 Jan 2004 23:18:34 -0000 1.2 --- LedgerBrowser.java 21 Mar 2004 00:48:35 -0000 1.3 *************** *** 1,8 **** package org.neuclear.ledger.browser; - import org.neuclear.ledger.Book; import org.neuclear.ledger.LowlevelLedgerException; - import java.util.Iterator; import java.sql.Timestamp; --- 1,6 ---- *************** *** 27,30 **** --- 25,31 ---- $Id$ $Log$ + 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. + Revision 1.2 2004/01/02 23:18:34 pelle Added StatementFactory pattern and refactored the ledger to use it. *************** *** 42,48 **** */ public interface LedgerBrowser { ! public BookBrowser browse(Book book) throws LowlevelLedgerException; ! public BookBrowser browseFrom(Book book,Timestamp from) throws LowlevelLedgerException; // public BookBrowser browseUntil(Book book,Timestamp until); ! public BookBrowser browseRange(Book book,Timestamp from, Timestamp until) throws LowlevelLedgerException; } --- 43,50 ---- */ public interface LedgerBrowser { ! 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; } |