Changeset 14753

Show
Ignore:
Timestamp:
01.11.2007 12:02:57 (12 years ago)
Author:
qq6
Message:

Convert gs2 collects to gs3 collects

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/gui/OpenCollectionDialog.java

    r14063 r14753  
    3939import org.greenstone.gatherer.util.StaticStrings; 
    4040import org.greenstone.gatherer.util.Utility; 
     41import org.greenstone.gatherer.shell.GShell; 
     42import org.greenstone.gatherer.shell.GShellEvent; 
     43import org.greenstone.gatherer.shell.GShellListener; 
     44import org.greenstone.gatherer.shell.GShellProgressMonitor; 
    4145 
    4246/** A dialog which provides a straight-forward access to the currently installed collections. It also will contain the ability to continue through to the original OpenCollectionDialog if your source collection is located somewhere other than the gsdl collect folder. */ 
     
    240244 
    241245    private TreeSet data; 
     246    static final public int COLLECT   = 3; 
    242247 
    243248    public CollectionListModel() { 
     
    253258        String collection_foldername = collection_folder.getName(); 
    254259        if(collection_folder.isDirectory() && !collection_foldername.equals(StaticStrings.MODEL_COLLECTION_NAME)) { 
    255             // this 'file_name' has already been prefixed by 'etc' 
    256             String file_name = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE; 
     260            // this 'file_name' has already been prefixed by 'etc' 
     261            String file_name; 
     262            if (Gatherer.GS3){ 
     263            convertToGS3Collection(collection_folder); 
     264            file_name = Utility.CONFIG_GS3_FILE; 
     265            }else{ 
     266            file_name = Utility.CONFIG_FILE; 
     267            } 
     268             
     269            //String file_name = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE; 
    257270            File config_file = new File(collection_folder, file_name); 
    258             File collection_metadata_directory = new File(collection_folder, "metadata"); 
     271            File collection_metadata_directory = new File(collection_folder, "metadata"); 
    259272            if (collection_metadata_directory.exists() && config_file.exists()) { 
    260273            BasicCollectionConfiguration collection_configuration = new BasicCollectionConfiguration(config_file); 
     
    287300        return data.size(); 
    288301    } 
     302 
     303    public void convertToGS3Collection(File collection_folder) { 
     304 
     305        File collect_cfg_file = new File(collection_folder.getAbsolutePath() + File.separator + "etc" + File.separator + "collect.cfg"); 
     306        File build_cfg_file = new File(collection_folder.getAbsolutePath() + File.separator+"index" + File.separator + "build.cfg"); 
     307 
     308        if (collect_cfg_file.exists() && build_cfg_file.exists()){ 
     309        // Generate the convert_coll_from_gs2.pl command 
     310        ArrayList command_parts_list = new ArrayList(); 
     311        if ((Utility.isWindows()) && (!Gatherer.isGsdlRemote)) { 
     312            command_parts_list.add(Configuration.perl_path); 
     313            command_parts_list.add("-S"); 
     314        } 
     315        command_parts_list.add(Configuration.getGS3ScriptPath() + "convert_coll_from_gs2.pl"); 
     316        command_parts_list.add("-collectdir"); 
     317        command_parts_list.add(collection_folder.getParent()); 
     318        command_parts_list.add(collection_folder.getName()); 
     319 
     320        // Run the convert_coll_from_gs2.pl command 
     321        String[] command_parts = (String[]) command_parts_list.toArray(new String[0]); 
     322        GShell process = new GShell(command_parts, GShell.CONVERT, COLLECT, null, null, GShell.GSHELL_CONVERT); 
     323        //process.addGShellListener(this); 
     324        process.run(); // Don't bother threading this... yet 
     325         
     326        collect_cfg_file.delete(); 
     327        build_cfg_file.delete(); 
     328        } 
     329    } 
     330 
    289331    } 
    290332