Ignore:
Timestamp:
2011-08-12T09:57:26+12:00 (13 years ago)
Author:
sjm84
Message:

Adding in the server-side code for the Document Maker as well as several other enhancements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java

    r24254 r24393  
    4141import java.util.Iterator;
    4242import java.util.ArrayList;
    43 import java.util.regex.Matcher;
    44 import java.util.regex.Pattern;
    4543
    4644import org.apache.log4j.*;
     
    198196       
    199197    } else {
    200         // prepare regex to work with mdoffset: looking for <offset\d*_>
    201         Pattern pattern = Pattern.compile("offset[0-9]*" + GSConstants.META_RELATION_SEP);
    202 
    203198        for (int i=0; i<metadata_names.size(); i++) {
    204199                String meta_name = (String) metadata_names.get(i);
    205200        String value = getMetadata(node_id, info, meta_name, lang);
    206 
    207         // Remove the occurrence (if any) in this metaname of the mdoffset number in the pattern <offset\d*_>
    208         // Leaving string "offset" in at this point: it will be handled in config_format.xsl's gsf:metadata template match
    209         Matcher matcher = pattern.matcher(meta_name);
    210         meta_name = matcher.replaceFirst("offset" + GSConstants.META_RELATION_SEP);
    211             //replaceFirst(""); // if removing the occurrence (if any) of entire pattern <offset\d*_> in input     
    212 
    213201        GSXML.addMetadata(this.doc, metadata_list, meta_name, value);
    214202        }
     
    329317    protected String getMetadata(String node_id, DBInfo info,
    330318                 String metadata, String lang) {
    331     String multiple = "false"; // multiple can now be "true", "false" or "offset<number>". It's no longer a boolean
     319    boolean multiple = false;
    332320    String relation = "";
    333321    String separator = ", ";
     
    358346    metadata = metadata.substring(pos+1);
    359347    // check for all on the front
    360     if (temp.equals("all") || temp.startsWith("offset")) { // multiple can now be "true", "false" or "offset"
    361         multiple = temp; // multiple=true;
     348    if (temp.equals("all")) {
     349        multiple=true;     
    362350        pos = metadata.indexOf(GSConstants.META_RELATION_SEP);
    363351        if (pos ==-1) {
     
    411399    StringBuffer result = new StringBuffer();
    412400
    413     if (multiple.equals("false")) {
     401    if (!multiple) {
    414402        result.append(this.macro_resolver.resolve(relation_info.getInfo(metadata), lang, MacroResolver.SCOPE_META, relation_id));
    415     } else if(multiple.startsWith("offset")) { // multiple = offset
    416         String offset = multiple.substring("offset".length(), multiple.length());
    417         int offsetVal = offset.equals("") ? 0 : Integer.parseInt(offset);
    418         String value = relation_info.getInfoOffset(metadata, offsetVal); // what if this metadata is not the one we need to get the offset for? MDTYPE!
    419            // at the moment, do we assume the user will specify retrieving the offset only for such metadata as has an offset?
    420            // At least, getInfoOffset will return the firstelement if the offset exceeds the bounds of the values for this metadata key
    421 
    422         result.append(this.macro_resolver.resolve(value, lang, MacroResolver.SCOPE_META, relation_id));
    423        
    424     } else { // multiple = true, we have multiple meta     
     403    } else {
     404        // we have multiple meta
    425405        Vector values = relation_info.getMultiInfo(metadata);
    426         if (values != null) {
     406        if (values != null) {
    427407        boolean first = true;
    428408        for (int i=0; i<values.size(); i++) {
     
    435415        }
    436416        }
    437         logger.info(result);
     417          logger.info(result);
    438418    }
    439419    // if not ancestors, then this is all we do
     
    448428        relation_info = this.coll_db.getInfo(relation_id);
    449429        if (relation_info == null) return result.toString();
    450         if (multiple.equals("false")) { //if (!multiple)
     430        if (!multiple) {
    451431        result.insert(0, separator);
    452432        result.insert(0, this.macro_resolver.resolve(relation_info.getInfo(metadata), lang, MacroResolver.SCOPE_META, relation_id));
Note: See TracChangeset for help on using the changeset viewer.