source: gli/trunk/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java@ 19430

Last change on this file since 19430 was 19430, checked in by oranfry, 15 years ago

correcting for whether to copy building to index

  • Property svn:keywords set to Author Date Id Revision
File size: 11.9 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 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26 */
27package org.greenstone.gatherer.cdm;
28
29import java.awt.event.*;
30import java.io.*;
31import javax.swing.event.*;
32import org.greenstone.gatherer.DebugStream;
33import org.greenstone.gatherer.Gatherer;
34import org.greenstone.gatherer.collection.CollectionManager;
35import org.w3c.dom.*;
36
37//save()
38import org.greenstone.gatherer.util.XMLTools;
39import javax.swing.*;
40
41/** This manager provides access to submanagers, which in turn provide tools for the designing of Greenstone collections via the information stored in etc/collect.cfg. This class acts as a hub for the managers that handle specific parts of the configuration such as classifiers, format strings and language settings.
42 * @author John Thompson, Greenstone Digital Library, University of Waikato
43 * @version 2.3d
44 */
45public class CollectionDesignManager {
46 /** This listener listens for any event on any of the components in any of the sub-views, and marks the collection as needing saving if any change occurs. */
47 static public CDMChangeListener change_listener;
48 /** These listeners listen to changes in the Design mode so as to allow minimal rebuilding */
49 static public DesignChangeListener all_change_listener;
50 static public DesignChangeListener buildcol_change_listener;
51 /** A list of classifiers to use at build time. */
52 static public ClassifierManager classifier_manager;
53 /** The CollectionConfiguration object on which this CDM will be based. */
54 static public CollectionConfiguration collect_config;
55 /** A manager of collection level metadata. */
56 static public CollectionMetaManager collectionmeta_manager;
57 /** A list of formating strings to use at build time. */
58 static public SharedByTwoFormatManager format_manager;
59 /** A manager of general options */
60 static public GeneralManager general_manager;
61 /** List of indexes to be built, and the default index.
62 also handles build type and levels */
63 static public IndexingManager index_manager;
64 /** Contains instructions dealing with the collection language. */
65 static public LanguageManager language_manager;
66 /** Handling writing extra.dm file */
67 static public MacrosManager macros_manager;
68 /** A list of plugins to use at build time. */
69 static public PluginManager plugin_manager;
70 /** a manager of searching metadata such as index names*/
71 static public SearchMetadataManager searchmetadata_manager;
72 /** Contains: A list of subcollections, (defined on metadatadata), a list of which subcollection indexes to build and the default subcollection index. */
73 static public SubcollectionManager subcollection_manager;
74
75 static public SubcollectionIndexManager subcollectionindex_manager;
76 /** A supercollection command allows a single search to be conducted across several collections. It is a very basic command and so avoids all the crazy model stuff that exists in most of the design managers. */
77 static public SuperCollectionManager supercollection_manager; // Just cause I could ;p
78 /** The text translation manager. */
79 static public TranslationView translation_manager;
80 /** A manager of configuring depositor metadata */
81 static public DepositorMetadataManager depositormetadata_manager;
82
83 /** These mark what needs to happen when building a collection where ONLY design options have been changed.
84 The build requirements of the higher numbers must include doing everything from the lower numbers. */
85 static final public int ALL = 3;
86 static final public int BUILDCOL = 2;
87 static final public int NOTHING = 0;
88 static private int rebuildTypeRequired = NOTHING; //Rebuild type required if only design options have changed
89
90 /** This indicates whether a minimal or complete build is required.
91 Minimal means do everything with the -incremental flag. Complete means do everything with -removeold
92 Note: This stores preceisely whether the user selected the minimal or full build radio button.
93 Its value does not indicate anything about what gli eventually chose as a result of that "suggestion" */
94 static private boolean isCompleteBuild = false;
95
96 /** These remember which scripts were run for the last build.
97 true indicated 'full-' prefix, false indicates 'incremental-' prefix to the given perl script (import.pl or buildcol.pl)
98 Note: This stores what gli did, regardless of whether minimal or full was requested by the user */
99 static private boolean importWasFull = false;
100 static private boolean buildcolWasFull = false;
101
102 /** Constructor. Loads a certain collection configuration file, which is parsed into a DOM. This model is then registered with the command information managers, each of whom knows how to, and provides controls to, alter certain commands.
103 * @param collect_config_file the File representing a collection configuration file either in its text (G2) or xml (G3) form
104 */
105 public CollectionDesignManager(File collect_config_file) {
106 DebugStream.println("Initializaing CollectionDesignModule.");
107 change_listener = new CDMChangeListener();
108 all_change_listener = new DesignChangeListener(ALL);
109 buildcol_change_listener = new DesignChangeListener(BUILDCOL);
110 // Parse the collection configuration
111 collect_config = new CollectionConfiguration(collect_config_file);
112 if (DebugStream.isDebuggingEnabled()) {
113 collect_config.display();
114 }
115 loadDesignDetails();
116 DebugStream.println("CollectionDesignModule loaded.");
117 }
118
119 /** Reloads the various managers to ensure they have built themselves from the latest details available in the collection configuration class
120 * @see org.greenstone.gatherer.cdm.ClassifierManager
121 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
122 * @see org.greenstone.gatherer.cdm.FormatManager
123 * @see org.greenstone.gatherer.cdm.GeneralManager
124 * @see org.greenstone.gatherer.cdm.IndexManager
125 * @see org.greenstone.gatherer.cdm.LanguageManager
126 * @see org.greenstone.gatherer.cdm.PluginManager
127 * @see org.greenstone.gatherer.cdm.SubcollectionIndexManager
128 * @see org.greenstone.gatherer.cdm.SubcollectionManager
129 * @see org.greenstone.gatherer.cdm.SuperCollectionManager
130 * @see org.greenstone.gatherer.cdm.TranslationView
131 */
132 private void loadDesignDetails() {
133 // Create the command information managers, registering the config file with each as necessary
134 language_manager = new LanguageManager(collect_config.getLanguages());
135 collectionmeta_manager = new CollectionMetaManager();
136 classifier_manager = new ClassifierManager();
137 general_manager = new GeneralManager();
138 macros_manager = new MacrosManager();
139 index_manager = new IndexingManager();
140 plugin_manager = new PluginManager();
141 subcollection_manager = new SubcollectionManager();
142 subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
143 supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
144 searchmetadata_manager = new SearchMetadataManager();
145 depositormetadata_manager = new DepositorMetadataManager();
146 translation_manager = new TranslationView();
147 if (Gatherer.GS3) {
148 format_manager = new Format4gs3Manager();
149 } else {
150 format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
151 }
152 }
153
154 /** This method deconstructs each of the managers, causing them to dispose of their controls.
155 */
156 public void destroy() {
157 // Remove references from persistant listeners.
158 classifier_manager.destroy();
159 classifier_manager = null;
160 searchmetadata_manager.destroy();
161 searchmetadata_manager = null;
162 format_manager.destroy();
163 format_manager = null;
164// format_4gs3_manager.destroy();
165// format_4gs3_manager = null;
166 general_manager.destroy();
167 general_manager = null;
168 index_manager.destroy();
169 index_manager = null;
170 language_manager.destroy();
171 language_manager = null;
172 plugin_manager.destroy();
173 plugin_manager = null;
174 subcollection_manager.destroy();
175 subcollection_manager = null;
176 supercollection_manager.destroy();
177 supercollection_manager = null;
178 depositormetadata_manager.destroy();
179 depositormetadata_manager = null;
180 translation_manager.destroy();
181 translation_manager = null;
182 }
183
184 /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
185 * @param mode the new mode as an int
186 */
187 public void modeChanged(int mode) {
188 plugin_manager.modeChanged(mode);
189 classifier_manager.modeChanged(mode);
190 subcollection_manager.modeChanged(mode);
191 supercollection_manager.modeChanged(mode);
192 //format_manager.modeChanged(mode);
193 index_manager.modeChanged(mode);
194 translation_manager.modeChanged(mode);
195 general_manager.modeChanged(mode);
196 language_manager.modeChanged(mode);
197 searchmetadata_manager.modeChanged(mode);
198 depositormetadata_manager.modeChanged(mode);
199 }
200
201 /** The cdm is considered to be ready if the collect.cfg file was found and parsed and the collection title is not error.
202 * @return true if the collection is ready, false otherwise
203 */
204 public boolean ready() {
205 return collect_config.ready();
206 }
207
208
209 /** Cause the current collection configuration to be written out to disk.
210 */
211 public void save() {
212 collect_config.saveIfNecessary();
213 }
214
215
216 public static int getRebuildTypeRequired() {
217 return rebuildTypeRequired;
218 }
219
220 public static void resetRebuildTypeRequired() {
221 setRebuildTypeRequired(NOTHING);
222 }
223 public static void setRebuildTypeRequired(int number) {
224 rebuildTypeRequired = number;
225 }
226
227 public static boolean isCompleteBuild() {
228 return isCompleteBuild;
229 }
230 public static void setCompleteBuild(boolean icb) {
231 isCompleteBuild = icb;
232 }
233
234 public static void setImportWasFull( boolean wasFull ) {
235 importWasFull = wasFull;
236 }
237 public static boolean importWasFull() {
238 return importWasFull;
239 }
240 public static void setBuildcolWasFull( boolean wasFull ) {
241 buildcolWasFull = wasFull;
242 }
243 public static boolean buildcolWasFull() {
244 return buildcolWasFull;
245 }
246
247 /**
248 * What exactly does this do?
249 */
250 private class CDMChangeListener
251 implements ActionListener, DocumentListener {
252
253 /** Gives notification that an event has happened */
254 public void actionPerformed(ActionEvent event) {
255 Gatherer.c_man.getCollection().setSaved(false);
256 }
257
258 /** Gives notification that an attribute or set of attributes changed. */
259 public void changedUpdate(DocumentEvent e) {
260 Gatherer.c_man.getCollection().setSaved(false);
261 }
262
263 /** Gives notification that there was an insert into the document. */
264 public void insertUpdate(DocumentEvent e) {
265 Gatherer.c_man.getCollection().setSaved(false);
266 }
267
268 /** Gives notification that a portion of the document has been removed. */
269 public void removeUpdate(DocumentEvent e) {
270 Gatherer.c_man.getCollection().setSaved(false);
271 }
272 }
273}
Note: See TracBrowser for help on using the repository browser.