KickJava   Java API By Example, From Geeks To Geeks.

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


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

12 import org.enhydra.snapper.Log;
13 import org.enhydra.snapper.spec.*;
14 import org.enhydra.snapper.data.*;
15
16 import com.lutris.appserver.server.sql.DBTransaction;
17 import com.lutris.appserver.server.sql.ObjectId;
18 import com.lutris.dods.builder.generator.query.DataObjectException;
19
20
21
22
23
24
25 // Standard imports
26
//import java.text.DateFormat;
27

28 public class NotIndexedImpl implements NotIndexed {
29     protected NotIndexedDO notIndexedDO = null;
30     public DBTransaction dbt = null;
31     
32     public NotIndexedImpl(){}
33     
34     
35     public NotIndexedImpl(DBTransaction dbt){
36          try {
37             this.notIndexedDO = NotIndexedDO.createVirgin(dbt);
38          }
39          catch(Exception JavaDoc ex) {
40             Log.log(ex.toString());
41         }
42          
43     }
44     
45     public void createNew(DBTransaction dbt) {
46         try {
47             this.notIndexedDO = NotIndexedDO.createVirgin(dbt);
48             this.dbt = dbt;
49         }
50          catch(Exception JavaDoc ex) {
51             Log.log(ex.toString());
52             
53         }
54     }
55     
56     protected NotIndexedImpl(NotIndexedDO indexed, DBTransaction dbt) throws Exception JavaDoc {
57         this.notIndexedDO = NotIndexedDO.createExisting(indexed.get_Handle(),dbt);
58     }
59     
60     public String JavaDoc getIndexed()
61         throws Exception JavaDoc {
62             try {
63                 return String.valueOf(notIndexedDO.getINDEXED_FK());
64             } catch(DataObjectException ex) {
65                 Log.logException(ex);
66                 throw new Exception JavaDoc("Error getting indexed fk", ex);
67             }
68         
69     }
70     
71     
72     
73     public void setIndexed(String JavaDoc str) throws Exception JavaDoc {
74     try {
75         notIndexedDO.oid_setINDEXED_FK(str);
76     } catch(Exception JavaDoc ex) {
77         Log.logException(ex);
78         throw new Exception JavaDoc("Error setting indexed fk", ex);
79     }
80     }
81     
82
83     
84     
85             
86     public void save() throws Exception JavaDoc {
87                 try {
88                     this.notIndexedDO.save();
89                 }
90                 catch (Exception JavaDoc ex) {
91                     Log.logException(ex);
92                     throw new Exception JavaDoc("Read-only table: DML operations not allowed");
93                 }
94             }
95     
96     public void delete() throws Exception JavaDoc {
97         try {
98             this.notIndexedDO.delete();
99         }
100         catch (Exception JavaDoc ex) {
101             Log.logException(ex);
102             throw new Exception JavaDoc("Read-only table: DML operations not allowed");
103         }
104     }
105
106     
107     
108     
109     public String JavaDoc getLink() throws Exception JavaDoc{
110         try {
111             return notIndexedDO.getFILENAME();
112            } catch(Exception JavaDoc ex) {
113             Log.logException(ex);
114                throw new Exception JavaDoc("Error getting timestamp");
115            }
116     }
117     
118     
119     public void setLink(String JavaDoc str) throws Exception JavaDoc{
120         try {
121             notIndexedDO.setFILENAME(str);
122         } catch(Exception JavaDoc ex) {
123             Log.logException(ex);
124             throw new Exception JavaDoc("Error setting link", ex);
125         }
126     }
127     
128     public NotIndexed findPathByID(String JavaDoc id, DBTransaction dbt) throws Exception JavaDoc
129     {
130         NotIndexedImpl ni = null;
131         try {
132             NotIndexedQuery query = new NotIndexedQuery(dbt);
133             //set query
134
query.setQueryOId(new ObjectId(id));
135             // Throw an exception if more than one user by this name is found
136
query.requireUniqueInstance();
137             NotIndexedDO objectDO = query.getNextDO();
138             ni = new NotIndexedImpl(objectDO, dbt);
139             return ni;
140         }catch(Exception JavaDoc ex) {
141             throw new Exception JavaDoc("Exception in findPathByID()", ex);
142         }
143     
144 }
145     
146     public NotIndexed[] getList(DBTransaction dbt){
147         NotIndexed[] niArray = null;
148         try {
149             NotIndexedQuery query = new NotIndexedQuery(dbt);
150             NotIndexedDO[] DOarray = query.getDOArray();
151             niArray = new NotIndexedImpl[ DOarray.length ];
152             for ( int i = 0; i < DOarray.length; i++ )
153                 niArray[i] = new NotIndexedImpl(DOarray[i], dbt);
154         }catch(Exception JavaDoc ex) {
155             System.out.println(ex.toString());
156         }
157         
158         return niArray;
159     }
160     
161     public NotIndexed[] getListForID(DBTransaction dbt, String JavaDoc str){
162         NotIndexed[] niArray = null;
163         try {
164             IndexedDO indexedDO = IndexedDO.createExisting(str, dbt);
165             NotIndexedQuery query = new NotIndexedQuery(dbt);
166             query.setQueryINDEXED_FK(indexedDO);
167             NotIndexedDO[] notIndexedDOArray = query.getDOArray();
168             niArray = new NotIndexedImpl[ notIndexedDOArray.length ];
169             for ( int i = 0; i < notIndexedDOArray.length; i++ )
170                 niArray[i] = new NotIndexedImpl(notIndexedDOArray[i], dbt);
171         }catch(Exception JavaDoc ex) {
172             System.out.println(ex.toString());
173         }
174         
175         return niArray;
176     }
177     
178 }
179
Popular Tags