KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > test > strong > impl > OrderImpl


1 package com.genimen.djeneric.test.strong.impl;
2
3 import com.genimen.djeneric.repository.DjAssociation;
4 import com.genimen.djeneric.repository.DjExtent;
5 import com.genimen.djeneric.repository.DjList;
6 import com.genimen.djeneric.repository.DjQueryByExample;
7 import com.genimen.djeneric.repository.DjSession;
8 import com.genimen.djeneric.repository.exceptions.DjenericException;
9 import com.genimen.djeneric.test.strong.Customer;
10 import com.genimen.djeneric.test.strong.Order;
11 import com.genimen.djeneric.test.strong.Orderline;
12 import com.genimen.djeneric.test.strong.OrderlineCursor;
13 import com.genimen.djeneric.test.strong.OrderlineQbe;
14 import com.genimen.djeneric.test.strong.TestException;
15
16 // Place your custom code BETWEEN the following tags
17
//<DjenericManualCode id="1">
18
//</DjenericManualCode>
19
public class OrderImpl extends TestObjectImpl implements Order
20 {
21   private static boolean propidx_set = false;
22   private static int PROPIDX_ID;
23   private static int PROPIDX_ORDERDATE;
24   private static int PROPIDX_ORDERNUMBER;
25   private static int PROPIDX_CUSTOMER;
26
27   protected OrderImpl(DjSession session, DjExtent extent) throws DjenericException
28   {
29     super(session, extent);
30     if (!propidx_set)
31     {
32       propidx_set = true;
33       PROPIDX_ID = extent.getPropertyIndex("id");
34       PROPIDX_ORDERDATE = extent.getPropertyIndex("orderdate");
35       PROPIDX_ORDERNUMBER = extent.getPropertyIndex("ordernumber");
36       PROPIDX_CUSTOMER = extent.getPropertyIndex("customer");
37     }
38   }
39
40   public long determineObjectId() throws TestException
41   {
42     try
43     {
44       return getObjectId();
45     }
46     catch (Exception JavaDoc x)
47     {
48       throw new TestException(x);
49     }
50   }
51
52   public long getId()
53   {
54     return getLong(PROPIDX_ID);
55   }
56
57   public boolean isNullId()
58   {
59     return isNull(PROPIDX_ID);
60   }
61
62   public java.util.Date JavaDoc getOrderdate()
63   {
64     return getDate(PROPIDX_ORDERDATE);
65   }
66
67   public boolean isNullOrderdate()
68   {
69     return isNull(PROPIDX_ORDERDATE);
70   }
71
72   public void setOrderdate(java.util.Date JavaDoc value) throws TestException
73   {
74     try
75     {
76       setDate(PROPIDX_ORDERDATE, value);
77     }
78     catch (Exception JavaDoc x)
79     {
80       throw new TestException(x);
81     }
82   }
83
84   public void setNullOrderdate() throws TestException
85   {
86     try
87     {
88       setNull(PROPIDX_ORDERDATE);
89     }
90     catch (Exception JavaDoc x)
91     {
92       throw new TestException(x);
93     }
94   }
95
96   public long getOrdernumber()
97   {
98     return getLong(PROPIDX_ORDERNUMBER);
99   }
100
101   public boolean isNullOrdernumber()
102   {
103     return isNull(PROPIDX_ORDERNUMBER);
104   }
105
106   public void setOrdernumber(long value) throws TestException
107   {
108     try
109     {
110       setLong(PROPIDX_ORDERNUMBER, value);
111     }
112     catch (Exception JavaDoc x)
113     {
114       throw new TestException(x);
115     }
116   }
117
118   public void setNullOrdernumber() throws TestException
119   {
120     try
121     {
122       setNull(PROPIDX_ORDERNUMBER);
123     }
124     catch (Exception JavaDoc x)
125     {
126       throw new TestException(x);
127     }
128   }
129
130   public Customer getCustomer() throws TestException
131   {
132     try
133     {
134       return (Customer) get(PROPIDX_CUSTOMER);
135     }
136     catch (Exception JavaDoc x)
137     {
138       throw new TestException(x);
139     }
140   }
141
142   public boolean isNullCustomer()
143   {
144     return isNull(PROPIDX_CUSTOMER);
145   }
146
147   public void setCustomer(Customer value) throws TestException
148   {
149     try
150     {
151       set(PROPIDX_CUSTOMER, (CustomerImpl) value);
152     }
153     catch (Exception JavaDoc x)
154     {
155       throw new TestException(x);
156     }
157   }
158
159   public void setNullCustomer() throws TestException
160   {
161     try
162     {
163       setNull(PROPIDX_CUSTOMER);
164     }
165     catch (Exception JavaDoc x)
166     {
167       throw new TestException(x);
168     }
169   }
170
171   // Set operations:
172

173   public Orderline[] getOrderlines() throws TestException
174   {
175     return getOrderlines(null);
176   }
177
178   public Orderline[] getOrderlines(OrderlineQbe qbeItf) throws TestException
179   {
180     try
181     {
182       DjList result;
183       DjQueryByExample qbe = (DjQueryByExample) qbeItf;
184       if (qbe == null) result = getDetailAssociationByName("orderlines").getObjects();
185       else result = getDetailAssociationByName("orderlines").getObjects(qbe, false);
186       result.sort(getExtent());
187       return (Orderline[]) result.toArray(new Orderline[0]);
188     }
189     catch (Exception JavaDoc x)
190     {
191       throw new TestException(x);
192     }
193   }
194
195   public OrderlineCursor getOrderlinesCursor(OrderlineQbe qbeItf) throws TestException
196   {
197     try
198     {
199       DjQueryByExample qbe = (DjQueryByExample) qbeItf;
200       return new OrderlineCursorImpl(getDetailAssociationByName("orderlines").getObjectsCursor(qbe, false));
201     }
202     catch (Exception JavaDoc x)
203     {
204       throw new TestException(x);
205     }
206   }
207
208   public OrderlineCursor getOrderlinesCursor() throws TestException
209   {
210     try
211     {
212       return new OrderlineCursorImpl(getDetailAssociationByName("orderlines").getObjectsCursor(false));
213     }
214     catch (Exception JavaDoc x)
215     {
216       throw new TestException(x);
217     }
218   }
219
220   public void addToOrderlines(Orderline orderlines) throws TestException
221   {
222     try
223     {
224       orderlines.setTheOrder(this);
225       DjAssociation assoc = getDetailAssociationByName("orderlines");
226       if (assoc.isDetailsLoaded()) assoc.getObjects().add(orderlines);
227     }
228     catch (Exception JavaDoc x)
229     {
230       throw new TestException(x);
231     }
232   }
233
234   public Orderline createOrderlineInOrderlines() throws TestException
235   {
236     try
237     {
238       TestSessionImpl ses = (TestSessionImpl) getSession();
239       Orderline obj = ses.createOrderline();
240       addToOrderlines(obj);
241       return obj;
242     }
243     catch (Exception JavaDoc x)
244     {
245       throw new TestException(x);
246     }
247   }
248
249   // Place your custom code BETWEEN the following tags
250
//<DjenericManualCode>
251
//</DjenericManualCode>
252
}
Popular Tags