Changeset 23394

Show
Ignore:
Timestamp:
07.12.2010 14:27:04 (9 years ago)
Author:
kjdon
Message:

added support for specifying accumulating=false in metadata set definition. GLI then won't allow user to add multiple values for that element.

Location:
main/trunk/gli/src/org/greenstone/gatherer/metadata
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataElement.java

    r12672 r23394  
    4646    /* This restricts the user to only the predefined values */ 
    4747    private boolean restricted_values = false; 
    48  
     48  /* can we have more than one value for this metadata element per document? */ 
     49  /* default, true = yes */ 
     50  private boolean accumulating = true; 
    4951    public MetadataElement(String metadata_element_name_full, Element metadata_element_element) 
    5052    { 
     
    6163        } 
    6264        } 
     65        if (metadata_element_element.getAttribute("accumulating").equals("false")) { 
     66          accumulating = false; 
     67        } 
    6368    } 
    6469    } 
     
    204209    } 
    205210 
     211  public boolean isAccumulating() { 
     212    return accumulating; 
     213  } 
    206214    public boolean isSubelement() 
    207215    { 
  • main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValue.java

    r11301 r23394  
    3939    private MetadataElement metadata_element = null; 
    4040    private MetadataValueTreeNode metadata_value_tree_node = null; 
     41  // this will be set to true if the metadata element definition says accumulating = false. 
     42  private boolean must_not_accumulate = false; 
    4143    private boolean is_accumulating_metadata = false; 
    4244    /** Whether this metadata applies to only one file (ie. there are no wildcards in the FileSet value) */ 
     
    4850    this.metadata_element = metadata_element; 
    4951    this.metadata_value_tree_node = metadata_value_tree_node; 
     52    if (metadata_element != null) { 
     53      if (!metadata_element.isAccumulating()) { 
     54        must_not_accumulate = true; 
     55      } 
     56    } 
    5057    } 
    5158 
     
    122129    public void setIsAccumulatingMetadata(boolean is_accumulating_metadata) 
    123130    { 
     131      if (!must_not_accumulate) { 
    124132    this.is_accumulating_metadata = is_accumulating_metadata; 
     133      }  
    125134    } 
    126135 
  • main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java

    r13817 r23394  
    127127        appropriate_fileset_element.appendChild(new_description_element); 
    128128 
    129         loaded_file_document.getDocumentElement().appendChild(appropriate_fileset_element); 
     129        if(file_path_regexp.equals(DIRECTORY_FILENAME)) { 
     130          loaded_file_document.getDocumentElement().insertBefore(appropriate_fileset_element, loaded_file_document.getDocumentElement().getFirstChild()); 
     131        } else { 
     132          loaded_file_document.getDocumentElement().appendChild(appropriate_fileset_element); 
     133        } 
    130134    } 
    131135 
     
    152156        String current_metadata_element_name_full = current_metadata_element.getAttribute("name"); 
    153157        if (current_metadata_element_name_full.equals(metadata_element_name_full)) { 
     158          // if the metadata must not accumulate, then edit teh current value 
     159          if (!metadata_value.isAccumulatingMetadata()) { 
     160            XMLTools.setNodeText(current_metadata_element, metadata_value_string); 
     161            metadata_already_assigned = true; 
     162            break; 
     163          } 
    154164            // Check if the metadata element value matches 
    155165            String current_metadata_value_string = XMLTools.getElementTextValue(current_metadata_element);