source: trunk/gli/src/org/greenstone/gatherer/gui/BuildOptions.java@ 4529

Last change on this file since 4529 was 4367, checked in by mdewsnip, 21 years ago

Fixed tabbing.

  • Property svn:keywords set to Author Date Id Revision
File size: 10.6 KB
Line 
1package org.greenstone.gatherer.gui;
2/**
3 *#########################################################################
4 *
5 * A component of the Gatherer application, part of the Greenstone digital
6 * library suite from the New Zealand Digital Library Project at the
7 * University of Waikato, New Zealand.
8 *
9 * <BR><BR>
10 *
11 * Author: John Thompson, Greenstone Digital Library, University of Waikato
12 *
13 * <BR><BR>
14 *
15 * Copyright (C) 1999 New Zealand Digital Library Project
16 *
17 * <BR><BR>
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * <BR><BR>
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * <BR><BR>
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the Free Software
35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 *########################################################################
37 */
38import java.io.*;
39import java.util.*;
40import org.greenstone.gatherer.Gatherer;
41import org.greenstone.gatherer.util.ArrayTools;
42import org.greenstone.gatherer.util.Utility;
43/** This data-only class contains all of the import and build options which persist between sessions, which currently is all of them.
44 * @author John Thompson, Greenstone Digital Library, University of Waikato
45 * @version 2.3
46 */
47public class BuildOptions
48 implements Serializable {
49 /** Do we include empty classifications? */
50 public boolean allclassifications = false;
51 /** Have we set an archive directory? */
52 public boolean archivedir = false;
53 /** Have we set a build directory? */
54 public boolean builddir = false;
55 /** Do we want debug information? */
56 public boolean debug = false;
57 /** Have we set a collect directory? */
58 public boolean collectdir = false;
59 /** Do we want the build process to create images as it goes along? */
60 public boolean create_images = false;
61 /** Have we set a groupsize value? */
62 public boolean groupsize = false;
63 /** Do we want the contents of the archive directory zipped? */
64 public boolean gzip = false;
65 /** Have we set an import directory? */
66 public boolean importdir = false;
67 /** Have we selected to build the collection on certain indexes? */
68 public boolean index = false;
69 /** Do we explicitly want to keep the archives dir? */
70 public boolean keepold = false;
71 /** Have we set a maxdocs value? */
72 public boolean maxdocs = false;
73 /** Have we selected a certain mode to build in? */
74 public boolean mode = false;
75 /** Do we build the indexes, but store no compressed text? */
76 public boolean notext = false;
77 /** Have we decided on a OID type? */
78 public boolean oidtype = false;
79 /** Have we set an out file? */
80 public boolean out = false;
81 /** Do we explicitly want to remove the archives dir? */
82 public boolean removeold = false;
83 /** Have we choosen a metadata element to sort on? */
84 public boolean sortmeta = false;
85 /** Have we set a verbosity value? */
86 public boolean verbosity = false;
87 /** How many documents to a hash group in the archive? */
88 public int groupsize_value = 1;
89 /** What is the maximum number of documents to process? */
90 public int maxdocs_value = 1;
91 /** What is the desired level of verbosity? */
92 public byte verbosity_value = 0;
93 /** The archive directory. */
94 public String archivedir_value = "";
95 /** The building directory. */
96 public String builddir_value = "";
97 /** The collect directory. */
98 public String collectdir_value = "";
99 /** The import directory. */
100 public String importdir_value = "";
101 /** The build mode. */
102 public String mode_value = "";
103 /** The OID generation method. */
104 public String oidtype_value = "";
105 /** The name of the file to write std_err to. */
106 public String out_value = "";
107 /** The name of the metadata element to sort the collection by. */
108 public String sortmeta_value = "";
109 /** The names of classifiers to be indexes for. */
110 public String[] index_value = null;
111 /** Element of argument type enumeration. */
112 static final public byte BUILD_ARGS = 0;
113 /** Element of argument type enumeration. */
114 static final public byte IMPORT_ARGS = 1;
115 /** Element of option type enumeration. */
116 static final public byte ALLCLASSIFICATIONS = 0;
117 /** Element of option type enumeration. */
118 static final public byte ARCHIVEDIR = 1;
119 /** Element of option type enumeration. */
120 static final public byte BUILDDIR = 2;
121 /** Element of option type enumeration. */
122 static final public byte DEBUG = 3;
123 /** Element of option type enumeration. */
124 static final public byte COLLECTDIR = 4;
125 /** Element of option type enumeration. */
126 static final public byte CREATEIMAGES = 5;
127 /** Element of option type enumeration. */
128 static final public byte GROUPSIZE = 6;
129 /** Element of option type enumeration. */
130 static final public byte GZIP = 7;
131 /** Element of option type enumeration. */
132 static final public byte IMPORTDIR = 8;
133 /** Element of option type enumeration. */
134 static final public byte INDEX = 9;
135 /** Element of option type enumeration. */
136 static final public byte KEEPOLD = 10;
137 /** Element of option type enumeration. */
138 static final public byte MAXDOCS = 11;
139 /** Element of option type enumeration. */
140 static final public byte MODE = 12;
141 /** Element of option type enumeration. */
142 static final public byte NOTEXT = 13;
143 /** Element of option type enumeration. */
144 static final public byte OIDTYPE = 14;
145 /** Element of option type enumeration. */
146 static final public byte OUT = 15;
147 /** Element of option type enumeration. */
148 static final public byte REMOVEOLD = 16;
149 /** Element of option type enumeration. */
150 static final public byte SORTMETA = 17;
151 /** Element of option type enumeration. */
152 static final public byte VERBOSITY = 18;
153 /** This constructor initializes values by using the current configuration and collect if there is one.
154 */
155 public BuildOptions() {
156 collectdir_value = Utility.getCollectionDir(Gatherer.config.gsdl_path);
157 // If we have a collection open gets its details.
158 if(Gatherer.c_man.ready()) {
159 archivedir_value = Gatherer.c_man.getCollectionArchive();
160 builddir_value = Gatherer.c_man.getCollectionBuild();
161 importdir_value = Gatherer.c_man.getCollectionImport();
162 }
163 }
164 /** This method returns a copy of this current <strong>BuildOptions</strong> object. Tried using stupid <i>Clonable</i> interface but it didn't work.
165 * @return A <strong>BuildOptions</strong> object with the same settings as this one.
166 */
167 public BuildOptions copy() {
168 BuildOptions options = new BuildOptions();
169 options.allclassifications = allclassifications;
170 options.archivedir = archivedir;
171 options.builddir = builddir;
172 options.debug = debug;
173 options.collectdir = collectdir;
174 options.create_images = create_images;
175 options.groupsize = groupsize;
176 options.gzip = gzip;
177 options.importdir = importdir;
178 options.index = index;
179 options.keepold = keepold;
180 options.maxdocs = maxdocs;
181 options.mode = mode;
182 options.notext = notext;
183 options.oidtype = oidtype;
184 options.out = out;
185 options.removeold = removeold;
186 options.sortmeta = sortmeta;
187 options.verbosity = verbosity;
188 options.groupsize_value = groupsize_value;
189 options.maxdocs_value = maxdocs_value;
190 options.verbosity_value = verbosity_value;
191 options.archivedir_value = archivedir_value;
192 options.builddir_value = builddir_value;
193 options.collectdir_value = collectdir_value;
194 options.importdir_value = importdir_value;
195 options.mode_value = mode_value;
196 options.oidtype_value = oidtype_value;
197 options.out_value = out_value;
198 options.sortmeta_value = sortmeta_value;
199 options.index_value = index_value;
200 return options;
201 }
202 /** When called this method returns the required arguments selected by the user. Only those arguments that are selected are returned, and even then some are never returned (i.e -out which is handled within the GShells instead).
203 * @param type The type of process that will recieve these arguments as a <strong>byte</strong>.
204 * @return A <strong>String[]</strong> containing the arguments and any required parameters as set by the user.
205 */
206 public String[] getArguments(byte type) {
207 ArrayList arguments = new ArrayList();
208 if(allclassifications && type == BUILD_ARGS) {
209 arguments.add("-allclassifications");
210 }
211 if(archivedir) {
212 arguments.add("-archivedir");
213 arguments.add(archivedir_value);
214 }
215 if(builddir && type == BUILD_ARGS) {
216 arguments.add("-builddir");
217 arguments.add(builddir_value);
218 }
219 if(debug) {
220 arguments.add("-debug");
221 }
222 if(collectdir) {
223 arguments.add("-collectdir");
224 arguments.add(collectdir_value);
225 }
226 if(create_images && type == BUILD_ARGS) {
227 arguments.add("-create_images");
228 }
229 if(groupsize && type == IMPORT_ARGS) {
230 arguments.add("-groupsize");
231 arguments.add(String.valueOf(groupsize_value));
232 }
233 if(gzip && type == IMPORT_ARGS) {
234 arguments.add("-gzip");
235 }
236 // Always ignore importdir eh?
237 if(false && importdir && type == IMPORT_ARGS) {
238 arguments.add("-importdir");
239 arguments.add(importdir_value);
240 }
241 if(index && type == BUILD_ARGS) {
242 arguments.add("-index");
243 StringBuffer temp = new StringBuffer("");
244 for(int i = 0; i < index_value.length; i++) {
245 temp.append(index_value[i]);
246 temp.append(",");
247 }
248 // Remember to remove extra ','
249 arguments.add(temp.substring(0, temp.length() - 1));
250 }
251 if(keepold) {
252 arguments.add("-keepold");
253 }
254 if(maxdocs) {
255 arguments.add("-maxdocs");
256 arguments.add(String.valueOf(maxdocs_value));
257 }
258 if(mode && type == BUILD_ARGS) {
259 arguments.add("-mode");
260 arguments.add(mode_value);
261 }
262 if(notext && type == BUILD_ARGS) {
263 arguments.add("-no_text");
264 }
265 if(oidtype && type == IMPORT_ARGS) {
266 arguments.add("-OIDtype");
267 arguments.add(oidtype_value);
268 }
269 // Never do out as its handled by the GShell.
270 if(removeold && type == IMPORT_ARGS) {
271 arguments.add("-removeold");
272 }
273 if(sortmeta && type == IMPORT_ARGS) {
274 arguments.add("-sortmeta");
275 arguments.add(sortmeta_value);
276 }
277 if(verbosity) {
278 arguments.add("-verbosity");
279 arguments.add(String.valueOf(verbosity_value));
280 }
281 return ArrayTools.arrayListToStringArray(arguments);
282 }
283}
Note: See TracBrowser for help on using the repository browser.