KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ejb > CustomerCMP


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

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

13 public class CustomerCMP
14    extends test.ejb.CustomerBean
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    /**
194     * Generated ejbPostCreate for corresponding ejbCreate method.
195     *
196     * @see #ejbCreate(test.interfaces.CustomerNormalValue data)
197     */

198    public void ejbPostCreate(test.interfaces.CustomerNormalValue data)
199    {
200    }
201
202    public void ejbLoad()
203    {
204       makeClean();
205    }
206
207    public void ejbStore() throws javax.ejb.EJBException JavaDoc
208    {
209       if (isModified())
210       {
211          super.ejbStore();
212          setVersion( getVersion() + 1 );
213          makeClean();
214       }
215    }
216
217    public void ejbActivate() throws javax.ejb.EJBException JavaDoc
218    {
219       super.ejbActivate();
220    }
221
222    public void ejbPassivate() throws javax.ejb.EJBException JavaDoc
223    {
224       super.ejbPassivate();
225
226       CustomerLightValue = null;
227       CustomerNormalValue = null;
228       CustomerValue = null;
229    }
230
231    public void setEntityContext(javax.ejb.EntityContext JavaDoc ctx) throws javax.ejb.EJBException JavaDoc
232    {
233       super.setEntityContext(ctx);
234    }
235
236    public void unsetEntityContext() throws javax.ejb.EJBException JavaDoc
237    {
238       super.unsetEntityContext();
239    }
240
241    public void ejbRemove() throws javax.ejb.EJBException JavaDoc, javax.ejb.RemoveException JavaDoc
242    {
243       super.ejbRemove();
244
245    }
246
247  /* Value Objects BEGIN */
248
249    public void addAccount(test.interfaces.AccountValue added)
250    throws javax.ejb.FinderException JavaDoc
251    {
252       try
253       {
254           test.interfaces.AccountPK pk = new test.interfaces.AccountPK(added.getId());
255
256          test.interfaces.AccountLocalHome home = test.interfaces.AccountUtil.getLocalHome();
257
258          test.interfaces.AccountLocal relation = home.findByPrimaryKey(pk);
259         getAccounts().add(relation);
260                 makeDirty();
261       }
262       catch (Exception JavaDoc e){
263          if (e instanceof javax.ejb.FinderException JavaDoc)
264             throw (javax.ejb.FinderException JavaDoc)e;
265          else
266             throw new javax.ejb.EJBException JavaDoc(e);
267       }
268    }
269
270    public void removeAccount(test.interfaces.AccountValue removed)
271    throws javax.ejb.RemoveException JavaDoc
272    {
273       try
274       {
275           test.interfaces.AccountPK pk = new test.interfaces.AccountPK(removed.getId());
276
277          test.interfaces.AccountLocalHome home = test.interfaces.AccountUtil.getLocalHome();
278
279         test.interfaces.AccountLocal relation = home.findByPrimaryKey(pk);
280         getAccounts().remove(relation);
281                 makeDirty();
282       }
283       catch (Exception JavaDoc e){
284          if (e instanceof javax.ejb.RemoveException JavaDoc)
285             throw (javax.ejb.RemoveException JavaDoc)e;
286          else
287             throw new javax.ejb.EJBException JavaDoc(e);
288       }
289    }
290
291    public void addShippingAddress(test.interfaces.AddressValue added)
292    throws javax.ejb.CreateException JavaDoc
293    {
294       try
295       {
296           java.lang.String JavaDoc pk = added.getId();
297
298          test.interfaces.AddressLocalHome home = test.interfaces.AddressUtil.getLocalHome();
299
300          test.interfaces.AddressLocal relation = home.create(added);
301         getShippingAddresses().add(relation);
302                 makeDirty();
303       }
304       catch (Exception JavaDoc e){
305          if (e instanceof javax.ejb.CreateException JavaDoc)
306             throw (javax.ejb.CreateException JavaDoc)e;
307          else
308             throw new javax.ejb.EJBException JavaDoc(e);
309       }
310    }
311
312    public void removeShippingAddress(test.interfaces.AddressValue removed)
313    throws javax.ejb.RemoveException JavaDoc
314    {
315       try
316       {
317           java.lang.String JavaDoc pk = removed.getId();
318
319          test.interfaces.AddressLocalHome home = test.interfaces.AddressUtil.getLocalHome();
320
321         test.interfaces.AddressLocal relation = home.findByPrimaryKey(pk);
322         getShippingAddresses().remove(relation);
323                 makeDirty();
324         relation.remove();
325       }
326       catch (Exception JavaDoc e){
327          if (e instanceof javax.ejb.RemoveException JavaDoc)
328             throw (javax.ejb.RemoveException JavaDoc)e;
329          else
330             throw new javax.ejb.EJBException JavaDoc(e);
331       }
332    }
333
334    public void updateShippingAddress(test.interfaces.AddressValue updated)
335    throws javax.ejb.FinderException JavaDoc
336    {
337       try
338       {
339           java.lang.String JavaDoc pk = updated.getId();
340
341          test.interfaces.AddressLocalHome home = test.interfaces.AddressUtil.getLocalHome();
342
343         test.interfaces.AddressLocal relation = home.findByPrimaryKey(pk);
344         relation.setAddressValue(updated);
345       }
346       catch (Exception JavaDoc e){
347          if (e instanceof javax.ejb.FinderException JavaDoc)
348             throw (javax.ejb.FinderException JavaDoc)e;
349          else
350             throw new javax.ejb.EJBException JavaDoc(e);
351       }
352    }
353
354    private test.interfaces.CustomerLightValue CustomerLightValue = null;
355
356    public test.interfaces.CustomerLightValue getCustomerLightValue()
357    {
358       CustomerLightValue = new test.interfaces.CustomerLightValue();
359       try
360          {
361             CustomerLightValue.setCredit( getCredit() );
362             CustomerLightValue.setId( getId() );
363
364             CustomerLightValue.setVersion(getVersion());
365          }
366          catch (Exception JavaDoc e)
367          {
368             throw new javax.ejb.EJBException JavaDoc(e);
369          }
370
371       return CustomerLightValue;
372    }
373    private test.interfaces.CustomerNormalValue CustomerNormalValue = null;
374
375    public test.interfaces.CustomerNormalValue getCustomerNormalValue()
376    {
377       CustomerNormalValue = new test.interfaces.CustomerNormalValue();
378       try
379          {
380             CustomerNormalValue.setCredit( getCredit() );
381             CustomerNormalValue.setId( getId() );
382             CustomerNormalValue.setName( getName() );
383             CustomerNormalValue.setFirstName( getFirstName() );
384             CustomerNormalValue.clearAccountViews();
385             java.util.Iterator JavaDoc iAccountView = getAccounts().iterator();
386             while (iAccountView.hasNext()){
387                 CustomerNormalValue.addAccountView( ((test.interfaces.AccountLocal)iAccountView.next()).getAccountValue() );
388             }
389             CustomerNormalValue.cleanAccountView();
390             CustomerNormalValue.clearShippingAddressValues();
391             java.util.Iterator JavaDoc iShippingAddressValue = getShippingAddresses().iterator();
392             while (iShippingAddressValue.hasNext()){
393                 CustomerNormalValue.addShippingAddressValue( ((test.interfaces.AddressLocal)iShippingAddressValue.next()).getAddressValue() );
394             }
395             CustomerNormalValue.cleanShippingAddressValue();
396
397             CustomerNormalValue.setVersion(getVersion());
398          }
399          catch (Exception JavaDoc e)
400          {
401             throw new javax.ejb.EJBException JavaDoc(e);
402          }
403
404       return CustomerNormalValue;
405    }
406    private test.interfaces.CustomerValue CustomerValue = null;
407
408    public test.interfaces.CustomerValue getCustomerValue()
409    {
410       CustomerValue = new test.interfaces.CustomerValue();
411       try
412          {
413             CustomerValue.setCredit( getCredit() );
414             CustomerValue.setId( getId() );
415             CustomerValue.setName( getName() );
416             CustomerValue.setFirstName( getFirstName() );
417             CustomerValue.setPhone( getPhone() );
418             CustomerValue.setFax( getFax() );
419             CustomerValue.clearAccountViews();
420             java.util.Iterator JavaDoc iAccountView = getAccounts().iterator();
421             while (iAccountView.hasNext()){
422                 CustomerValue.addAccountView( ((test.interfaces.AccountLocal)iAccountView.next()).getAccountValue() );
423             }
424             CustomerValue.cleanAccountView();
425             CustomerValue.clearShippingAddressValues();
426             java.util.Iterator JavaDoc iShippingAddressValue = getShippingAddresses().iterator();
427             while (iShippingAddressValue.hasNext()){
428                 CustomerValue.addShippingAddressValue( ((test.interfaces.AddressLocal)iShippingAddressValue.next()).getAddressValue() );
429             }
430             CustomerValue.cleanShippingAddressValue();
431
432             CustomerValue.setVersion(getVersion());
433          }
434          catch (Exception JavaDoc e)
435          {
436             throw new javax.ejb.EJBException JavaDoc(e);
437          }
438
439       return CustomerValue;
440    }
441
442    public void setCustomerNormalValue( test.interfaces.CustomerNormalValue valueHolder )
443    throws test.interfaces.ApplicationException{
444       validate(valueHolder);
445       if( getVersion() != valueHolder.getVersion() )
446          throw new IllegalStateException JavaDoc( "Wrong version. Had " + getVersion() + ", got " + valueHolder.getVersion() );
447
448       try
449       {
450          setCredit( valueHolder.getCredit() );
451          setName( valueHolder.getName() );
452          setFirstName( valueHolder.getFirstName() );
453
454       {
455
456          java.util.Iterator JavaDoc iAccountView = valueHolder.getAddedAccountViews().iterator();
457          while (iAccountView.hasNext())
458          {
459             test.interfaces.AccountValue o = (test.interfaces.AccountValue)iAccountView.next();
460             addAccount(o);
461          }
462          iAccountView = valueHolder.getRemovedAccountViews().iterator();
463          while (iAccountView.hasNext())
464          {
465             test.interfaces.AccountValue o = (test.interfaces.AccountValue)iAccountView.next();
466             removeAccount(o);
467          }
468       }
469       // Anonymous block to allow variable declations without conflicts
470
{
471
472          java.util.Iterator JavaDoc iShippingAddressValue = valueHolder.getUpdatedShippingAddressValues().iterator();
473          while (iShippingAddressValue.hasNext())
474          {
475             test.interfaces.AddressValue o = (test.interfaces.AddressValue)iShippingAddressValue.next();
476             updateShippingAddress(o);
477          }
478          iShippingAddressValue = valueHolder.getAddedShippingAddressValues().iterator();
479          while (iShippingAddressValue.hasNext())
480          {
481             test.interfaces.AddressValue o = (test.interfaces.AddressValue)iShippingAddressValue.next();
482             addShippingAddress(o);
483          }
484          iShippingAddressValue = valueHolder.getRemovedShippingAddressValues().iterator();
485          while (iShippingAddressValue.hasNext())
486          {
487             test.interfaces.AddressValue o = (test.interfaces.AddressValue)iShippingAddressValue.next();
488             removeShippingAddress(o);
489          }
490       }
491       }
492       catch (Exception JavaDoc e)
493       {
494          throw new javax.ejb.EJBException JavaDoc(e);
495       }
496    }
497
498 /* Value Objects END */
499
500 }
501
Popular Tags