Changeset 29057 for main


Ignore:
Timestamp:
05/15/14 13:46:48 (7 years ago)
Author:
kjdon
Message:

added a few functions for helping with returning oai metadata

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIXML.java

    r28983 r29057  
    129129  public static final String RESUMPTION_TOKEN_EXPIRATION = "resumptionTokenExpiration";
    130130  public static final String OAI_SUPER_SET = "oaiSuperSet";
     131  public static final String ELEMENT = "element";
     132  public static final String ELEMENTS = "elements";
    131133  public static final String MAPPING = "mapping";
    132   public static final String MAPPING_LIST = "mappingList";
    133 
     134  public static final String SELECT = "select";
     135  public static final String SELECT_SINGLE_VALUE = "firstvalue";
     136  public static final String SELECT_FIRST_VALID_META = "firstvalidmetadata";
     137  public static final String SELECT_ALL_VALUES = "allvalues";
    134138  // code constants
    135139   public static final String GS_OAI_RESOURCE_URL = "gs.OAIResourceURL";
     
    275279  }
    276280
    277    
     281  /** Copies out the main info from a metadataFormat element, leaving behind the mapping stuff. This gets the bit needed for OAI response */
     282  public static Element getMetadataFormatShort(Document doc, Element meta_format_long) {
     283    Element meta_fmt = doc.createElement(OAIXML.METADATA_FORMAT);
     284    // Copy in the elements that we want, and ignore the rest
     285    meta_fmt.appendChild(doc.importNode(GSXML.getChildByTagName(meta_format_long, OAIXML.METADATA_PREFIX), true));
     286    meta_fmt.appendChild(doc.importNode(GSXML.getChildByTagName(meta_format_long, OAIXML.SCHEMA), true));
     287    meta_fmt.appendChild(doc.importNode(GSXML.getChildByTagName(meta_format_long, OAIXML.METADATA_NAMESPACE), true));
     288
     289    return meta_fmt;
     290  }
     291
    278292  public static long getTokenExpiration() {
    279293    return token_expiration*1000; // in milliseconds
     
    495509    return oai;
    496510  }
    497   public static Element getMetadataPrefixElement(Document doc, String tag_name, String version) {
     511  public static Element getMetadataPrefixElement(Document doc, String prefix, String version) {
    498512    //examples of tag_name: dc, oai_dc:dc, etc.
     513    String tag_name = getMetadataTagName(prefix, version);
    499514    Element oai = doc.createElement(tag_name);
    500515    if (version.equals(OAI_VERSION2)) {
     
    511526    return oai;
    512527  }
     528  public static String getMetadataTagName(String prefix, String oai_version) {
     529    if (prefix.equals("oai_dc")) {
     530      if (oai_version.equals(OAI_VERSION2)) {
     531    return "oai_dc:dc";
     532      }
     533      return "dc";
     534    }
     535    return prefix;
     536  }
     537
    513538  public static HashMap<String, Node> getChildrenMapByTagName(Node n, String tag_name) {
    514539   
Note: See TracChangeset for help on using the changeset viewer.