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

📄 inputparameters.java

📁 数据仓库工具
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
     LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
    Copyright (C) 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
 */

package org.webdocwf.util.loader.generator;

import java.io.File;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;

import org.webdocwf.util.loader.LoaderException;
import org.webdocwf.util.loader.logging.Logger;
import org.webdocwf.util.loader.logging.StandardLogger;
/**
 * InputParameters class sets the input parameters.
 * @author Radoslav Dutina
 * @version 1.0
 */
public class InputParameters {

    private String sourceType = "msql";
    private String targetType = "msql";
    private String sourceDataBase = null;
    private String targetDataBase = null;

    private String valueMode = "Overwrite";
    private String generatorOutput = "";
    private String sourceUser = "";
    private String sourcePassword = "";
    private String targetUser = "";
    private String targetPassword = "";
    private String sourceDriverName = "";
    private String targetDriverName = "";
    private String domlPath = "";

    private String packageName = null;

    private String alterTablePrimaryKey = null;
    private String pathToSourceConf = null;
    private String pathToTargetConf = null;

    //  private String path="conf/OctopusDBVendors.xml";
    private String path = "OctopusDBVendors.xml";
    private SearchXmlFile searchXmlFile = null;

    //sql statements only
    private Vector sqlToGenerate = new Vector();
    private boolean generateSomeSql = false;
    private boolean generateSqlForAllVendors = false;

    private Vector allVendors = new Vector();
    private String generateXml = "false";
    private String generateDoml = "false";
    private String restoreMode = "false";

    //optimized modes
    private boolean fullMode = true;
    private String[] excludedTables = null;

    private Vector includeTableList = new Vector();

    private String confJarStructure = "";

    //oid and version columns
    private String oidColumnName = "oid";
    private String versionColumnName = "version";
    private String oidColumnType = "decimal";
    private String versionColumnType = "bigint";

    private String maxConstraintLength = "";

    //ZK added for new attribute hasSize
    private Hashtable htHasSize = new Hashtable();
    private Hashtable htIsDecimal = new Hashtable();
    private Logger logger;
    //ZK end 

    /**
     * Set hasSize values for db vendor 
     */

    public void setHasSize() throws LoaderException {
        try {
            setLogger();
//            if (this.logger != null) {
//                this.logger.write("full", "\tsetHasSize is started.");
//            }
            SearchXmlFile searchXmlFile = new SearchXmlFile("absolute", getPathToSourceConf(), getConfJarStructure());
            this.htHasSize = searchXmlFile.getHasSize();
//            if (this.logger != null) {
//                this.logger.write("full", "\tsetHasSize is finished.");
//            }

        } catch (Exception ex) {
            
            LoaderException le = new LoaderException("Exception:" + ex.getMessage(), ex);
						if (this.logger != null) {
							this.logger.write("full", "Exception:" + le.getStackTraceAsString());
						}
						throw le;
        }
    }
    /**
     * Return boolean if size for this type must be defined by user or not
     * @param sqlType
     * @return String which represents is this type has size or not
     * @throws LoaderException
     */
    public String getHasSize(String sqlType) throws LoaderException {
        try {
            setLogger();
           // this.logger.write("full", "\tgetHasSize is started.");
            if (htHasSize.containsKey((sqlType).toUpperCase())) {
//                if (this.logger != null) {
//                    this.logger.write("full", "\tgetHasSize is finished.");
//                }
                return this.htHasSize.get((sqlType).toUpperCase()).toString();
            } else {
//                if (this.logger != null) {
//                    this.logger.write("full", "\tgetHasSize is finished.");
//                }
                return "false";
            }

        } catch (Exception e) {
            
            LoaderException le = new LoaderException("Exception:", (Throwable) e);
						if (this.logger != null) {
							this.logger.write("full", "Exception:" + le.getStackTraceAsString());
						}
						throw le;
        }

    }
    /**
     * Set decimal types for this DB vendor
     * @throws LoaderException
     */
    public void setIsDecimal() throws LoaderException {
        try {
            setLogger();
//            if (this.logger != null) {
//                this.logger.write("full", "\tsetIsDecimal is started.");
//            }
            SearchXmlFile searchXmlFile = new SearchXmlFile("absolute", getPathToSourceConf(), getConfJarStructure());
            this.htIsDecimal = searchXmlFile.getIsDecimal();

        } catch (Exception ex) {
            
            LoaderException le = new LoaderException("Exception" + ex.getMessage(), ex);
						if (this.logger != null) {
								this.logger.write("full", "Exception:" + le.getStackTraceAsString());
						}
						throw le;
        }
//        if (this.logger != null) {
//            this.logger.write("full", "\tsetIsDecimal is finished.");
//        }
    }
    /**
     * Return boolean if this string represents decimal type or not
     * @param sqlType
     * @return String which represents is this number decimal or not
     * @throws LoaderException
     */
    public String getIsDecimal(String sqlType) throws LoaderException {
        try {
            setLogger();
//            if (this.logger != null) {
//                this.logger.write("full", "\tgetIsDecimal is started.");
//            }
            if (htIsDecimal.containsKey((sqlType).toUpperCase())) {
                //this.logger.write("full", "\tgetIsDecimal is finished.");
                return this.htIsDecimal.get((sqlType).toUpperCase()).toString();
            } else {
//                if (this.logger != null) {
//                    this.logger.write("full", "\tgetIsDecimal is finished.");
//                }
                return "false";
            }
        } catch (Exception e) {
						LoaderException le = new LoaderException("Exception:" + e.getMessage(), e);
            if (this.logger != null) {
                this.logger.write("full", "Exception:" + le.getStackTraceAsString());
            }
            throw le;
        }

    }

