Changeset 4516


Ignore:
Timestamp:
2003-06-09T12:39:19+12:00 (21 years ago)
Author:
kjdon
Message:

at teh start of addMetadata, we display a warning dialog if there are no metadata sets specified for the collection - we cant add metadata in this case

File:
1 edited

Legend:

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

    r4449 r4516  
    4141import java.util.*;
    4242import java.util.regex.*;
     43import javax.swing.JOptionPane;
    4344import javax.swing.tree.*;
    4445import org.greenstone.gatherer.Gatherer;
    4546import org.greenstone.gatherer.cdm.CommandTokenizer;
    4647import org.greenstone.gatherer.file.FileNode;
     48import org.greenstone.gatherer.gui.WarningDialog;
    4749import org.greenstone.gatherer.msm.ElementWrapper;
    4850import org.greenstone.gatherer.msm.Metadata;
     
    204206    }
    205207    else {
    206                 ///ystem.err.println("Not a greenstone collection (no collect.cfg found).");
     208        ///ystem.err.println("Not a greenstone collection (no collect.cfg found).");
    207209    }
    208210    return dialog_cancelled;
     
    214216
    215217    private void addMetadata(FileNode destination, ArrayList metadatum, File collection_dir, CollectCFG collect_cfg, boolean dummy_run) {
     218    // before we try to addMetadata, we need to check that there are some metadata sets for the collection - otherwise we cant add or import
     219    Vector meta_sets = Gatherer.c_man.getCollection().msm.getSets(false);
     220    if (meta_sets.size()==0) {
     221        ///ystem.out.println("GreenstoneMetadataParser:Error: we have been asked to add metadata but there are no existing sets");
     222        // print the warning dialog
     223        WarningDialog dialog = new WarningDialog("warning.MissingMDS", true);
     224        if (dialog.display() == JOptionPane.CANCEL_OPTION) {
     225        // the user has cancelled
     226        dialog_cancelled = true;
     227        }
     228        return;
     229    }
    216230    ///ystem.err.print("6 ");
    217231    // Used in a complicated test later on.
     
    221235        metadata.collection = collection_dir;
    222236        Metadata final_metadata = null;
    223                 // If this BasicMetadata already exists in the transform cache then we can save ourselves a lot of work.
     237        // If this BasicMetadata already exists in the transform cache then we can save ourselves a lot of work.
    224238        SoftReference reference = (SoftReference) transform.get(basic_metadata);
    225239        if(reference != null) {
Note: See TracChangeset for help on using the changeset viewer.