1 package net.sf.imca.web.backingbeans; 2 3 import javax.faces.model.ArrayDataModel; 4 5 import net.sf.imca.model.PersonBO; 6 import net.sf.imca.model.entities.MembershipEntity; 7 import net.sf.imca.services.CommitteeService; 8 9 public class MembershipTableModel { 10 11 private ArrayDataModel model = null; 12 13 private MembershipEntityData[] membershipData = new MembershipEntityData[0]; 14 15 public MembershipTableModel() { 16 model = new ArrayDataModel(membershipData); 17 } 18 19 public MembershipEntityData[] getMembershipData() { 20 return membershipData; 21 } 22 23 24 25 public void setMembershipData(MembershipEntityData[] membershipData) { 26 this.membershipData = membershipData; 27 } 28 29 public class MembershipEntityData extends MembershipEntity { 30 31 private boolean markedForDeletion = false; 32 private boolean markedForConfirm = false; 33 34 public MembershipEntityData(MembershipEntity membershipEntity) { 35 this.setFee(membershipEntity.getFee()); 36 this.setId(membershipEntity.getId()); 37 this.setNote(membershipEntity.getNote()); 38 this.setPaid(membershipEntity.getPaid()); 39 this.setPerson(membershipEntity.getPerson()); 40 this.setType(membershipEntity.getType()); 41 } 42 43 public String getRiderPageUrl() {; 44 return new PersonBO(getPerson()).getRiderPageUrl(); 45 } 46 47 public boolean getMarkedForDeletion() { 48 return markedForDeletion; 49 } 50 51 public void setMarkedForDeletion(boolean markedForDeletion) { 52 this.markedForDeletion = markedForDeletion; 53 } 54 55 public boolean getMarkedForConfirm() { 56 return markedForConfirm; 57 } 58 59 public void setMarkedForConfirm(boolean markedForConfirm) { 60 this.markedForConfirm = markedForConfirm; 61 } 62 } 63 64 public void setMembershipEntities(MembershipEntity[] membershipRequestList) { 65 66 membershipData = new MembershipEntityData[membershipRequestList.length]; 67 68 for (int i=0; i < membershipRequestList.length; i++){ 69 membershipData[i] = new MembershipEntityData(membershipRequestList[i]); 70 } 71 72 } 73 74 public void actionDeleteMembers() { 75 76 CommitteeService service = new CommitteeService(); 77 78 for (int i=0; i < membershipData.length; i++) { 79 if (membershipData[i].getMarkedForDeletion()) { 80 service.deleteMembershipEntity(membershipData[i].getId()); 81 } 82 } 83 } 84 85 public void actionConfirmPaidMembers() { 86 87 CommitteeService service = new CommitteeService(); 88 89 for (int i=0; i < membershipData.length; i++) { 90 if (membershipData[i].getMarkedForConfirm()) { 91 service.confirmPaidMembershipEntity(membershipData[i].getId()); 92 } 93 } 94 } 95 96 }