Changeset 4466 for trunk/gli


Ignore:
Timestamp:
2003-06-03T16:27:12+12:00 (21 years ago)
Author:
jmt12
Message:

2030093: CustomAZList now has valueIsAdjusting() to stop inifinite loops, and only adds hidden range metadata to files/folders which have the ranged metadata set. Having tested this works if the user appends new metadata.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/custom/CustomAZList.java

    r4416 r4466  
    9090    /** An array of togglebuttons showing what separations are available. */
    9191    private JToggleButton separators[] = null;
     92    /** A reference to the progress dialog if it exists. */
     93    private ProgressDialog pd = null;
    9294    /** A private dictionary for this custom classifier. */
    9395    private ResourceBundle dictionary = null;
     
    601603    // 33% - Allocation of metadata to records, 33 / <number of files>.
    602604    // Hopefully the previous dialog should have already vanished (its dispose() caused by the process click).
    603     ProgressDialog pd = new ProgressDialog("Custom Classifier Creation", "Preparing for operation.");
     605    pd = new ProgressDialog("Custom Classifier Creation", "Preparing for operation.");
    604606    // Step 1: Create the new dummy element and add it if necessary.
    605607    pd.setText("Creating dummy metadata element.");
     
    652654    // Step 5: Recurse the entire tree, adding the appropriate values where necessary (overwriting any existing value for this element).
    653655    pd.setText("Allocating metadata to records.");
    654     int document_count = gatherer.c_man.getCollection().getDocumentCount();
     656    int count = gatherer.c_man.getCollection().getCount();
    655657    TreeModel record_tree = gatherer.c_man.getRecordSet();
    656658    FileNode records[] = ArrayTools.add(null, (FileNode)record_tree.getRoot());
    657659    while(records != null) {
    658         if(records[0].isLeaf()) {
    659         addMetadata(0L, records[0], element);
    660         // Each iteration.
    661         pd.increase(1, document_count, 50);
    662         }
    663         else {
     660        FileNode current_record = records[0];
     661        // There is no point in assigning hidden metadata to a file node we doesn't have any of that metadata set...
     662        ArrayList current_metadatum = Gatherer.c_man.getCollection().gdm.getMetadata(current_record.getFile());
     663        for(int z = 0; z < current_metadatum.size(); z++) {
     664        Metadata current_metadata = (Metadata) current_metadatum.get(z);
     665        if(current_metadata.getElement().equals(element) && current_metadata.isFileLevel()) {
     666            ///ystem.err.println("The file " + current_record + " has previous " + element + " metadata in: " + current_metadata);
     667            addMetadata(0L, current_record, element);
     668        }
     669        }
     670        if(!current_record.isLeaf()) {
    664671        // Add all children to records at once hopefully.
    665         FileNode children[] = new FileNode[records[0].getChildCount()];
     672        FileNode children[] = new FileNode[current_record.getChildCount()];
    666673        for(int i = 0; i < children.length; i++) {
    667             children[i] = (FileNode) records[0].getChildAt(i);
     674            children[i] = (FileNode) current_record.getChildAt(i);
    668675        }
    669676        records = ArrayTools.add(records, children);
    670677        }
    671678        records = ArrayTools.tail(records);
     679        pd.increase(1, count, 50);
    672680    }
    673681    // Step 6: Done.
    674682    pd.dispose();
    675     }
     683    pd = null;
     684    }
     685
     686    public boolean valueIsAdjusting() {
     687    return (pd == null);
     688    }
     689
    676690    /** A dialog window used to show the progress of processing the file records in terms of adding hidden metadata. */
    677691    private class ProgressDialog
Note: See TracChangeset for help on using the changeset viewer.