KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ejb > CustomerBMPBMP


1 /*
2  * Generated by XDoclet - Do not edit!
3  */

4 package test.ejb;
5
6 /**
7  * BMP layer for CustomerBMP.
8  * @xdoclet-generated at 16-04-05
9  * @copyright The XDoclet Team
10  * @author XDoclet
11  * @version 1.2.3
12  */

13 public class CustomerBMPBMP
14    extends test.ejb.CustomerBMPBean
15    implements javax.ejb.EntityBean JavaDoc
16 {
17    public int version = 0;
18
19    public float credit;
20    public java.lang.String JavaDoc[][] array;
21    public byte[] image;
22    public float tax;
23    public java.lang.String JavaDoc id;
24    public java.lang.String JavaDoc name;
25    public java.lang.String JavaDoc firstName;
26    public java.lang.String JavaDoc phone;
27    public java.lang.String JavaDoc fax;
28    public java.util.Date JavaDoc creationDate;
29
30    public int getVersion()
31    {
32       return this.version;
33    }
34
35    public void setVersion( int version )
36    {
37       this.version = version;
38       makeDirty();
39    }
40
41    public float getCredit()
42    {
43       return this.credit;
44    }
45
46    public void setCredit( float credit )
47    {
48       this.credit = credit;
49       makeDirty();
50    }
51    public java.lang.String JavaDoc[][] getArray()
52    {
53       return this.array;
54    }
55
56    public byte[] getImage()
57    {
58       return this.image;
59    }
60
61    public float getTax()
62    {
63       return this.tax;
64    }
65
66    public java.lang.String JavaDoc getId()
67    {
68       return this.id;
69    }
70
71    public void setId( java.lang.String JavaDoc id )
72    {
73       this.id = id;
74       makeDirty();
75    }
76    public java.lang.String JavaDoc getName()
77    {
78       return this.name;
79    }
80
81    public void setName( java.lang.String JavaDoc name )
82    {
83       this.name = name;
84       makeDirty();
85    }
86    public java.lang.String JavaDoc getFirstName()
87    {
88       return this.firstName;
89    }
90
91    public void setFirstName( java.lang.String JavaDoc firstName )
92    {
93       this.firstName = firstName;
94       makeDirty();
95    }
96    public java.lang.String JavaDoc getPhone()
97    {
98       return this.phone;
99    }
100
101    public void setPhone( java.lang.String JavaDoc phone )
102    {
103       this.phone = phone;
104       makeDirty();
105    }
106    public java.lang.String JavaDoc getFax()
107    {
108       return this.fax;
109    }
110
111    public void setFax( java.lang.String JavaDoc fax )
112    {
113       this.fax = fax;
114       makeDirty();
115    }
116    public java.util.Date JavaDoc getCreationDate()
117    {
118       return this.creationDate;
119    }
120
121    public void setCreationDate( java.util.Date JavaDoc creationDate )
122    {
123       this.creationDate = creationDate;
124       makeDirty();
125    }
126
127    public boolean isModified()
128    {
129       return dirty;
130    }
131
132    protected void makeDirty()
133    {
134       dirty = true;
135    }
136
137    protected void makeClean()
138    {
139       dirty = false;
140    }
141
142    private boolean dirty = false;
143
144    public test.interfaces.CustomerData getData()
145    {
146       test.interfaces.CustomerData dataHolder = null;
147       try
148       {
149          dataHolder = new test.interfaces.CustomerData();
150
151          dataHolder.setCredit( getCredit() );
152          dataHolder.setArray( getArray() );
153          dataHolder.setImage( getImage() );
154          dataHolder.setTax( getTax() );
155          dataHolder.setId( getId() );
156          dataHolder.setName( getName() );
157          dataHolder.setFirstName( getFirstName() );
158          dataHolder.setPhone( getPhone() );
159          dataHolder.setFax( getFax() );
160          dataHolder.setCreationDate( getCreationDate() );
161
162          dataHolder.setVersion(getVersion());
163       }
164       catch (RuntimeException JavaDoc e)
165       {
166          throw new javax.ejb.EJBException JavaDoc(e);
167       }
168
169       return dataHolder;
170    }
171
172    public void setData( test.interfaces.CustomerData dataHolder )
173    {
174       if( getVersion() != dataHolder.getVersion() )
175          throw new IllegalStateException JavaDoc( "Wrong version. Had " + getVersion() + ", got " + dataHolder.getVersion() );
176
177       try
178       {
179          setCredit( dataHolder.getCredit() );
180          setName( dataHolder.getName() );
181          setFirstName( dataHolder.getFirstName() );
182          setPhone( dataHolder.getPhone() );
183          setFax( dataHolder.getFax() );
184          setCreationDate( dataHolder.getCreationDate() );
185
186       }
187       catch (Exception JavaDoc e)
188       {
189          throw new javax.ejb.EJBException JavaDoc(e);
190       }
191    }
192
193    public java.lang.Object JavaDoc ejbCreate(test.interfaces.CustomerData detail) throws javax.ejb.CreateException JavaDoc
194    {
195       super.ejbCreate(detail);
196
197       return getDao().create((test.ejb.CustomerBMPBean) this);
198    }
199
200    public java.lang.Object JavaDoc ejbCreate(test.interfaces.CustomerNormalValue detail) throws javax.ejb.CreateException JavaDoc
201    {
202       super.ejbCreate(detail);
203
204       return getDao().create((test.ejb.CustomerBMPBean) this);
205    }
206
207    /**
208     * Generated ejbPostCreate for corresponding ejbCreate method.
209     *
210     * @see #ejbCreate(test.interfaces.CustomerNormalValue detail)
211     */

212    public void ejbPostCreate(test.interfaces.CustomerNormalValue detail)
213    {
214    }
215
216    public java.util.Collection JavaDoc ejbFindAll() throws javax.ejb.FinderException JavaDoc
217    {
218       return getDao().findAll();
219    }
220
221    public test.interfaces.CustomerPK ejbFindByPrimaryKey(test.interfaces.CustomerPK pk) throws javax.ejb.FinderException JavaDoc
222    {
223       return getDao().findByPrimaryKey(pk);
224    }
225
226    public void ejbLoad()
227    {
228       getDao().load((test.interfaces.CustomerPK) ctx.getPrimaryKey(), this);
229       makeClean();
230    }
231
232    public void ejbStore() throws javax.ejb.EJBException JavaDoc
233    {
234       if (isModified())
235       {
236          super.ejbStore();
237          getDao().store((test.ejb.CustomerBMPBean) this);
238          setVersion( getVersion() + 1 );
239          makeClean();
240       }
241    }
242
243    public void ejbActivate() throws javax.ejb.EJBException JavaDoc
244    {
245       super.ejbActivate();
246    }
247
248    public void ejbPassivate() throws javax.ejb.EJBException JavaDoc
249    {
250       super.ejbPassivate();
251
252       CustomerLightValue = null;
253       CustomerNormalValue = null;
254       CustomerValue = null;
255    }
256
257    private javax.ejb.EntityContext JavaDoc ctx = null;
258
259    public void setEntityContext(javax.ejb.EntityContext JavaDoc ctx) throws javax.ejb.EJBException JavaDoc
260    {
261       super.setEntityContext(ctx);
262       this.ctx = ctx;
263    }
264
265    public void unsetEntityContext() throws javax.ejb.EJBException JavaDoc
266    {
267       super.unsetEntityContext();
268       this.ctx = null;
269    }
270
271    public void ejbRemove() throws javax.ejb.EJBException JavaDoc, javax.ejb.RemoveException JavaDoc
272    {
273       super.ejbRemove();
274
275       getDao().remove((test.interfaces.CustomerPK) ctx.getPrimaryKey());
276
277    }
278
279       private static test.dao.CustomerDAO dao = null;
280
281    protected static synchronized test.dao.CustomerDAO getDao()
282    {
283       if (dao != null) {
284          return dao;
285       } else {
286
287          try{
288             javax.naming.InitialContext JavaDoc ctx = new javax.naming.InitialContext JavaDoc();
289             Object JavaDoc ref = ctx.lookup("java:comp/env/dao");
290             String JavaDoc daoStr = (String JavaDoc) javax.rmi.PortableRemoteObject.narrow(ref, String JavaDoc.class);
291             dao = (test.dao.CustomerDAO) Class.forName(daoStr).newInstance();
292          } catch (javax.naming.NamingException JavaDoc e) {
293             throw new IllegalStateException JavaDoc("DAO not defined in JNDI 'java:comp/env/dao': " + e.getLocalizedMessage());
294          } catch (Exception JavaDoc e) {
295             throw new IllegalStateException JavaDoc("Exception while looking in JNDI for 'java:comp/env/dao': " + e.getLocalizedMessage());
296          }
297
298          dao.init();
299          return dao;
300       }
301    }
302
303     public void ejbHomeCopyToArchive(test.interfaces.CustomerPK pk)
304     {
305
306         super.ejbHomeCopyToArchive(pk);
307
308         getDao().backup(pk);
309
310     }
311
312    /* Value Objects BEGIN */
313
314    public void addAccount(test.interfaces.AccountValue added)
315    throws javax.ejb.FinderException JavaDoc
316    {
317       try
318       {
319           test.interfaces.AccountPK pk = new test.interfaces.AccountPK(added.getId());
320
321          test.interfaces.AccountLocalHome home = test.interfaces.AccountUtil.getLocalHome();
322
323          test.interfaces.AccountLocal relation = home.findByPrimaryKey(pk);
324         getAccounts().add(relation);
325                 makeDirty();
326       }
327       catch (Exception JavaDoc e){
328          if (e instanceof javax.ejb.FinderException JavaDoc)
329             throw (javax.ejb.FinderException JavaDoc)e;
330          else
331             throw new javax.ejb.EJBException JavaDoc(e);
332       }
333    }
334
335    public void removeAccount(test.interfaces.AccountValue removed)
336    throws javax.ejb.RemoveException JavaDoc
337    {
338       try
339       {
340           test.interfaces.AccountPK pk = new test.interfaces.AccountPK(removed.getId());
341
342          test.interfaces.AccountLocalHome home = test.interfaces.AccountUtil.getLocalHome();
343
344         test.interfaces.AccountLocal relation = home.findByPrimaryKey(pk);
345         getAccounts().remove(relation);
346                 makeDirty();
347       }
348       catch (Exception JavaDoc e){
349          if (e instanceof javax.ejb.RemoveException JavaDoc)
350             throw (javax.ejb.RemoveException JavaDoc)e;
351          else
352             throw new javax.ejb.EJBException JavaDoc(e);
353       }
354    }
355
356    public void addShippingAddress(test.interfaces.AddressValue added)
357    throws javax.ejb.CreateException JavaDoc
358    {
359       try
360       {
361           java.lang.String JavaDoc pk = added.getId();
362
363          test.interfaces.AddressLocalHome home = test.interfaces.AddressUtil.getLocalHome();
364
365          test.interfaces.AddressLocal relation = home.create(added);
366         getShippingAddresses().add(relation);
367                 makeDirty();
368       }
369       catch (Exception JavaDoc e){
370          if (e instanceof javax.ejb.CreateException JavaDoc)
371             throw (javax.ejb.CreateException JavaDoc)e;
372          else
373             throw new javax.ejb.EJBException JavaDoc(e);
374       }
375    }
376
377    public void removeShippingAddress(test.interfaces.AddressValue removed)
378    throws javax.ejb.RemoveException JavaDoc
379    {
380       try
381       {
382           java.lang.String JavaDoc pk = removed.getId();
383
384          test.interfaces.AddressLocalHome home = test.interfaces.AddressUtil.getLocalHome();
385
386         test.interfaces.AddressLocal relation = home.findByPrimaryKey(pk);
387         getShippingAddresses().remove(relation);
388                 makeDirty();
389         relation.remove();
390       }
391       catch (Exception JavaDoc e){
392          if (e instanceof javax.ejb.RemoveException JavaDoc)
393             throw (javax.ejb.RemoveException JavaDoc)e;
394          else
395             throw new javax.ejb.EJBException JavaDoc(e);
396       }
397    }
398
399    public void updateShippingAddress(test.interfaces.AddressValue updated)
400    throws javax.ejb.FinderException JavaDoc
401    {
402       try
403       {
404           java.lang.String JavaDoc pk = updated.getId();
405
406          test.interfaces.AddressLocalHome home = test.interfaces.AddressUtil.getLocalHome();
407
408         test.interfaces.AddressLocal relation = home.findByPrimaryKey(pk);
409         relation.setAddressValue(updated);
410       }
411       catch (Exception JavaDoc e){
412          if (e instanceof javax.ejb.FinderException JavaDoc)
413             throw (javax.ejb.FinderException JavaDoc)e;
414          else
415             throw new javax.ejb.EJBException JavaDoc(e);
416       }
417    }
418
419    private test.interfaces.CustomerLightValue CustomerLightValue = null;
420
421    public test.interfaces.CustomerLightValue getCustomerLightValue()
422    {
423       CustomerLightValue = new test.interfaces.CustomerLightValue();
424       try
425          {
426             CustomerLightValue.setCredit( getCredit() );
427             CustomerLightValue.setId( getId() );
428
429             CustomerLightValue.setVersion(getVersion());
430          }
431          catch (Exception JavaDoc e)
432          {
433             throw new javax.ejb.EJBException JavaDoc(e);
434          }
435
436       return CustomerLightValue;
437    }
438    private test.interfaces.CustomerNormalValue CustomerNormalValue = null;
439
440    public test.interfaces.CustomerNormalValue getCustomerNormalValue()
441    {
442       CustomerNormalValue = new test.interfaces.CustomerNormalValue();
443       try
444          {
445             CustomerNormalValue.setCredit( getCredit() );
446             CustomerNormalValue.setId( getId() );
447             CustomerNormalValue.setName( getName() );
448             CustomerNormalValue.setFirstName( getFirstName() );
449             CustomerNormalValue.clearAccountViews();
450             java.util.Iterator JavaDoc iAccountView = getAccounts().iterator();
451             while (iAccountView.hasNext()){
452                 CustomerNormalValue.addAccountView( ((test.interfaces.AccountLocal)iAccountView.next()).getAccountValue() );
453             }
454             CustomerNormalValue.cleanAccountView();
455             CustomerNormalValue.clearShippingAddressValues();
456             java.util.Iterator JavaDoc iShippingAddressValue = getShippingAddresses().iterator();
457             while (iShippingAddressValue.hasNext()){
458                 CustomerNormalValue.addShippingAddressValue( ((test.interfaces.AddressLocal)iShippingAddressValue.next()).getAddressValue() );
459             }
460             CustomerNormalValue.cleanShippingAddressValue();
461
462             CustomerNormalValue.setVersion(getVersion());
463          }
464          catch (Exception JavaDoc e)
465          {
466             throw new javax.ejb.EJBException JavaDoc(e);
467          }
468
469       return CustomerNormalValue;
470    }
471    private test.interfaces.CustomerValue CustomerValue = null;
472
473    public test.interfaces.CustomerValue getCustomerValue()
474    {
475       CustomerValue = new test.interfaces.CustomerValue();
476       try
477          {
478             CustomerValue.setCredit( getCredit() );
479             CustomerValue.setId( getId() );
480             CustomerValue.setName( getName() );
481             CustomerValue.setFirstName( getFirstName() );
482             CustomerValue.setPhone( getPhone() );
483             CustomerValue.setFax( getFax() );
484             CustomerValue.clearAccountViews();
485             java.util.Iterator JavaDoc iAccountView = getAccounts().iterator();
486             while (iAccountView.hasNext()){
487                 CustomerValue.addAccountView( ((test.interfaces.AccountLocal)iAccountView.next()).getAccountValue() );
488             }
489             CustomerValue.cleanAccountView();
490             CustomerValue.clearShippingAddressValues();
491             java.util.Iterator JavaDoc iShippingAddressValue = getShippingAddresses().iterator();
492             while (iShippingAddressValue.hasNext()){
493                 CustomerValue.addShippingAddressValue( ((test.interfaces.AddressLocal)iShippingAddressValue.next()).getAddressValue() );
494             }
495             CustomerValue.cleanShippingAddressValue();
496
497             CustomerValue.setVersion(getVersion());
498          }
499          catch (Exception JavaDoc e)
500          {
501             throw new javax.ejb.EJBException JavaDoc(e);
502          }
503
504       return CustomerValue;
505    }
506
507    public void setCustomerNormalValue( test.interfaces.CustomerNormalValue valueHolder )
508    throws test.interfaces.ApplicationException{
509       validate(valueHolder);
510       if( getVersion() != valueHolder.getVersion() )
511          throw new IllegalStateException JavaDoc( "Wrong version. Had " + getVersion() + ", got " + valueHolder.getVersion() );
512
513       try
514       {
515          setCredit( valueHolder.getCredit() );
516          setName( valueHolder.getName() );
517          setFirstName( valueHolder.getFirstName() );
518
519       {
520
521          java.util.Iterator JavaDoc iAccountView = valueHolder.getAddedAccountViews().iterator();
522          while (iAccountView.hasNext())
523          {
524             test.interfaces.AccountValue o = (test.interfaces.AccountValue)iAccountView.next();
525             addAccount(o);
526          }
527          iAccountView = valueHolder.getRemovedAccountViews().iterator();
528          while (iAccountView.hasNext())
529          {
530             test.interfaces.AccountValue o = (test.interfaces.AccountValue)iAccountView.next();
531             removeAccount(o);
532          }
533       }
534       // Anonymous block to allow variable declations without conflicts
535
{
536
537          java.util.Iterator JavaDoc iShippingAddressValue = valueHolder.getUpdatedShippingAddressValues().iterator();
538          while (iShippingAddressValue.hasNext())
539          {
540             test.interfaces.AddressValue o = (test.interfaces.AddressValue)iShippingAddressValue.next();
541             updateShippingAddress(o);
542          }
543          iShippingAddressValue = valueHolder.getAddedShippingAddressValues().iterator();
544          while (iShippingAddressValue.hasNext())
545          {
546             test.interfaces.AddressValue o = (test.interfaces.AddressValue)iShippingAddressValue.next();
547             addShippingAddress(o);
548          }
549          iShippingAddressValue = valueHolder.getRemovedShippingAddressValues().iterator();
550          while (iShippingAddressValue.hasNext())
551          {
552             test.interfaces.AddressValue o = (test.interfaces.AddressValue)iShippingAddressValue.next();
553             removeShippingAddress(o);
554          }
555       }
556       }
557       catch (Exception JavaDoc e)
558       {
559          throw new javax.ejb.EJBException JavaDoc(e);
560       }
561    }
562
563 /* Value Objects END */
564
565 }
566
Popular Tags