KickJava   Java API By Example, From Geeks To Geeks.

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


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.OrderCursor;
12 import com.genimen.djeneric.test.strong.OrderQbe;
13 import com.genimen.djeneric.test.strong.TestException;
14
15 // Place your custom code BETWEEN the following tags
16
//<DjenericManualCode id="1">
17
//</DjenericManualCode>
18
public class CustomerImpl extends TestObjectImpl implements Customer
19 {
20   private static boolean propidx_set = false;
21   private static int PROPIDX_ID;
22   private static int PROPIDX_NAME;
23   private static int PROPIDX_STREET;
24   private static int PROPIDX_CITY;
25   private static int PROPIDX_ZIPCODE;
26
27   protected CustomerImpl(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_NAME = extent.getPropertyIndex("name");
35       PROPIDX_STREET = extent.getPropertyIndex("street");
36       PROPIDX_CITY = extent.getPropertyIndex("city");
37       PROPIDX_ZIPCODE = extent.getPropertyIndex("zipCode");
38     }
39   }
40
41   public long determineObjectId() throws TestException
42   {
43     try
44     {
45       return getObjectId();
46     }
47     catch (Exception JavaDoc x)
48     {
49       throw new TestException(x);
50     }
51   }
52
53   public long getId()
54   {
55     return getLong(PROPIDX_ID);
56   }
57
58   public boolean isNullId()
59   {
60     return isNull(PROPIDX_ID);
61   }
62
63   public String JavaDoc getName()
64   {
65     return getString(PROPIDX_NAME);
66   }
67
68   public boolean isNullName()
69   {
70     return isNull(PROPIDX_NAME);
71   }
72
73   public void setName(String JavaDoc value) throws TestException
74   {
75     try
76     {
77       setString(PROPIDX_NAME, value);
78     }
79     catch (Exception JavaDoc x)
80     {
81       throw new TestException(x);
82     }
83   }
84
85   public void setNullName() throws TestException
86   {
87     try
88     {
89       setNull(PROPIDX_NAME);
90     }
91     catch (Exception JavaDoc x)
92     {
93       throw new TestException(x);
94     }
95   }
96
97   public String JavaDoc getStreet()
98   {
99     return getString(PROPIDX_STREET);
100   }
101
102   public boolean isNullStreet()
103   {
104     return isNull(PROPIDX_STREET);
105   }
106
107   public void setStreet(String JavaDoc value) throws TestException
108   {
109     try
110     {
111       setString(PROPIDX_STREET, value);
112     }
113     catch (Exception JavaDoc x)
114     {
115       throw new TestException(x);
116     }
117   }
118
119   public void setNullStreet() throws TestException
120   {
121     try
122     {
123       setNull(PROPIDX_STREET);
124     }
125     catch (Exception JavaDoc x)
126     {
127       throw new TestException(x);
128     }
129   }
130
131   public String JavaDoc getCity()
132   {
133     return getString(PROPIDX_CITY);
134   }
135
136   public boolean isNullCity()
137   {
138     return isNull(PROPIDX_CITY);
139   }
140
141   public void setCity(String JavaDoc value) throws TestException
142   {
143     try
144     {
145       setString(PROPIDX_CITY, value);
146     }
147     catch (Exception JavaDoc x)
148     {
149       throw new TestException(x);
150     }
151   }
152
153   public void setNullCity() throws TestException
154   {
155     try
156     {
157       setNull(PROPIDX_CITY);
158     }
159     catch (Exception JavaDoc x)
160     {
161       throw new TestException(x);
162     }
163   }
164
165   public String JavaDoc getZipCode()
166   {
167     return getString(PROPIDX_ZIPCODE);
168   }
169
170   public boolean isNullZipCode()
171   {
172     return isNull(PROPIDX_ZIPCODE);
173   }
174
175   public void setZipCode(String JavaDoc value) throws TestException
176   {
177     try
178     {
179       setString(PROPIDX_ZIPCODE, value);
180     }
181     catch (Exception JavaDoc x)
182     {
183       throw new TestException(x);
184     }
185   }
186
187   public void setNullZipCode() throws TestException
188   {
189     try
190     {
191       setNull(PROPIDX_ZIPCODE);
192     }
193     catch (Exception JavaDoc x)
194     {
195       throw new TestException(x);
196     }
197   }
198
199   // Set operations:
200

201   public Order[] getOrders() throws TestException
202   {
203     return getOrders(null);
204   }
205
206   public Order[] getOrders(OrderQbe qbeItf) throws TestException
207   {
208     try
209     {
210       DjList result;
211       DjQueryByExample qbe = (DjQueryByExample) qbeItf;
212       if (qbe == null) result = getDetailAssociationByName("orders").getObjects();
213       else result = getDetailAssociationByName("orders").getObjects(qbe, false);
214       result.sort(getExtent());
215       return (Order[]) result.toArray(new Order[0]);
216     }
217     catch (Exception JavaDoc x)
218     {
219       throw new TestException(x);
220     }
221   }
222
223   public OrderCursor getOrdersCursor(OrderQbe qbeItf) throws TestException
224   {
225     try
226     {
227       DjQueryByExample qbe = (DjQueryByExample) qbeItf;
228       return new OrderCursorImpl(getDetailAssociationByName("orders").getObjectsCursor(qbe, false));
229     }
230     catch (Exception JavaDoc x)
231     {
232       throw new TestException(x);
233     }
234   }
235
236   public OrderCursor getOrdersCursor() throws TestException
237   {
238     try
239     {
240       return new OrderCursorImpl(getDetailAssociationByName("orders").getObjectsCursor(false));
241     }
242     catch (Exception JavaDoc x)
243     {
244       throw new TestException(x);
245     }
246   }
247
248   public void addToOrders(Order orders) throws TestException
249   {
250     try
251     {
252       orders.setCustomer(this);
253       DjAssociation assoc = getDetailAssociationByName("orders");
254       if (assoc.isDetailsLoaded()) assoc.getObjects().add(orders);
255     }
256     catch (Exception JavaDoc x)
257     {
258       throw new TestException(x);
259     }
260   }
261
262   public Order createOrderInOrders() throws TestException
263   {
264     try
265     {
266       TestSessionImpl ses = (TestSessionImpl) getSession();
267       Order obj = ses.createOrder();
268       addToOrders(obj);
269       return obj;
270     }
271     catch (Exception JavaDoc x)
272     {
273       throw new TestException(x);
274     }
275   }
276
277   // Place your custom code BETWEEN the following tags
278
//<DjenericManualCode>
279
//</DjenericManualCode>
280
}
Popular Tags