|
From: Pelle B. <pe...@us...> - 2004-03-31 23:23:23
|
Update of /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28873/src/java/org/neuclear/ledger/hibernate Modified Files: HHeld.hbm.xml HHeld.java HHeldItem.java HTransaction.hbm.xml HTransaction.java HTransactionItem.java HibernateBookBrowser.java HibernateLedger.java Log Message: Reworked the ID's of the transactions. The primary ID is now the request ID. Receipt ID's are optional and added using a separate set method. The various interactive passphrase agents now have shell methods for the new interactive approach. Index: HHeldItem.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HHeldItem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HHeldItem.java 23 Mar 2004 21:57:48 -0000 1.1 --- HHeldItem.java 31 Mar 2004 23:11:30 -0000 1.2 *************** *** 13,17 **** this.amount = amount; this.held = held; ! // this.heldId=held.getId(); } --- 13,17 ---- this.amount = amount; this.held = held; ! // this.heldId=held.getRequestId(); } Index: HibernateLedger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HibernateLedger.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** HibernateLedger.java 29 Mar 2004 16:57:00 -0000 1.11 --- HibernateLedger.java 31 Mar 2004 23:11:30 -0000 1.12 *************** *** 57,61 **** public PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!trans.isBalanced()) ! throw new UnBalancedTransactionException(this, trans); try { Session ses = factory.openSession(); --- 57,61 ---- public PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!trans.isBalanced()) ! throw new UnBalancedTransactionException(this, trans, trans.getBalance()); try { Session ses = factory.openSession(); *************** *** 80,84 **** public PostedTransaction performVerifiedTransfer(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!trans.isBalanced()) ! throw new UnBalancedTransactionException(this, trans); try { Session ses = factory.openSession(); --- 80,84 ---- public PostedTransaction performVerifiedTransfer(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!trans.isBalanced()) ! throw new UnBalancedTransactionException(this, trans, trans.getBalance()); try { Session ses = factory.openSession(); *************** *** 111,115 **** public PostedHeldTransaction performHeldTransfer(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!trans.isBalanced()) ! throw new UnBalancedTransactionException(this, trans); try { Session ses = factory.openSession(); --- 111,115 ---- public PostedHeldTransaction performHeldTransfer(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!trans.isBalanced()) ! throw new UnBalancedTransactionException(this, trans, trans.getBalance()); try { Session ses = factory.openSession(); *************** *** 139,143 **** Session ses = factory.openSession(); net.sf.hibernate.Transaction t = ses.beginTransaction(); ! HHeld posted = (HHeld) ses.get(HHeld.class, hold.getId()); if (posted != null) { --- 139,143 ---- Session ses = factory.openSession(); net.sf.hibernate.Transaction t = ses.beginTransaction(); ! HHeld posted = (HHeld) ses.get(HHeld.class, hold.getRequestId()); if (posted != null) { *************** *** 148,152 **** t.rollback(); ses.close(); ! throw new UnknownTransactionException(this, hold.getId()); } --- 148,152 ---- t.rollback(); ses.close(); ! throw new UnknownTransactionException(this, hold.getRequestId()); } *************** *** 177,185 **** Session ses = factory.openSession(); net.sf.hibernate.Transaction t = ses.beginTransaction(); ! HHeld posted = (HHeld) ses.get(HHeld.class, hold.getId()); if (posted == null) { t.rollback(); ses.close(); ! throw new UnknownTransactionException(this, hold.getId()); } final Date time = new Date(); --- 177,185 ---- Session ses = factory.openSession(); net.sf.hibernate.Transaction t = ses.beginTransaction(); ! HHeld posted = (HHeld) ses.get(HHeld.class, hold.getRequestId()); if (posted == null) { t.rollback(); ses.close(); ! throw new UnknownTransactionException(this, hold.getRequestId()); } final Date time = new Date(); *************** *** 188,192 **** throw new TransactionExpiredException(this, hold); } ! HTransaction htran = new HTransaction(posted, time); htran.setComment(comment); ses.save(htran); --- 188,192 ---- throw new TransactionExpiredException(this, hold); } ! HTransaction htran = new HTransaction(hold, time, amount); htran.setComment(comment); ses.save(htran); *************** *** 339,342 **** --- 339,360 ---- } + public void setReceiptId(String id, String receipt) throws LowlevelLedgerException, UnknownTransactionException { + try { + Session ses = factory.openSession(); + net.sf.hibernate.Transaction t = ses.beginTransaction(); + HTransaction tran = (HTransaction) ses.get(HTransaction.class, id); + if (tran == null) { + ses.close(); + throw new UnknownTransactionException(this, id); + } + tran.setReceipt(receipt); + t.commit(); + ses.close(); + } catch (HibernateException e) { + throw new LowlevelLedgerException(e); + } + + } + public double getTestBalance() throws LowlevelLedgerException { try { Index: HTransaction.hbm.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HTransaction.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HTransaction.hbm.xml 25 Mar 2004 16:45:08 -0000 1.3 --- HTransaction.hbm.xml 31 Mar 2004 23:11:30 -0000 1.4 *************** *** 14,20 **** <generator class="assigned"/> </id> ! <property name="requestId" type="string"> ! <column name="reqid" sql-type="char(32)" ! not-null="true"/> </property> <property name="transactionTime" type="timestamp"> --- 14,19 ---- <generator class="assigned"/> </id> ! <property name="receipt" type="string"> ! <column name="receipt" sql-type="char(32)"/> </property> <property name="transactionTime" type="timestamp"> Index: HHeld.hbm.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HHeld.hbm.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HHeld.hbm.xml 25 Mar 2004 21:40:45 -0000 1.5 --- HHeld.hbm.xml 31 Mar 2004 23:11:30 -0000 1.6 *************** *** 14,20 **** <generator class="assigned"/> </id> ! <property name="requestId"> ! <column name="reqid" sql-type="char(32)" ! not-null="true"/> </property> <property name="transactionTime" type="timestamp"> --- 14,19 ---- <generator class="assigned"/> </id> ! <property name="receipt"> ! <column name="receipt" sql-type="char(32)"/> </property> <property name="transactionTime" type="timestamp"> Index: HHeld.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HHeld.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HHeld.java 25 Mar 2004 21:40:45 -0000 1.3 --- HHeld.java 31 Mar 2004 23:11:30 -0000 1.4 *************** *** 21,26 **** public HHeld(UnPostedHeldTransaction tran, Date transactionTime) { ! this.id = tran.getId(); ! this.requestId = tran.getRequestId(); this.transactionTime = transactionTime; this.expiryTime = tran.getExpiryTime(); --- 21,25 ---- public HHeld(UnPostedHeldTransaction tran, Date transactionTime) { ! this.id = tran.getRequestId(); this.transactionTime = transactionTime; this.expiryTime = tran.getExpiryTime(); *************** *** 44,53 **** } ! public String getRequestId() { ! return requestId; } ! public void setRequestId(String requestId) { ! this.requestId = requestId; } --- 43,52 ---- } ! public String getReceipt() { ! return receipt; } ! public void setReceipt(String receipt) { ! this.receipt = receipt; } *************** *** 101,105 **** public PostedHeldTransaction createPosted() throws InvalidTransactionException { ! UnPostedHeldTransaction unp = new UnPostedHeldTransaction(requestId, id, comment, expiryTime); Iterator iter = items.iterator(); while (iter.hasNext()) { --- 100,104 ---- public PostedHeldTransaction createPosted() throws InvalidTransactionException { ! UnPostedHeldTransaction unp = new UnPostedHeldTransaction(id, comment, expiryTime); Iterator iter = items.iterator(); while (iter.hasNext()) { *************** *** 111,115 **** private String id; ! private String requestId; private Date transactionTime; private Date expiryTime; --- 110,114 ---- private String id; ! private String receipt; private Date transactionTime; private Date expiryTime; Index: HTransactionItem.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HTransactionItem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTransactionItem.java 23 Mar 2004 21:57:48 -0000 1.1 --- HTransactionItem.java 31 Mar 2004 23:11:30 -0000 1.2 *************** *** 13,17 **** this.amount = amount; this.transaction = tran; ! // this.transactionId=tran.getId(); } --- 13,17 ---- this.amount = amount; this.transaction = tran; ! // this.transactionId=tran.getRequestId(); } Index: HibernateBookBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HibernateBookBrowser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HibernateBookBrowser.java 26 Mar 2004 23:36:50 -0000 1.2 --- HibernateBookBrowser.java 31 Mar 2004 23:11:30 -0000 1.3 *************** *** 26,29 **** --- 26,34 ---- $Id$ $Log$ + Revision 1.3 2004/03/31 23:11:30 pelle + Reworked the ID's of the transactions. The primary ID is now the request ID. + Receipt ID's are optional and added using a separate set method. + The various interactive passphrase agents now have shell methods for the new interactive approach. + 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. *************** *** 58,62 **** } } ! setRow(tran.getId(), tran.getRequestId(), counterparty, tran.getComment(), tran.getTransactionTime(), item.getAmount(), null, null, null); return true; } --- 63,67 ---- } } ! setRow(tran.getId(), counterparty, tran.getComment(), tran.getTransactionTime(), item.getAmount(), null, null, null); return true; } Index: HTransaction.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-hibernate/src/java/org/neuclear/ledger/hibernate/HTransaction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HTransaction.java 25 Mar 2004 21:40:45 -0000 1.5 --- HTransaction.java 31 Mar 2004 23:11:30 -0000 1.6 *************** *** 1,8 **** package org.neuclear.ledger.hibernate; ! import org.neuclear.ledger.InvalidTransactionException; ! import org.neuclear.ledger.PostedTransaction; ! import org.neuclear.ledger.TransactionItem; ! import org.neuclear.ledger.UnPostedTransaction; import java.util.*; --- 1,5 ---- package org.neuclear.ledger.hibernate; ! import org.neuclear.ledger.*; import java.util.*; *************** *** 21,26 **** public HTransaction(UnPostedTransaction unp, Date transactionTime) { ! this.id = unp.getId(); ! this.requestId = unp.getRequestId(); this.transactionTime = transactionTime; this.comment = unp.getComment(); --- 18,22 ---- public HTransaction(UnPostedTransaction unp, Date transactionTime) { ! this.id = unp.getRequestId(); this.transactionTime = transactionTime; this.comment = unp.getComment(); *************** *** 33,45 **** } ! public HTransaction(HHeld held, Date transactionTime) { ! this.id = held.getId(); ! this.requestId = held.getRequestId(); this.transactionTime = transactionTime; this.comment = held.getComment(); this.items = new HashSet(); ! Iterator iter = held.getItems().iterator(); while (iter.hasNext()) { ! HHeldItem item = (HHeldItem) iter.next(); items.add(new HTransactionItem(this, item.getBook(), item.getAmount())); } --- 29,40 ---- } ! public HTransaction(final PostedHeldTransaction held, final Date transactionTime, final double amount) throws ExceededHeldAmountException, UnBalancedTransactionException { ! this.id = held.getRequestId(); this.transactionTime = transactionTime; this.comment = held.getComment(); this.items = new HashSet(); ! Iterator iter = held.getAdjustedItems(amount).iterator(); while (iter.hasNext()) { ! TransactionItem item = (TransactionItem) iter.next(); items.add(new HTransactionItem(this, item.getBook(), item.getAmount())); } *************** *** 54,63 **** } ! public String getRequestId() { ! return requestId; } ! public void setRequestId(String requestId) { ! this.requestId = requestId; } --- 49,58 ---- } ! public String getReceipt() { ! return receipt; } ! public void setReceipt(String receipt) { ! this.receipt = receipt; } *************** *** 87,91 **** public PostedTransaction createPosted() throws InvalidTransactionException { ! UnPostedTransaction unp = new UnPostedTransaction(requestId, id, comment); Iterator iter = items.iterator(); while (iter.hasNext()) { --- 82,86 ---- public PostedTransaction createPosted() throws InvalidTransactionException { ! UnPostedTransaction unp = new UnPostedTransaction(id, comment); Iterator iter = items.iterator(); while (iter.hasNext()) { *************** *** 97,101 **** private String id; ! private String requestId; private Date transactionTime; private String comment; --- 92,96 ---- private String id; ! private String receipt; private Date transactionTime; private String comment; |