KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > CounterColumns


1 /**
2   CounterColumns - insert auto increment values in target counter columns.
3     Copyright (C) 2002-2003 Together
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8     This library is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11     Lesser General Public License for more details.
12     You should have received a copy of the GNU Lesser General Public
13     License along with this library; if not, write to the Free Software
14     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  CounterColumns.java
16  Date: 11.03.2003.
17  @version 1.1.0
18  @author: Milosevic Sinisa sinisa@prozone.co.yu
19  @author: Radoslav Dutina rale@prozone.co.yu
20  */

21
22 package org.webdocwf.util.loader;
23
24 import java.util.Hashtable JavaDoc;
25 import java.util.Enumeration JavaDoc;
26 import java.util.Vector JavaDoc;
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.NodeList JavaDoc;
29 import org.w3c.dom.Node JavaDoc;
30 import org.w3c.dom.Element JavaDoc;
31 import org.w3c.dom.NamedNodeMap JavaDoc;
32 import java.sql.Connection JavaDoc;
33 import java.math.BigDecimal JavaDoc;
34 import java.sql.Statement JavaDoc;
35 import java.sql.SQLException JavaDoc;
36 import java.sql.ResultSet JavaDoc;
37 import org.webdocwf.util.loader.logging.Logger;
38
39 /**
40  *
41  * CounterColumns - insert auto increment values in target counter columns.
42  */

