Changeset 5793


Ignore:
Timestamp:
2003-11-07T10:39:53+13:00 (20 years ago)
Author:
kjdon
Message:

changed this slightly to allow a dummy load of the metadata files - ie we create new ones everywhere there should be one, and ignore the existing ones. This is done for opening a non-gatherer collection, where we dont want the old metadata except when we 'import' the files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/msm/GDMManager.java

    r5589 r5793  
    7272    Gatherer.c_man.getCollection().msm.addMSMListener(this);
    7373    // Now create and start the synchronous GDM loader.
    74     gdm_loader = new GDMLoader();
     74    gdm_loader = new GDMLoader(false);
     75    gdm_loader.start();
     76    ///atherer.println("New GDMManager created.");
     77    }
     78
     79   
     80
     81   
     82    public GDMManager(boolean dummy_load) {
     83    super();
     84    this.metadata_cache = new HashMap3D(Gatherer.c_man.getCollection().msm.getSize());
     85    // Connect
     86    Gatherer.c_man.getCollection().msm.addMSMListener(this);
     87    // Now create and start the synchronous GDM loader.
     88    gdm_loader = new GDMLoader(dummy_load);
    7589    gdm_loader.start();
    7690    ///atherer.println("New GDMManager created.");
     
    8498    }
    8599    }
    86     /** Destructor necessary for clean exit, subsequent to saving of metadata.xml files.
     100
     101   /** Destructor necessary for clean exit, subsequent to saving of metadata.xml files.
    87102     * @see org.greenstone.gatherer.Gatherer
    88103     * @see org.greenstone.gatherer.collection.CollectionManager
     
    152167    }
    153168
     169    // returns metadata file from cache or creates a new one
     170    public GDMDocument getDummyDocument(File file) {
     171    ///ystem.err.println("Get the GDMDocument for " + file.getAbsolutePath());
     172    GDMDocument metadata_xml = null;
     173    // Determine the name of the target files metadata.xml file.
     174    File metadata_file = null;
     175    if(file.isFile()) {
     176        metadata_file = new File(file.getParentFile(), METADATA_XML);
     177    }
     178    else {
     179        metadata_file = new File(file, METADATA_XML);
     180    }
     181    // Then try to retrieve it from cache. First we consider the case of a cache hit.
     182    if(containsKey(metadata_file)) {
     183        metadata_xml = (GDMDocument) get(metadata_file);
     184    }
     185    else {
     186        metadata_xml = new GDMDocument();
     187        put(metadata_file, metadata_xml);
     188    }
     189    return metadata_xml;
     190    }
     191
     192    public synchronized void dummyGetMetadata(File file) {
     193    String filename = null;
     194    if(file.isFile()) {
     195        filename = file.getName();
     196        file = file.getParentFile();
     197    }
     198    GDMDocument document = getDummyDocument(file);
     199
     200   
     201    }
    154202    /** Recover the metadata associated with a particular file. Note that this call is synchronized, so that all of the data holders don't need to be. */
    155203    public synchronized ArrayList getMetadata(File file) {
     
    390438    extends Thread {
    391439    private boolean complete = false;
     440    private boolean dummy_load = false;
     441
     442    GDMLoader(boolean dummy_load) {
     443        super("blarg");
     444        this.dummy_load = dummy_load;
     445    }
     446
     447   
    392448    public void run() {
    393449        // Can't open a collections metadata when the collection isn't open!
     
    407463        if(!record.isLeaf()) {
    408464            ///atherer.println("Retrieving metadata.xml for " + record);
    409             getMetadata(record.getFile());
     465            if (this.dummy_load) {
     466            dummyGetMetadata(record.getFile());
     467            } else {
     468            getMetadata(record.getFile());
     469            }
    410470            for(int i = 0; i < record.getChildCount(); i++) {
    411471            remaining.add(record.getChildAt(i));
Note: See TracChangeset for help on using the changeset viewer.