⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countercolumns.java

📁 数据仓库工具
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/**
  CounterColumns - insert auto increment values in target counter columns.
    Copyright (C) 2002-2003  Together
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 CounterColumns.java
 Date: 11.03.2003.
 @version 1.1.0
 @author: Milosevic Sinisa sinisa@prozone.co.yu
 @author: Radoslav Dutina rale@prozone.co.yu
 */

package org.webdocwf.util.loader;

import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import java.sql.Connection;
import java.math.BigDecimal;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.ResultSet;
import org.webdocwf.util.loader.logging.Logger;

/**
 *
 * CounterColumns - insert auto increment values in target counter columns.
 */
public class CounterColumns {

  private String counterTableName = null;
  private String counterNameColumn = null;
  private String counterValueColumn = null;

  private Hashtable counterName;
  private Hashtable counterStartValue;
  private Hashtable counterIncrement;
  private Hashtable targetColumnName;
  private Hashtable valueMode;
  private Hashtable counterStartValueReset;
  private Hashtable targetColumnTyp;

//subCounter columns
  private Hashtable subCounterName;
  private Hashtable subCounterStartValue;
  private Hashtable subCounterIncrement;
  private Hashtable subTargetColumnName;
  private Hashtable subValueMode;
  private Hashtable subCounterKeyColumns;
  private Hashtable subCounterKeyValues;
  private Hashtable subCounterKeyColumnsTyp;
  private Hashtable subTargetColumnTyp;

  private Vector vecCounterName = new Vector();
  private Vector vecCounterIncrement = new Vector();
  private Vector vecCounterStartValue = new Vector();
  private Vector vecTargetColumnName = new Vector();
  private Vector vecValueMode = new Vector();
  private Vector vecCounterStartValueReset = new Vector();
  private Vector vecTargetTableName = new Vector();
  private Vector vecTargetTableID = new Vector();

  private Vector vecSubCounterName = new Vector();
  private Vector vecSubCounterIncrement = new Vector();
  private Vector vecSubCounterStartValue = new Vector();
  private Vector vecSubTargetTableName = new Vector();
  private Vector vecSubTargetTableID = new Vector();
  private Vector vecSubTargetColumnName = new Vector();
  private Vector vecSubValueMode = new Vector();
  private Vector vecSubKeyColumns = new Vector();
  private Vector vecSubKeyColumnsTyp = new Vector();

  private Hashtable currentCounterValue;

  //caching the subcounter value
  private Hashtable subCounterCache = new Hashtable();
  private Logger logger;

  /**
   * Empty constructor of CounterColumns class
   */
  public CounterColumns() {

    this.counterTableName = null;
    this.counterNameColumn = null;
    this.counterValueColumn = null;
    this.counterName = new Hashtable();
    this.counterStartValue = new Hashtable();
    this.counterIncrement = new Hashtable();
    this.targetColumnName = new Hashtable();
    this.targetColumnTyp = new Hashtable();
    this.valueMode = new Hashtable();
    this.counterStartValueReset = new Hashtable();

    this.subCounterName = new Hashtable();
    this.subCounterStartValue = new Hashtable();
    this.subCounterIncrement = new Hashtable();
    this.subTargetColumnName = new Hashtable();
    this.subValueMode = new Hashtable();
    this.subCounterKeyColumns = new Hashtable();
    this.subCounterKeyValues = new Hashtable();
    this.subCounterKeyColumnsTyp = new Hashtable();
    this.subTargetColumnTyp = new Hashtable();

    this.vecCounterName = new Vector();
    this.vecCounterIncrement = new Vector();
    this.vecCounterStartValue = new Vector();
    this.vecTargetColumnName = new Vector();
    this.vecValueMode = new Vector();
    this.vecCounterStartValueReset = new Vector();
    this.vecTargetTableName = new Vector();
    this.vecTargetTableID = new Vector();
    this.currentCounterValue = new Hashtable();

    this.vecSubCounterName = new Vector();
    this.vecSubCounterIncrement = new Vector();
    this.vecSubCounterStartValue = new Vector();
    this.vecSubTargetTableName = new Vector();
    this.vecSubTargetTableID = new Vector();
    this.vecSubTargetColumnName = new Vector();
    this.vecSubValueMode = new Vector();
    this.vecSubKeyColumns = new Vector();
    this.vecSubKeyColumnsTyp = new Vector();
  }

  /**
   * This method set logger object
   */
  public void setLogger(Logger logger) {
    this.logger = logger;
  }

  /**
   * This method read value of counterTableName parameter
   * @return string name of counter table
   */
  public String getCounterTableName() {
    return this.counterTableName;
  }

  /**
   * This method read value of counterValueColumn parameter
   * @return String name of column in counter table with current values of each counter
   */
  public String getCounterValueColumn() {
    return this.counterValueColumn;
  }

