Ignore:
Timestamp:
2009-05-12T13:45:58+12:00 (15 years ago)
Author:
oranfry
Message:

incremental import and build in gli (brought over from branch)

File:
1 edited

Legend:

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

    r19242 r19404  
    5151import org.greenstone.gatherer.cdm.CollectionMetaManager;
    5252import org.greenstone.gatherer.cdm.CommandTokenizer;
     53import org.greenstone.gatherer.cdm.BuildTypeManager;
     54import org.greenstone.gatherer.cdm.CollectionConfiguration;
    5355import org.greenstone.gatherer.greenstone.Classifiers;
    5456import org.greenstone.gatherer.greenstone.LocalGreenstone;
     
    153155     * @see org.greenstone.gatherer.util.Utility
    154156     */
    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());
    159161    DebugStream.println("Is event dispatch thread: " + SwingUtilities.isEventDispatchThread());
    160162    building = true;
     
    187189    }
    188190    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        }
    190197    }
    191198    command_parts_list.add("-gli");
     
    194201    command_parts_list.add("-collectdir");
    195202    command_parts_list.add(getCollectDirectory());
    196 
    197     // If the user hasn't manually specified "-keepold" or "-removeold" then pick one based on incremental_build
    198     if (!collection.build_options.getValueEnabled("keepold") && !collection.build_options.getValueEnabled("removeold")) {
    199         command_parts_list.add(incremental_build ? "-keepold" : "-removeold");
    200     }
    201203
    202204    String[] build_options = collection.build_options.getValues();
     
    217219
    218220    /*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());
    223224    DebugStream.println("Is event dispatch threa: " + SwingUtilities.isEventDispatchThread());
    224225
     
    240241        import_list.add("-S");
    241242    }
    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");
    243246    import_list.add("-language");
    244247    import_list.add(Configuration.getLanguage());
     
    273276        build_list.add("-S");
    274277    }
    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
    276286    build_list.add("-language");
    277287    build_list.add(Configuration.getLanguage());
    278288    build_list.add("-collectdir");
    279289    build_list.add(getCollectDirectory());
    280 
    281     // If the user hasn't manually specified "-keepold" or "-removeold" then pick one based on incremental_build
    282     if (!collection.build_options.getValueEnabled("keepold") && !collection.build_options.getValueEnabled("removeold")) {
    283         build_list.add(incremental_build ? "-keepold" : "-removeold");
    284     }
    285290
    286291    String[] build_options = collection.build_options.getValues();
     
    345350    }
    346351
     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    }
    347363
    348364    /** 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 */
     
    549565        collection = new Collection(new File(collection_directory_path, name + ".col"));
    550566
    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);
    553569
    554570        // for remote case, scheduling causes an Exception on creating a new collection that
     
    10311047    }
    10321048    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");
    10341051    }
    10351052
     
    10421059    String[] import_options = collection.import_options.getValues();
    10431060    for (int i = 0; i < import_options.length; i++) {
     1061        System.err.println( "Tacking on option: " + import_options[i] );
    10441062        command_parts_list.add(import_options[i]);
    10451063    }
     
    10501068    String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
    10511069    GShell shell = new GShell(command_parts, GShell.IMPORT, BUILDING, this, import_monitor, GShell.GSHELL_IMPORT);
     1070    //shell.setEventProperty("is_incremental", Boolean.toString(is_incremental));
    10521071    shell.addGShellListener(Gatherer.g_man.create_pane);
    10531072        shell.addGShellListener(Gatherer.g_man.format_pane);
     
    14971516    //ystem.err.println("CollectionManager.processComplete(" + event.getType() + ")");
    14981517    Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), false);
    1499     ///ystem.err.println("Recieved process complete event - " + event);
     1518    ///ystem.err.println("Received process complete event - " + event);
    15001519    // If we were running an import, now run a build.
    15011520    if(event.getType() == GShell.IMPORT && event.getStatus() == GShell.OK) {
     
    15041523        collection.setFilesChanged(false);
    15051524        collection.setMetadataChanged(false);
    1506         buildCollection(false);
     1525        buildCollection();
    15071526    }
    15081527    else if(event.getType() == GShell.SCHEDULE && event.getStatus() == GShell.OK ) {
     
    15171536    else if(event.getType() == GShell.BUILD && event.getStatus() == GShell.OK) {
    15181537           
    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        }
    15471568    }
    15481569    else if (event.getStatus() == GShell.CANCELLED) {
Note: See TracChangeset for help on using the changeset viewer.