001: /**
002: ImportDefinitionElement - ImportDefinition element in xml file.
003:
004: Copyright (C) 2002-2003 Together
005:
006: This library is free software; you can redistribute it and/or
007: modify it under the terms of the GNU Lesser General Public
008: License as published by the Free Software Foundation; either
009: version 2.1 of the License, or (at your option) any later version.
010:
011: This library is distributed in the hope that it will be useful,
012: but WITHOUT ANY WARRANTY; without even the implied warranty of
013: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: Lesser General Public License for more details.
015:
016: You should have received a copy of the GNU Lesser General Public
017: License along with this library; if not, write to the Free Software
018: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019:
020: */package org.webdocwf.util.loader;
021:
022: import java.util.Vector;
023:
024: import org.w3c.dom.Document;
025: import org.webdocwf.util.loader.logging.Logger;
026:
027: /**
028: * Class is wrapper for ImportDefinitionElement tag in XML file.
029: *
030: * @author Zoran Milakovic
031: * @version 1.1
032: */
033: public class ImportDefinitionElement {
034:
035: private Logger logger;
036: private LoaderJobAttrReader loaderJobReader;
037: private CounterColumns counterColumns;
038:
039: String strImportDefinitionName = "";
040: String strImportDefinitionTableName = "";
041: int iImportDefinitionCommitCount;
042: //String strImportDefinitionLogMode = "normal";
043: String strImportDefinitionSelectStatement = "";
044: String strRestartCounterTableName = "";
045: String strRestartCounterImportDefinitionName = "";
046: String strRestartCounterValue = "";
047: boolean bRestartAutoCreate = false;
048: Vector vecRestartCounterSortColumn = new Vector();
049:
050: int iObjectID = 0;
051: int iObjectIDCT = 0;
052: String strObjectIDTableName = "";
053: String strObjectIDColumnName = "";
054:
055: // TOS
056: String strObjectIDNameColumnName = "";
057: String strObjectIDNameColumnValue = "";
058:
059: boolean bObjectIDAutoCreate;
060: int iObjectIDStartValue;
061: // String strLogMode = "";
062: int iCommitCount = 0;
063:
064: //importDefinition copy table
065: String strOnErrorContinueXml = "";
066: String strDefaultCutOffData = "";
067:
068: //copyTable
069: //String strCopyTableLogMode = "normal";
070: String strCopyTableName = "";
071: String strCopyTableSourceTableName = "";
072: String strCopyTableTargetTableName = "";
073: String strCopyTableOidLogic = "false";
074: String strCopyTableOnErrorContinue = "";
075:
076: String strCopyTableCommitCount;
077: int iCopyTableCommitCount;
078:
079: String setFetchSizeID = "";
080: String setCursorNameID = "";
081: String setFetchSizeCT = "";
082: String setCursorNameCT = "";
083:
084: /**
085: * Method importXMLFile is used for setting of global variables
086: * during importing values from XML file.
087: * This method validates the imported data from XML file.
088: * If there is an error Exception "NullPointerException" or "Exception" is thrown.
089: * @param doc Parsed imports XML file.
090: * @param iJobNumber Number of ImportJob tag which is processed.
091: * @throws NullPointerException Constructs a NullPointerException with the specified detail message.
092: * @throws Exception Constructs an Exception with the specified detail message.
093: */
094: public void importXMLFile(Document doc, int iJobNumber)
095: throws NullPointerException, Exception {
096: this .logger.write("full", "\timportXMLFile method is started.");
097: //onErrorContinue
098: this .strOnErrorContinueXml = OctopusXMLUtil
099: .importAttributeValue(doc, "importDefinition",
100: "onErrorContinue", iJobNumber);
101: this .strDefaultCutOffData = OctopusXMLUtil
102: .importAttributeValue(doc, "importDefinition",
103: "dataCutOff", iJobNumber);
104: //importDefinitionName
105: this .strImportDefinitionName = OctopusXMLUtil
106: .importAttributeValue(doc, "importDefinition", "name",
107: iJobNumber);
108: //importDefinitionTableName
109: this .strImportDefinitionTableName = OctopusXMLUtil
110: .importAttributeValue(doc, "importDefinition",
111: "tableName", iJobNumber);
112: //commitCount
113: String strCommitCount = OctopusXMLUtil.importAttributeValue(
114: doc, "importDefinition", "commitCount", iJobNumber);
115: if (!strCommitCount.equals(""))
116: this .iImportDefinitionCommitCount = Integer
117: .parseInt(strCommitCount);
118: else {
119: if (loaderJobReader.getLoaderJobCommitCount() != 0) {
120: this .iImportDefinitionCommitCount = loaderJobReader
121: .getLoaderJobCommitCount();
122: } else {
123: if (this .iCommitCount != 0)
124: this .iImportDefinitionCommitCount = this .iCommitCount;
125: else
126: this .iImportDefinitionCommitCount = loaderJobReader
127: .getDefaultCommitCount();
128: }
129: }
130: //copyTable
131: /*
132: this.strCopyTableLogMode = OctopusXMLUtil.importAttributeValue(doc,
133: "copyTable", "logMode", iJobNumber);
134: if (this.strCopyTableLogMode.equals("")) {
135: this.strCopyTableLogMode = loaderJobReader.getDefaultLogMode();
136: }
137: */
138: this .strCopyTableName = OctopusXMLUtil.importAttributeValue(
139: doc, "copyTable", "name", iJobNumber);
140: this .strCopyTableSourceTableName = OctopusXMLUtil
141: .importAttributeValue(doc, "copyTable",
142: "sourceTableName", iJobNumber);
143: this .strCopyTableTargetTableName = OctopusXMLUtil
144: .importAttributeValue(doc, "copyTable",
145: "targetTableName", iJobNumber);
146: this .strCopyTableOidLogic = OctopusXMLUtil
147: .importAttributeValue(doc, "copyTable", "oidLogic",
148: iJobNumber);
149: this .strCopyTableOnErrorContinue = OctopusXMLUtil
150: .importAttributeValue(doc, "copyTable",
151: "onErrorContinue", iJobNumber);
152: //commitCount
153: String strCopyTableCommitCount = OctopusXMLUtil
154: .importAttributeValue(doc, "copyTable", "commitCount",
155: iJobNumber);
156: if (!strCopyTableCommitCount.equals("")) {
157: this .iCopyTableCommitCount = Integer
158: .parseInt(strCopyTableCommitCount);
159: } else {
160: if (loaderJobReader.getLoaderJobCommitCount() != 0) {
161: this .iCopyTableCommitCount = loaderJobReader
162: .getLoaderJobCommitCount();
163: } else {
164: if (this .iCommitCount != 0)
165: this .iCopyTableCommitCount = this .iCommitCount;
166: else
167: this .iCopyTableCommitCount = loaderJobReader
168: .getDefaultCommitCount();
169: }
170: }
171: String strIncrementCT = OctopusXMLUtil.importAttributeValue(
172: doc, "copyTable", "objectIDIncrement", iJobNumber);
173: if (!strIncrementCT.equals(""))
174: this .iObjectIDCT = Integer.parseInt(strIncrementCT);
175: else
176: this .iObjectIDCT = loaderJobReader
177: .getDefaultObjectIDIncrement();
178:
179: //setFetchSize and setCursorName (importDefinition)
180: this .setFetchSizeID = OctopusXMLUtil.importAttributeValue(doc,
181: "importDefinition", "setFetchSize", iJobNumber);
182: if (this .setFetchSizeID.equalsIgnoreCase(""))
183: this .setFetchSizeID = this .loaderJobReader
184: .getSetFetchSize();
185:
186: this .setCursorNameID = OctopusXMLUtil.importAttributeValue(doc,
187: "importDefinition", "setCursorName", iJobNumber);
188: if (this .setCursorNameID.equalsIgnoreCase(""))
189: this .setCursorNameID = this .loaderJobReader
190: .getSetCursorName();
191:
192: //setFetchSize and setCursorName (copyTable)
193: this .setFetchSizeCT = OctopusXMLUtil.importAttributeValue(doc,
194: "copyTable", "setFetchSize", iJobNumber);
195: if (this .setFetchSizeCT.equalsIgnoreCase(""))
196: this .setFetchSizeCT = this .loaderJobReader
197: .getSetFetchSize();
198:
199: this .setCursorNameCT = OctopusXMLUtil.importAttributeValue(doc,
200: "copyTable", "setCursorName", iJobNumber);
201: if (this .setCursorNameCT.equalsIgnoreCase(""))
202: this .setCursorNameCT = this .loaderJobReader
203: .getSetFetchSize();
204:
205: //importDefinitonLogMode
206: /*
207: this.strImportDefinitionLogMode = OctopusXMLUtil.importAttributeValue(doc,
208: "importDefinition", "logMode", iJobNumber);
209: if (this.strImportDefinitionLogMode.equals("")) {
210: this.strImportDefinitionLogMode = loaderJobReader.getDefaultLogMode();
211: }
212: */
213: //importDefinitionSelectStatement
214: this .strImportDefinitionSelectStatement = OctopusXMLUtil
215: .importAttributeValue(doc, "importDefinition",
216: "selectStatement", iJobNumber);
217: //increment
218: String strIncrement = OctopusXMLUtil.importAttributeValue(doc,
219: "importDefinition", "objectIDIncrement", iJobNumber);
220: if (!strIncrement.equals(""))
221: this .iObjectID = Integer.parseInt(strIncrement);
222: else
223: this .iObjectID = loaderJobReader
224: .getDefaultObjectIDIncrement();
225: //objectIDTableName
226: this .strObjectIDTableName = OctopusXMLUtil
227: .importAttributeValue(doc, "importDefinition",
228: "objectIDTableName", iJobNumber);
229: if (this .strObjectIDTableName.equals(""))
230: this .strObjectIDTableName = loaderJobReader
231: .getDefaultObjectIDTableName();
232: //objectIDColumnName
233: this .strObjectIDColumnName = OctopusXMLUtil
234: .importAttributeValue(doc, "importDefinition",
235: "objectIDColumnName", iJobNumber);
236: if (this .strObjectIDColumnName.equals(""))
237: this .strObjectIDColumnName = loaderJobReader
238: .getDefaultObjectIDColumnName();
239:
240: //TOS
241: this .strObjectIDNameColumnName = OctopusXMLUtil
242: .importAttributeValue(doc, "importDefinition",
243: "objectIDNameColumnName", iJobNumber);
244: this .strObjectIDNameColumnValue = OctopusXMLUtil
245: .importAttributeValue(doc, "importDefinition",
246: "objectIDNameColumnValue", iJobNumber);
247:
248: if (this .strObjectIDNameColumnName.equals("")) {
249: this .strObjectIDNameColumnName = loaderJobReader
250: .getDefaultObjectIDNameColumnName();
251: }
252: if (this .strObjectIDNameColumnValue.equals("")) {
253: this .strObjectIDNameColumnValue = loaderJobReader
254: .getDefaultObjectIDNameColumnValue();
255: }
256:
257: //objectIDAutoCreate
258: String strObjectIDAutoCreate = OctopusXMLUtil
259: .importAttributeValue(doc, "importDefinition",
260: "objectIDAutoCreate", iJobNumber);
261: if (strObjectIDAutoCreate.equals(""))
262: this .bObjectIDAutoCreate = loaderJobReader
263: .getDefaultObjectIDAutoCreate();
264: else
265: this .bObjectIDAutoCreate = (new Boolean(
266: strObjectIDAutoCreate)).booleanValue();
267: if (this .bObjectIDAutoCreate == true) {
268: String strObjectIDStartValue = OctopusXMLUtil
269: .importAttributeValue(doc, "importDefinition",
270: "objectIDStartValue", iJobNumber);
271: if (strObjectIDStartValue.equals(""))
272: this .iObjectIDStartValue = loaderJobReader
273: .getDefaultObjectIDStartValue();
274: else
275: this .iObjectIDStartValue = Integer
276: .parseInt(strObjectIDStartValue);
277: }
278: String strReturnCode = OctopusXMLUtil.importAttributeValue(doc,
279: "importDefinition", "returnCode", iJobNumber);
280: if (!strReturnCode.equals(""))
281: ReturnCode.setErrorReturnCode(Integer
282: .parseInt(strReturnCode));
283: else
284: ReturnCode.setErrorReturnCode(ReturnCode
285: .getDefaultErrorReturnCode());
286: // senka added this check
287: if (this .strImportDefinitionName != "") {
288: this .vecRestartCounterSortColumn = OctopusXMLUtil
289: .importValue(doc, "sortColumn", "entry", iJobNumber);
290: }
291: }
292:
293: /**
294: * Set Logger object
295: * @param logger Logger object which is used for log file
296: */
297: public void setLogger(Logger logger) {
298: this .logger = logger;
299: }
300:
301: /**
302: * Set LoaderJobAttrReader object
303: * @param loader LoaderJobAttrReader object,which stores loaderJob tag attributes
304: */
305: public void setLoaderJob(LoaderJobAttrReader loader) {
306: this.loaderJobReader = loader;
307: }
308: }
|