Ignore:
Timestamp:
2004-05-13T17:08:42+12:00 (20 years ago)
Author:
kjdon
Message:

the intial stage of making gli work with gs3 - still uses gs2 building, but uses colls in gs3 setup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r7281 r7326  
    3434    private MutableTreeNode parent;
    3535    private String title;
     36    private boolean gs3_site = false;
    3637
    3738    public FileNode(File file) {
     
    267268
    268269    public void map() {
    269     if(children == null) {
    270         children = new ArrayList();
    271         // Super Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually be the collect directory of greenstone.
    272         if(file == null && title.equals(Dictionary.get("Tree.World"))) {
     270    if(children != null) {
     271        return;
     272    }
     273    children = new ArrayList();
     274    // Super Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually be the collect directory of greenstone.
     275    if(file == null) { // a special mapping folder
     276        if (title.equals(Dictionary.get("Tree.World")) && Gatherer.GS3) {
     277        // the Greenstone collections folder for GS3 - this contains a
     278        // folder for each site
     279        File start = new File(Utility.getSitesDir(Gatherer.config.gsdl3_path));
     280        File sites[] = start.listFiles();
     281        ArrayTools.sort(sites);
     282        for (int i=0; sites != null && i < sites.length; i++) {
     283            //File site = sites[i];
     284            File collect_dir = new File(sites[i], Utility.COL_DIR);
     285            if(!collect_dir.exists()) {
     286            continue;
     287            }
     288           
     289            FileNode child = new FileNode(sites[i].getName());
     290            child.setGS3Site(true);
     291            child.unmap();
     292            child.setParent(this);
     293            child.setModel(model);
     294            child.map();
     295            children.add(child);
     296        }
     297
     298        } else if (title.equals(Dictionary.get("Tree.World")) || gs3_site) {
     299        // the collect dir for gs2 or a site dir for gs3
    273300        ///atherer.println("Map the 'Greenstone Collections' node.");
    274301        // For each of the children directories, which are collections...
    275         File start = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
     302        File start;
     303        if (gs3_site) {
     304            start = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, title));
     305        } else {
     306            start = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
     307        }
    276308        File cols[] = start.listFiles();
    277309        ArrayTools.sort(cols);
     
    279311        for(int i = 0; cols != null && i < cols.length; i++) {
    280312            if (!cols[i].getName().equals(StaticStrings.MODEL_COLLECTION_NAME)) {
    281             File dirs[] = cols[i].listFiles();
    282             ArrayTools.sort(dirs);
     313            //File dirs[] = cols[i].listFiles();
     314            //ArrayTools.sort(dirs);
    283315            File import_dir = new File(cols[i], StaticStrings.IMPORT_FOLDER);
    284             if(import_dir.exists()) {
    285                 // we don't care if there is no config file
    286                 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(cols[i], Utility.CONFIG_FILE));
    287                 FileNode collection_root = new FileNode(import_dir, collect_cfg.toString(), true);
    288                 collection_root.setParent(this);
    289                 collection_root.setModel(model);
    290                 // One last piece of magic so we can determine the current collection
    291                 Collection collection = Gatherer.c_man.getCollection();
    292                 if(collection != null) {
    293                 collection_root.setCurrentCollection(cols[i].getName().equals(collection.getName()));
    294                 }
    295                 children.add(collection_root);
    296                 collection_root = null;
     316            if(!import_dir.exists()) {
     317                continue;
    297318            }
     319            // we don't care if there is no config file
     320            BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(cols[i], Utility.CONFIG_FILE));
     321            FileNode collection_root = new FileNode(import_dir, collect_cfg.toString(), true);
     322            collection_root.setParent(this);
     323            collection_root.setModel(model);
     324            // One last piece of magic so we can determine the current collection
     325            Collection collection = Gatherer.c_man.getCollection();
     326            if(collection != null) {
     327                collection_root.setCurrentCollection(cols[i].getName().equals(collection.getName()));
     328            }
     329            children.add(collection_root);
     330            collection_root = null;
    298331            import_dir = null;
    299             dirs = null;
    300             }
    301         }
     332            //dirs = null;
     333            }
     334        } // for each coll
    302335        cols = null;
    303336        model.nodeStructureChanged(this);
    304337        }
    305         // General case: Only map if there are no children.
    306         else if(file != null && getAllowsChildren()) {
     338    } // if file == null
     339    // General case: Only map if there are no children.
     340    else { // file !=null
     341        if(getAllowsChildren()) {
    307342        File[] files = file.listFiles();
    308343        if(files != null && files.length > 0) {
     
    318353            raw_children.add(child);
    319354            }
    320 
     355           
    321356            // Apply the filters set in the model.
    322357            //if(model != null) {
     
    326361            }
    327362            //}
    328 
     363           
    329364            // Now add them to children.
    330365            for(int i = 0; i < files.length; i++) {
     
    343378        }
    344379    }
     380   
    345381    }
    346382
     
    376412    public void setFile(File file) {
    377413    this.file = file;
     414    }
     415
     416    public void setGS3Site(boolean is_site) {
     417    this.gs3_site = is_site;
    378418    }
    379419
     
    426466    public void unmap() {
    427467    // You cannot unmap nodes that have no file basis.
    428     if(file != null || title.equals(Dictionary.get("Tree.World"))) {
     468    if(file != null || title.equals(Dictionary.get("Tree.World")) || gs3_site) {
    429469        ///atherer.println("Unmap: " + this);
    430470        children = null;
Note: See TracChangeset for help on using the changeset viewer.