*/
public Validation createValidation(PlugInDTO dto) throws ValidationException, ClassNotFoundException {
//create a PlugIn from a PlugInDTO
Class plugInClass = null;
plugInClass = Class.forName(dto.getClassName());
PlugIn plugIn = new PlugIn(dto.getName(), plugInClass, dto.getDescription(), dto.getArgs());
// copy the arguments over to the new object
// NOTE: this may not be necessary, but we've cloned each argument and
// hashmap here to ensure each new validation has its own unique argument
// (and are not accidentally shared).
Map<String, ArgumentDTO> oldArgs = dto.getArgs();
Map<String, ArgumentDTO> newArgs = new HashMap<String, ArgumentDTO>();
for (Iterator i = oldArgs.keySet().iterator(); i.hasNext();) {
ArgumentDTO oldArg = (ArgumentDTO) oldArgs.get(i.next());
ArgumentDTO newArg = (ArgumentDTO) oldArg.clone();
newArgs.put(newArg.getName(), newArg);
}
// we have the default args, but we'll scan the complete list of args
// and add any that are missing
Map allArgs = plugIn.getPropertyMap();
for (Iterator i = allArgs.keySet().iterator(); i.hasNext();) {
Object thisArg = allArgs.get(i.next());
if (thisArg instanceof PropertyDescriptor) {
PropertyDescriptor thisElement = ((PropertyDescriptor) thisArg);
String argName = thisElement.getName();
Object argValue = thisElement.getValue(argName);
// add keys to the map which do not contain "name", "description", or an existing key
if (!(newArgs.containsKey(argName)) && !(argName.equals("name")) && !(argName.equals("description"))) { //$NON-NLS-1$//$NON-NLS-2$
ArgumentDTO newArg = new ArgumentDTO();
newArg.setName(argName);
newArg.setValue(argValue);
newArgs.put(newArg.getName(), newArg);
}
}
}
//store the complete list of Args for future use (will be overwritten by the latest test creation)
this.allArgs = newArgs;
//create a new validation
Validation validation = plugIn.createValidation(getUniqueName(getTests(), "Test"),dto.getDescription(), newArgs); //$NON-NLS-1$
return validation;
}