Changeset 29177 for main/trunk/gli


Ignore:
Timestamp:
2014-08-08T18:37:35+12:00 (10 years ago)
Author:
ak19
Message:

GLI now preserves the newly added (optional) option subelements of collectionConfig.xml's index element. This is only used for solr collections at present when the user hand-edits collectionConfig.xml and specifies the solr field type (option-name solrfieldtype) for an index other than the default text_en_splitting. E.g. type text_es for index allfields.

File:
1 edited

Legend:

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

    r26572 r29177  
    266266            String index_str_display = index_str;//for creating collectionmetadata for this index
    267267
     268
     269            String options_str = "";
     270            NodeList option_children = e.getElementsByTagName(StaticStrings.OPTION_STR);
     271            if(option_children != null) {
     272               for (int j = 0; j < option_children.getLength(); j++) {
     273                Element el = (Element) option_children.item(j);
     274
     275                String name_str = el.getAttribute(StaticStrings.NAME_ATTRIBUTE);
     276                options_str = options_str + ((name_str.equals("")) ? "" : (" " + name_str));
     277
     278                String value_str = el.getAttribute(StaticStrings.VALUE_ATTRIBUTE);
     279                options_str = options_str + ((name_str.equals("")) ? "" : (" " + value_str));
     280
     281                if (name_str.equals("") && !value_str.equals(""))
     282                {
     283                    continue; //invalid condition
     284                }
     285
     286                Element option_element = null;
     287                option_element = to.createElement(StaticStrings.OPTION_ELEMENT);
     288                option_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
     289
     290                if (!name_str.equals(""))
     291                {
     292                    option_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_str);
     293                }
     294                if (value_str != null && !value_str.equals(""))
     295                {
     296                    XMLTools.setNodeText(option_element, value_str);
     297                }
     298                index_element.appendChild(option_element);
     299               }
     300            }
     301
    268302            // Handling 'index' element
    269303            // Double check to make sure it's not colon separated style index.
     
    20072041                    index_ele.appendChild(displayItem);
    20082042                }
     2043            }
     2044
     2045            // deal with any <option name='' value=''> children of this index
     2046            // e.g. <option name='solrfieldtype' value='text_es'>
     2047            NodeList option_children = index_element.getElementsByTagName(StaticStrings.OPTION_ELEMENT);
     2048            for (int k = 0; k < option_children.getLength(); k++)
     2049            {
     2050                Element el = (Element) option_children.item(k);
     2051                if (el.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.FALSE_STR))
     2052                {
     2053                    continue;
     2054                }
     2055                String name_str = el.getAttribute(StaticStrings.NAME_ATTRIBUTE);
     2056                String value_str = XMLTools.getNodeText(el);
     2057
     2058                if (name_str == null && value_str == null)
     2059                {
     2060                    continue;
     2061                }
     2062                Element option_element = to.createElement(StaticStrings.OPTION_STR);
     2063                if (!name_str.equals("")) {
     2064                    option_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name_str);
     2065                }
     2066                if (!value_str.equals("")) { // or no value attribute without name attribute?
     2067                    option_element.setAttribute(StaticStrings.VALUE_ATTRIBUTE, value_str);     
     2068                }
     2069                index_ele.appendChild(option_element);
    20092070            }
    20102071
Note: See TracChangeset for help on using the changeset viewer.