Changeset 4336


Ignore:
Timestamp:
2003-05-26T16:26:49+12:00 (21 years ago)
Author:
jmt12
Message:

when using a base collection dumps collection icon, and has special case for custom AZList in dls - John

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r4304 r4336  
    8888     /** The collection this manager is managing! */
    8989     private Collection collection = null;
     90     /** The collection_model. */
     91     private FileSystemModel collection_model = null;
     92     /** The workspace model. This becomes invalid on a collection change. */
     93     private FileSystemModel workspace_model = null;
    9094     /** An inner class listener responsible for noting tree changes and resetting saved when they occur. */
    9195     private FMTreeModelListener fm_tree_model_listener = null;
     
    96100     /** The monitor resposible for parsing the import process. */
    97101     private GShellProgressMonitor import_monitor = null;
    98      /** The collection_model. */
    99      private FileSystemModel collection_model = null;
    100      /** The workspace model. This becomes invalid on a collection change. */
    101      private FileSystemModel workspace_model = null;
     102
     103     private int special_case = -1;
    102104     /** The name of the standard lock file. */
    103105     static final public String LOCK_FILE = "gatherer.lck";
     106     static final public int NO_SPECIAL_CASE = -1;
     107     static final public int SPECIAL_DLS = 0;
    104108     /** Constructor. */
    105109     public CollectionManager() {
     
    194198     /** Used to set the current collection to the given collection. Note that this call should -always- be proceeded by a ready call, and if the colection is ready and the saved flag is unset then the user should be prompted to save. Also note that this method creates yet another GShell to run buildcol.pl. */
    195199     public void createCollection(String description, String email, String name, String title, File base_collection_directory, ArrayList metadata_sets) {
     200          special_case = NO_SPECIAL_CASE;
    196201          try {
    197202                // Create a progress monitor.
     
    200205                makeCollection(description, email, name, title);
    201206                progress.setProgress(1);
    202  
     207
    203208                // ACTIVE_DIR/gimport/
    204209                String a_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path) + name + File.separator;
    205                
     210
    206211                // Has to be done before creating greenstone directory metadata manager.
    207212                File gimport_dir_temp = new File(Utility.getImportDir(a_dir)+"temp.dat");
     
    211216                     progress.setNote(get("Gimport_Created"));
    212217                }
    213                
     218
    214219                File gcache_dir_temp = new File(Utility.getCacheDir(a_dir)+"temp.dat");
    215220                File gcache_dir = gcache_dir_temp.getParentFile();
     
    218223                     progress.setNote(get("Gcache_Created"));
    219224                }
    220                
     225
    221226                progress.setProgress(2);
    222227
     
    244249                                     ///ystem.err.println("Found a metadata set. Importing: " + possible_metadata_sets[i].getAbsolutePath());
    245250                                     collection.msm.importMDS(possible_metadata_sets[i], false);
    246                                 }                                   
     251                                }
    247252                          }
    248253                     }
     
    255260                          // Demo collection - part of the DLS
    256261                          if(collection_name.equals(Utility.COLLECTION_DEMO) || collection_name.equals(Utility.COLLECTION_DLS)) {
     262                                special_case = SPECIAL_DLS;
    257263                                String demo_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DEMO_DIRECTORY)).getAbsolutePath();
    258264                                String dls_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DLS_DIRECTORY)).getAbsolutePath();
     
    317323                collection.cdm = new CollectionDesignManager();
    318324                collection.gdm = new GDMManager();
    319                
     325
    320326                progress.setProgress(3);
    321327
     
    841847                installCollection();
    842848                collection.setBuilt(true);
    843                 if(Gatherer.g_man != null) {
    844                      workspace_model = null;
    845                      Gatherer.g_man.collectionChanged(ready());
    846                 }
     849                // If we have a local library running (that we know about) then we ask it to add our newly create collection
     850                System.err.println("Check if we should reset local server.");
     851                if(Gatherer.config.exec_file != null) {
     852                    System.err.println("Local Library Found!");
     853                    Gatherer.g_man.preview_pane.resetServer();
     854                }
     855                else {
     856                    System.err.println("GLI can't recognize a local library.");
     857                }
     858                // Signal collection changed.
     859                workspace_model = null;
     860                Gatherer.g_man.collectionChanged(ready());
    847861                JOptionPane.showMessageDialog(Gatherer.g_man, get("Preview_Ready"), get("Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE);
    848862          }
     
    10931107                          }
    10941108                     }
     1109                     else if(command_lc.startsWith(Utility.CFG_COLLECTIONMETA_ICONCOLLECTION)) {
     1110                          write(out, Utility.CFG_COLLECTIONMETA_ICONCOLLECTION + " \"\"");
     1111                     }
     1112
     1113                     // Just before we try more general parsing there are the special cases to check. These are explicit changes required by some collections to produce sensible results.
     1114                     else if(special_case == SPECIAL_DLS && command_lc.equals("classify      hierarchy -hfile azlist.txt -metadata azlist -sort title -buttonname title -hlist_at_top")) {
     1115                          write(out, "classify AZList -metadata dls.Title -buttonname Title");
     1116                     }
    10951117                     else if(command_lc.startsWith(Utility.CFG_CLASSIFY)) {
    10961118                          StringTokenizer tokenizer = new StringTokenizer(command);
    10971119                          StringBuffer text = new StringBuffer(tokenizer.nextToken());
    10981120                          // Read in the classifier command watching for hfile, metadata and sort arguments.
     1121                          String buttonname = null;
    10991122                          String hfile = null;
    1100                           String metadata = null;
     1123                          String new_metadata = null;
     1124                          String old_metadata = null;
    11011125                          while(tokenizer.hasMoreTokens()) {
    11021126                                String token = tokenizer.nextToken();
     
    11171141                                          if(replacement != null) {
    11181142                                                token = replacement;
    1119                                                 metadata = replacement;
     1143                                                old_metadata = temp_metadata;
     1144                                                new_metadata = replacement;
    11201145                                          }
    11211146                                          else {
     
    11421167                                     }
    11431168                                }
     1169                                else if(token.equals(Utility.CFG_CLASSIFY_BUTTONNAME)) {
     1170                                    buttonname = token;
     1171                                }
    11441172                                text.append(' ');
    11451173                                text.append(token);
     
    11471175                          }
    11481176                          tokenizer = null;
     1177
     1178                          // If we replaced the metadata argument and didn't encounter a buttonname, then add one now pointing back to the old metadata name in order to accomodate macro files which required such names (buttonname is metadata name by default)!
     1179                          if(old_metadata != null && new_metadata != null && buttonname == null) {
     1180                            text.append(' ');
     1181                            text.append(Utility.CFG_CLASSIFY_BUTTONNAME);
     1182                            text.append(' ');
     1183                            text.append(old_metadata);
     1184                          }
    11491185                          command = text.toString();
    11501186                          // Replace the hfile if we found it
    1151                           if(hfile != null && metadata != null) {
    1152                                 command = command.replaceAll(hfile, metadata + ".txt");
     1187                          if(hfile != null && new_metadata != null) {
     1188                                command = command.replaceAll(hfile, new_metadata + ".txt");
    11531189                          }
     1190                          buttonname = null;
    11541191                          hfile = null;
    1155                           metadata = null;
     1192                          new_metadata = null;
     1193                          old_metadata = null;
    11561194                          write(out, command);
    11571195                     }
     
    11661204                                     if(format_command) {
    11671205                                          target = "\\[" + target + "\\]";
    1168                                           replacement = "[" + replacement + "]";
     1206                                          replacement = "{Or}{[" + replacement + "]," + target + "}";
    11691207                                     }
    1170                                      command = command.replaceAll(target, replacement);
     1208                                     command = command.replaceAll(target, replacement);
    11711209                                }
    11721210                          }
Note: See TracChangeset for help on using the changeset viewer.