source: other-projects/FileTransfer-WebSocketPair/testGXTWithGreenstone/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java@ 33053

Last change on this file since 33053 was 33053, checked in by ak19, 5 years ago

I still had some stuff of Nathan Kelly's (FileTransfer-WebSocketPair) sitting on my USB. Had already commited the Themes folder at the time, 2 years back. Not sure if he wanted this additional folder commited. But I didn't want to delete it and decided it will be better off on SVN. When we use his project, if we find we didn't need this test folder, we can remove it from svn then.

File size: 12.0 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 static public DesignChangeListener databasecol_change_listener;
52 /** A list of classifiers to use at build time. */
53 static public ClassifierManager classifier_manager;
54 /** The CollectionConfiguration object on which this CDM will be based. */
55 static public CollectionConfiguration collect_config;
56 /** A manager of collection level metadata. */
57 static public CollectionMetaManager collectionmeta_manager;
58 /** A list of formating strings to use at build time. */
59 static public SharedByTwoFormatManager format_manager;
60 /** A manager of general options */
61 static public GeneralManager general_manager;
62 /** List of indexes to be built, and the default index.
63 also handles build type and levels */
64 static public IndexingManager index_manager;
65 /** Contains instructions dealing with the collection language. */
66 static public LanguageManager language_manager;
67 /** Handling writing extra.dm file */
68 static public MacrosManager macros_manager;
69 /** A list of plugins to use at build time. */
70 static public PluginManager plugin_manager;
71 /** a manager of searching metadata such as index names*/
72 static public SearchMetadataManager searchmetadata_manager;
73 /** Contains: A list of subcollections, (defined on metadatadata), a list of which subcollection indexes to build and the default subcollection index. */
74 static public SubcollectionManager subcollection_manager;
75
76 static public SubcollectionIndexManager subcollectionindex_manager;
77 /** 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. */
78 static public SuperCollectionManager supercollection_manager; // Just cause I could ;p
79 /** The text translation manager. */
80 static public TranslationView translation_manager;
81 /** A manager of configuring depositor metadata */
82 static public DepositorMetadataManager depositormetadata_manager;
83
84 /** These mark what needs to happen when building a collection where ONLY design options have been changed.
85 The build requirements of the higher numbers must include doing everything from the lower numbers. */
86 static final public int ALL = 3;
87 static final public int BUILDCOL = 2;
88 static final public int NOTHING = 0;
89 static private int rebuildTypeRequired = NOTHING; //Rebuild type required if only design options have changed
90
91 /** This indicates whether a minimal or complete build is required.
92 Minimal means do an incremental rebuild. Complete means do a full rebuild
93 Note: This stores preceisely whether the user selected the minimal or full build radio button.
94 Its value does not indicate anything about what gli eventually chose as a result of that "suggestion" */
95 static private boolean isCompleteBuild = false;
96
97 /** These remember which scripts were run for the last build.
98 true indicated 'full-' prefix, false indicates 'incremental-' prefix to the given perl script (import.pl or buildcol.pl)
99 Note: This stores what gli did, regardless of whether minimal or full was requested by the user */
100 static private boolean importWasFull = false;
101 static private boolean buildcolWasFull = false;
102
103 /** 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.
104 * @param collect_config_file the File representing a collection configuration file either in its text (G2) or xml (G3) form
105 */
106 public CollectionDesignManager(File collect_config_file) {
107 DebugStream.println("Initializaing CollectionDesignModule.");
108 change_listener = new CDMChangeListener();
109 all_change_listener = new DesignChangeListener(ALL);
110 buildcol_change_listener = new DesignChangeListener(BUILDCOL);
111 databasecol_change_listener = new DesignChangeListener(BUILDCOL);
112
113 // Parse the collection configuration
114 collect_config = new CollectionConfiguration(collect_config_file);
115 if (DebugStream.isDebuggingEnabled()) {
116 collect_config.display();
117 }
118 loadDesignDetails();
119 DebugStream.println("CollectionDesignModule loaded.");
120 }
121
122 /** Reloads the various managers to ensure they have built themselves from the latest details available in the collection configuration class
123 * @see org.greenstone.gatherer.cdm.ClassifierManager
124 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
125 * @see org.greenstone.gatherer.cdm.FormatManager
126 * @see org.greenstone.gatherer.cdm.GeneralManager
127 * @see org.greenstone.gatherer.cdm.IndexManager
128 * @see org.greenstone.gatherer.cdm.LanguageManager
129 * @see org.greenstone.gatherer.cdm.PluginManager
130 * @see org.greenstone.gatherer.cdm.SubcollectionIndexManager
131 * @see org.greenstone.gatherer.cdm.SubcollectionManager
132 * @see org.greenstone.gatherer.cdm.SuperCollectionManager
133 * @see org.greenstone.gatherer.cdm.TranslationView
134 */
135 private void loadDesignDetails() {
136 // Create the command information managers, registering the config file with each as necessary
137 language_manager = new LanguageManager(collect_config.getLanguages());
138 collectionmeta_manager = new CollectionMetaManager();
139 classifier_manager = new ClassifierManager();
140 general_manager = new GeneralManager();
141 macros_manager = new MacrosManager();
142 index_manager = new IndexingManager();
143 plugin_manager = new PluginManager();
144 subcollection_manager = new SubcollectionManager();
145 subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
146 supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
147 searchmetadata_manager = new SearchMetadataManager();
148 depositormetadata_manager = new DepositorMetadataManager();
149 translation_manager = new TranslationView();
150 if (Gatherer.GS3) {
151 format_manager = new Format4gs3Manager();
152 } else {
153 format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
154 }
155 }
156
157 /** This method deconstructs each of the managers, causing them to dispose of their controls.
158 */
159 public void destroy() {
160 // Remove references from persistant listeners.
161 classifier_manager.destroy();
162 classifier_manager = null;
163 searchmetadata_manager.destroy();
164 searchmetadata_manager = null;
165 format_manager.destroy();
166 format_manager = null;
167// format_4gs3_manager.destroy();
168// format_4gs3_manager = null;
169 general_manager.destroy();
170 general_manager = null;
171 index_manager.destroy();
172 index_manager = null;
173 language_manager.destroy();
174 language_manager = null;
175 plugin_manager.destroy();
176 plugin_manager = null;
177 subcollection_manager.destroy();
178 subcollection_manager = null;
179 supercollection_manager.destroy();
180 supercollection_manager = null;
181 depositormetadata_manager.destroy();
182 depositormetadata_manager = null;
183 translation_manager.destroy();
184 translation_manager = null;
185 }
186
187 /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
188 * @param mode the new mode as an int
189 */
190 public void modeChanged(int mode) {
191 plugin_manager.modeChanged(mode);
192 classifier_manager.modeChanged(mode);
193 subcollection_manager.modeChanged(mode);
194 supercollection_manager.modeChanged(mode);
195 //format_manager.modeChanged(mode);
196 index_manager.modeChanged(mode);
197 translation_manager.modeChanged(mode);
198 general_manager.modeChanged(mode);
199 language_manager.modeChanged(mode);
200 searchmetadata_manager.modeChanged(mode);
201 depositormetadata_manager.modeChanged(mode);
202 }
203
204 /** The cdm is considered to be ready if the collect.cfg file was found and parsed and the collection title is not error.
205 * @return true if the collection is ready, false otherwise
206 */
207 public boolean ready() {
208 return collect_config.ready();
209 }
210
211
212 /** Cause the current collection configuration to be written out to disk.
213 */
214 public void save() {
215 collect_config.saveIfNecessary();
216 }
217
218
219 public static int getRebuildTypeRequired() {
220 return rebuildTypeRequired;
221 }
222
223 public static void resetRebuildTypeRequired() {
224 setRebuildTypeRequired(NOTHING);
225 }
226 public static void setRebuildTypeRequired(int number) {
227 rebuildTypeRequired = number;
228 }
229
230 public static boolean isCompleteBuild() {
231 return isCompleteBuild;
232 }
233 public static void setCompleteBuild(boolean icb) {
234 isCompleteBuild = icb;
235 }
236
237 public static void setImportWasFull( boolean wasFull ) {
238 importWasFull = wasFull;
239 }
240 public static boolean importWasFull() {
241 return importWasFull;
242 }
243 public static void setBuildcolWasFull( boolean wasFull ) {
244 buildcolWasFull = wasFull;
245 }
246 public static boolean buildcolWasFull() {
247 return buildcolWasFull;
248 }
249
250 /**
251 * What exactly does this do?
252 */
253 private class CDMChangeListener
254 implements ActionListener, DocumentListener {
255
256 /** Gives notification that an event has happened */
257 public void actionPerformed(ActionEvent event) {
258 Gatherer.c_man.getCollection().setSaved(false);
259 }
260
261 /** Gives notification that an attribute or set of attributes changed. */
262 public void changedUpdate(DocumentEvent e) {
263 Gatherer.c_man.getCollection().setSaved(false);
264 }
265
266 /** Gives notification that there was an insert into the document. */
267 public void insertUpdate(DocumentEvent e) {
268 Gatherer.c_man.getCollection().setSaved(false);
269 }
270
271 /** Gives notification that a portion of the document has been removed. */
272 public void removeUpdate(DocumentEvent e) {
273 Gatherer.c_man.getCollection().setSaved(false);
274 }
275 }
276}
Note: See TracBrowser for help on using the repository browser.