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

Last change on this file since 7183 was 5589, checked in by mdewsnip, 21 years ago

Nearly finished adding tooltips (and thank goodness for that).

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