Changeset 4838


Ignore:
Timestamp:
2003-07-01T11:51:47+12:00 (21 years ago)
Author:
jmt12
Message:

2030159: Had confused element name and identifier. Also added ability for ElementWrappers to be stored as Argument values, and thus have identifier appear within GLI while the name is written to the collect.cfg

Location:
trunk/gli/src/org/greenstone/gatherer/cdm
Files:
4 edited

Legend:

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

    r4675 r4838  
    5454import java.util.Iterator;
    5555import java.util.HashMap;
     56import org.greenstone.gatherer.msm.ElementWrapper;
    5657import org.greenstone.gatherer.msm.MSMUtils;
    5758import org.greenstone.gatherer.util.Utility;
     
    7879    /** The type of this argument. Initially an int, but bytes are cheaper. */
    7980    private byte type = FLAG;
     81
     82    private ElementWrapper element = null;
    8083    /** If the argument is of type ENUM then this map holds all the various options. Each entry is an <option value> -> <description> mapping. */
    8184    private HashMap list = null;
     
    229232      */
    230233    public String getValue() {
     234    if(element != null) {
     235        return element.toString();
     236    }
    231237    return value;
    232238    }
     
    272278    desc = new_desc;
    273279    }
     280
     281    public void setElementValue(ElementWrapper element) {
     282    this.element = element;
     283    }
     284
    274285    /** Set the value of name.
    275286      * @param new_name The new value of name as a <strong>String</strong>.
     
    341352    }
    342353    }
     354
    343355    /** Method to set the value of value.
    344356      * @param new_value The new value of value as a <strong>String</strong>.
     
    360372    case FLAG:
    361373        return "-" + name;
     374    case METADATA:
     375        StringBuffer metadata_text = new StringBuffer("-");
     376        metadata_text.append(name);
     377        metadata_text.append(" ");
     378        if(element != null) {
     379        String element_name = element.toString();
     380        if(element_name.indexOf(" ") != -1) {
     381            metadata_text.append("\"");
     382            metadata_text.append(element_name);
     383            metadata_text.append("\"");
     384        }
     385        else {
     386            metadata_text.append(element_name);
     387        }
     388        element_name = null;
     389        }
     390        else {
     391        metadata_text.append(value);
     392        }
     393        return metadata_text.toString();
    362394    case METADATUM:
    363         StringBuffer text = new StringBuffer("-");
    364         text.append(name);
    365         text.append(" ");
     395        StringBuffer metadatum_text = new StringBuffer("-");
     396        metadatum_text.append(name);
     397        metadatum_text.append(" ");
    366398        for(int i = 0; i < values.size(); i++) {
    367         text.append(values.get(i).toString());
     399        metadatum_text.append(values.get(i).toString());
    368400        if(i < values.size() - 1) {
    369             text.append(",");
    370         }
    371         }
    372         return text.toString();
     401            metadatum_text.append(",");
     402        }
     403        }
     404        return metadatum_text.toString();
    373405    case STRING:
    374406        // we need to put quotes if they are not there
     
    385417    switch(type) {
    386418    case METADATA:
    387         if (value != null) {
    388         String temp_value = value;
    389        
    390         if (temp_value.startsWith(Utility.EXTRACTED_METADATA_NAMESPACE+MSMUtils.NS_SEP)) {
     419        StringBuffer metadata_text = new StringBuffer("-");
     420        metadata_text.append(name);
     421        if(element != null) {
     422        metadata_text.append(" ");
     423        String element_name = element.getName();
     424        if (element_name.startsWith(Utility.EXTRACTED_METADATA_NAMESPACE+MSMUtils.NS_SEP)) {
    391425           
    392             temp_value = temp_value.substring(temp_value.indexOf(MSMUtils.NS_SEP)+1);
    393         }
    394         return "-" + name + " " + temp_value;
    395         }
    396         return "-" + name;
     426            element_name = element_name.substring(element_name.indexOf(MSMUtils.NS_SEP)+1);
     427        }
     428        metadata_text.append(element_name);
     429        element_name = null;
     430        }
     431        else if(value != null) {
     432        metadata_text.append(" ");
     433        metadata_text.append(value);
     434        }
     435        return metadata_text.toString();
    397436    case METADATUM:
    398         StringBuffer text = new StringBuffer("-");
    399         text.append(name);
    400         text.append(" ");
     437        StringBuffer metadatum_text = new StringBuffer("-");
     438        metadatum_text.append(name);
     439        metadatum_text.append(" ");
    401440        for(int i = 0; i < values.size(); i++) {
    402441        String temp_value = values.get(i).toString();
     
    405444            temp_value = temp_value.substring(temp_value.indexOf(MSMUtils.NS_SEP)+1);
    406445        }
    407         text.append(temp_value);
     446        metadatum_text.append(temp_value);
    408447        if(i < values.size() - 1) {
    409             text.append(",");
    410         }
    411         }
    412         return text.toString();
     448            metadatum_text.append(",");
     449        }
     450        }
     451        return metadatum_text.toString();
    413452    default:
    414453        return toString();
  • trunk/gli/src/org/greenstone/gatherer/cdm/ArgumentConfiguration.java

    r4675 r4838  
    651651            return true;
    652652        case Argument.METADATA:
     653            // I feel like a cast-away
     654            argument.setElementValue((ElementWrapper)((JComboBox)value).getSelectedItem());
     655            return true;
    653656        case Argument.HIERARCHY:
    654657            argument.setValue(((JComboBox)value).getSelectedItem().toString());
     
    740743        this.target = target;
    741744        }
    742                 /** When the add button is clicked, we attempt to add the selected metadata from the source into the target.
    743                 * @param event An <strong>ActionEvent</strong> containing information about the event.
    744                 * @see org.greenstone.gatherer.msm.ElementWrapper
    745                 */
     745        /** When the add button is clicked, we attempt to add the selected metadata from the source into the target.
     746        * @param event An <strong>ActionEvent</strong> containing information about the event.
     747        * @see org.greenstone.gatherer.msm.ElementWrapper
     748        */
    746749        public void actionPerformed(ActionEvent event) {
    747750        ElementWrapper element = (ElementWrapper) source.getSelectedItem();
    748         String name = element.toString();
     751        String name = element.getName();
    749752        if(!model.contains(name)) {
    750753            boolean found = false;
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r4675 r4838  
    8282import org.greenstone.gatherer.cdm.DynamicListModel;
    8383import org.greenstone.gatherer.file.FileNode;
     84import org.greenstone.gatherer.msm.ElementWrapper;
    8485import org.greenstone.gatherer.msm.MSMEvent;
    8586import org.greenstone.gatherer.msm.MSMListener;
     
    381382                if(argument.getType() != Argument.FLAG && tokenizer.hasMoreTokens()) {
    382383                String value = tokenizer.nextToken();
    383                 // special hack for metadata
     384                ElementWrapper element = null;
     385                // special check for metadata
    384386                if (argument.getType() == Argument.METADATA) {
    385387                    value = value.replace(':', MSMUtils.NS_SEP);
    386388                    if (value.indexOf(MSMUtils.NS_SEP)==-1){
    387                     value = Utility.EXTRACTED_METADATA_NAMESPACE +MSMUtils.NS_SEP+value;
     389                    value = Utility.EXTRACTED_METADATA_NAMESPACE + MSMUtils.NS_SEP + value;
    388390                    }
     391                    // Now retrieve the element this refers to, if available.
     392                    element = Gatherer.c_man.getCollection().msm.getElement(value);
    389393                }
    390                 // shoudl probably do the same for METADATUM
    391                
    392                 argument.setValue(value);
     394                if(element != null) {
     395                    argument.setElementValue(element);
     396                    element = null;
     397                }
     398                else {
     399                    argument.setValue(value);
     400                }
    393401                }
    394402            }
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r4675 r4838  
    6565import org.greenstone.gatherer.cdm.DynamicListModel;
    6666import org.greenstone.gatherer.cdm.PlugIn;
     67import org.greenstone.gatherer.msm.ElementWrapper;
     68import org.greenstone.gatherer.msm.MSMUtils;
    6769import org.greenstone.gatherer.util.Utility;
    6870import org.w3c.dom.*;
     
    339341                // And if the argument is of a parameter type, parse a parameter.
    340342                if(argument.getType() != Argument.FLAG && tokenizer.hasMoreTokens()) {
    341                 argument.setValue(tokenizer.nextToken());
     343                String value = tokenizer.nextToken();
     344                ElementWrapper element = null;
     345                if(argument.getType() == Argument.METADATA) {
     346                    value = value.replace(':', MSMUtils.NS_SEP);
     347                    if (value.indexOf(MSMUtils.NS_SEP)==-1){
     348                    value = Utility.EXTRACTED_METADATA_NAMESPACE + MSMUtils.NS_SEP + value;
     349                    }
     350                    // Now retrieve the element this refers to, if available.
     351                    element = Gatherer.c_man.getCollection().msm.getElement(value);
     352                }
     353                if(element != null) {
     354                    argument.setElementValue(element);
     355                    element = null;
     356                }
     357                else {
     358                    argument.setValue(value);
     359                }
    342360                }
    343361                key = null;
Note: See TracChangeset for help on using the changeset viewer.