KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > business > PathImpl


1 /*
2  * snapper
3  *
4  * Enhydra super-servlet business object
5  *
6  */

7
8 package org.enhydra.snapper.business;
9
10 // Enhydra SuperServlet specification imports
11
import org.enhydra.snapper.spec.*;
12 import org.enhydra.snapper.data.*;
13
14 import com.lutris.appserver.server.sql.DBTransaction;
15 import com.lutris.appserver.server.sql.ObjectId;
16 import com.lutris.dods.builder.generator.query.DataObjectException;
17
18
19
20
21
22 // Standard imports
23
//import java.text.DateFormat;
24

25 public class PathImpl implements Path {
26     protected PathDO objectDO = null;
27     
28     public PathImpl(){}
29     
30     public PathImpl(DBTransaction dbt){
31          try {
32             this.objectDO = PathDO.createVirgin(dbt);
33          }
34          catch(Exception JavaDoc ex) {
35             System.out.print(ex.toString());
36         }
37          
38     }
39     
40     public void createNew(DBTransaction dbt) {
41         try {
42             this.objectDO = PathDO.createVirgin(dbt);
43          }
44          catch(Exception JavaDoc ex) {
45             System.out.print(ex.toString());
46         }
47     }
48     
49     protected PathImpl(PathDO objectDO, DBTransaction dbt) throws Exception JavaDoc {
50         this.objectDO = PathDO.createExisting(objectDO.get_Handle(),dbt);
51     }
52     
53     public String JavaDoc getType()
54         throws Exception JavaDoc {
55             try {
56                 return String.valueOf(objectDO.oid_getPATHTYPE());
57                 
58             } catch(DataObjectException ex) {
59                 throw new Exception JavaDoc("Error getting type: ", ex);
60             }
61         
62     }
63     
64     public String JavaDoc getRoot()
65     throws Exception JavaDoc {
66         try {
67             return objectDO.getROOT();
68         } catch(Exception JavaDoc ex) {
69             throw new Exception JavaDoc("Error getting ID: ", ex);
70         }
71     
72     }
73     
74     public String JavaDoc getID()
75     throws Exception JavaDoc {
76         try {
77             return objectDO.get_Handle();
78         } catch(Exception JavaDoc ex) {
79             throw new Exception JavaDoc("Error getting ID: ", ex);
80         }
81     
82     }
83     
84     public String JavaDoc getUser()
85     throws Exception JavaDoc {
86         try {
87             return objectDO.getLOGINNAME();
88         } catch(Exception JavaDoc ex) {
89             throw new Exception JavaDoc("Error getting username: ", ex);
90         }
91     
92     }
93     
94     public String JavaDoc getPass()
95     throws Exception JavaDoc {
96         try {
97             return objectDO.getPASSWORD();
98         } catch(Exception JavaDoc ex) {
99             throw new Exception JavaDoc("Error getting password: ", ex);
100         }
101     
102     }
103     
104     public String JavaDoc getSite()
105     throws Exception JavaDoc {
106         try {
107             return String.valueOf(objectDO.oid_getSITE_FK());
108         } catch(Exception JavaDoc ex) {
109             throw new Exception JavaDoc("Error getting site_oid: ", ex);
110         }
111     
112     }
113     
114     public String JavaDoc getHost()
115     throws Exception JavaDoc {
116         try {
117             return objectDO.getHOST();
118         } catch(Exception JavaDoc ex) {
119             throw new Exception JavaDoc("Error getting host: ", ex);
120         }
121     
122     }
123     
124     public String JavaDoc getPort() throws Exception JavaDoc {
125         try {
126             return objectDO.getPORT();
127         } catch(Exception JavaDoc ex) {
128             throw new Exception JavaDoc("Error getting host: ", ex);
129         }
130     
131     }
132     
133     public String JavaDoc getMappingRoot() throws Exception JavaDoc {
134         try {
135             return objectDO.getMAPPINGROOT();
136         } catch(Exception JavaDoc ex) {
137             throw new Exception JavaDoc("Error getting mapping root: ", ex);
138         }
139     
140     }
141     
142     public void setType(String JavaDoc str)
143     throws Exception JavaDoc {
144         try {
145             objectDO.oid_setPATHTYPE(str);
146             
147         } catch(DataObjectException ex) {
148             throw new Exception JavaDoc("Error setting type: ", ex);
149         }
150     
151     }
152     public void setRoot(String JavaDoc str) throws Exception JavaDoc {
153     try {
154         objectDO.setROOT(str);
155     } catch(Exception JavaDoc ex) {
156         throw new Exception JavaDoc("Error setting root: ", ex);
157     }
158     }
159     
160     public void setUser(String JavaDoc str) throws Exception JavaDoc {
161         try {
162             objectDO.setLOGINNAME(str);
163         } catch(Exception JavaDoc ex) {
164             throw new Exception JavaDoc("Error setting username: ", ex);
165         }
166         }
167     public void setPass(String JavaDoc str) throws Exception JavaDoc {
168         try {
169             objectDO.setPASSWORD(str);
170         } catch(Exception JavaDoc ex) {
171             throw new Exception JavaDoc("Error setting password: ", ex);
172         }
173         }
174     public void setSite(String JavaDoc str) throws Exception JavaDoc {
175         try {
176             objectDO.oid_setSITE_FK(str);
177         } catch(Exception JavaDoc ex) {
178             throw new Exception JavaDoc("Error setting password: ", ex);
179         }
180         }
181     
182     public void setHost(String JavaDoc str) throws Exception JavaDoc {
183         try {
184             objectDO.setHOST(str);
185         } catch(Exception JavaDoc ex) {
186             throw new Exception JavaDoc("Error setting host: ", ex);
187         }
188         }
189     
190     public void setPort(String JavaDoc str) throws Exception JavaDoc {
191         try {
192             objectDO.setPORT(str);
193         } catch(Exception JavaDoc ex) {
194             throw new Exception JavaDoc("Error setting host: ", ex);
195         }
196         }
197     
198     public void setMappingRoot(String JavaDoc str) throws Exception JavaDoc {
199         try {
200             objectDO.setMAPPINGROOT(str);
201         } catch(Exception JavaDoc ex) {
202             throw new Exception JavaDoc("Error setting mapping root: ", ex);
203         }
204         }
205
206             
207     public void save() throws Exception JavaDoc {
208                 try {
209                     this.objectDO.save();
210                 }
211                 catch (Exception JavaDoc ex) {
212                     throw new Exception JavaDoc("Read-only table: DML operations not allowed", ex);
213                 }
214             }
215     
216     public void delete() throws Exception JavaDoc {
217         try {
218             this.objectDO.delete();
219         }
220         catch (Exception JavaDoc ex) {
221             throw new Exception JavaDoc("Read-only table: DML operations not allowed", ex);
222         }
223     }
224     
225     public Path findPathByID(String JavaDoc id, DBTransaction dbt) throws Exception JavaDoc
226     {
227         PathImpl path = null;
228         try {
229             PathQuery query = new PathQuery(dbt);
230             //set query
231
query.setQueryOId(new ObjectId(id));
232             // Throw an exception if more than one user by this name is found
233
query.requireUniqueInstance();
234             PathDO objectDO = query.getNextDO();
235             path = new PathImpl(objectDO, dbt);
236             return path;
237         }catch(Exception JavaDoc ex) {
238             throw new Exception JavaDoc("Exception in findPathByID()", ex);
239         }
240     }
241         
242     public Path[] getList(DBTransaction dbt){
243         Path[] pathArray = null;
244         try {
245             PathQuery query = new PathQuery(dbt);
246             query.addOrderByROOT();
247             PathDO[] DOarray = query.getDOArray();
248             pathArray = new PathImpl[ DOarray.length ];
249             for ( int i = 0; i < DOarray.length; i++ )
250                 pathArray[i] = new PathImpl(DOarray[i], dbt);
251         }catch(Exception JavaDoc ex) {
252             System.out.println(ex.toString());
253         }
254         
255         return pathArray;
256     }
257     
258     public Path[] getListForID(DBTransaction dbt, String JavaDoc str){
259         Path[] pathArray = null;
260         try {
261             SitesDO siteDO = SitesDO.createExisting(str, dbt);
262             PathQuery query = new PathQuery(dbt);
263             query.setQuerySITE_FK(siteDO);
264             query.addOrderByROOT();
265             PathDO[] DOarray = query.getDOArray();
266             pathArray = new PathImpl[ DOarray.length ];
267             for ( int i = 0; i < DOarray.length; i++ )
268                 pathArray[i] = new PathImpl(DOarray[i], dbt);
269         }catch(Exception JavaDoc ex) {
270             System.out.println(ex.toString());
271         }
272         
273         return pathArray;
274     }
275     
276     
277     
278     
279 }
280
Popular Tags