43 public class CounterColumns {
44
45   private String JavaDoc counterTableName = null;
46   private String JavaDoc counterNameColumn = null;
47   private String JavaDoc counterValueColumn = null;
48
49   private Hashtable JavaDoc counterName;
50   private Hashtable JavaDoc counterStartValue;
51   private Hashtable JavaDoc counterIncrement;
52   private Hashtable JavaDoc targetColumnName;
53   private Hashtable JavaDoc valueMode;
54   private Hashtable JavaDoc counterStartValueReset;
55   private Hashtable JavaDoc targetColumnTyp;
56
57 //subCounter columns
58
private Hashtable JavaDoc subCounterName;
59   private Hashtable JavaDoc subCounterStartValue;
60   private Hashtable JavaDoc subCounterIncrement;
61   private Hashtable JavaDoc subTargetColumnName;
62   private Hashtable JavaDoc subValueMode;
63   private Hashtable JavaDoc subCounterKeyColumns;
64   private Hashtable JavaDoc subCounterKeyValues;
65   private Hashtable JavaDoc subCounterKeyColumnsTyp;
66   private Hashtable JavaDoc subTargetColumnTyp;
67
68   private Vector JavaDoc vecCounterName = new Vector JavaDoc();
69   private Vector JavaDoc vecCounterIncrement = new Vector JavaDoc();
70   private Vector JavaDoc vecCounterStartValue = new Vector JavaDoc();
71   private Vector JavaDoc vecTargetColumnName = new Vector JavaDoc();
72   private Vector JavaDoc vecValueMode = new Vector JavaDoc();
73   private Vector JavaDoc vecCounterStartValueReset = new Vector JavaDoc();
74   private Vector JavaDoc vecTargetTableName = new Vector JavaDoc();
75   private Vector JavaDoc vecTargetTableID = new Vector JavaDoc();
76
77   private Vector JavaDoc vecSubCounterName = new Vector JavaDoc();
78   private Vector JavaDoc vecSubCounterIncrement = new Vector JavaDoc();
79   private Vector JavaDoc vecSubCounterStartValue = new Vector JavaDoc();
80   private Vector JavaDoc vecSubTargetTableName = new Vector JavaDoc();
81   private Vector JavaDoc vecSubTargetTableID = new Vector JavaDoc();
82   private Vector JavaDoc vecSubTargetColumnName = new Vector JavaDoc();
83   private Vector JavaDoc vecSubValueMode = new Vector JavaDoc();
84   private Vector JavaDoc vecSubKeyColumns = new Vector JavaDoc();
85   private Vector JavaDoc vecSubKeyColumnsTyp = new Vector JavaDoc();
86
87   private Hashtable JavaDoc currentCounterValue;
88
89   //caching the subcounter value
90
private Hashtable JavaDoc subCounterCache = new Hashtable JavaDoc();
91   private Logger logger;
92
93   /**
94    * Empty constructor of CounterColumns class
95    */

96   public CounterColumns() {
97
98     this.counterTableName = null;
99     this.counterNameColumn = null;
100     this.counterValueColumn = null;
101     this.counterName = new Hashtable JavaDoc();
102     this.counterStartValue = new Hashtable JavaDoc();
103     this.counterIncrement = new Hashtable JavaDoc();
104     this.targetColumnName = new Hashtable JavaDoc();
105     this.targetColumnTyp = new Hashtable JavaDoc();
106     this.valueMode = new Hashtable JavaDoc();
107     this.counterStartValueReset = new Hashtable JavaDoc();
108
109     this.subCounterName = new Hashtable JavaDoc();
110     this.subCounterStartValue = new Hashtable JavaDoc();
111     this.subCounterIncrement = new Hashtable JavaDoc();
112     this.subTargetColumnName = new Hashtable JavaDoc();
113     this.subValueMode = new Hashtable JavaDoc();
114     this.subCounterKeyColumns = new Hashtable JavaDoc();
115     this.subCounterKeyValues = new Hashtable JavaDoc();
116     this.subCounterKeyColumnsTyp = new Hashtable JavaDoc();
117     this.subTargetColumnTyp = new Hashtable JavaDoc();
118
119     this.vecCounterName = new Vector JavaDoc();
120     this.vecCounterIncrement = new Vector JavaDoc();
121     this.vecCounterStartValue = new Vector JavaDoc();
122     this.vecTargetColumnName = new Vector JavaDoc();
123     this.vecValueMode = new Vector JavaDoc();
124     this.vecCounterStartValueReset = new Vector JavaDoc();
125     this.vecTargetTableName = new Vector JavaDoc();
126     this.vecTargetTableID = new Vector JavaDoc();
127     this.currentCounterValue = new Hashtable JavaDoc();
128
129     this.vecSubCounterName = new Vector JavaDoc();
130     this.vecSubCounterIncrement = new Vector JavaDoc();
131     this.vecSubCounterStartValue = new Vector JavaDoc();
132     this.vecSubTargetTableName = new Vector JavaDoc();
133     this.vecSubTargetTableID = new Vector JavaDoc();
134     this.vecSubTargetColumnName = new Vector JavaDoc();
135     this.vecSubValueMode = new Vector JavaDoc();
136     this.vecSubKeyColumns = new Vector JavaDoc();
137     this.vecSubKeyColumnsTyp = new Vector JavaDoc();
138   }
139
140   /**
141    * This method set logger object
142    */

143   public void setLogger(Logger logger) {
144     this.logger = logger;
145   }
146
147   /**
148    * This method read value of counterTableName parameter
149    * @return string name of counter table
150    */

151   public String JavaDoc getCounterTableName() {
152     return this.counterTableName;
153   }
154
155   /**
156    * This method read value of counterValueColumn parameter
157    * @return String name of column in counter table with current values of each counter
158    */

159   public String JavaDoc getCounterValueColumn() {
160     return this.counterValueColumn;
161   }
162
163   /**
164    * This method read value of counterNameColumn parameter
165    * @return String name of column in counter table with counter names.
166    */

167   public String JavaDoc getCounterNameColumn() {
168     return this.counterNameColumn;
169   }
170
171   /**
172    * This method sets the value of counterNameColumn parameter
173    * @param nameColumn is name of the column
174    */

175   public void setCounterNameColumn(String JavaDoc nameColumn) {
176     this.counterNameColumn = nameColumn;
177   }
178
179   /**
180    * This method sets the value of counterValueColumn parameter
181    * @param valueColumn is value of the column
182    */

183   public void setCounterValueColumn(String JavaDoc valueColumn) {
184     this.counterValueColumn = valueColumn;
185   }
186
187   /**
188    * This method sets the value of counterTableName parameter
189    * @param tableName is table name
190    */

191   public void setCounterTableName(String JavaDoc tableName) {
192     this.counterTableName = tableName;
193   }
194
195   /**
196    * This method sets the value of:
197    * counterTableName, counterNameColumn and counterValueColumn parameters
198    * @param doc represents Object document
199    * @param importJob represents current import job
200    */

201   public void readConstantColumnAttributes(Document JavaDoc doc, int importJob) {
202     this.counterTableName = importAttributeValue(doc, "counterColumns", "counterTableName",
203                             importJob);
204     this.counterNameColumn = importAttributeValue(doc, "counterColumns", "counterNameColumn",
205                              importJob);
206     this.counterValueColumn = importAttributeValue(doc, "counterColumns", "counterValueColumn",
207                               importJob);
208   }
209
210   /**
211    * This method sets the value of next parameters:
212    * vecCounterName, vecCounterIncrement, vecCounterStartValue, vecTargetColumnName,
213    * vecValueMode, vecCounterStartValueReset, vecTargetTableName, vecTargetTableID,
214    * vecSubCounterName, vecSubCounterIncrement, vecSubCounterStartValue,
215    * vecSubTargetTableName, vecSubTargetTableID, vecSubTargetColumnName,
216    * vecSubValueMode and vecSubKeyColumns
217    * @param doc represents Object document
218    * @param importJob represents current import job
219    */

220   public void readConstantColumnsParameters(Document JavaDoc doc, int importJob) {
221     this.vecCounterName = importValue(doc, "counterColumn", "counterName", importJob, null);
222     this.vecCounterIncrement = importValue(doc, "counterColumn", "counterIncrement", importJob, "1");
223     this.vecCounterStartValue = importValue(doc, "counterColumn", "counterStartValue", importJob,
224                                 "0");
225     this.vecTargetColumnName = importValue(doc, "counterColumn", "targetColumnName", importJob, null);
226     this.vecValueMode = importValue(doc, "counterColumn", "valueMode", importJob, "setIfCreated");
227     this.vecCounterStartValueReset = importValue(doc, "counterColumn", "counterStartValueReset",
228                                      importJob, (new Boolean JavaDoc(false)).toString());
229     this.vecTargetTableName = importValue(doc, "counterColumn", "targetTableName", importJob, null);
230     this.vecTargetTableID = importValue(doc, "counterColumn", "targetTableID", importJob, null);
231
232     this.vecSubCounterName = importValue(doc, "subCounterColumn", "counterName", importJob, null);
233     this.vecSubCounterIncrement = importValue(doc, "subCounterColumn", "counterIncrement",
234                                   importJob, "1");
235     this.vecSubCounterStartValue = importValue(doc, "subCounterColumn", "counterStartValue",
236                                    importJob, "0");
237     this.vecSubTargetTableName = importValue(doc, "subCounterColumn", "targetTableName", importJob, null);
238     this.vecSubTargetTableID = importValue(doc, "subCounterColumn", "targetTableID", importJob, null);
239     this.vecSubTargetColumnName = importValue(doc, "subCounterColumn", "targetColumnName",
240                                   importJob, null);
241     this.vecSubValueMode = importValue(doc, "subCounterColumn", "valueMode", importJob,
242                            "setIfCreated");
243
244     for (int i = 0; i < this.vecSubCounterName.size(); i++) {
245       this.vecSubKeyColumns.addElement(importSubCounterKeyValue(doc, "keyColumnName", importJob, i));
246     }
247
248   }
249
250   /**
251    * This method sets the value of Constant Columns parameters
252    * @param tableName is table name
253    * @param tableID is table ID
254    */

255   public void setConstantColumnsParameters(String JavaDoc tableName, String JavaDoc tableID) {
256
257     Vector JavaDoc targetCounterName = new Vector JavaDoc();
258     Vector JavaDoc targetCounterIncrement = new Vector JavaDoc();
259     Vector JavaDoc targetCounterStartValue = new Vector JavaDoc();
260     Vector JavaDoc targetTargetColumnName = new Vector JavaDoc();
261     Vector JavaDoc targetValueMode = new Vector JavaDoc();
262     Vector JavaDoc targetCounterStartValueReset = new Vector JavaDoc();
263
264     Vector JavaDoc targetSubCounterName = new Vector JavaDoc();
265     Vector JavaDoc targetSubCounterIncrement = new Vector JavaDoc();
266     Vector JavaDoc targetSubCounterStartValue = new Vector JavaDoc();
267     Vector JavaDoc targetSubTargetColumnName = new Vector JavaDoc();
268     Vector JavaDoc targetSubValueMode = new Vector JavaDoc();
269     Vector JavaDoc targetSubKeyColumns = new Vector JavaDoc();
270     Vector JavaDoc subKeyColumnsKey = new Vector JavaDoc();
271
272     for (int i = 0; i < this.vecTargetTableName.size(); i++) {
273       if (tableName.equalsIgnoreCase(this.vecTargetTableName.get(i).toString()) &&
274           tableID.equalsIgnoreCase(this.vecTargetTableID.get(i).toString())) {
275         if (this.vecCounterName.get(i) != null)
276           targetCounterName.addElement(this.vecCounterName.get(i).toString());
277         else
278           targetCounterName.addElement(null);
279
280         if (this.vecCounterStartValue.get(i) != null)
281           targetCounterStartValue.addElement(this.vecCounterStartValue.get(i).toString());
282         else
283           targetCounterStartValue.addElement(null);
284
285         if (this.vecCounterIncrement.get(i) != null)
286           targetCounterIncrement.addElement(this.vecCounterIncrement.get(i).toString());
287         else
288           targetCounterIncrement.addElement(null);
289
290         if (this.vecTargetColumnName.get(i) != null)
291           targetTargetColumnName.addElement(this.vecTargetColumnName.get(i).toString());
292         else
293           targetTargetColumnName.addElement(null);
294
295         if (this.vecValueMode.get(i) != null)
296           targetValueMode.addElement(this.vecValueMode.get(i).toString());
297         else
298           targetValueMode.addElement(null);
299
300         if (this.vecCounterStartValueReset.get(i) != null)
301           targetCounterStartValueReset.addElement(this.vecCounterStartValueReset.get(i).toString());
302         else
303           targetCounterStartValueReset.addElement(null);
304
305 //sub counter columns
306
}
307     }
308     for (int i = 0; i < this.vecSubTargetTableName.size(); i++) {
309       if (tableName.equalsIgnoreCase(this.vecSubTargetTableName.get(i).toString()) &&
310           tableID.equalsIgnoreCase(this.vecSubTargetTableID.get(i).toString())) {
311         if (this.vecSubCounterName.get(i) != null) {
312           targetSubCounterName.addElement(this.vecSubCounterName.get(i).toString());
313         } else
314           targetSubCounterName.addElement(null);
315         if (this.vecSubCounterStartValue.get(i) != null)
316           targetSubCounterStartValue.addElement(this.vecSubCounterStartValue.get(i).toString());
317         else
318           targetSubCounterStartValue.addElement(null);
319         if (this.vecSubCounterIncrement.get(i) != null)
320           targetSubCounterIncrement.addElement(this.vecSubCounterIncrement.get(i).toString());
321         else
322           targetSubCounterIncrement.addElement(null);
323         if (this.vecSubTargetColumnName.get(i) != null)
324           targetSubTargetColumnName.addElement(this.vecSubTargetColumnName.get(i).toString());
325         else
326           targetSubTargetColumnName.addElement(null);
327         if (this.vecSubValueMode.get(i) != null)
328           targetSubValueMode.addElement(this.vecSubValueMode.get(i).toString());
329         else
330           targetSubValueMode.addElement(null);
331         if (this.vecSubKeyColumns.get(i) != null)
332           targetSubKeyColumns.addElement(this.vecSubKeyColumns.get(i));
333         else
334           targetSubKeyColumns.addElement(null);
335
336       }
337     }
338     this.counterName.put(tableName + "_" + tableID, targetCounterName);
339     this.counterIncrement.put(tableName + "_" + tableID, targetCounterIncrement);
340     this.counterStartValue.put(tableName + "_" + tableID, targetCounterStartValue);
341     this.targetColumnName.put(tableName + "_" + tableID, targetTargetColumnName);
342     this.valueMode.put(tableName + "_" + tableID, targetValueMode);
343     this.counterStartValueReset.put(tableName + "_" + tableID, targetCounterStartValueReset);
344
345 // subCounter columns
346
this.subCounterName.put(tableName + "_" + tableID, targetSubCounterName);
347     this.subCounterIncrement.put(tableName + "_" + tableID, targetSubCounterIncrement);
348     this.subCounterStartValue.put(tableName + "_" + tableID, targetSubCounterStartValue);
349     this.subTargetColumnName.put(tableName + "_" + tableID, targetSubTargetColumnName);
350     this.subValueMode.put(tableName + "_" + tableID, targetSubValueMode);
351     this.subCounterKeyColumns.put(tableName + "_" + tableID, targetSubKeyColumns);
352
353   }
354
355   private int getVectorsSize() {
356     if (this.vecCounterName != null)
357       return this.vecCounterName.size();
358     else
359       return 0;
360   }
361
362   /**
363    * This method read value of counterNames parameter
364    * @param tableName is table name
365    * @param tableID is table ID
366    * @return vector
367    */

368   public Vector JavaDoc getCounterName(String JavaDoc tableName, String JavaDoc tableID) {
369     return (Vector JavaDoc)this.counterName.get(tableName + "_" + tableID);
370   }
371
372   /**
373    * This method read value of counterIncrement parameter
374    * @param tableName is table name
375    * @param tableID is table ID
376    * @return Vector of increment values for all counter columns in table tableName.
377    */

378   public Vector JavaDoc getCounterIncrement(String JavaDoc tableName, String JavaDoc tableID) {
379     return (Vector JavaDoc)this.counterIncrement.get(tableName + "_" + tableID);
380   }
381
382   /**
383    * This method read value of counterStartValue parameter
384    * @param tableName is table name
385    * @param tableID is table ID
386    * @return Vector of start values for all counter columns in table tableName.
387    */

388   public Vector JavaDoc getCounterStartValue(String JavaDoc tableName, String JavaDoc tableID) {
389     return (Vector JavaDoc)this.counterStartValue.get(tableName + "_" + tableID);
390   }
391
392   /**
393    * This method read value of targetColumnName parameter
394    * @param tableName is table name
395    * @param tableID is table ID
396    * @return Vector of counter column names for all counter columns in table tableName.
397    */

398   public Vector JavaDoc getTargetColumnName(String JavaDoc tableName, String JavaDoc tableID) {
399     return (Vector JavaDoc)this.targetColumnName.get(tableName + "_" + tableID);
400
401   }
402
403   /**
404    * This method read value of targetColumnTyp parameter
405    * @param tableName is table name
406    * @param tableID is table ID
407    * @return Vector of counter column types for all counter columns in table tableName.
408    */

409   public Vector JavaDoc getTargetColumnTyp(String JavaDoc tableName, String JavaDoc tableID) {
410     return (Vector JavaDoc)this.targetColumnTyp.get(tableName + "_" + tableID);
411
412   }
413
414   /**
415    * This method read value of valueMode parameter
416    * @param tableName is table name
417    * @param tableID is table ID
418    * @return vector
419    */

420   public Vector JavaDoc getValueMode(String JavaDoc tableName, String JavaDoc tableID) {
421     return (Vector JavaDoc)this.valueMode.get(tableName + "_" + tableID);
422   }
423
424   /**
425    * This method read value of counterStartValueReset parameter
426    * @param tableName is table name
427    * @param tableID is table ID
428    * @return vector
429    */

430   public Vector JavaDoc getCounterStartValueReset(String JavaDoc tableName, String JavaDoc tableID) {
431     return (Vector JavaDoc)this.counterStartValueReset.get(tableName + "_" + tableID);
432   }
433
434 //subCounter columns
435
/**
436    * This method read value of subCounterName parameter
437    * @param tableName is table name
438    * @param tableID is table ID
439    * @return vector
440    */

441   public Vector JavaDoc getSubCounterName(String JavaDoc tableName, String JavaDoc tableID) {
442     return (Vector JavaDoc)this.subCounterName.get(tableName + "_" + tableID);
443   }
444
445   /**
446    * This method read value of getSubCounterIncrement parameter
447    * @param tableName is table name
448    * @param tableID is table ID
449    * @return vector
450    */

451   public Vector JavaDoc getSubCounterIncrement(String JavaDoc tableName, String JavaDoc tableID) {
452     return (Vector JavaDoc)this.subCounterIncrement.get(tableName + "_" + tableID);
453   }
454
455   /**
456    * This method read value of getSubCounterStartValue parameter
457    * @param tableName is table name
458    * @param tableID is table ID
459    * @return vector
460    */

461   public Vector JavaDoc getSubCounterStartValue(String JavaDoc tableName, String JavaDoc tableID) {
462     return (Vector JavaDoc)this.subCounterStartValue.get(tableName + "_" + tableID);
463   }
464
465   /**
466    * This method read value of subTargetColumnName parameter
467    * @param tableName is table name
468    * @param tableID is table ID
469    * @return vector
470    */

471   public Vector JavaDoc getSubTargetColumnName(String JavaDoc tableName, String JavaDoc tableID) {
472     return (Vector JavaDoc)this.subTargetColumnName.get(tableName + "_" + tableID);
473
474   }
475
476   /**
477    * This method read value of subTargetColumnTyp parameter
478    * @param tableName is table name
479    * @param tableID is table ID
480    * @return vector
481    */

482   public Vector JavaDoc getSubTargetColumnTyp(String JavaDoc tableName, String JavaDoc tableID) {
483     return (Vector JavaDoc)this.subTargetColumnTyp.get(tableName + "_" + tableID);
484
485   }
486
487   /**
488    * This method read value of subValueMode parameter
489    * @param tableName is table name
490    * @param tableID is table ID
491    * @return vector
492    */

493   public Vector JavaDoc getSubValueMode(String JavaDoc tableName, String JavaDoc tableID) {
494     return (Vector JavaDoc)this.subValueMode.get(tableName + "_" + tableID);
495   }
496
497   /**
498    * This method read value of subCounterKeyColumns parameter
499    * @param tableName is table name
500    * @param tableID is table ID
501    * @return vector
502    */

503   public Vector JavaDoc getSubCounterKeyColumns(String JavaDoc tableName, String JavaDoc tableID) {
504     return (Vector JavaDoc)this.subCounterKeyColumns.get(tableName + "_" + tableID);
505   }
506
507   /**
508    * This method read value of subCounterKeyColumnsTyp parameter
509    * @param tableName is table name
510    * @param tableID is table ID
511    * @return vector
512    */

513   public Vector JavaDoc getSubCounterKeyColumnsTyp(String JavaDoc tableName, String JavaDoc tableID) {
514     return (Vector JavaDoc)this.subCounterKeyColumnsTyp.get(tableName + "_" + tableID);
515   }
516
517   /**
518    * This method read value of subCounterKeyValues parameter
519    * @param tableName is table name
520    * @param tableID is table ID
521    * @return vector
522    */

523   public Vector JavaDoc getSubCounterKeyValues(String JavaDoc tableName, String JavaDoc tableID) {
524     return (Vector JavaDoc)this.subCounterKeyValues.get(tableName + "_" + tableID);
525   }
526
527   /**
528    * This method set value of subCounterKeyValues parameter
529    * @param tableName defines table name
530    * @param tableID defines table ID
531    * @param values is hashtable new key values
532    */

533   public void setSubCounterKeyValues(String JavaDoc tableName, String JavaDoc tableID, Hashtable JavaDoc values) {
534
535     Enumeration JavaDoc keys = values.keys();
536     Vector JavaDoc vecColumns = (Vector JavaDoc)this.subCounterKeyColumns.get(tableName + "_" + tableID);
537     Vector JavaDoc vecValues = new Vector JavaDoc(vecColumns.size());
538
539     String JavaDoc column;
540     for (int i = 0; i < vecColumns.size(); i++) {
541       Vector JavaDoc subValues = new Vector JavaDoc();
542       for (int j = 0; j < ( (Vector JavaDoc)vecColumns.get(i)).size(); j++) {
543         column = ( (Vector JavaDoc)vecColumns.get(i)).get(j).toString();
544         subValues.add(values.get(column));
545       }
546       vecValues.add(subValues);
547     }
548     this.subCounterKeyValues.put(tableName + "_" + tableID, vecValues);
549   }
550
551   /**
552    * This method set values for Counter columns
553    * @param tableName is table name
554    * @param tableID is table ID
555    */

556   public void setCounterValue(String JavaDoc tableName, String JavaDoc tableID) {
557     Vector JavaDoc targetCounterValue = new Vector JavaDoc();
558     Vector JavaDoc oldValues = getCounterValue(tableName, tableID);
559     Vector JavaDoc counterIncrement = getCounterIncrement(tableName, tableID);
560     for (int i = 0; i < counterIncrement.size(); i++) {
561       BigDecimal JavaDoc newValue = new BigDecimal JavaDoc(oldValues.get(i).toString());
562       newValue = newValue.add(new BigDecimal JavaDoc(counterIncrement.get(i).toString()));
563       targetCounterValue.addElement(newValue);
564     }
565     this.currentCounterValue.put(tableName + "_" + tableID, targetCounterValue);
566   }
567
568   /**
569    * This method set values for currentCounterValue parameter
570    * @param tableName is table name
571    * @param tableID is table ID
572    * @return Vector of current counter values for table - tableName
573    */

574   public Vector JavaDoc getCounterValue(String JavaDoc tableName, String JavaDoc tableID) {
575     return (Vector JavaDoc)this.currentCounterValue.get(tableName + "_" + tableID);
576   }
577
578   /**
579    * This method set values for currentCounterValue parameter
580    * @param tableName is table name
581    * @param tableID is table ID
582    * @param conn is connection to target database
583    * @param firstColumn is first column
584    * @throws SQLException
585    */

586   public void setTargetColumnStartValues(String JavaDoc tableName, String JavaDoc tableID, Connection JavaDoc conn,
587       int firstColumn) throws SQLException JavaDoc {
588     Vector JavaDoc values = new Vector JavaDoc();
589     //TODO ZORAN
590
Vector JavaDoc valuesFromTable = readCounter(tableName, tableID, conn, firstColumn);
591     for (int i = 0; i < this.getCounterName(tableName, tableID).size(); i++) {
592       if (this.getCounterStartValueReset(tableName,
593           tableID).get(i).toString().equalsIgnoreCase("true")) {
594         if (this.getCounterStartValue(tableName, tableID).get(i) != null) {
595           BigDecimal JavaDoc newValue = new BigDecimal JavaDoc( (this.getCounterStartValue(tableName,
596                                 tableID)).get(i).toString());
597           values.addElement(newValue);
598         } else
599           values.addElement(null);
600       } else if (this.getCounterStartValueReset(tableName,
601           tableID).get(i).toString().equalsIgnoreCase("false")) {
602         if (this.getCounterStartValue(tableName, tableID).get(i) != null) {
603           BigDecimal JavaDoc newValue = new BigDecimal JavaDoc(valuesFromTable.get(i).toString());
604           values.addElement(newValue);
605         } else
606           values.addElement(null);
607       }
608     }
609     this.currentCounterValue.put(tableName + "_" + tableID, values);
610   }
611
612   /**
613    * Method importValue reads values from desired XML tag and puts them into Vector.
614    * @param doc Parsed import XML file.
615    * @param tagName The name of XML tag.
616    * @param strAttrName The name of tag attribute which reads input strValue.
617    * @param iImportJobItem Number of ImportDefinition tag which is processed.
618    * @param defaultValue The default value of strattrname attribute.
619    * @return Vector of importing values.
620    */

621   private Vector JavaDoc importValue(Document JavaDoc doc, String JavaDoc tagName, String JavaDoc strAttrName,
622       int iImportJobItem, String JavaDoc defaultValue) {
623     Vector JavaDoc strValue = new Vector JavaDoc();
624     NodeList JavaDoc tagBasic = doc.getElementsByTagName("importDefinition");
625     if (tagBasic.getLength() != 0) {
626       Element JavaDoc docFragment = (Element JavaDoc)tagBasic.item(iImportJobItem);
627       NodeList JavaDoc tag = docFragment.getElementsByTagName(tagName);
628       for (int i = 0; i < tag.getLength(); i++) {
629         String JavaDoc nodeValue = "";
630         if (strAttrName != null) {
631           NamedNodeMap JavaDoc attrs = tag.item(i).getAttributes();
632           Node JavaDoc nodeResult = attrs.getNamedItem(strAttrName);
633           if (nodeResult != null)
634             nodeValue = nodeResult.getNodeValue();
635           else
636             nodeValue = defaultValue;
637           strValue.addElement(nodeValue);
638         } else {
639           NodeList JavaDoc nodeText = tag.item(i).getChildNodes();
640           if (nodeText.item(0) != null) {
641             nodeValue = nodeText.item(0).getNodeValue();
642             strValue.addElement(nodeValue);
643           }
644         }
645       }
646     }
647     return strValue;
648   }
649
650   /**
651    * Method importSubCounterKeyValue reads values from strAttrName attribute
652    * XML tag and puts them into Vector.
653    * @param doc Parsed import XML file.
654    * @param strAttrName The name of tag attribute which reads input strValue.
655    * @param iImportJobItem Number of ImportDefinition tag which is processed.
656    * @param iSubCounterItem Number of subCounterColumn tag which is processed.
657    * @return Vector of importing values.
658    */

659   private Vector JavaDoc importSubCounterKeyValue(Document JavaDoc doc, String JavaDoc strAttrName,
660       int iImportJobItem, int iSubCounterItem) {
661     Vector JavaDoc strValue = null;
662     NodeList JavaDoc tagBasic = doc.getElementsByTagName("importDefinition");
663     if (tagBasic.getLength() != 0) {
664       Element JavaDoc docFragment = (Element JavaDoc)tagBasic.item(iImportJobItem);
665       NodeList JavaDoc tag = docFragment.getElementsByTagName("subCounterColumn");
666       if (tag.getLength() != 0) {
667         Element JavaDoc docCounterColumn = (Element JavaDoc)tag.item(iSubCounterItem);
668         NodeList JavaDoc tagSubCounterColumn = docCounterColumn.getElementsByTagName("subCounterKeyColumn");
669         strValue = new Vector JavaDoc();
670         for (int i = 0; i < tagSubCounterColumn.getLength(); i++) {
671           String JavaDoc nodeValue = "";
672           if (strAttrName != null) {
673             NamedNodeMap JavaDoc attrs = tagSubCounterColumn.item(i).getAttributes();
674             Node JavaDoc nodeResult = attrs.getNamedItem(strAttrName);
675             if (nodeResult != null) {
676               nodeValue = nodeResult.getNodeValue();
677             } else
678               nodeValue = null;
679             strValue.addElement(nodeValue);
680