Changeset 16258
- Timestamp:
- 18/07/08 15:02:51 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/intermine/web/main/src/org/intermine/web/logic/config/WebConfig.java
r15876 r16258 40 40 public class WebConfig 41 41 { 42 private Map<String, Type> types = new HashMap(); 43 private Map tableExportConfigs = new HashMap(); 44 private Map<String, WidgetConfig> widgets = new HashMap(); 45 42 private Map<String, Type> types = new HashMap<String, Type>(); 43 private Map<String, TableExportConfig> tableExportConfigs = 44 new HashMap<String, TableExportConfig>(); 45 private Map<String, WidgetConfig> widgets = new HashMap<String, WidgetConfig>(); 46 46 47 /** 47 48 * Parse a WebConfig XML file … … 128 129 129 130 webConfig.validate(model); 130 131 131 132 webConfig.setSubClassConfig(model); 132 133 133 134 return webConfig; 134 135 } 135 136 136 137 /** 137 * Validate web config according to the model. Test that configured classes exist in 138 * Validate web config according to the model. Test that configured classes exist in 138 139 * model and configured fields in web config exist in model. 139 140 * @param model model used for validation … … 143 144 if (!model.getClassNames().contains(typeName)) { 144 145 throw new RuntimeException("Invalid web config. Class specified in web config " 145 + "doesn't exist in model. Web config class: " + typeName + ".");146 + "doesn't exist in model. Web config class: " + typeName + "."); 146 147 } 147 148 Type type = types.get(typeName); … … 150 151 String pathString; 151 152 try { 152 pathString = Class.forName(typeName).getSimpleName() 153 pathString = Class.forName(typeName).getSimpleName() 153 154 + "." + fieldConfig.getFieldExpr(); 154 155 } catch (ClassNotFoundException e) { … … 158 159 } 159 160 try { 160 Path path =new Path(model, pathString);161 new Path(model, pathString); 161 162 } catch (PathError e) { 162 throw new RuntimeException("Invalid web config. Field expression '" 163 + fieldConfig.getFieldExpr() + "' for class " 163 throw new RuntimeException("Invalid web config. Field expression '" 164 + fieldConfig.getFieldExpr() + "' for class " 164 165 + typeName + " is not valid according to the model. " 165 166 + "Corresponding path " + pathString + " doesn't exist."); 166 167 } 167 168 } 168 } 169 } 169 170 } 170 171 … … 259 260 void setSubClassConfig(Model model) throws ClassNotFoundException { 260 261 TreeSet<String> classes = new TreeSet<String>(model.getClassNames()); 261 for (Iterator modelIter = classes.iterator(); modelIter.hasNext();) {262 263 String className = (String)modelIter.next();264 Type thisClassType = (Type)types.get(className);262 for (Iterator<String> modelIter = classes.iterator(); modelIter.hasNext();) { 263 264 String className = modelIter.next(); 265 Type thisClassType = types.get(className); 265 266 266 267 if (thisClassType == null) { … … 270 271 } 271 272 272 Set cds = model.getClassDescriptorsForClass(Class.forName(className));273 List cdList = new ArrayList(cds);274 275 for (Iterator cdIter = cdList.iterator(); cdIter.hasNext(); ) {276 ClassDescriptor cd = (ClassDescriptor)cdIter.next();273 Set<ClassDescriptor> cds = model.getClassDescriptorsForClass(Class.forName(className)); 274 List<ClassDescriptor> cdList = new ArrayList<ClassDescriptor>(cds); 275 276 for (Iterator<ClassDescriptor> cdIter = cdList.iterator(); cdIter.hasNext(); ) { 277 ClassDescriptor cd = cdIter.next(); 277 278 278 279 if (className.equals(cd.getName())) { … … 280 281 } 281 282 282 Type superClassType = (Type)types.get(cd.getName());283 Type superClassType = types.get(cd.getName()); 283 284 284 285 if (superClassType != null) { … … 310 311 && superClassType.getWidgets() != null 311 312 && superClassType.getWidgets().size() > 0) { 312 Iterator widgetIter 313 = superClassType.getWidgets().iterator(); 313 Iterator widgetIter = superClassType.getWidgets().iterator(); 314 314 315 315 while (widgetIter.hasNext()) { … … 331 331 StringBuffer sb = new StringBuffer(); 332 332 sb.append("<webconfig>"); 333 Iterator typesIter = types.values().iterator();333 Iterator<Type> typesIter = types.values().iterator(); 334 334 while (typesIter.hasNext()) { 335 335 sb.append(typesIter.next().toString()); 336 336 } 337 Iterator tableExportConfigIter = tableExportConfigs.values().iterator();337 Iterator<TableExportConfig> tableExportConfigIter = tableExportConfigs.values().iterator(); 338 338 while (tableExportConfigIter.hasNext()) { 339 339 sb.append(tableExportConfigIter.next().toString());
