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: *
028: * OctopusGenerator class sets the input parameters and start the process (LoaderGenerator)
029: * @author Radoslav Dutina
030: * @version 1.0
031: */
032: public class OctopusGenerator {
033: protected WizardFrame wizard = null;
034: private OctopusGeneratorData initData;
035:
036: /**
037: * Construct the object of OctopusGenerator class with associated parameter
038: * @param initData is object of LoaderGeneratorEntry which contain input parameters
039: */
040: public OctopusGenerator(OctopusGeneratorData initData) {
041: this .initData = initData;
042: }
043:
044: /**
045: * This method start the process (LoaderGenerator)
046: * @return process
047: * @throws Exception
048: */
049: public String[] generateAll() throws Exception {
050: int exit = 0;
051: Process process = null;
052: String tmp[] = new String[55];
053: String as[] = null;
054: try {
055: ErrorReader errorReader;
056:
057: BufferedReader buffer;
058: BufferedReader error;
059: String s;
060: int param = 0;
061: if (!initData.getAdditionalPaths().equalsIgnoreCase("")) {
062: AddClassPath.setClassPathString(initData
063: .getAdditionalPaths());
064: }
065: if (!initData.getValueMode().equalsIgnoreCase("")) {
066: tmp[param] = "-m";
067: param++;
068: tmp[param] = initData.getValueMode();
069: param++;
070: }
071: if (!initData.getGeneratorOutput().equalsIgnoreCase("")) {
072: tmp[param] = "-o";
073: param++;
074: tmp[param] = initData.getGeneratorOutput();
075: param++;
076: }
077: if (!initData.getSourceDatabase().equalsIgnoreCase("")) {
078: tmp[param] = "-sdb";
079: param++;
080: tmp[param] = initData.getSourceDatabase();
081: param++;
082: }
083: if (!initData.getSourceType().equalsIgnoreCase("")) {
084: tmp[param] = "-st";
085: param++;
086: tmp[param] = initData.getSourceType();
087: param++;
088: }
089: if (!initData.getSourceUser().equalsIgnoreCase("")) {
090: tmp[param] = "-su";
091: param++;
092: tmp[param] = initData.getSourceUser();
093: param++;
094: }
095: if (!initData.getSourcePassword().equalsIgnoreCase("")) {
096: tmp[param] = "-sp";
097: param++;
098: tmp[param] = initData.getSourcePassword();
099: param++;
100: }
101: if (!initData.getTargetDatabase().equalsIgnoreCase("")) {
102: tmp[param] = "-tdb";
103: param++;
104: tmp[param] = initData.getTargetDatabase();
105: param++;
106: }
107: if (!initData.getTargetType().equalsIgnoreCase("")) {
108: tmp[param] = "-tt";
109: param++;
110: tmp[param] = initData.getTargetType();
111: param++;
112: }
113: if (!initData.getTargetUser().equalsIgnoreCase("")) {
114: tmp[param] = "-tu";
115: param++;
116: tmp[param] = initData.getTargetUser();
117: param++;
118: }
119: if (!initData.getTargetPassword().equalsIgnoreCase("")) {
120: tmp[param] = "-tp";
121: param++;
122: tmp[param] = initData.getTargetPassword();
123: param++;
124: }
125: if (!initData.getDomlPath().equalsIgnoreCase("")) {
126: tmp[param] = "-doml";
127: param++;
128: tmp[param] = initData.getDomlPath();
129: param++;
130: }
131: if (!initData.getPackageName().equalsIgnoreCase("")) {
132: tmp[param] = "-pack";
133: param++;
134: tmp[param] = initData.getPackageName();
135: param++;
136: }
137: if (!initData.getSourceDriverName().equalsIgnoreCase("")) {
138: tmp[param] = "-sdn";
139: param++;
140: tmp[param] = initData.getSourceDriverName();
141: param++;
142: }
143: if (!initData.getTargetDriverName().equalsIgnoreCase("")) {
144: tmp[param] = "-tdn";
145: param++;
146: tmp[param] = initData.getTargetDriverName();
147: param++;
148: }
149: if (initData.getXmlGenerate().equalsIgnoreCase("true")) {
150: tmp[param] = "-xml";
151: param++;
152: tmp[param] = initData.getXmlGenerate();
153: param++;
154: }
155: if (initData.getDomlGenerate().equalsIgnoreCase("true")) {
156: tmp[param] = "-gdoml";
157: param++;
158: tmp[param] = initData.getDomlGenerate();
159: param++;
160: }
161: if (initData.getSqlStmtDropTable().equalsIgnoreCase("true")) {
162: tmp[param] = "-sqlDT";
163: param++;
164: tmp[param] = initData.getSqlStmtDropTable();
165: param++;
166: }
167: if (initData.getSqlStmtDropIntegrity().equalsIgnoreCase(
168: "true")) {
169: tmp[param] = "-sqlDI";
170: param++;
171: tmp[param] = initData.getSqlStmtDropIntegrity();
172: param++;
173: }
174:
175: if (initData.getSqlStmtCreateTable().equalsIgnoreCase(
176: "true")) {
177: tmp[param] = "-sqlCT";
178: param++;
179: tmp[param] = initData.getSqlStmtCreateTable();
180: param++;
181: }
182: if (initData.getSqlStmtCreatePK().equalsIgnoreCase("true")) {
183: tmp[param] = "-sqlCPK";
184: param++;
185: tmp[param] = initData.getSqlStmtCreatePK();
186: param++;
187: }
188: if (initData.getSqlStmtCreateFK().equalsIgnoreCase("true")) {
189: tmp[param] = "-sqlCFK";
190: param++;
191: tmp[param] = initData.getSqlStmtCreateFK();
192: param++;
193: }
194: if (initData.getSqlStmtCreateIndex().equalsIgnoreCase(
195: "true")) {
196: tmp[param] = "-sqlCI";
197: param++;
198: tmp[param] = initData.getSqlStmtCreateIndex();
199: param++;
200: }
201: if (initData.getSqlStmtForAllVendors().equalsIgnoreCase(
202: "true")) {
203: tmp[param] = "-sqlAll";
204: param++;
205: tmp[param] = initData.getSqlStmtForAllVendors();
206: param++;
207: }
208: if (initData.getFullMode().equalsIgnoreCase("true")) {
209: tmp[param] = "-fm";
210: param++;
211: tmp[param] = initData.getFullMode();
212: param++;
213: } else {
214: tmp[param] = "-fm";
215: param++;
216: tmp[param] = initData.getFullMode();
217: param++;
218: }
219: if (!initData.getIncludeTableList().equalsIgnoreCase("")) {
220: tmp[param] = "-it";
221: param++;
222: tmp[param] = initData.getIncludeTableList();
223: param++;
224: }
225: if (!initData.getConfJarStructure().equalsIgnoreCase("")) {
226: tmp[param] = "-cjs";
227: param++;
228: tmp[param] = initData.getConfJarStructure();
229: param++;
230:
231: }
232: if (!initData.getLogMode().equalsIgnoreCase("")) {
233: tmp[param] = "-lm";
234: param++;
235: tmp[param] = initData.getLogMode();
236: param++;
237:
238: }
239: if (!initData.getLogFileDir().equalsIgnoreCase("")) {
240: tmp[param] = "-l";
241: param++;
242: tmp[param] = initData.getLogFileDir();
243: param++;
244:
245: }
246: if (!initData.getLogFileName().equalsIgnoreCase("")) {
247: tmp[param] = "-f";
248: param++;
249: tmp[param] = initData.getLogFileName();
250: param++;
251:
252: }
253:
254: as = new String[param];
255: for (int i = 0; i < param; i++) {
256: if (!tmp[i].equalsIgnoreCase("null"))
257: as[i] = tmp[i];
258: }
259: } catch (Exception e) {
260: e.printStackTrace();
261: System.out.println(e.getMessage());
262: throw new Exception(e.getMessage());
263:
264: }
265: return as;
266: }
267:
268: }
|