  /**
   * This method read value of counterNameColumn parameter
   * @return String name of column in counter table with counter names.
   */
  public String getCounterNameColumn() {
    return this.counterNameColumn;
  }

  /**
   * This method sets the value of counterNameColumn parameter
   * @param nameColumn is name of the column
   */
  public void setCounterNameColumn(String nameColumn) {
    this.counterNameColumn = nameColumn;
  }

  /**
   * This method sets the value of counterValueColumn parameter
   * @param valueColumn is value of the column
   */
  public void setCounterValueColumn(String valueColumn) {
    this.counterValueColumn = valueColumn;
  }

  /**
   * This method sets the value of counterTableName parameter
   * @param tableName is table name
   */
  public void setCounterTableName(String tableName) {
    this.counterTableName = tableName;
  }

  /**
   * This method sets the value of:
   * counterTableName, counterNameColumn and counterValueColumn parameters
   * @param doc represents Object document
   * @param importJob represents current import job
   */
  public void readConstantColumnAttributes(Document doc, int importJob) {
    this.counterTableName = importAttributeValue(doc, "counterColumns", "counterTableName",
                            importJob);
    this.counterNameColumn = importAttributeValue(doc, "counterColumns", "counterNameColumn",
                             importJob);
    this.counterValueColumn = importAttributeValue(doc, "counterColumns", "counterValueColumn",
                              importJob);
  }

  /**
   * This method sets the value of next parameters:
   * vecCounterName, vecCounterIncrement, vecCounterStartValue, vecTargetColumnName,
   * vecValueMode, vecCounterStartValueReset, vecTargetTableName, vecTargetTableID,
   * vecSubCounterName, vecSubCounterIncrement, vecSubCounterStartValue,
   * vecSubTargetTableName, vecSubTargetTableID, vecSubTargetColumnName,
   * vecSubValueMode and vecSubKeyColumns
   * @param doc represents Object document
   * @param importJob represents current import job
   */
  public void readConstantColumnsParameters(Document doc, int importJob) {
    this.vecCounterName = importValue(doc, "counterColumn", "counterName", importJob, null);
    this.vecCounterIncrement = importValue(doc, "counterColumn", "counterIncrement", importJob, "1");
    this.vecCounterStartValue = importValue(doc, "counterColumn", "counterStartValue", importJob,
                                "0");
    this.vecTargetColumnName = importValue(doc, "counterColumn", "targetColumnName", importJob, null);
    this.vecValueMode = importValue(doc, "counterColumn", "valueMode", importJob, "setIfCreated");
    this.vecCounterStartValueReset = importValue(doc, "counterColumn", "counterStartValueReset",
                                     importJob, (new Boolean(false)).toString());
    this.vecTargetTableName = importValue(doc, "counterColumn", "targetTableName", importJob, null);
    this.vecTargetTableID = importValue(doc, "counterColumn", "targetTableID", importJob, null);

    this.vecSubCounterName = importValue(doc, "subCounterColumn", "counterName", importJob, null);
    this.vecSubCounterIncrement = importValue(doc, "subCounterColumn", "counterIncrement",
                                  importJob, "1");
    this.vecSubCounterStartValue = importValue(doc, "subCounterColumn", "counterStartValue",
                                   importJob, "0");
    this.vecSubTargetTableName = importValue(doc, "subCounterColumn", "targetTableName", importJob, null);
    this.vecSubTargetTableID = importValue(doc, "subCounterColumn", "targetTableID", importJob, null);
    this.vecSubTargetColumnName = importValue(doc, "subCounterColumn", "targetColumnName",
                                  importJob, null);
    this.vecSubValueMode = importValue(doc, "subCounterColumn", "valueMode", importJob,
                           "setIfCreated");

    for (int i = 0; i < this.vecSubCounterName.size(); i++) {
      this.vecSubKeyColumns.addElement(importSubCounterKeyValue(doc, "keyColumnName", importJob, i));
    }

  }

