- Timestamp:
- 2009-04-06T11:16:07+12:00 (15 years ago)
- Location:
- gli/trunk/src/org/greenstone/gatherer/cdm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/cdm/IndexManager.java
r18610 r18886 939 939 // Before we add the index to the model, we have to add a default collection metadata for this 940 940 CollectionMeta metadatum = new CollectionMeta(StaticStrings.STOP_CHARACTER + index.getID()); 941 metadatum.setValue(index.getID()); 941 if (use_macro_as_display_name(index.getID())) { 942 metadatum.setValue(get_macro_name(index.getID())); 943 } else { 944 metadatum.setValue(index.getID()); 945 } 942 946 943 947 // Finally, add the index … … 1032 1036 // Create the new collection meta 1033 1037 CollectionMeta metadatum = new CollectionMeta(StaticStrings.STOP_CHARACTER + index.getID()); 1034 metadatum.setValue(index.getID()); 1038 if (use_macro_as_display_name(index.getID())) { 1039 metadatum.setValue(get_macro_name(index.getID())); 1040 } else { 1041 metadatum.setValue(index.getID()); 1042 } 1035 1043 1036 1044 // replace the index … … 1043 1051 } 1044 1052 } 1053 1054 /** 1055 * If the index is built with DC metadata, use macro variable as the display text, 1056 * so that translations of DC metadata can be displayed in the search field drop-down list 1057 * when interface language changes. 1058 * 1059 * @param index_id Current index id. 1060 * @return Whether macro variable should be used. 1061 */ 1062 private boolean use_macro_as_display_name(String index_id) { 1063 //String metaname = index_id; 1064 if (index_id.indexOf(":") != -1) { 1065 index_id = index_id.substring(index_id.indexOf(":") + 1); 1066 } 1067 1068 String field = null; 1069 String[] fields = index_id.split(","); 1070 for (int i = 0; i < fields.length; i++) { 1071 String s = fields[i]; 1072 if (s.indexOf(".") != -1) { 1073 s = s.substring(s.indexOf(".") + 1); 1074 } 1075 if (field == null) { 1076 field = s; 1077 } 1078 else if (!field.equals(s)) { 1079 return false; 1080 } 1081 } 1082 1083 field = field.toLowerCase(); 1084 if (field.equals("text") || field.equals("title") || field.equals("creator") || field.equals("subject") || 1085 field.equals("description") || field.equals("publisher") || field.equals("contributor") || field.equals("date") || 1086 field.equals("type") || field.equals("format") || field.equals("identifier") || field.equals("source") || 1087 field.equals("language") || field.equals("relation") || field.equals("coverage") || field.equals("rights")) { 1088 return true; 1089 } 1090 1091 return false; 1092 } 1093 1094 /** 1095 * Get the corresponding macro variable name, eg. _labelTitle_, _labelCreator_. 1096 * 1097 * @param index_id Current index id. 1098 * @return Name of the macro variable. 1099 */ 1100 private String get_macro_name(String index_id) { 1101 if (index_id.indexOf(":") != -1) { 1102 index_id = index_id.substring(index_id.indexOf(":") + 1); 1103 } 1104 if (index_id.indexOf(",") != -1) { 1105 index_id = index_id.substring(0, index_id.indexOf(",")); 1106 } 1107 if (index_id.indexOf(".") != -1) { 1108 index_id = index_id.substring(index_id.indexOf(".") + 1); 1109 } 1110 1111 return "_label" + index_id + "_"; 1112 } 1045 1113 } 1046 1114 } -
gli/trunk/src/org/greenstone/gatherer/cdm/IndexOptionManager.java
r18688 r18886 95 95 CollectionMeta meta = new CollectionMeta(StaticStrings.STOP_CHARACTER + level); 96 96 meta.setAssigned(true); 97 meta.setValue(level); 97 if (level.equals("document") || level.equals("section")) { 98 meta.setValue("_text" + level + "_"); 99 } else { 100 meta.setValue(level); 101 } 98 102 CollectionDesignManager.collectionmeta_manager.addMetadatum(meta); 99 103 }
Note:
See TracChangeset
for help on using the changeset viewer.