1 7 8 package org.enhydra.snapper.business; 9 10 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 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 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 ex) { 45 System.out.print(ex.toString()); 46 } 47 } 48 49 protected PathImpl(PathDO objectDO, DBTransaction dbt) throws Exception { 50 this.objectDO = PathDO.createExisting(objectDO.get_Handle(),dbt); 51 } 52 53 public String getType() 54 throws Exception { 55 try { 56 return String.valueOf(objectDO.oid_getPATHTYPE()); 57 58 } catch(DataObjectException ex) { 59 throw new Exception ("Error getting type: ", ex); 60 } 61 62 } 63 64 public String getRoot() 65 throws Exception { 66 try { 67 return objectDO.getROOT(); 68 } catch(Exception ex) { 69 throw new Exception ("Error getting ID: ", ex); 70 } 71 72 } 73 74 public String getID() 75 throws Exception { 76 try { 77 return objectDO.get_Handle(); 78 } catch(Exception ex) { 79 throw new Exception ("Error getting ID: ", ex); 80 } 81 82 } 83 84 public String getUser() 85 throws Exception { 86 try { 87 return objectDO.getLOGINNAME(); 88 } catch(Exception ex) { 89 throw new Exception ("Error getting username: ", ex); 90 } 91 92 } 93 94 public String getPass() 95 throws Exception { 96 try { 97 return objectDO.getPASSWORD(); 98 } catch(Exception ex) { 99 throw new Exception ("Error getting password: ", ex); 100 } 101 102 } 103 104 public String getSite() 105 throws Exception { 106 try { 107 return String.valueOf(objectDO.oid_getSITE_FK()); 108 } catch(Exception ex) { 109 throw new Exception ("Error getting site_oid: ", ex); 110 } 111 112 } 113 114 public String getHost() 115 throws Exception { 116 try { 117 return objectDO.getHOST(); 118 } catch(Exception ex) { 119 throw new Exception ("Error getting host: ", ex); 120 } 121 122 } 123 124 public String getPort() throws Exception { 125 try { 126 return objectDO.getPORT(); 127 } catch(Exception ex) { 128 throw new Exception ("Error getting host: ", ex); 129 } 130 131 } 132 133 public String getMappingRoot() throws Exception { 134 try { 135 return objectDO.getMAPPINGROOT(); 136 } catch(Exception ex) { 137 throw new Exception ("Error getting mapping root: ", ex); 138 } 139 140 } 141 142 public void setType(String str) 143 throws Exception { 144 try { 145 objectDO.oid_setPATHTYPE(str); 146 147 } catch(DataObjectException ex) { 148 throw new Exception ("Error setting type: ", ex); 149 } 150 151 } 152 public void setRoot(String str) throws Exception { 153 try { 154 objectDO.setROOT(str); 155 } catch(Exception ex) { 156 throw new Exception ("Error setting root: ", ex); 157 } 158 } 159 160 public void setUser(String str) throws Exception { 161 try { 162 objectDO.setLOGINNAME(str); 163 } catch(Exception ex) { 164 throw new Exception ("Error setting username: ", ex); 165 } 166 } 167 public void setPass(String str) throws Exception { 168 try { 169 objectDO.setPASSWORD(str); 170 } catch(Exception ex) { 171 throw new Exception ("Error setting password: ", ex); 172 } 173 } 174 public void setSite(String str) throws Exception { 175 try { 176 objectDO.oid_setSITE_FK(str); 177 } catch(Exception ex) { 178 throw new Exception ("Error setting password: ", ex); 179 } 180 } 181 182 public void setHost(String str) throws Exception { 183 try { 184 objectDO.setHOST(str); 185 } catch(Exception ex) { 186 throw new Exception ("Error setting host: ", ex); 187 } 188 } 189 190 public void setPort(String str) throws Exception { 191 try { 192 objectDO.setPORT(str); 193 } catch(Exception ex) { 194 throw new Exception ("Error setting host: ", ex); 195 } 196 } 197 198 public void setMappingRoot(String str) throws Exception { 199 try { 200 objectDO.setMAPPINGROOT(str); 201 } catch(Exception ex) { 202 throw new Exception ("Error setting mapping root: ", ex); 203 } 204 } 205 206 207 public void save() throws Exception { 208 try { 209 this.objectDO.save(); 210 } 211 catch (Exception ex) { 212 throw new Exception ("Read-only table: DML operations not allowed", ex); 213 } 214 } 215 216 public void delete() throws Exception { 217 try { 218 this.objectDO.delete(); 219 } 220 catch (Exception ex) { 221 throw new Exception ("Read-only table: DML operations not allowed", ex); 222 } 223 } 224 225 public Path findPathByID(String id, DBTransaction dbt) throws Exception 226 { 227 PathImpl path = null; 228 try { 229 PathQuery query = new PathQuery(dbt); 230 query.setQueryOId(new ObjectId(id)); 232 query.requireUniqueInstance(); 234 PathDO objectDO = query.getNextDO(); 235 path = new PathImpl(objectDO, dbt); 236 return path; 237 }catch(Exception ex) { 238 throw new Exception ("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 ex) { 252 System.out.println(ex.toString()); 253 } 254 255 return pathArray; 256 } 257 258 public Path[] getListForID(DBTransaction dbt, String 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 ex) { 270 System.out.println(ex.toString()); 271 } 272 273 return pathArray; 274 } 275 276 277 278 279 } 280 | Popular Tags |