KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > relation > tier > TestFacadeBean


1 package org.objectweb.jonas.jtests.beans.relation.tier;
2
3 import javax.ejb.SessionContext JavaDoc;
4 import javax.naming.NamingException JavaDoc;
5 import javax.ejb.CreateException JavaDoc;
6 import javax.ejb.FinderException JavaDoc;
7 import javax.ejb.EJBException JavaDoc;
8 import javax.ejb.RemoveException JavaDoc;
9
10 import java.rmi.RemoteException JavaDoc;
11 import java.util.ArrayList JavaDoc;
12 import java.util.Collection JavaDoc;
13 import java.util.Iterator JavaDoc;
14
15 public class TestFacadeBean {
16
17     private SessionContext JavaDoc _ctx;
18
19     protected int nbMaxLignes = 20;
20
21     // Tier entity bean methods
22
protected TierLocalHome getTierLocalHome() throws NamingException JavaDoc {
23         return TierUtil.getLocalHome();
24     }
25
26     public TierValue create(TierValue value) throws CreateException JavaDoc, RemoteException JavaDoc, FinderException JavaDoc, NamingException JavaDoc {
27         return getTierLocalHome().create(value).getTierValue();
28     }
29
30     public TierValue findTierByKey(java.lang.Integer JavaDoc pk) throws FinderException JavaDoc, RemoteException JavaDoc, NamingException JavaDoc {
31         return getTierLocalHome().findByPrimaryKey(pk).getTierValue();
32     }
33
34     public TiephyValue getTiephyValueOfTier(java.lang.Integer JavaDoc pk) throws FinderException JavaDoc, NamingException JavaDoc,
35             RemoteException JavaDoc {
36         return getTierLocalHome().findByPrimaryKey(pk).getTiephyValue();
37     }
38
39     public TiemorValue getTiemorValueOfTier(java.lang.Integer JavaDoc pk) throws FinderException JavaDoc, NamingException JavaDoc,
40             RemoteException JavaDoc {
41         return getTierLocalHome().findByPrimaryKey(pk).getTiemorValue();
42     }
43
44     public void update(TierValue value) throws FinderException JavaDoc, NamingException JavaDoc, RemoteException JavaDoc {
45         getTierLocalHome().findByPrimaryKey(value.getPrimaryKey()).update(value);
46     }
47
48     public java.util.Collection JavaDoc tierfindByTiemorOrTiephy(java.lang.String JavaDoc nom) throws FinderException JavaDoc, RemoteException JavaDoc,
49             NamingException JavaDoc {
50         Collection JavaDoc col = getTierLocalHome().findByTiemorOrTiephy(nom);
51         Iterator JavaDoc ite = col.iterator();
52         TierLocal tl = null;
53         ArrayList JavaDoc al = new ArrayList JavaDoc();
54         int page = 0;
55         while (ite.hasNext()) {
56             tl = (TierLocal) ite.next();
57             if (page < nbMaxLignes)
58                 al.add(tl.getTierValue());
59             else
60                 al.add(tl.getPrimaryKey());
61             page++;
62         }
63         return al;
64     }
65
66     public void removeTier(java.lang.Integer JavaDoc pk) throws FinderException JavaDoc, NamingException JavaDoc, EJBException JavaDoc, RemoveException JavaDoc {
67         try {
68             getTierLocalHome().findByPrimaryKey(pk).remove();
69         } catch (EJBException JavaDoc e) {
70             // TODO Auto-generated catch block
71
e.printStackTrace();
72         } catch (RemoveException JavaDoc e) {
73             // TODO Auto-generated catch block
74
e.printStackTrace();
75         } catch (FinderException JavaDoc e) {
76             // TODO Auto-generated catch block
77
e.printStackTrace();
78         } catch (NamingException JavaDoc e) {
79             // TODO Auto-generated catch block
80
e.printStackTrace();
81         }
82     }
83
84     public java.util.Collection JavaDoc getTierValueWithCollectionPK(Collection JavaDoc pks) throws RemoteException JavaDoc, FinderException JavaDoc,
85             NamingException JavaDoc {
86         ArrayList JavaDoc al = new ArrayList JavaDoc();
87         Iterator JavaDoc ite = pks.iterator();
88         java.lang.Integer JavaDoc pk = null;
89         while (ite.hasNext()) {
90             pk = (java.lang.Integer JavaDoc) ite.next();
91             al.add(findTierByKey(pk));
92         }
93         return al;
94     }
95
96     public void ejbCreate() throws CreateException JavaDoc {
97     }
98
99     public void setSessionContext(SessionContext JavaDoc ctx) {
100         _ctx = ctx;
101     }
102
103     public void ejbActivate() {
104     }
105
106     public void ejbPassivate() {
107     }
108
109     public void unsetSessionContext() {
110     }
111
112     public void ejbRemove() {
113     }
114
115 }
Popular Tags