Changeset 12798


Ignore:
Timestamp:
2006-09-21T11:16:14+12:00 (18 years ago)
Author:
mdewsnip
Message:

Started tidying up the CollectionConfiguration class so we can reliably tell when it needs to be saved.

Location:
trunk/gli/src/org/greenstone/gatherer/cdm
Files:
11 edited

Legend:

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

    r12641 r12798  
    106106            // The trick thing is that we have to create a new element in the DOM as well.
    107107            Argument new_argument = base_argument.copy();
    108             Element argument_element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.OPTION_ELEMENT);
     108            Element argument_element = CollectionConfiguration.createElement(StaticStrings.OPTION_ELEMENT);
    109109            argument_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, base_argument_name);
    110110            argument_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR);
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r12749 r12798  
    420420
    421421        // Create a new element in the DOM
    422         Element new_classifier_element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.CLASSIFY_ELEMENT);
     422        Element new_classifier_element = CollectionConfiguration.createElement(StaticStrings.CLASSIFY_ELEMENT);
    423423        new_classifier_element.setAttribute(StaticStrings.TYPE_ATTRIBUTE, classifier.getName());
    424424        Classifier new_classifier = new Classifier(new_classifier_element, classifier);
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java

    r12416 r12798  
    5656    static final public String ENCODING = "UTF-8";
    5757
    58     static public Document document;
     58    static private Document document;
     59
     60
     61    static public Element createElement(String element_name)
     62    {
     63    return document.createElement(element_name);
     64    }
     65
    5966
    6067    /** Find the best insertion position for the given DOM Element. This should try to match command tag, and if found should then try to group by name or type (eg CollectionMeta), or append to end is no such grouping exists (eg Plugins). Failing a command match it will check against the command order for the best insertion location.
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMeta.java

    r12641 r12798  
    5858    /** Constructor to create a new piece of metadata given its name. */
    5959    public CollectionMeta(String name) {
    60     element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.COLLECTIONMETADATA_ELEMENT);
     60    element = CollectionConfiguration.createElement(StaticStrings.COLLECTIONMETADATA_ELEMENT);
    6161    element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name);
    6262    element.setAttribute(StaticStrings.LANGUAGE_ATTRIBUTE, Configuration.getLanguage());
     
    6666    /** Constructor to create a new piece of metadata given its name. */
    6767    public CollectionMeta(String name, String language) {
    68     element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.COLLECTIONMETADATA_ELEMENT);
     68    element = CollectionConfiguration.createElement(StaticStrings.COLLECTIONMETADATA_ELEMENT);
    6969    element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name);
    7070    element.setAttribute(StaticStrings.LANGUAGE_ATTRIBUTE, language);
  • trunk/gli/src/org/greenstone/gatherer/cdm/Format.java

    r12641 r12798  
    127127    public Format(Object feature, String part, boolean state) {
    128128
    129     element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.FORMAT_ELEMENT);
     129    element = CollectionConfiguration.createElement(StaticStrings.FORMAT_ELEMENT);
    130130    setName(feature, part);
    131131    setState(state);
     
    140140    public Format(Object feature, String part, String value) {
    141141
    142     element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.FORMAT_ELEMENT);       
     142    element = CollectionConfiguration.createElement(StaticStrings.FORMAT_ELEMENT);       
    143143    setName(feature, part);
    144144    setValue(value);
  • trunk/gli/src/org/greenstone/gatherer/cdm/Index.java

    r12641 r12798  
    6666    this.sources = sources;
    6767    // Create a new element
    68     Document document = CollectionDesignManager.collect_config.document;
    69     this.element = document.createElement(StaticStrings.INDEX_ELEMENT);
     68    this.element = CollectionConfiguration.createElement(StaticStrings.INDEX_ELEMENT);
    7069    // For each source add a content element
    7170    int size = sources.size();
    7271    for(int i = 0; i < size; i++) {
    73         Element content_element = document.createElement(StaticStrings.CONTENT_ELEMENT);
     72        Element content_element = CollectionConfiguration.createElement(StaticStrings.CONTENT_ELEMENT);
    7473        Object source_object = sources.get(i);
    7574        if (source_object instanceof MetadataElement) {
     
    8483        content_element = null;
    8584    }
    86     document = null;
    8785    }
    8886
  • trunk/gli/src/org/greenstone/gatherer/cdm/Language.java

    r12641 r12798  
    5656    this.code = code;
    5757    // Create the new element
    58     element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.LANGUAGE_ELEMENT);
     58    element = CollectionConfiguration.createElement(StaticStrings.LANGUAGE_ELEMENT);
    5959    element.setAttribute(StaticStrings.NAME_ATTRIBUTE, code);
    6060    element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
     
    7474    }
    7575    this.code = code_str.toString();
    76     element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.LANGUAGE_ELEMENT);
     76    element = CollectionConfiguration.createElement(StaticStrings.LANGUAGE_ELEMENT);
    7777    element.setAttribute(StaticStrings.NAME_ATTRIBUTE, code);
    7878    element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.TRUE_STR);
  • trunk/gli/src/org/greenstone/gatherer/cdm/Level.java

    r12641 r12798  
    5454     */
    5555    public Level(String level) {
    56     this.element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.LEVEL_ELEMENT);
     56    this.element = CollectionConfiguration.createElement(StaticStrings.LEVEL_ELEMENT);
    5757    this.element.setAttribute(StaticStrings.NAME_ATTRIBUTE, level);
    5858    }
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r12749 r12798  
    342342        }
    343343    }
    344     Element element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.PLUGIN_ELEMENT);
     344    Element element = CollectionConfiguration.createElement(StaticStrings.PLUGIN_ELEMENT);
    345345    element.setAttribute(StaticStrings.TYPE_ATTRIBUTE, StaticStrings.SEPARATOR_ATTRIBUTE);
    346346    element.setAttribute(StaticStrings.SEPARATOR_ATTRIBUTE, StaticStrings.TRUE_STR);
     
    588588
    589589        // Create a new element in the DOM
    590         Element new_plugin_element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.PLUGIN_ELEMENT);
     590        Element new_plugin_element = CollectionConfiguration.createElement(StaticStrings.PLUGIN_ELEMENT);
    591591        new_plugin_element.setAttribute(StaticStrings.TYPE_ATTRIBUTE, plugin.getName());
    592592        Plugin new_plugin = new Plugin(new_plugin_element, plugin);
     
    958958
    959959        // Create a new element in the DOM
    960         Element new_plugin_element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.PLUGIN_ELEMENT);
     960        Element new_plugin_element = CollectionConfiguration.createElement(StaticStrings.PLUGIN_ELEMENT);
    961961        new_plugin_element.setAttribute(StaticStrings.TYPE_ATTRIBUTE, plugin.getName());
    962962        Plugin new_plugin = new Plugin(new_plugin_element, plugin);
  • trunk/gli/src/org/greenstone/gatherer/cdm/Subcollection.java

    r12641 r12798  
    8383    }
    8484    // Create a new DOM Element with the appropriate attributes and text value
    85     element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.SUBCOLLECTION_ELEMENT);
     85    element = CollectionConfiguration.createElement(StaticStrings.SUBCOLLECTION_ELEMENT);
    8686    element.setAttribute(StaticStrings.CONTENT_ATTRIBUTE, source);
    8787    element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name);
  • trunk/gli/src/org/greenstone/gatherer/cdm/SubcollectionIndex.java

    r12641 r12798  
    5757    this.sources = new ArrayList();
    5858    // Create a new element
    59     Document document = CollectionDesignManager.collect_config.document;
    60     element = document.createElement(StaticStrings.INDEX_ELEMENT);
     59    element = CollectionConfiguration.createElement(StaticStrings.INDEX_ELEMENT);
    6160    // For each source add a content element
    6261    int size = raw_sources.length;
     
    6564        String subcollection_name = subcollection.getName();
    6665        sources.add(subcollection_name);
    67         Element content_element = document.createElement(StaticStrings.CONTENT_ELEMENT);
     66        Element content_element = CollectionConfiguration.createElement(StaticStrings.CONTENT_ELEMENT);
    6867        content_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, subcollection_name);
    6968        element.appendChild(content_element);
    7069        content_element = null;
    7170    }
    72     document = null;
    7371    }
    7472
Note: See TracChangeset for help on using the changeset viewer.