Changeset 4336
- Timestamp:
- 2003-05-26T16:26:49+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r4304 r4336 88 88 /** The collection this manager is managing! */ 89 89 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; 90 94 /** An inner class listener responsible for noting tree changes and resetting saved when they occur. */ 91 95 private FMTreeModelListener fm_tree_model_listener = null; … … 96 100 /** The monitor resposible for parsing the import process. */ 97 101 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; 102 104 /** The name of the standard lock file. */ 103 105 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; 104 108 /** Constructor. */ 105 109 public CollectionManager() { … … 194 198 /** 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. */ 195 199 public void createCollection(String description, String email, String name, String title, File base_collection_directory, ArrayList metadata_sets) { 200 special_case = NO_SPECIAL_CASE; 196 201 try { 197 202 // Create a progress monitor. … … 200 205 makeCollection(description, email, name, title); 201 206 progress.setProgress(1); 202 207 203 208 // ACTIVE_DIR/gimport/ 204 209 String a_dir = Utility.getCollectionDir(Gatherer.config.gsdl_path) + name + File.separator; 205 210 206 211 // Has to be done before creating greenstone directory metadata manager. 207 212 File gimport_dir_temp = new File(Utility.getImportDir(a_dir)+"temp.dat"); … … 211 216 progress.setNote(get("Gimport_Created")); 212 217 } 213 218 214 219 File gcache_dir_temp = new File(Utility.getCacheDir(a_dir)+"temp.dat"); 215 220 File gcache_dir = gcache_dir_temp.getParentFile(); … … 218 223 progress.setNote(get("Gcache_Created")); 219 224 } 220 225 221 226 progress.setProgress(2); 222 227 … … 244 249 ///ystem.err.println("Found a metadata set. Importing: " + possible_metadata_sets[i].getAbsolutePath()); 245 250 collection.msm.importMDS(possible_metadata_sets[i], false); 246 } 251 } 247 252 } 248 253 } … … 255 260 // Demo collection - part of the DLS 256 261 if(collection_name.equals(Utility.COLLECTION_DEMO) || collection_name.equals(Utility.COLLECTION_DLS)) { 262 special_case = SPECIAL_DLS; 257 263 String demo_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DEMO_DIRECTORY)).getAbsolutePath(); 258 264 String dls_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DLS_DIRECTORY)).getAbsolutePath(); … … 317 323 collection.cdm = new CollectionDesignManager(); 318 324 collection.gdm = new GDMManager(); 319 325 320 326 progress.setProgress(3); 321 327 … … 841 847 installCollection(); 842 848 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()); 847 861 JOptionPane.showMessageDialog(Gatherer.g_man, get("Preview_Ready"), get("Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE); 848 862 } … … 1093 1107 } 1094 1108 } 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 } 1095 1117 else if(command_lc.startsWith(Utility.CFG_CLASSIFY)) { 1096 1118 StringTokenizer tokenizer = new StringTokenizer(command); 1097 1119 StringBuffer text = new StringBuffer(tokenizer.nextToken()); 1098 1120 // Read in the classifier command watching for hfile, metadata and sort arguments. 1121 String buttonname = null; 1099 1122 String hfile = null; 1100 String metadata = null; 1123 String new_metadata = null; 1124 String old_metadata = null; 1101 1125 while(tokenizer.hasMoreTokens()) { 1102 1126 String token = tokenizer.nextToken(); … … 1117 1141 if(replacement != null) { 1118 1142 token = replacement; 1119 metadata = replacement; 1143 old_metadata = temp_metadata; 1144 new_metadata = replacement; 1120 1145 } 1121 1146 else { … … 1142 1167 } 1143 1168 } 1169 else if(token.equals(Utility.CFG_CLASSIFY_BUTTONNAME)) { 1170 buttonname = token; 1171 } 1144 1172 text.append(' '); 1145 1173 text.append(token); … … 1147 1175 } 1148 1176 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 } 1149 1185 command = text.toString(); 1150 1186 // 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"); 1153 1189 } 1190 buttonname = null; 1154 1191 hfile = null; 1155 metadata = null; 1192 new_metadata = null; 1193 old_metadata = null; 1156 1194 write(out, command); 1157 1195 } … … 1166 1204 if(format_command) { 1167 1205 target = "\\[" + target + "\\]"; 1168 replacement = " [" + replacement + "]";1206 replacement = "{Or}{[" + replacement + "]," + target + "}"; 1169 1207 } 1170 command = command.replaceAll(target, replacement);1208 command = command.replaceAll(target, replacement); 1171 1209 } 1172 1210 }
Note:
See TracChangeset
for help on using the changeset viewer.