- Timestamp:
- 2009-05-12T13:45:58+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/collection/CollectionManager.java
r19242 r19404 51 51 import org.greenstone.gatherer.cdm.CollectionMetaManager; 52 52 import org.greenstone.gatherer.cdm.CommandTokenizer; 53 import org.greenstone.gatherer.cdm.BuildTypeManager; 54 import org.greenstone.gatherer.cdm.CollectionConfiguration; 53 55 import org.greenstone.gatherer.greenstone.Classifiers; 54 56 import org.greenstone.gatherer.greenstone.LocalGreenstone; … … 153 155 * @see org.greenstone.gatherer.util.Utility 154 156 */ 155 public void buildCollection( boolean incremental_build)156 { 157 158 DebugStream.println("In CollectionManager.buildCollection(), incremental_build: " + incremental_build);157 public void buildCollection() 158 { 159 160 DebugStream.println("In CollectionManager.buildCollection(), CollectionDesignManager.isCompleteBuild(): " + CollectionDesignManager.isCompleteBuild()); 159 161 DebugStream.println("Is event dispatch thread: " + SwingUtilities.isEventDispatchThread()); 160 162 building = true; … … 187 189 } 188 190 else { 189 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl"); 191 String buildType = (new CollectionMeta( CollectionDesignManager.collect_config.getBuildType() )).getValue(CollectionMeta.TEXT); 192 if ( !CollectionDesignManager.isCompleteBuild() && buildType.equals( BuildTypeManager.BUILD_TYPE_LUCENE ) ) { 193 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "incremental-buildcol.pl"); 194 } else { 195 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "full-buildcol.pl"); 196 } 190 197 } 191 198 command_parts_list.add("-gli"); … … 194 201 command_parts_list.add("-collectdir"); 195 202 command_parts_list.add(getCollectDirectory()); 196 197 // If the user hasn't manually specified "-keepold" or "-removeold" then pick one based on incremental_build198 if (!collection.build_options.getValueEnabled("keepold") && !collection.build_options.getValueEnabled("removeold")) {199 command_parts_list.add(incremental_build ? "-keepold" : "-removeold");200 }201 203 202 204 String[] build_options = collection.build_options.getValues(); … … 217 219 218 220 /*probably repeating alot of work, but I want to keep this separate... wendy*/ 219 public void scheduleBuild(boolean incremental_build) 220 { 221 222 DebugStream.println("In CollectionManager.scheduleBuild(), incremental_build: " + incremental_build); 221 public void scheduleBuild() 222 { 223 DebugStream.println("In CollectionManager.scheduleBuild(), CollectionDesignManager.isCompleteBuild(): " + CollectionDesignManager.isCompleteBuild()); 223 224 DebugStream.println("Is event dispatch threa: " + SwingUtilities.isEventDispatchThread()); 224 225 … … 240 241 import_list.add("-S"); 241 242 } 242 import_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl"); 243 244 String cmdPrefix = CollectionDesignManager.isCompleteBuild() ? "full-" : "incremental-"; 245 import_list.add(LocalGreenstone.getBinScriptDirectoryPath() + cmdPrefix + "import.pl"); 243 246 import_list.add("-language"); 244 247 import_list.add(Configuration.getLanguage()); … … 273 276 build_list.add("-S"); 274 277 } 275 build_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "buildcol.pl"); 278 279 String buildType = (new CollectionMeta( CollectionDesignManager.collect_config.getBuildType() )).getValue(CollectionMeta.TEXT); 280 if ( !CollectionDesignManager.isCompleteBuild() && buildType.equals( BuildTypeManager.BUILD_TYPE_LUCENE ) ) { 281 build_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "incremental-buildcol.pl"); 282 } else { 283 build_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "full-buildcol.pl"); 284 } 285 276 286 build_list.add("-language"); 277 287 build_list.add(Configuration.getLanguage()); 278 288 build_list.add("-collectdir"); 279 289 build_list.add(getCollectDirectory()); 280 281 // If the user hasn't manually specified "-keepold" or "-removeold" then pick one based on incremental_build282 if (!collection.build_options.getValueEnabled("keepold") && !collection.build_options.getValueEnabled("removeold")) {283 build_list.add(incremental_build ? "-keepold" : "-removeold");284 }285 290 286 291 String[] build_options = collection.build_options.getValues(); … … 345 350 } 346 351 352 /** Used to determine whether the currently active collection has been imported. 353 * @return A boolean indicating the imported status of the collection. 354 */ 355 public boolean imported() { 356 if ( collection != null ) { 357 String file_name = getLoadedCollectionDirectoryPath() + "archives"; 358 File test_file = new File(file_name); 359 return test_file.exists(); 360 } 361 return false; 362 } 347 363 348 364 /** a test method to see if we can delete a directory/file - returns false is the file or any of the contents of a directory cannot be deleted */ … … 549 565 collection = new Collection(new File(collection_directory_path, name + ".col")); 550 566 551 // "-removeold" is on by default for import.pl 552 collection.import_options.setValue("removeold", true, null);567 // "-removeold" is on by default for import.pl (not anymore; it would wreck incremental import) 568 //collection.import_options.setValue("removeold", true, null); 553 569 554 570 // for remote case, scheduling causes an Exception on creating a new collection that … … 1031 1047 } 1032 1048 else { 1033 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "import.pl"); 1049 String cmdPrefix = CollectionDesignManager.isCompleteBuild() ? "full-" : "incremental-"; 1050 command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + cmdPrefix + "import.pl"); 1034 1051 } 1035 1052 … … 1042 1059 String[] import_options = collection.import_options.getValues(); 1043 1060 for (int i = 0; i < import_options.length; i++) { 1061 System.err.println( "Tacking on option: " + import_options[i] ); 1044 1062 command_parts_list.add(import_options[i]); 1045 1063 } … … 1050 1068 String[] command_parts = (String[]) command_parts_list.toArray(new String[0]); 1051 1069 GShell shell = new GShell(command_parts, GShell.IMPORT, BUILDING, this, import_monitor, GShell.GSHELL_IMPORT); 1070 //shell.setEventProperty("is_incremental", Boolean.toString(is_incremental)); 1052 1071 shell.addGShellListener(Gatherer.g_man.create_pane); 1053 1072 shell.addGShellListener(Gatherer.g_man.format_pane); … … 1497 1516 //ystem.err.println("CollectionManager.processComplete(" + event.getType() + ")"); 1498 1517 Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), false); 1499 ///ystem.err.println("Rec ieved process complete event - " + event);1518 ///ystem.err.println("Received process complete event - " + event); 1500 1519 // If we were running an import, now run a build. 1501 1520 if(event.getType() == GShell.IMPORT && event.getStatus() == GShell.OK) { … … 1504 1523 collection.setFilesChanged(false); 1505 1524 collection.setMetadataChanged(false); 1506 buildCollection( false);1525 buildCollection(); 1507 1526 } 1508 1527 else if(event.getType() == GShell.SCHEDULE && event.getStatus() == GShell.OK ) { … … 1517 1536 else if(event.getType() == GShell.BUILD && event.getStatus() == GShell.OK) { 1518 1537 1519 if(installCollection()) { 1520 // If we have a local library running then ask it to add our newly create collection 1521 if (LocalLibraryServer.isRunning() == true) { 1522 LocalLibraryServer.addCollection(collection.getName()); 1523 } 1524 else if (Gatherer.GS3) { 1525 //xiao comment out this: convertToGS3Collection(); 1526 Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + collection.getName()); 1527 } 1528 1529 // Fire a collection changed first to update the preview etc buttons 1530 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1531 1532 // Now display a message dialog saying its all built 1533 WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", Dictionary.get("CollectionBuilt.Title"), Dictionary.get("CollectionBuilt.Message"), null, false); 1534 collection_built_warning_dialog.setMessageOnly(true); // Not a warning 1535 collection_built_warning_dialog.display(); 1536 collection_built_warning_dialog.dispose(); 1537 collection_built_warning_dialog = null; 1538 1539 //Set nothing as needing rebuilding, as a build has just finished :-) 1540 CollectionDesignManager.resetRebuildTypeRequired(); 1541 } 1542 else { 1543 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1544 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1545 DebugStream.println("Status is ok but !installCollection()"); 1546 } 1538 if ( CollectionDesignManager.isCompleteBuild() ) { 1539 if(installCollection()) { 1540 // If we have a local library running then ask it to add our newly create collection 1541 if (LocalLibraryServer.isRunning() == true) { 1542 LocalLibraryServer.addCollection(collection.getName()); 1543 } 1544 else if (Gatherer.GS3) { 1545 //xiao comment out this: convertToGS3Collection(); 1546 Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + collection.getName()); 1547 } 1548 1549 // Fire a collection changed first to update the preview etc buttons 1550 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1551 1552 // Now display a message dialog saying its all built 1553 WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", Dictionary.get("CollectionBuilt.Title"), Dictionary.get("CollectionBuilt.Message"), null, false); 1554 collection_built_warning_dialog.setMessageOnly(true); // Not a warning 1555 collection_built_warning_dialog.display(); 1556 collection_built_warning_dialog.dispose(); 1557 collection_built_warning_dialog = null; 1558 1559 //Set nothing as needing rebuilding, as a build has just finished :-) 1560 CollectionDesignManager.resetRebuildTypeRequired(); 1561 } 1562 else { 1563 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1564 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1565 DebugStream.println("Status is ok but !installCollection()"); 1566 } 1567 } 1547 1568 } 1548 1569 else if (event.getStatus() == GShell.CANCELLED) {
Note:
See TracChangeset
for help on using the changeset viewer.