Changeset 4304 for trunk/gli


Ignore:
Timestamp:
2003-05-23T16:14:15+12:00 (21 years ago)
Author:
jmt12
Message:

hardcoded understanding that dls=demo and doesn't mung format and classify statements

File:
1 edited

Legend:

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

    r4293 r4304  
    253253                          // If the source collection is one of the 'big five' then we know what the metadata set is.
    254254                          String collection_name = col_con.getName();
    255                           if(collection_name.equals(Utility.COLLECTION_DLS)) {
     255                          // Demo collection - part of the DLS
     256                          if(collection_name.equals(Utility.COLLECTION_DEMO) || collection_name.equals(Utility.COLLECTION_DLS)) {
     257                                String demo_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DEMO_DIRECTORY)).getAbsolutePath();
     258                                String dls_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DLS_DIRECTORY)).getAbsolutePath();
    256259                                // Add the dls.mds
    257260                                collection.msm.importMDS(new File(Utility.METADATA_DIR + Utility.DLS_MDS), false);
    258                                 // Add the mappings
    259                                 collection.msm.profiler.addAction(base_collection_directory.getAbsolutePath(), "AZList", "dls.AZList");
    260                                 collection.msm.profiler.addAction(base_collection_directory.getAbsolutePath(), "Keyword", "dls.Keyword");
    261                                 collection.msm.profiler.addAction(base_collection_directory.getAbsolutePath(), "Language", "dls.Language");
    262                                 collection.msm.profiler.addAction(base_collection_directory.getAbsolutePath(), "Organization", "dls.Organization");
    263                                 collection.msm.profiler.addAction(base_collection_directory.getAbsolutePath(), "Subject", "dls.Subject");
    264                                 collection.msm.profiler.addAction(base_collection_directory.getAbsolutePath(), "Title", "dls.Title");
     261                                // Add the mappings for the dls (even if its not present).
     262                                collection.msm.profiler.addAction(dls_directory, "AZList", "dls.AZList");
     263                                collection.msm.profiler.addAction(dls_directory, "Keyword", "dls.Keyword");
     264                                collection.msm.profiler.addAction(dls_directory, "Language", "dls.Language");
     265                                collection.msm.profiler.addAction(dls_directory, "Organization", "dls.Organization");
     266                                collection.msm.profiler.addAction(dls_directory, "Subject", "dls.Subject");
     267                                collection.msm.profiler.addAction(dls_directory, "Title", "dls.Title");
     268                                // Add the mappings for the demo dls (even if its not present).
     269                                collection.msm.profiler.addAction(demo_directory, "AZList", "dls.AZList");
     270                                collection.msm.profiler.addAction(demo_directory, "Keyword", "dls.Keyword");
     271                                collection.msm.profiler.addAction(demo_directory, "Language", "dls.Language");
     272                                collection.msm.profiler.addAction(demo_directory, "Organization", "dls.Organization");
     273                                collection.msm.profiler.addAction(demo_directory, "Subject", "dls.Subject");
     274                                collection.msm.profiler.addAction(demo_directory, "Title", "dls.Title");
    265275                                // Skip the import phase
    266276                                skip_import_phase = true;
     
    10831093                          }
    10841094                     }
     1095                     else if(command_lc.startsWith(Utility.CFG_CLASSIFY)) {
     1096                          StringTokenizer tokenizer = new StringTokenizer(command);
     1097                          StringBuffer text = new StringBuffer(tokenizer.nextToken());
     1098                          // Read in the classifier command watching for hfile, metadata and sort arguments.
     1099                          String hfile = null;
     1100                          String metadata = null;
     1101                          while(tokenizer.hasMoreTokens()) {
     1102                                String token = tokenizer.nextToken();
     1103                                if(token.equals(Utility.CFG_CLASSIFY_HFILE)) {
     1104                                     if(tokenizer.hasMoreTokens()) {
     1105                                          text.append(" ");
     1106                                          text.append(token);
     1107                                          token = tokenizer.nextToken();
     1108                                          hfile = token;
     1109                                     }
     1110                                }
     1111                                else if(token.equals(Utility.CFG_CLASSIFY_METADATA)) {
     1112                                     if(tokenizer.hasMoreTokens()) {
     1113                                          text.append(" ");
     1114                                          text.append(token);
     1115                                          String temp_metadata = tokenizer.nextToken();
     1116                                          String replacement = (String) mappings.get(temp_metadata);
     1117                                          if(replacement != null) {
     1118                                                token = replacement;
     1119                                                metadata = replacement;
     1120                                          }
     1121                                          else {
     1122                                                token = temp_metadata;
     1123                                          }
     1124                                          temp_metadata = null;
     1125                                          replacement = null;
     1126                                     }
     1127                                }
     1128                                else if(token.equals(Utility.CFG_CLASSIFY_SORT)) {
     1129                                     if(tokenizer.hasMoreTokens()) {
     1130                                          text.append(" ");
     1131                                          text.append(token);
     1132                                          String temp_metadata = tokenizer.nextToken();
     1133                                          String replacement = (String) mappings.get(temp_metadata);
     1134                                          if(replacement != null) {
     1135                                                token = replacement;
     1136                                          }
     1137                                          else {
     1138                                                token = temp_metadata;
     1139                                          }
     1140                                          temp_metadata = null;
     1141                                          replacement = null;
     1142                                     }
     1143                                }
     1144                                text.append(' ');
     1145                                text.append(token);
     1146                                token = null;
     1147                          }
     1148                          tokenizer = null;
     1149                          command = text.toString();
     1150                          // Replace the hfile if we found it
     1151                          if(hfile != null && metadata != null) {
     1152                                command = command.replaceAll(hfile, metadata + ".txt");
     1153                          }
     1154                          hfile = null;
     1155                          metadata = null;
     1156                          write(out, command);
     1157                     }
    10851158                     else {
     1159                          // There is still one special case, that of the format command. In such a command we have to search for [<target>] to ensure we don't change parts of the format which have nothing to do with the metadata elements.
     1160                          boolean format_command = command_lc.startsWith(Utility.CFG_FORMAT);
    10861161                          // Replace mapping strings
    10871162                          if(mappings != null) {
     
    10891164                                     String target = (String) keys.next();
    10901165                                     String replacement = (String) mappings.get(target);
     1166                                     if(format_command) {
     1167                                          target = "\\[" + target + "\\]";
     1168                                          replacement = "[" + replacement + "]";
     1169                                     }
    10911170                                     command = command.replaceAll(target, replacement);
    10921171                                }
    1093                                 // See if the command line contains any of the things that need changing.
    1094                                 String hfile = null;
    1095                                 String metadata = null;
    1096                                 CommandTokenizer tokenizer = new CommandTokenizer(command);
    1097                                 while(tokenizer.hasMoreTokens()) {
    1098                                      String token = tokenizer.nextToken();
    1099                                      if(token.equals(Utility.CFG_CLASSIFY_HFILE)) {
    1100                                           hfile = tokenizer.nextToken();
    1101                                      }
    1102                                      else if(token.equals(Utility.CFG_CLASSIFY_METADATA)) {
    1103                                           metadata = tokenizer.nextToken();
    1104                                      }
    1105                                 }
    1106                                 tokenizer = null;
    1107                                 // Replace the hfile if we found it
    1108                                 if(hfile != null && metadata != null) {
    1109                                      String result = (String) mappings.get(metadata);
    1110                                      if(result == null) {
    1111                                           result = metadata;
    1112                                      }
    1113                                      command = command.replaceAll(hfile, result + ".txt");
    1114                                 }
    1115                                 hfile = null;
    1116                                 metadata = null;
    11171172                          }
    11181173                          write(out, command);
Note: See TracChangeset for help on using the changeset viewer.