001: /*
002: LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
003:
004:
005: Copyright (C) 2003 Together
006:
007: This library is free software; you can redistribute it and/or
008: modify it under the terms of the GNU Lesser General Public
009: License as published by the Free Software Foundation; either
010: version 2.1 of the License, or (at your option) any later version.
011:
012: This library is distributed in the hope that it will be useful,
013: but WITHOUT ANY WARRANTY; without even the implied warranty of
014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: Lesser General Public License for more details.
016:
017: You should have received a copy of the GNU Lesser General Public
018: License along with this library; if not, write to the Free Software
019: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021:
022: package org.webdocwf.util.loader.wizard;
023:
024: import java.io.*;
025:
026: /**
027: * Octopus class sets the input parameters and start the process (Loader)
028: * @author Radoslav Dutina
029: * @version 1.0
030: */
031: public class OctopusLoader {
032: protected WizardFrame wizard = null;
033: private OctopusLoaderData initData;
034:
035: /**
036: * Construct the object of Octopus class with associated parameter
037: * @param initData is object of LoaderOctopusEntry which contain input parameters
038: */
039: public OctopusLoader(OctopusLoaderData initData) {
040: this .initData = initData;
041: }
042:
043: /**
044: * This method start the process (Loaderp)
045: * @return process
046: * @throws java.lang.Exception
047: */
048: public String[] generateAll() throws Exception {
049: int exit = 0;
050: Process process = null;
051: String tmp[] = new String[27];
052: String as[] = null;
053: try {
054: ErrorReader errorReader;
055: BufferedReader buffer;
056: BufferedReader error;
057: String s;
058: int param = 0;
059:
060: if (!initData.getLogMode().equalsIgnoreCase("")) {
061: tmp[param] = "-m";
062: param++;
063: tmp[param] = initData.getLogMode();
064: param++;
065: }
066: if (!initData.getLogFileDir().equalsIgnoreCase("")) {
067: tmp[param] = "-l";
068: param++;
069: tmp[param] = initData.getLogFileDir();
070: param++;
071: }
072: if (!initData.getLogFileName().equalsIgnoreCase("")) {
073: tmp[param] = "-f";
074: param++;
075: tmp[param] = initData.getLogFileName();
076: param++;
077: }
078: if (!initData.getRestartIndicator().equalsIgnoreCase("")) {
079: tmp[param] = "-r";
080: param++;
081: tmp[param] = initData.getRestartIndicator();
082: param++;
083: }
084: if (!initData.getUserId().equalsIgnoreCase("")) {
085: tmp[param] = "-u";
086: param++;
087: tmp[param] = initData.getUserId();
088: param++;
089: }
090:
091: if (!initData.getVariables().equalsIgnoreCase("")) {
092: tmp[param] = "-v";
093: param++;
094: tmp[param] = initData.getVariables();
095: param++;
096: }
097: if (!initData.getVendorConf().equalsIgnoreCase("")) {
098: tmp[param] = "-d";
099: param++;
100: tmp[param] = initData.getVendorConf();
101: param++;
102: }
103: if (!initData.getOnErrorCon().equalsIgnoreCase("")) {
104: tmp[param] = "-e";
105: param++;
106: tmp[param] = initData.getOnErrorCon();
107: param++;
108: }
109:
110: if (!initData.getAdditionalPaths().equalsIgnoreCase("")) {
111: tmp[param] = "-p";
112: param++;
113: tmp[param] = initData.getAdditionalPaths();
114: param++;
115: }
116:
117: if (!initData.getCommitCount().equalsIgnoreCase("")) {
118: tmp[param] = "-c";
119: param++;
120: tmp[param] = initData.getCommitCount();
121: param++;
122: }
123: if (!initData.getReturnCode().equalsIgnoreCase("")) {
124: tmp[param] = "-rc";
125: param++;
126: tmp[param] = initData.getReturnCode();
127: param++;
128: }
129: if (!initData.getIncludeTables().equalsIgnoreCase("")) {
130: tmp[param] = "-it";
131: param++;
132: tmp[param] = initData.getIncludeTables();
133: param++;
134: }
135: if (!initData.getConfJarStructure().equalsIgnoreCase("")) {
136: tmp[param] = "-cjs";
137: param++;
138: tmp[param] = initData.getConfJarStructure();
139: param++;
140: }
141: if (!initData.getPathToXml().equalsIgnoreCase("")) {
142: tmp[param] = " ";
143: param++;
144: tmp[param] = initData.getPathToXml();
145: param++;
146: }
147:
148: as = new String[param];
149: for (int i = 0; i < param; i++) {
150: if (!tmp[i].equalsIgnoreCase("null"))
151: as[i] = tmp[i];
152: }
153: } catch (Exception e) {
154: e.printStackTrace();
155: System.out.println(e.getMessage());
156: throw new Exception(e.getMessage());
157: }
158: return as;
159: }
160:
161: }
|