1 4 package com.nightlabs.ipanema.trade; 5 6 import javax.jdo.JDOHelper; 7 import javax.jdo.PersistenceManager; 8 9 import com.nightlabs.ipanema.accounting.Accountant; 10 import com.nightlabs.ipanema.accounting.InterLegalEntityMoneyTransfer; 11 import com.nightlabs.ipanema.accounting.IntraLegalEntityMoneyTransfer; 12 import com.nightlabs.ipanema.accounting.MoneyTransfer; 13 import com.nightlabs.ipanema.person.Person; 14 import com.nightlabs.ipanema.store.ProductTransfer; 15 import com.nightlabs.ipanema.transfer.Anchor; 16 import com.nightlabs.ipanema.transfer.Transfer; 17 18 29 public class LegalEntity extends Anchor 30 { 31 32 public LegalEntity() { } 33 37 public LegalEntity(String organisationID, String anchorID) 38 { 39 super(organisationID, anchorID); 40 } 41 42 45 private Person person; 46 47 50 private Accountant accountant; 51 52 protected void bookMoneyTransfer(PersistenceManager pm, MoneyTransfer transfer) 53 { 54 if (accountant == null) 55 throw new NullPointerException ("There is no accountant existing in this LegalEntity (\""+this.getPrimaryKey()+"\")!"); 56 57 if (transfer instanceof InterLegalEntityMoneyTransfer) 58 accountant.bookTransfer(this,transfer); 59 else if (transfer instanceof IntraLegalEntityMoneyTransfer) { 60 } 63 64 87 } 92 93 94 protected void bookProductTransfer(PersistenceManager pm, ProductTransfer transfer) 95 { 96 97 } 98 99 102 protected void internalBookTransfer(Transfer transfer) 103 { 104 PersistenceManager pm = JDOHelper.getPersistenceManager(this); 105 if (pm == null) 106 throw new NullPointerException ("This instance of LegalEntity is not linked to a PersistenceManager! Cannot call this method while being detached."); 107 108 if (transfer instanceof MoneyTransfer) { 109 bookMoneyTransfer(pm, (MoneyTransfer)transfer); 110 } 111 else if (transfer instanceof ProductTransfer) { 112 bookProductTransfer(pm, (ProductTransfer)transfer); 113 } 114 else 115 throw new IllegalArgumentException ("unsupported Transfer type: "+transfer.getClass().getName()); 116 } 117 118 119 } 120 | Popular Tags |