    public void setOidAndVersionColumnName() throws LoaderException {

        try {
            setLogger();
//            if (this.logger != null) {
//                this.logger.write("full", "\tsetOidAndVersionColumnName is started.");
//            }
            SearchXmlFile searchXmlFile = new SearchXmlFile("absolute", getPathToTargetConf(), getConfJarStructure());

            this.oidColumnName = searchXmlFile.getOidDbColumn();
            this.versionColumnName = searchXmlFile.getVersionDbColumn();
            this.oidColumnType = searchXmlFile.getOidDB();
            this.versionColumnType = searchXmlFile.getVersionDb();

        } catch (Exception ex) {
						LoaderException le = new LoaderException("Exception:" + ex.getMessage(), ex);
            if (this.logger != null) {
                this.logger.write("full", "Exception:" + le.getStackTraceAsString());
            }
            throw le;
        }
//        if (this.logger != null) {
//            this.logger.write("full", "\tsetOidAndVersionColumnName is finished.");
//        }
    }

    public String getOidColumnName() {
        return this.oidColumnName;
    }

    public String getVersionColumnName() {
        return this.versionColumnName;
    }

    public String getOidColumnType() {
        return this.oidColumnType;
    }

    public String getVersionColumnType() {
        return this.versionColumnType;
    }

    /**
     * This method set value of includeTableList parameter
     * @param include_table_list is value of parameter
     * @throws LoaderException
     */
    public void setIncludeTableList(String include_table_list) throws LoaderException {
        setLogger();
//        if (this.logger != null) {
//            this.logger.write("full", "\tsetIncludeTableList is started.");
//        }
        if (include_table_list.indexOf(",") != -1) {
            String msg = "\tDelimiter for tables in 'Include Table List' parameter is ';' and not ','";
						LoaderException le = new LoaderException("Exception:", new Exception(msg + "\n"));
            if (this.logger != null) {
                this.logger.write("full", "Exception:" + "\tDelimiter for tables in 'Include Table List' parameter is ';' and not ','"+le.getStackTraceAsString());
            }
            throw le;
        }

        StringTokenizer st = new StringTokenizer(include_table_list, ";");
        while (st.hasMoreTokens()) {
            String tableName = st.nextElement().toString();
            if (tableName.length() > 0)
                this.includeTableList.add(tableName);
        }
//        if (this.logger != null) {
//            this.logger.write("full", "\tsetIncludeTableList is finished.");
//        }
    }

    /**
     * This method read value from includeTableList parameter
     * @return value of parameter
     */
    public Vector getIncludeTableList() {
        return this.includeTableList;
    }

    /**
     * This method set value of restroreMode parameter
     * @param restoreMode is value of parameter
     */
    public void setRestoreMode(String restoreMode) {
        this.restoreMode = restoreMode;
    }

    /**
     * This method read value from restoreMode parameter
     * @return value of parameter
     */
    public String getRestoreMode() {
        return this.restoreMode;
    }

    /**
     * This method set value of fullMode parameter
     * @param full_mode is value of parameter
     */
    public void setFullMode(String full_mode) {
        if (full_mode.equalsIgnoreCase("true"))
            fullMode = true;
        else
            fullMode = false;
    }

    /**
     * This method read value of fullMode parameter
     * @return value of parameter
     */
    public boolean getFullMode() {
        return fullMode;
    }

    /**
     * This method set value of generateXml parameter
     * @param generate_Xml is value of parameter
     */
    public void setGenerateXml(String generate_Xml) {
        this.generateXml = generate_Xml;
    }

    /**
     * This method read value of generateXml parameter
     * @return value of parameter
     */
    public String getGenerateXml() {
        return this.generateXml;
    }

    /**
     * This method read value of  generateDoml parameter
     * @return value of parameter
     */
    public String getGenerateDoml() {
        return this.generateDoml;
    }

    /**
     * This method set value of generateDoml parameter
     * @param generate_Doml is value of parameter
     */

⌨️ 快捷键说明

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