* @throws IllegalArgumentException
*/
public void addGroup(Object data) throws InvalidMappingException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
{
CormObject ct;
CormObjectField cfg;
FormFieldset group;
// Comprueba si el objeto proporcionado es un objeto CORM v�lido
if (!OrmFactory.isValidCormObject(data.getClass()))
{
throw new InvalidMappingException(data.getClass() + " is not a CORM object.");
}
// Obtiene las propiedades de la clase y las mapea al formulario
ct = data.getClass().getAnnotation(CormObject.class);
this.name = ct.formName();
// Obtiene la lista de campos y los mapea a un grupo
group = new FormFieldset("");
group.setTitle(ct.title());
group.setDescription(ct.description());
for (Method method : data.getClass().getMethods())
{
cfg = method.getAnnotation(CormObjectField.class);
if (cfg != null && !cfg.isAutogenerated())
{
if (cfg.fieldClass() == FormFieldText.class)
{
FormFieldText fld = new FormFieldText(cfg.dbTableColumn(), cfg.label());
fld.setValue(method.invoke(data));
group.addField(fld);
}
else if (cfg.fieldClass() == FormFieldTextArea.class)
{
FormFieldTextArea fld = new FormFieldTextArea(cfg.dbTableColumn(), cfg.label());
fld.setValue(method.invoke(data));
group.addField(fld);
}
else if (cfg.fieldClass() == FormFieldInteger.class)
{
FormFieldInteger fld = new FormFieldInteger(cfg.dbTableColumn(), cfg.label());
fld.setValue(method.invoke(data));
group.addField(fld);
}
else if (cfg.fieldClass() == FormFieldNumber.class)
{
FormFieldNumber fld = new FormFieldNumber(cfg.dbTableColumn(), cfg.label());
fld.setValue(method.invoke(data));
group.addField(fld);
}
else if (cfg.fieldClass() == FormFieldList.class)
{
FormFieldList fld = new FormFieldList(cfg.dbTableColumn(), cfg.label());
fld.setList(getWorkspace().getProperties().getDataProperties().getDataList(cfg.list()));
fld.setValue(method.invoke(data));
group.addField(fld);
}
else if (cfg.fieldClass() == FormFieldBoolean.class)
{
FormFieldBoolean fld = new FormFieldBoolean(cfg.dbTableColumn(), cfg.label());
fld.setValue(method.invoke(data));
group.addField(fld);
}
else if (cfg.fieldClass() == FormFieldDate.class)
{
FormFieldDate fld = new FormFieldDate(cfg.dbTableColumn(), cfg.label());
fld.setValue(method.invoke(data));
group.addField(fld);
}
else if (cfg.fieldClass() == FormFieldCaptcha.class)
{
FormFieldCaptcha fld = new FormFieldCaptcha(cfg.dbTableColumn(), cfg.label());
fld.setValue(method.invoke(data));
group.addField(fld);
}
}
}