  /**
   * This method sets the value of Constant Columns parameters
   * @param tableName is table name
   * @param tableID is table ID
   */
  public void setConstantColumnsParameters(String tableName, String tableID) {

    Vector targetCounterName = new Vector();
    Vector targetCounterIncrement = new Vector();
    Vector targetCounterStartValue = new Vector();
    Vector targetTargetColumnName = new Vector();
    Vector targetValueMode = new Vector();
    Vector targetCounterStartValueReset = new Vector();

    Vector targetSubCounterName = new Vector();
    Vector targetSubCounterIncrement = new Vector();
    Vector targetSubCounterStartValue = new Vector();
    Vector targetSubTargetColumnName = new Vector();
    Vector targetSubValueMode = new Vector();
    Vector targetSubKeyColumns = new Vector();
    Vector subKeyColumnsKey = new Vector();

    for (int i = 0; i < this.vecTargetTableName.size(); i++) {
      if (tableName.equalsIgnoreCase(this.vecTargetTableName.get(i).toString()) &&
          tableID.equalsIgnoreCase(this.vecTargetTableID.get(i).toString())) {
        if (this.vecCounterName.get(i) != null)
          targetCounterName.addElement(this.vecCounterName.get(i).toString());
        else
          targetCounterName.addElement(null);

        if (this.vecCounterStartValue.get(i) != null)
          targetCounterStartValue.addElement(this.vecCounterStartValue.get(i).toString());
        else
          targetCounterStartValue.addElement(null);

        if (this.vecCounterIncrement.get(i) != null)
          targetCounterIncrement.addElement(this.vecCounterIncrement.get(i).toString());
        else
          targetCounterIncrement.addElement(null);

        if (this.vecTargetColumnName.get(i) != null)
          targetTargetColumnName.addElement(this.vecTargetColumnName.get(i).toString());
        else
          targetTargetColumnName.addElement(null);

        if (this.vecValueMode.get(i) != null)
          targetValueMode.addElement(this.vecValueMode.get(i).toString());
        else
          targetValueMode.addElement(null);

        if (this.vecCounterStartValueReset.get(i) != null)
          targetCounterStartValueReset.addElement(this.vecCounterStartValueReset.get(i).toString());
        else
          targetCounterStartValueReset.addElement(null);

//sub counter columns
      }
    }
    for (int i = 0; i < this.vecSubTargetTableName.size(); i++) {
      if (tableName.equalsIgnoreCase(this.vecSubTargetTableName.get(i).toString()) &&
          tableID.equalsIgnoreCase(this.vecSubTargetTableID.get(i).toString())) {
        if (this.vecSubCounterName.get(i) != null) {
          targetSubCounterName.addElement(this.vecSubCounterName.get(i).toString());
        } else
          targetSubCounterName.addElement(null);
        if (this.vecSubCounterStartValue.get(i) != null)
          targetSubCounterStartValue.addElement(this.vecSubCounterStartValue.get(i).toString());
        else
          targetSubCounterStartValue.addElement(null);
        if (this.vecSubCounterIncrement.get(i) != null)
          targetSubCounterIncrement.addElement(this.vecSubCounterIncrement.get(i).toString());
        else
          targetSubCounterIncrement.addElement(null);
        if (this.vecSubTargetColumnName.get(i) != null)
          targetSubTargetColumnName.addElement(this.vecSubTargetColumnName.get(i).toString());
        else
          targetSubTargetColumnName.addElement(null);
        if (this.vecSubValueMode.get(i) != null)
          targetSubValueMode.addElement(this.vecSubValueMode.get(i).toString());
        else
          targetSubValueMode.addElement(null);
        if (this.vecSubKeyColumns.get(i) != null)
          targetSubKeyColumns.addElement(this.vecSubKeyColumns.get(i));
        else
          targetSubKeyColumns.addElement(null);

      }
    }
    this.counterName.put(tableName + "_" + tableID, targetCounterName);
    this.counterIncrement.put(tableName + "_" + tableID, targetCounterIncrement);
    this.counterStartValue.put(tableName + "_" + tableID, targetCounterStartValue);
    this.targetColumnName.put(tableName + "_" + tableID, targetTargetColumnName);
    this.valueMode.put(tableName + "_" + tableID, targetValueMode);
    this.counterStartValueReset.put(tableName + "_" + tableID, targetCounterStartValueReset);

// subCounter columns
    this.subCounterName.put(tableName + "_" + tableID, targetSubCounterName);
    this.subCounterIncrement.put(tableName + "_" + tableID, targetSubCounterIncrement);
    this.subCounterStartValue.put(tableName + "_" + tableID, targetSubCounterStartValue);
    this.subTargetColumnName.put(tableName + "_" + tableID, targetSubTargetColumnName);
    this.subValueMode.put(tableName + "_" + tableID, targetSubValueMode);
    this.subCounterKeyColumns.put(tableName + "_" + tableID, targetSubKeyColumns);

  }

  private int getVectorsSize() {
    if (this.vecCounterName != null)
      return this.vecCounterName.size();
    else
      return 0;
  }

  /**
   * This method read value of counterNames parameter
   * @param tableName is table name
   * @param tableID is table ID
   * @return vector
   */
  public Vector getCounterName(String tableName, String tableID) {
    return (Vector)this.counterName.get(tableName + "_" + tableID);
  }

  /**
   * This method read value of counterIncrement parameter
   * @param tableName is table name
   * @param tableID is table ID
   * @return Vector of increment values for all counter columns in table tableName.
   */
  public Vector getCounterIncrement(String tableName, String tableID) {
    return (Vector)this.counterIncrement.get(tableName + "_" + tableID);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -