1 40 41 package org.dspace.app.webui.util; 42 43 import java.util.List ; 44 import java.util.Map ; 45 46 import org.dspace.content.MetadataSchema; 47 48 54 public class DCInput 55 { 56 57 private String dcElement = null; 58 59 60 private String dcQualifier = null; 61 62 63 private String dcSchema = null; 64 65 66 private String label = null; 67 68 69 private String inputType = null; 70 71 72 private boolean required = false; 73 74 75 private String warning = null; 76 77 78 private boolean repeatable = false; 79 80 81 private String hint = null; 82 83 84 private String valueListName = null; 85 86 87 private List valueList = null; 88 89 90 private String visibility = null; 91 92 93 private String vocabulary = null; 94 95 102 public DCInput(Map fieldMap, Map listMap) 103 { 104 dcElement = (String ) fieldMap.get("dc-element"); 105 dcQualifier = (String ) fieldMap.get("dc-qualifier"); 106 107 dcSchema = (String ) fieldMap.get("dc-schema"); 109 if (dcSchema == null) 110 { 111 dcSchema = MetadataSchema.DC_SCHEMA; 112 } 113 114 String repStr = (String ) fieldMap.get("repeatable"); 115 repeatable = "true".equalsIgnoreCase(repStr) 116 || "yes".equalsIgnoreCase(repStr); 117 label = (String ) fieldMap.get("label"); 118 inputType = (String ) fieldMap.get("input-type"); 119 if ("dropdown".equals(inputType) || "qualdrop_value".equals(inputType)) 121 { 122 valueListName = (String ) fieldMap.get("value-pairs-name"); 123 valueList = (List ) listMap.get(valueListName); 124 } 125 hint = (String ) fieldMap.get("hint"); 126 warning = (String ) fieldMap.get("required"); 127 required = (warning != null && warning.length() > 0); 128 visibility = (String ) fieldMap.get("visibility"); 129 vocabulary = (String ) fieldMap.get("vocabulary"); 130 } 131 132 143 public boolean isVisible(String scope) 144 { 145 return (visibility == null || visibility.equals(scope)); 146 } 147 148 153 public boolean isRepeatable() 154 { 155 return repeatable; 156 } 157 158 163 public boolean getRepeatable() 164 { 165 return isRepeatable(); 166 } 167 168 173 public String getInputType() 174 { 175 return inputType; 176 } 177 178 183 public String getElement() 184 { 185 return dcElement; 186 } 187 188 193 public String getSchema() 194 { 195 return dcSchema; 196 } 197 198 204 public String getWarning() 205 { 206 return "<tr><td colspan=\"4\" class=\"submitFormWarn\">" + warning 207 + "</td></tr>"; 208 } 209 210 215 public boolean isRequired() 216 { 217 return required; 218 } 219 220 225 public String getQualifier() 226 { 227 return dcQualifier; 228 } 229 230 235 public String getHints() 236 { 237 return "<tr><td colspan=\"4\" class=\"submitFormHelp\">" + hint 238 + "</td></tr>"; 239 } 240 241 246 public String getLabel() 247 { 248 return label; 249 } 250 251 256 public String getPairsType() 257 { 258 return valueListName; 259 } 260 261 266 public List getPairs() 267 { 268 return valueList; 269 } 270 271 277 public String getVocabulary() 278 { 279 return vocabulary; 280 } 281 282 289 public void setVocabulary(String vocabulary) 290 { 291 this.vocabulary = vocabulary; 292 } 293 294 308 public String getDisplayString(String pairTypeName, String storedString) 309 { 310 if (valueList != null) 311 { 312 for (int i = 0; i < valueList.size(); i += 2) 313 { 314 if (((String ) valueList.get(i + 1)).equals(storedString)) 315 { 316 return (String ) valueList.get(i); 317 } 318 } 319 } 320 return null; 321 } 322 323 337 public String getStoredString(String pairTypeName, String displayedString) 338 { 339 if (valueList != null) 340 { 341 for (int i = 0; i < valueList.size(); i += 2) 342 { 343 if (((String ) valueList.get(i)).equals(displayedString)) 344 { 345 return (String ) valueList.get(i + 1); 346 } 347 } 348 } 349 return null; 350 } 351 352 } 353 | Popular Tags |