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

Last change on this file since 36272 was 36192, checked in by kjdon, 2 years ago

searchmetadata_manager renamed to searchmeta_manager to keep it the same as collectionmeta_manager

  • Property svn:keywords set to Author Date Id Revision
File size: 12.7 KB
RevLine 
[4932]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;
[5590]28
[4932]29import java.awt.event.*;
30import java.io.*;
31import javax.swing.event.*;
[8236]32import org.greenstone.gatherer.DebugStream;
[4932]33import org.greenstone.gatherer.Gatherer;
[14038]34import org.greenstone.gatherer.collection.CollectionManager;
35import org.w3c.dom.*;
[5590]36
[14038]37//save()
38import org.greenstone.gatherer.util.XMLTools;
39import javax.swing.*;
[13582]40
[4932]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;
[12809]48 /** These listeners listen to changes in the Design mode so as to allow minimal rebuilding */
[10237]49 static public DesignChangeListener all_change_listener;
50 static public DesignChangeListener buildcol_change_listener;
[22970]51 static public DesignChangeListener databasecol_change_listener;
[4932]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. */
[14038]59 static public SharedByTwoFormatManager format_manager;
[12095]60 /** A manager of general options */
[4932]61 static public GeneralManager general_manager;
[12095]62 /** List of indexes to be built, and the default index.
63 also handles build type and levels */
64 static public IndexingManager index_manager;
[4932]65 /** Contains instructions dealing with the collection language. */
66 static public LanguageManager language_manager;
[12095]67 /** Handling writing extra.dm file */
68 static public MacrosManager macros_manager;
[4932]69 /** A list of plugins to use at build time. */
[8601]70 static public PluginManager plugin_manager;
[12095]71 /** a manager of searching metadata such as index names*/
[36192]72 static public SearchMetadataManager searchmeta_manager;
[4932]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. */
[12095]80 static public TranslationView translation_manager;
[16680]81 /** A manager of configuring depositor metadata */
82 static public DepositorMetadataManager depositormetadata_manager;
[19404]83
[10237]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
[19404]91 /** This indicates whether a minimal or complete build is required.
[19781]92 Minimal means do an incremental rebuild. Complete means do a full rebuild
[19430]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" */
[19404]95 static private boolean isCompleteBuild = false;
96
[19430]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;
[19404]102
[4932]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) {
[8236]107 DebugStream.println("Initializaing CollectionDesignModule.");
[4932]108 change_listener = new CDMChangeListener();
[10237]109 all_change_listener = new DesignChangeListener(ALL);
110 buildcol_change_listener = new DesignChangeListener(BUILDCOL);
[22970]111 databasecol_change_listener = new DesignChangeListener(BUILDCOL);
112
[4932]113 // Parse the collection configuration
114 collect_config = new CollectionConfiguration(collect_config_file);
[8236]115 if (DebugStream.isDebuggingEnabled()) {
[4932]116 collect_config.display();
117 }
[6389]118 loadDesignDetails();
[8236]119 DebugStream.println("CollectionDesignModule loaded.");
[6389]120 }
121
[34205]122
123 public void reloadConfig() {
124 // Parse and load the current collection configuration again
125 // Used after GLI > Edit > collectionConfig.xml > Save to get these edits into GLI.
126
127 collect_config.reload();
128 if (DebugStream.isDebuggingEnabled()) {
129 collect_config.display();
130 }
131 loadDesignDetails();
132 DebugStream.println("CollectionDesignModule loaded.");
133 }
134
[6389]135 /** Reloads the various managers to ensure they have built themselves from the latest details available in the collection configuration class
136 * @see org.greenstone.gatherer.cdm.ClassifierManager
137 * @see org.greenstone.gatherer.cdm.CollectionMetaManager
138 * @see org.greenstone.gatherer.cdm.FormatManager
139 * @see org.greenstone.gatherer.cdm.GeneralManager
140 * @see org.greenstone.gatherer.cdm.IndexManager
141 * @see org.greenstone.gatherer.cdm.LanguageManager
[8601]142 * @see org.greenstone.gatherer.cdm.PluginManager
[6389]143 * @see org.greenstone.gatherer.cdm.SubcollectionIndexManager
144 * @see org.greenstone.gatherer.cdm.SubcollectionManager
145 * @see org.greenstone.gatherer.cdm.SuperCollectionManager
146 * @see org.greenstone.gatherer.cdm.TranslationView
147 */
[8002]148 private void loadDesignDetails() {
[4932]149 // Create the command information managers, registering the config file with each as necessary
150 language_manager = new LanguageManager(collect_config.getLanguages());
151 collectionmeta_manager = new CollectionMetaManager();
152 classifier_manager = new ClassifierManager();
153 general_manager = new GeneralManager();
[12095]154 macros_manager = new MacrosManager();
155 index_manager = new IndexingManager();
[8601]156 plugin_manager = new PluginManager();
[4932]157 subcollection_manager = new SubcollectionManager();
158 subcollectionindex_manager = new SubcollectionIndexManager(collect_config.getSubIndexes());
159 supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
[36192]160 searchmeta_manager = new SearchMetadataManager();
[16680]161 depositormetadata_manager = new DepositorMetadataManager();
[12095]162 translation_manager = new TranslationView();
[14038]163 if (Gatherer.GS3) {
164 format_manager = new Format4gs3Manager();
165 } else {
166 format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
[4932]167 }
[14038]168 }
[6389]169
[4932]170 /** This method deconstructs each of the managers, causing them to dispose of their controls.
171 */
172 public void destroy() {
173 // Remove references from persistant listeners.
174 classifier_manager.destroy();
175 classifier_manager = null;
[36192]176 searchmeta_manager.destroy();
177 searchmeta_manager = null;
[4932]178 format_manager.destroy();
179 format_manager = null;
[14038]180// format_4gs3_manager.destroy();
181// format_4gs3_manager = null;
[4932]182 general_manager.destroy();
183 general_manager = null;
184 index_manager.destroy();
185 index_manager = null;
186 language_manager.destroy();
187 language_manager = null;
188 plugin_manager.destroy();
189 plugin_manager = null;
190 subcollection_manager.destroy();
191 subcollection_manager = null;
192 supercollection_manager.destroy();
193 supercollection_manager = null;
[16680]194 depositormetadata_manager.destroy();
195 depositormetadata_manager = null;
[12095]196 translation_manager.destroy();
197 translation_manager = null;
[4932]198 }
199
[6389]200 /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
201 * @param mode the new mode as an int
[4932]202 */
[6389]203 public void modeChanged(int mode) {
[32704]204 if (plugin_manager != null) plugin_manager.modeChanged(mode);
205 if(classifier_manager != null) classifier_manager.modeChanged(mode);
206 if(subcollection_manager != null) subcollection_manager.modeChanged(mode);
207 if(supercollection_manager != null) supercollection_manager.modeChanged(mode);
208 //if(format_manager != null) format_manager.modeChanged(mode);
209 if(index_manager != null) index_manager.modeChanged(mode);
210 if(translation_manager != null) translation_manager.modeChanged(mode);
211 if(general_manager != null) general_manager.modeChanged(mode);
212 if(language_manager != null) language_manager.modeChanged(mode);
[36192]213 if(searchmeta_manager != null) searchmeta_manager.modeChanged(mode);
[32704]214 if(depositormetadata_manager != null) depositormetadata_manager.modeChanged(mode);
[6389]215 }
[4932]216
[5995]217 /** The cdm is considered to be ready if the collect.cfg file was found and parsed and the collection title is not error.
218 * @return true if the collection is ready, false otherwise
219 */
220 public boolean ready() {
221 return collect_config.ready();
222 }
223
[12803]224
[4932]225 /** Cause the current collection configuration to be written out to disk.
226 */
[14679]227 public void save() {
[14237]228 collect_config.saveIfNecessary();
[8597]229 }
[7739]230
[6051]231
[10237]232 public static int getRebuildTypeRequired() {
[19404]233 return rebuildTypeRequired;
[10237]234 }
[19404]235
[10237]236 public static void resetRebuildTypeRequired() {
[19404]237 setRebuildTypeRequired(NOTHING);
[10237]238 }
239 public static void setRebuildTypeRequired(int number) {
[19404]240 rebuildTypeRequired = number;
[10237]241 }
[8249]242
[19404]243 public static boolean isCompleteBuild() {
244 return isCompleteBuild;
245 }
246 public static void setCompleteBuild(boolean icb) {
247 isCompleteBuild = icb;
248 }
249
[19430]250 public static void setImportWasFull( boolean wasFull ) {
251 importWasFull = wasFull;
252 }
253 public static boolean importWasFull() {
254 return importWasFull;
255 }
256 public static void setBuildcolWasFull( boolean wasFull ) {
257 buildcolWasFull = wasFull;
258 }
259 public static boolean buildcolWasFull() {
260 return buildcolWasFull;
261 }
262
[10237]263 /**
264 * What exactly does this do?
265 */
[4932]266 private class CDMChangeListener
267 implements ActionListener, DocumentListener {
[6051]268
[10237]269 /** Gives notification that an event has happened */
[4932]270 public void actionPerformed(ActionEvent event) {
271 Gatherer.c_man.getCollection().setSaved(false);
272 }
273
274 /** Gives notification that an attribute or set of attributes changed. */
275 public void changedUpdate(DocumentEvent e) {
276 Gatherer.c_man.getCollection().setSaved(false);
277 }
[6051]278
[4932]279 /** Gives notification that there was an insert into the document. */
280 public void insertUpdate(DocumentEvent e) {
281 Gatherer.c_man.getCollection().setSaved(false);
282 }
[6051]283
[4932]284 /** Gives notification that a portion of the document has been removed. */
285 public void removeUpdate(DocumentEvent e) {
286 Gatherer.c_man.getCollection().setSaved(false);
287 }
288 }
289}
Note: See TracBrowser for help on using the repository browser.