Changeset 5668 for trunk


Ignore:
Timestamp:
2003-10-17T04:45:05+13:00 (21 years ago)
Author:
jmt12
Message:

Slight changes to allow [ and ] fix

Location:
trunk/gli/src/org/greenstone/gatherer/msm
Files:
3 edited

Legend:

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

    r5589 r5668  
    3232import org.greenstone.gatherer.msm.GDMManager;
    3333import org.greenstone.gatherer.msm.MSMUtils;
     34import org.greenstone.gatherer.util.Codec;
    3435import org.greenstone.gatherer.util.HashMap3D;
    3536import org.greenstone.gatherer.util.StaticStrings;
     
    164165            if(sibling_metadata_element.getAttribute(NAME_ATTRIBUTE).equals(metadata_element.getAttribute(NAME_ATTRIBUTE))) {
    165166                // Check the values and return if they are the same.
    166                 //if(metadata_element.getAttribute(NAME_ATTRIBUTE).equalsIgnoreCase("dls.Title")) {
    167                 //  Gatherer.println("Comparing:");
    168                 //  Gatherer.println("'" + metadata.getAbsoluteValue() + "'");
    169                 //  Gatherer.println(" with:");
    170                 //  Gatherer.println("'" + MSMUtils.getValue(sibling_metadata_element) + "'");
    171                 //}
    172                 if(metadata.getAbsoluteValue().equals(MSMUtils.getValue(sibling_metadata_element))) {
    173                 //  Gatherer.println("Value already exists: " + metadata);
    174                     return;
    175                 }
    176                 will_accumulate = true;
    177             }
     167               if(metadata.getAbsoluteValue().equals(MSMUtils.getValue(sibling_metadata_element))) {
     168              return;
     169               }
     170               will_accumulate = true;
     171            }
    178172            sibling_metadata_element = null;
    179173        }
     
    191185        }
    192186        String node_value = metadata.getAbsoluteValue();
     187        ///ystem.err.println("Creating node in GDMDocument: '" + node_value + "'");
    193188        metadata_element.appendChild(base_document.createTextNode(node_value));
    194189        // Retrieve the first description element for this fileset (there should only be one, but I'll play it safe).
     
    279274                String raw_value = metadata_element.getAttribute(HVALUE_ATTRIBUTE);
    280275                if(raw_value == null || raw_value.length() == 0) {
    281                     raw_value = MSMUtils.getValue(metadata_element);
     276                   raw_value = MSMUtils.getValue(metadata_element);
     277                   // Raw value is in GREENSTONE form, convert to DOM
     278                   raw_value = Codec.transform(raw_value, Codec.GREENSTONE_TO_DOM);
    282279                }
    283280                // ***** LEGACY SUPPORT *****
     
    498495    this.up_to_date = up_to_date;
    499496    }
    500 
    501     /** Decode a string that was previously made Perl safe. */
    502     private String decode(String safe) {
    503     return safe.replaceAll("\\\\.",".");
    504     }
    505 
    506     /** Encodes unsafe filename characters (such as the . before the file extension) into Perl safe ones. */
    507     private String encode(String dangerous) {
    508     return dangerous.replaceAll("\\.", "\\\\.");
    509     }
    510497}
  • trunk/gli/src/org/greenstone/gatherer/msm/Metadata.java

    r5589 r5668  
    120120    }
    121121    /** Determine the absolute path value of this metadata, taking into account whether this value is hierarchical. */
    122     public String getAbsoluteValue() {
    123     String abs_value = getValue();
     122   public String getAbsoluteValue() {
     123        String abs_result = "";
     124    if(value != null) {
     125        abs_result = value.toString(GValueNode.GREENSTONE);
     126    }
     127    return abs_result;
     128   
     129    //String abs_value = getValue();
    124130    // What actually gets written as the value depends on whether this is a hierarchy based element.
    125     GValueModel model = Gatherer.c_man.getCollection().msm.getValueTree(element);
    126     /*if(model != null && model.isHierarchy()) {
    127         if(value != null) {
    128         abs_value = value.getFullPath(false);
    129         }
    130         abs_value = model.getHIndex(abs_value);
    131     }
    132     else {*/
    133         abs_value = abs_value.replaceAll(StaticStrings.LBRACKET_PATTERN, StaticStrings.ESCAPE_PATTERN + StaticStrings.LBRACKET_PATTERN);
    134         abs_value = abs_value.replaceAll(StaticStrings.RBRACKET_PATTERN, StaticStrings.ESCAPE_PATTERN + StaticStrings.RBRACKET_PATTERN);
    135         //}
     131    //GValueModel model = Gatherer.c_man.getCollection().msm.getValueTree(element);
    136132    // Return the result
    137     return abs_value;
     133    //return abs_value;
    138134    }
    139135    /** Retrieve the reference count.
     
    207203    return element.toString() + "=" + getValue();
    208204    }
     205   
    209206    /** Retrieve the value node associated with a certain value string. */
    210207    static final public GValueNode getDefaultValueNode(ElementWrapper element, String value) {
  • trunk/gli/src/org/greenstone/gatherer/msm/MetadataSetManager.java

    r5593 r5668  
    104104     * @param value The value to assign to the metadata as a String.
    105105     */
    106     public void addMetadata(long id, FileNode records[], ElementWrapper element, String value_str) {
    107     if (records.length == 1) {
    108         addMetadata(id, records, element, value_str, MetaEditPrompt.ACCUMULATE_ALL);
    109     }
    110     else {
    111         addMetadata(id, records, element, value_str, MetaEditPrompt.CONFIRM);
    112     }
    113     }
    114     public void addMetadata(long id, FileNode records[], ElementWrapper element, String value_str, int action) {
     106    public Metadata addMetadata(long id, FileNode records[], ElementWrapper element, String value_str) {
     107       Metadata metadata = null;
     108       if (records.length == 1) {
     109      metadata = addMetadata(id, records, element, value_str, MetaEditPrompt.ACCUMULATE_ALL);
     110       }
     111       else {
     112      metadata = addMetadata(id, records, element, value_str, MetaEditPrompt.CONFIRM);
     113       }
     114       return metadata;
     115    }
     116    public Metadata addMetadata(long id, FileNode records[], ElementWrapper element, String value_str, int action) {
    115117    // Retrieve the appropriate value node from the value tree for this element, creating it if necessary.
    116118    GValueModel model = getValueTree(element);
     
    138140        }
    139141    }
     142    return metadata;
    140143    }
    141144
     
    10721075    }
    10731076    else {
    1074                 // Recover the metadata from this file.
     1077       // Recover the metadata from this file.
    10751078        ArrayList metadata = Gatherer.c_man.getCollection().gdm.getMetadata(record.getFile());
    1076                 // Most important test, we don't have to add the metadata if its already there!
     1079        // Most important test, we don't have to add the metadata if its already there!
    10771080        if(!metadata.contains(data)) {
    10781081        // Record undo information for this file node.
Note: See TracChangeset for help on using the changeset viewer.