1 package hero.session; 2 24 25 import hero.interfaces.BnProjectLocal; 26 import hero.interfaces.BnProjectLocalHome; 27 import hero.util.EventConstants; 28 import hero.util.HeroException; 29 import hero.util.StrutsProjectValue; 30 31 import java.util.ArrayList ; 32 import java.util.Collection ; 33 import java.util.Iterator ; 34 35 import javax.ejb.CreateException ; 36 import javax.ejb.FinderException ; 37 import javax.ejb.SessionBean ; 38 import javax.ejb.SessionContext ; 39 40 41 42 43 64 65 public class AllProjectsSessionBean implements SessionBean , EventConstants { 66 67 68 72 76 private SessionContext mContext; 77 78 82 90 public Collection getProjects() throws HeroException { 91 BnProjectLocalHome pHome; 92 ArrayList projects = new ArrayList (); 93 94 try { 95 pHome=hero.interfaces.BnProjectUtil.getLocalHome(); 96 } catch (javax.naming.NamingException be) { 97 throw new HeroException(be.getMessage()); 98 } 99 try { 100 Collection allProjects= pHome.findAll(); 101 Iterator i = allProjects.iterator(); 102 while(i.hasNext()) { 103 BnProjectLocal pvalue = (BnProjectLocal)i.next(); 104 StrutsProjectValue spv = new StrutsProjectValue(); 105 spv.setName(pvalue.getName()); 106 spv.setCreator(pvalue.getCreator()); 107 spv.setState(hero.interfaces.Constants.Pj.projectStateName[pvalue.getState()]); 108 spv.setNact(pvalue.getBnNodes().size()); 109 spv.setNusers(pvalue.getBnUsers().size()); 110 projects.add(spv); 111 } 112 return((Collection )projects); 113 114 } catch (FinderException fe) { 115 throw new HeroException(fe.getMessage());} 116 } 117 125 126 public void ejbCreate() throws CreateException { 127 } 128 129 public void setSessionContext(final javax.ejb.SessionContext context) { 130 mContext = context; 131 } 132 133 public void ejbRemove() { 134 } 135 136 public void ejbActivate() { 137 } 138 139 public void ejbPassivate() { 140 } 141 142 } 143 | Popular Tags |