1 20 21 package org.webdocwf.util.loader; 22 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 26 import javax.xml.parsers.DocumentBuilder ; 27 import javax.xml.parsers.DocumentBuilderFactory ; 28 29 import org.w3c.dom.Document ; 30 import org.w3c.dom.NamedNodeMap ; 31 import org.w3c.dom.Node ; 32 import org.w3c.dom.NodeList ; 33 import org.webdocwf.util.loader.logging.Logger; 34 35 41 public class LoaderJobAttrReader { 42 43 boolean bDefaultOnErrorContinue = false; 45 boolean bDefaultCommit = true; 46 String strDefaultUserID = ""; 47 String strDefaultLogDir = ""; 48 String strDefaultLogFile = "default"; 49 String strDefaultVendorConfig = "OctopusDBVendors.xml"; 50 boolean bDefaultObjectIDAutoCreate = false; 51 int iDefaultObjectIDStartValue = 1; 52 int iDefaultCommitCount = 100; 53 int iLoaderJobCommitCount = 0; 54 boolean bDefaultOidLogic = true; 55 56 String strDefaultLogMode = "normal"; 57 int iDefaultObjectIDIncrement = 20; 58 String strDefaultObjectIDTableName = "objectid"; 59 String strDefaultObjectIDColumnName = "next"; 60 String strDefaultObjectIDNameColumnName = ""; 61 String strDefaultObjectIDNameColumnValue = ""; 62 String strDefaultTableMode = "Query"; 63 64 String strDefaultDataCutOff = ""; 66 String strLogTableName = ""; 67 String strLogTable = ""; 68 String strLogColumnName = ""; 69 String strLogRowNumber = ""; 70 String strLogOriginalValue = ""; 71 String strLogNewValue = ""; 72 String strLogImportDefinitionName = ""; 73 String strLogOperationName = ""; 74 String strLogTypeName = ""; 75 String strLogFailedStatemet = ""; 76 String strLogTime = ""; 77 78 private Logger logger; 79 String strLogClassName = ""; 80 String strPathToLoggerConf = ""; 81 String setFetchSize = ""; 82 String setCursorName = ""; 83 84 90 public void importLoaderJobAttributes(InputStream inputStream) throws LoaderException { 91 Document doc = null; 92 this.logger.write("full", "\timportLoaderJobAttributes method is started."); 93 try { 94 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 95 DocumentBuilder db = null; 96 db = dbf.newDocumentBuilder(); 97 doc = db.parse(inputStream); 98 } catch (Exception e) { 99 this.logger.write("normal", "Sorry, an error occurred: " + e); 100 LoaderException le = new LoaderException("Exception: ", (Throwable ) e); 101 throw le; 102 } 104 if (doc != null) { 105 NodeList tagRestartCounter = doc.getElementsByTagName("loaderJob"); 106 if (tagRestartCounter.getLength() != 0) { 107 NamedNodeMap attrs = tagRestartCounter.item(0).getAttributes(); 108 Node nodeResult = attrs.getNamedItem("logMode"); 109 if (nodeResult != null) 110 this.strDefaultLogMode = nodeResult.getNodeValue(); 111 112 nodeResult = attrs.getNamedItem("objectIDIncrement"); 113 String strIncrement = ""; 114 if (nodeResult != null) 115 strIncrement = nodeResult.getNodeValue(); 116 if (!strIncrement.equals("")) 117 this.iDefaultObjectIDIncrement = Integer.parseInt(strIncrement); 118 119 nodeResult = attrs.getNamedItem("objectIDTableName"); 120 if (nodeResult != null) 121 this.strDefaultObjectIDTableName = nodeResult.getNodeValue(); 122 123 nodeResult = attrs.getNamedItem("objectIDColumnName"); 124 if (nodeResult != null) 125 this.strDefaultObjectIDColumnName = nodeResult.getNodeValue(); 126 127 nodeResult = attrs.getNamedItem("dataCutOff"); 129 if (nodeResult != null) 130 this.strDefaultDataCutOff = nodeResult.getNodeValue(); 131 132 nodeResult = attrs.getNamedItem("logTableName"); 133 if (nodeResult != null) 134 this.strLogTableName = nodeResult.getNodeValue(); 135 136 nodeResult = attrs.getNamedItem("logTable"); 137 if (nodeResult != null) 138 this.strLogTable = nodeResult.getNodeValue(); 139 140 nodeResult = attrs.getNamedItem("logColumnName"); 141 if (nodeResult != null) 142 this.strLogColumnName = nodeResult.getNodeValue(); 143 144 nodeResult = attrs.getNamedItem("logRowNumber"); 145 if (nodeResult != null) 146 this.strLogRowNumber = nodeResult.getNodeValue(); 147 148 nodeResult = attrs.getNamedItem("logOriginalValue"); 149 if (nodeResult != null) 150 this.strLogOriginalValue = nodeResult.getNodeValue(); 151 152 nodeResult = attrs.getNamedItem("logNewValue"); 153 if (nodeResult != null) 154 this.strLogNewValue = nodeResult.getNodeValue(); 155 156 nodeResult = attrs.getNamedItem("logImportDefinitionName"); 157 if (nodeResult != null) 158 this.strLogImportDefinitionName = nodeResult.getNodeValue(); 159 160 nodeResult = attrs.getNamedItem("logOperationName"); 161 if (nodeResult != null) 162 this.strLogOperationName = nodeResult.getNodeValue(); 163 164 nodeResult = attrs.getNamedItem("logTypeName"); 165 if (nodeResult != null) 166 this.strLogTypeName = nodeResult.getNodeValue(); 167 nodeResult = attrs.getNamedItem("logTime"); 169 if (nodeResult != null) 170 this.strLogTime = nodeResult.getNodeValue(); 171 172 nodeResult = attrs.getNamedItem("logPrimaryKeyValue"); 173 if (nodeResult != null) 174 this.strLogFailedStatemet = nodeResult.getNodeValue(); 175 177 nodeResult = attrs.getNamedItem("objectIDNameColumnName"); 178 if (nodeResult != null) 179 this.strDefaultObjectIDNameColumnName = nodeResult.getNodeValue(); 180 181 nodeResult = attrs.getNamedItem("objectIDNameColumnValue"); 182 if (nodeResult != null) 183 this.strDefaultObjectIDNameColumnValue = nodeResult.getNodeValue(); 184 185 nodeResult = attrs.getNamedItem("onErrorContinue"); 186 if (nodeResult != null) 187 this.bDefaultOnErrorContinue = (new Boolean (nodeResult.getNodeValue())).booleanValue(); 188 189 nodeResult = attrs.getNamedItem("commit"); 190 if (nodeResult != null) 191 this.bDefaultCommit = (new Boolean (nodeResult.getNodeValue())).booleanValue(); 192 193 nodeResult = attrs.getNamedItem("userID"); 194 if (nodeResult != null) 195 this.strDefaultUserID = nodeResult.getNodeValue(); 196 197 nodeResult = attrs.getNamedItem("logDir"); 198 if (nodeResult != null) 199 this.strDefaultLogDir = nodeResult.getNodeValue(); 200 201 nodeResult = attrs.getNamedItem("logFile"); 202 if (nodeResult != null) 203 this.strDefaultLogFile = nodeResult.getNodeValue(); 204 205 nodeResult = attrs.getNamedItem("vendorConfig"); 206 if (nodeResult != null) 207 this.strDefaultVendorConfig = nodeResult.getNodeValue(); 208 209 nodeResult = attrs.getNamedItem("objectIDAutoCreate"); 210 if (nodeResult != null) 211 this.bDefaultObjectIDAutoCreate = (new Boolean (nodeResult.getNodeValue())).booleanValue(); 212 213 nodeResult = attrs.getNamedItem("objectIDStartValue"); 214 if (nodeResult != null) 215 this.iDefaultObjectIDStartValue = Integer.parseInt(nodeResult.getNodeValue()); 216 217 nodeResult = attrs.getNamedItem("commitCount"); 218 if (nodeResult != null) 219 this.iLoaderJobCommitCount = Integer.parseInt(nodeResult.getNodeValue()); 220 221 nodeResult = attrs.getNamedItem("oidLogic"); 222 if (nodeResult != null) 223 this.bDefaultOidLogic = (new Boolean (nodeResult.getNodeValue())).booleanValue(); 224 225 nodeResult = attrs.getNamedItem("tableMode"); 226 if (nodeResult != null) 227 this.strDefaultTableMode = nodeResult.getNodeValue(); 228 229 233 237 nodeResult = attrs.getNamedItem("returnCode"); 238 if (nodeResult != null) { 239 if (!ReturnCode.isParameter) 240 ReturnCode.setDefaultErrorReturnCode(Integer.parseInt(nodeResult.getNodeValue())); 241 } 242 243 nodeResult = attrs.getNamedItem("setFetchSize"); 244 if (nodeResult != null) 245 this.setFetchSize = nodeResult.getNodeValue(); 246 247 nodeResult = attrs.getNamedItem("setCursorName"); 248 if (nodeResult != null) 249 this.setCursorName = nodeResult.getNodeValue(); 250 251 } 252 } 253 try { 254 inputStream.reset(); 255 } catch (IOException e) { 256 this.logger.write("normal", "Sorry, an error occurred: " + e); 257 LoaderException le = new LoaderException("IOException: ", (Throwable ) e); 258 throw le; 259 } 260 this.logger.write("full", "\timportLoaderJobAttributes method is finished."); 261 } 262 263 267 public void setSetCursorName(String setCursorName) { 268 this.setCursorName = setCursorName; 269 } 270 271 275 public String getSetCursorName() { 276 return this.setCursorName; 277 } 278 279 283 public void setSetFetchSize(String setFetchSize) { 284 this.setFetchSize = setFetchSize; 285 } 286 287 291 public String getSetFetchSize() { 292 return this.setFetchSize; 293 } 294 295 299 public void setLogger(Logger logger) { 300 this.logger = logger; 301 } 302 303 307 public String getDefaultTableMode() { 308 return this.strDefaultTableMode; 309 } 310 311 315 public String getDefaultDataCutOff() { 316 return this.strDefaultDataCutOff; 317 } 318 319 323 public String getDefaultObjectIDNameColumnValue() { 324 return this.strDefaultObjectIDNameColumnValue; 325 } 326 327 331 public String getDefaultObjectIDNameColumnName() { 332 return this.strDefaultObjectIDNameColumnName; 333 } 334 335 339 public String getDefaultObjectIDColumnName() { 340 return this.strDefaultObjectIDColumnName; 341 } 342 343 347 public String getDefaultObjectIDTableName() { 348 return this.strDefaultObjectIDTableName; 349 } 350 351 355 public int getDefaultObjectIDIncrement() { 356 return this.iDefaultObjectIDIncrement; 357 } 358 359 363 public String getDefaultLogMode() { 364 return this.strDefaultLogMode; 365 } 366 369 public void setDefaultLogMode(String logMode) { 370 this.strDefaultLogMode = logMode; 371 } 372 373 377 public boolean getDefaultOidLogic() { 378 return this.bDefaultOidLogic; 379 } 380 381 385 public int getDefaultCommitCount() { 386 return this.iDefaultCommitCount; 387 } 388 389 393 public int getLoaderJobCommitCount() { 394 return this.iLoaderJobCommitCount; 395 } 396 397 401 public int getDefaultObjectIDStartValue() { 402 return this.iDefaultObjectIDStartValue; 403 } 404 405 409 public boolean getDefaultObjectIDAutoCreate() { 410 return this.bDefaultObjectIDAutoCreate; 411 } 412 413 417 public String getDefaultVendorConfig() { 418 return this.strDefaultVendorConfig; 419 } 420 421 425 public String getDefaultLogFile() { 426 return this.strDefaultLogFile; 427 } 428 429 433 public String getDefaultLogDir() { 434 return this.strDefaultLogDir; 435 } 436 437 441 public String getDefaultUserID() { 442 return this.strDefaultUserID; 443 } 444 445 449 public boolean getDefaultCommit() { 450 return this.bDefaultCommit; 451 } 452 453 457 public boolean getDefaultOnErrorContinue() { 458 return this.bDefaultOnErrorContinue; 459 } 460 461 public void setDefaultOnErrorContinue(boolean value) { 462 this.bDefaultOnErrorContinue = value; 463 } 464 465 469 public String getLogTableName() { 470 return this.strLogTableName; 471 } 472 473 477 public String getLogTable() { 478 return this.strLogTable; 479 } 480 481 485 public String getLogColumnName() { 486 return this.strLogColumnName; 487 } 488 489 493 public String getLogRowNumber() { 494 return this.strLogRowNumber; 495 } 496 497 501 public String getLogOriginalValue() { 502 return this.strLogOriginalValue; 503 } 504 505 509 public String getLogNewValue() { 510 return this.strLogNewValue; 511 } 512 513 517 public String getLogImportDefinitionName() { 518 return this.strLogImportDefinitionName; 519 } 520 521 525 public String getLogOperationName() { 526 return this.strLogOperationName; 527 } 528 529 533 public String getLogTypeName() { 534 return this.strLogTypeName; 535 } 536 537 541 public String getLogFailedStatement() { 542 return this.strLogFailedStatemet; 543 } 544 545 549 public String getLogTime() { 550 return this.strLogTime; 551 } 552 553 } 554 | Popular Tags |