KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class PathTypeImpl implements PathType {
20     protected PathTypeDO pathTypeDO = null;
21     
22     public PathTypeImpl(){}
23     
24     public PathTypeImpl(DBTransaction dbt){
25          try {
26             this.pathTypeDO = PathTypeDO.createVirgin(dbt);
27          }
28          catch(Exception JavaDoc ex) {
29             System.out.print(ex.toString());
30         }
31          
32     }
33     
34     protected PathTypeImpl(PathTypeDO path, DBTransaction dbt) throws Exception JavaDoc {
35         this.pathTypeDO = PathTypeDO.createExisting(path.get_Handle(),dbt);
36     }
37     
38     public void createNew(DBTransaction dbt) {
39         try {
40             this.pathTypeDO = PathTypeDO.createVirgin(dbt);
41          }
42          catch(Exception JavaDoc ex) {
43             System.out.print(ex.toString());
44         }
45     }
46     
47     public String JavaDoc getName()
48         throws Exception JavaDoc {
49             try {
50                 return pathTypeDO.getTYPENAME();
51             } catch(DataObjectException ex) {
52                 throw new Exception JavaDoc("Error getting site's name", ex);
53             }
54         
55     }
56     
57     public String JavaDoc getID()
58     throws Exception JavaDoc {
59         try {
60             return pathTypeDO.get_Handle();
61         } catch(Exception JavaDoc ex) {
62             throw new Exception JavaDoc("Error getting site's ID", ex);
63         }
64     
65     }
66     
67     public void setName(String JavaDoc str) throws Exception JavaDoc {
68     try {
69         pathTypeDO.setTYPENAME(str);
70     } catch(Exception JavaDoc ex) {
71         throw new Exception JavaDoc("Error setting name", ex);
72     }
73     }
74             
75     public void save() throws Exception JavaDoc {
76                 try {
77                     this.pathTypeDO.save();
78                 }
79                 catch (Exception JavaDoc ex) {
80                     throw new Exception JavaDoc("Read-only table: DML operations not allowed", ex);
81                 }
82             }
83     
84     public void delete() throws Exception JavaDoc {
85         try {
86             this.pathTypeDO.delete();
87         }
88         catch (Exception JavaDoc ex) {
89             throw new Exception JavaDoc("Read-only table: DML operations not allowed", ex);
90         }
91     }
92     
93     public PathType findPathTypeByID(String JavaDoc id, DBTransaction dbt) throws Exception JavaDoc
94     {
95         PathTypeImpl pathType = null;
96         try {
97             PathTypeQuery query = new PathTypeQuery(dbt);
98             //set query
99
query.setQueryOId(new ObjectId(id));
100             // Throw an exception if more than one user by this name is found
101
query.requireUniqueInstance();
102             PathTypeDO pathTypeDO = query.getNextDO();
103             pathType = new PathTypeImpl(pathTypeDO, dbt);
104             return pathType;
105         }catch(Exception JavaDoc ex) {
106             throw new Exception JavaDoc("Exception in findPathTypeByID()", ex);
107         }
108     }
109     
110     public PathType[] getList(DBTransaction dbt) throws Exception JavaDoc{
111         PathTypeImpl[] pathArray = null;
112         try {
113             PathTypeQuery query = new PathTypeQuery(dbt);
114             //set query
115
//query.setQueryOwner(PersonDO.createExisting(owner.getHandle()));
116
// Order discs alphabetically by artist
117
query.addOrderByTYPENAME();
118             PathTypeDO[] DOarray = query.getDOArray();
119             pathArray = new PathTypeImpl[ DOarray.length ];
120             for ( int i = 0; i < DOarray.length; i++ )
121                 pathArray[i] = new PathTypeImpl(DOarray[i], dbt);
122         }catch(Exception JavaDoc ex) {
123             throw new Exception JavaDoc("Exception in getList()", ex);
124         }
125         
126         return pathArray;
127     }
128             
129     
130     
131 }
132
Popular Tags