Changeset 5930
- Timestamp:
- 2003-11-21T10:57:52+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/cdm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java
r5907 r5930 737 737 boolean special = false; 738 738 // If there is no value attribute, then we don't write anything 739 StringBuffer text = new StringBuffer(""); 740 String name_str = command_element.getAttribute(NAME_ATTRIBUTE); 741 // If the name is one of the special four, we don't write the collectionmeta first. Note the maintainer collectionmeta is singled out for 'prittying' reasons. 742 if(name_str.equals(COLLECTIONMETADATA_MAINTAINER_STR)) { 743 text.append(name_str); 744 text.append(TAB_CHARACTER); 745 special = true; 746 } 747 else if(name_str.equals(COLLECTIONMETADATA_BETA_STR) || name_str.equals(COLLECTIONMETADATA_CREATOR_STR) || name_str.equals(COLLECTIONMETADATA_PUBLIC_STR)) { 748 text.append(name_str); 749 text.append(TAB_CHARACTER); 750 text.append(TAB_CHARACTER); 751 special = true; 752 } 753 else { 754 text.append(COLLECTIONMETADATA_STR); 755 text.append(TAB_CHARACTER); 756 text.append(name_str); 757 text.append(SPACE_CHARACTER); 758 String language_str = command_element.getAttribute(LANGUAGE_ATTRIBUTE); 759 // If this is element is in english, and it is the first one found, we don't need to write the language argument. 760 //if(!language_str.equals(ENGLISH_LANGUAGE_STR) || known_metadata == null || known_metadata.contains(name_str)) { 761 // changed so that we always write the language string 762 text.append(LBRACKET_CHARACTER); 763 text.append(LANGUAGE_ARGUMENT); 764 text.append(language_str); 765 text.append(RBRACKET_CHARACTER); 766 text.append(SPACE_CHARACTER); 767 //} 768 if(known_metadata != null) { 769 known_metadata.add(name_str); 770 } 771 language_str = null; 772 } 773 name_str = null; 774 739 775 String value_str = MSMUtils.getValue(command_element); 740 if(value_str == null || value_str.length() == 0) { 741 return ""; 776 // The value string we retrieved will be encoded for xml, so we now decode it - to text if text_value set. This parameter was originally show_extracted_namespace, but sincethis is only true for 'toString()' commands from within the CDM, its good enough to determine if this toString() will be used to display on screen, or write to collect.cfg 777 if(text_value == CollectionMeta.TEXT) { 778 value_str = Codec.transform(value_str, Codec.DOM_TO_TEXT); 742 779 } 743 780 else { 744 StringBuffer text = new StringBuffer(""); 745 String name_str = command_element.getAttribute(NAME_ATTRIBUTE); 746 // If the name is one of the special four, we don't write the collectionmeta first. Note the maintainer collectionmeta is singled out for 'prittying' reasons. 747 if(name_str.equals(COLLECTIONMETADATA_MAINTAINER_STR)) { 748 text.append(name_str); 749 text.append(TAB_CHARACTER); 750 special = true; 751 } 752 else if(name_str.equals(COLLECTIONMETADATA_BETA_STR) || name_str.equals(COLLECTIONMETADATA_CREATOR_STR) || name_str.equals(COLLECTIONMETADATA_PUBLIC_STR)) { 753 text.append(name_str); 754 text.append(TAB_CHARACTER); 755 text.append(TAB_CHARACTER); 756 special = true; 757 } 758 else { 759 text.append(COLLECTIONMETADATA_STR); 760 text.append(TAB_CHARACTER); 761 text.append(name_str); 762 text.append(SPACE_CHARACTER); 763 String language_str = command_element.getAttribute(LANGUAGE_ATTRIBUTE); 764 // If this is element is in english, and it is the first one found, we don't need to write the language argument. 765 //if(!language_str.equals(ENGLISH_LANGUAGE_STR) || known_metadata == null || known_metadata.contains(name_str)) { 766 // changed so that we always write the language string 767 text.append(LBRACKET_CHARACTER); 768 text.append(LANGUAGE_ARGUMENT); 769 text.append(language_str); 770 text.append(RBRACKET_CHARACTER); 771 text.append(SPACE_CHARACTER); 772 //} 773 if(known_metadata != null) { 774 known_metadata.add(name_str); 775 } 776 language_str = null; 777 } 778 name_str = null; 779 780 // The value string we retrieved will be encoded for xml, so we now decode it - to text if text_value set. This parameter was originally show_extracted_namespace, but sincethis is only true for 'toString()' commands from within the CDM, its good enough to determine if this toString() will be used to display on screen, or write to collect.cfg 781 if(text_value == CollectionMeta.TEXT) { 782 value_str = Codec.transform(value_str, Codec.DOM_TO_TEXT); 783 } 784 else { 785 value_str = Codec.transform(value_str, Codec.DOM_TO_GREENSTONE); 786 } 787 788 // We don't wrap the email addresses in quotes, nor any string without spaces 789 if(special) { 790 text.append(value_str); 791 } 792 else { 793 text.append(SPEECH_CHARACTER); 794 text.append(value_str); 795 text.append(SPEECH_CHARACTER); 796 } 797 value_str = null; 798 return text.toString(); 799 } 781 value_str = Codec.transform(value_str, Codec.DOM_TO_GREENSTONE); 782 } 783 784 // We don't wrap the email addresses in quotes, nor the other special metadata 785 if(special) { 786 text.append(value_str); 787 } 788 else { 789 text.append(SPEECH_CHARACTER); 790 text.append(value_str); 791 text.append(SPEECH_CHARACTER); 792 } 793 value_str = null; 794 return text.toString(); 800 795 } 801 796 … … 1254 1249 command_element.setAttribute(NAME_ATTRIBUTE, name_str); 1255 1250 command_element.setAttribute(LANGUAGE_ATTRIBUTE, language_str); 1251 command_element.setAttribute(ASSIGNED_ATTRIBUTE, TRUE_STR); 1256 1252 MSMUtils.setValue(command_element, value_str); 1257 1253 } … … 1293 1289 command_element.setAttribute(LANGUAGE_ATTRIBUTE, ENGLISH_LANGUAGE_STR); 1294 1290 command_element.setAttribute(SPECIAL_ATTRIBUTE, TRUE_STR); 1291 command_element.setAttribute(ASSIGNED_ATTRIBUTE, TRUE_STR); 1295 1292 if(value_str.startsWith(SPEECH_CHARACTER) && value_str.endsWith(SPEECH_CHARACTER)) { 1296 1293 value_str = value_str.substring(1, value_str.length() - 1); -
trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMeta.java
r5899 r5930 53 53 54 54 private boolean dummy = false; 55 private Element element ;56 private String text ;55 private Element element = null; 56 private String text = null; 57 57 58 58 /** Constructor. … … 68 68 element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name); 69 69 element.setAttribute(StaticStrings.LANGUAGE_ATTRIBUTE, Gatherer.config.interface_language); 70 element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR); 70 71 } 71 72 … … 75 76 element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name); 76 77 element.setAttribute(StaticStrings.LANGUAGE_ATTRIBUTE, language); 78 element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR); 77 79 } 78 80 … … 170 172 MSMUtils.setValue(element, Codec.transform(raw_value, Codec.TEXT_TO_DOM)); 171 173 text = null; // Reset text 174 // And determine if this makes the metadata assigned 175 setAssigned(raw_value != null && raw_value.length() > 0); 172 176 } 173 177 -
trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMetaManager.java
r5900 r5930 61 61 // Locate where we should insert this new subcollection. 62 62 Node target_node = CollectionConfiguration.findInsertionPoint(element); 63 // Failing that we insert immediately after a language string64 63 add(root, metadata, target_node); 65 64 Gatherer.c_man.configurationChanged(); … … 126 125 CollectionMeta metadatum = (CollectionMeta) getElementAt(i); 127 126 if(metadatum.getName().equals(name) && metadatum.getLanguage().equals(Gatherer.config.interface_language)) { 128 //Gatherer.println("Found '" + metadatum + "'");127 Gatherer.println("Found '" + metadatum + "'"); 129 128 return metadatum; 130 129 } … … 137 136 CollectionMeta result = new CollectionMeta(name); 138 137 addMetadatum(result); 139 //Gatherer.println("Added new metadata.");138 Gatherer.println("Added new metadata: " + name); 140 139 return result; 141 140 }
Note:
See TracChangeset
for help on using the changeset viewer.