Changeset 22381

Show
Ignore:
Timestamp:
13.07.2010 12:08:12 (10 years ago)
Author:
kjdon
Message:

There can be more than one replaceListRef, so hanlde this case. OAI element no longer used. Instead its inside a serviceRackList, so handle this instead

Files:
1 modified

Legend:

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

    r22346 r22381  
    874874    Element toElement = to.getDocumentElement (); 
    875875         
    876     Node replace_element = XMLTools.getChildByTagName (from, StaticStrings.REPLACELISTREF_STR); 
    877     if (replace_element == null) { 
    878       return; // such an element not found 
    879     } 
    880          
    881     Element to_element = XMLTools.duplicateElement (to, (Element)replace_element, true); 
    882     toElement.appendChild (to_element); 
     876    NodeList replace_elements = from.getElementsByTagName(StaticStrings.REPLACELISTREF_STR); 
     877    int num_elems = replace_elements.getLength(); 
     878    if (num_elems < 1) { 
     879      return; 
     880    } 
     881    for (int i=0; i<num_elems; i++) { 
     882      Element to_element = XMLTools.duplicateElement (to, (Element)replace_elements.item(i), true); 
     883      toElement.appendChild (to_element); 
     884    } 
    883885  } 
    884886  static private void convertReplaceListRef (Document from, Document to) { 
    885887    Element toElement = to.getDocumentElement (); 
    886888         
    887     Node replace_element = XMLTools.getChildByTagName (from.getDocumentElement (), StaticStrings.REPLACELISTREF_STR); 
    888     if (replace_element == null) { 
     889    NodeList replace_elements = from.getDocumentElement().getElementsByTagName(StaticStrings.REPLACELISTREF_STR); 
     890    int num_elems = replace_elements.getLength(); 
     891    if (num_elems < 1) { 
     892      return; 
     893    } 
     894    for (int i=0; i<num_elems; i++) { 
     895      Element to_element = XMLTools.duplicateElement (to, (Element)replace_elements.item(i), true); 
     896      toElement.appendChild (to_element); 
     897    } 
     898  } 
     899 
     900  /** serviceRackList is currently not editable in GLI - just copy it in from config file and write it out again. */ 
     901  static private void doServiceRackList (Document to, Element from) { 
     902    Element toElement = to.getDocumentElement (); 
     903         
     904    Node srl_element = XMLTools.getChildByTagName (from, StaticStrings.SERVICE_RACK_LIST_ELEMENT); 
     905    if (srl_element == null) { 
    889906      return; // such an element not found 
    890907    } 
    891908         
    892     Element to_element = XMLTools.duplicateElement (to, (Element)replace_element, true); 
     909    Element to_element = XMLTools.duplicateElement (to, (Element)srl_element, true); 
    893910    toElement.appendChild (to_element); 
    894911  } 
    895   static private void doOAIElement (Document to, Element from) { 
     912  static private void convertServiceRackList (Document from, Document to) { 
    896913    Element toElement = to.getDocumentElement (); 
    897914         
    898     Node oai_element = XMLTools.getChildByTagName (from, StaticStrings.OAI_ELEMENT); 
    899     if (oai_element == null) { 
     915    Node srl_element = XMLTools.getChildByTagName (from.getDocumentElement (), StaticStrings.SERVICE_RACK_LIST_ELEMENT); 
     916    if (srl_element == null) { 
    900917      return; // such an element not found 
    901918    } 
    902919         
    903     Element to_element = XMLTools.duplicateElement (to, (Element)oai_element, true); 
    904     toElement.appendChild (to_element); 
    905   } 
    906   static private void convertOAIElement (Document from, Document to) { 
    907     Element toElement = to.getDocumentElement (); 
    908          
    909     Node oai_element = XMLTools.getChildByTagName (from.getDocumentElement (), StaticStrings.OAI_ELEMENT); 
    910     if (oai_element == null) { 
    911       return; // such an element not found 
    912     } 
    913          
    914     Element to_element = XMLTools.duplicateElement (to, (Element)oai_element, true); 
     920    Element to_element = XMLTools.duplicateElement (to, (Element)srl_element, true); 
    915921    toElement.appendChild (to_element); 
    916922  } 
     
    20262032    doDisplayFormat (dOc, fromElement); 
    20272033    doReplaceListRef (dOc, fromElement); 
    2028     doOAIElement (dOc, fromElement); 
     2034    doServiceRackList (dOc, fromElement); 
    20292035         
    20302036  } 
     
    20622068    convertDisplayFormat (dOc, skeleton); 
    20632069    convertReplaceListRef (dOc, skeleton); 
    2064     convertOAIElement(dOc, skeleton); 
     2070    convertServiceRackList(dOc, skeleton); 
    20652071 
    20662072    return skeleton;