private static String getLabel(Field field) {
return field.isAnnotationPresent(Label.class) ? field.getAnnotation(Label.class).value() : "";
}
private static ModuleDto getEntityMetaData(final Class<?> domainClass) {
final ModuleDto moduleDto = new ModuleDto();
final String kind = domainClass.getSimpleName();
moduleDto.setModule(kind);
moduleDto.setTitle(kind);
moduleDto.setHistoryToken(kind);
moduleDto.setHidden(domainClass.isAnnotationPresent(Hidden.class));
moduleDto.setFields(getFields(domainClass));
if (domainClass.isAnnotationPresent(HasExtraButton.class)) {
final String label = domainClass.getAnnotation(HasExtraButton.class).label();
final Class<? extends AbstractAction> action = domainClass.getAnnotation(HasExtraButton.class).action();
final ModuleAction show = domainClass.getAnnotation(HasExtraButton.class).show();
final ExtraButton b = new ExtraButton();
b.setLabel(label);
try {
b.setAction(action.newInstance());
} catch (Exception e) {
e.printStackTrace();
log.warning("Cannot instantiate action for " + ExtraButton.class);
}
b.setShow(show);
moduleDto.setExtraButtons(new ExtraButton[] { b });
} else {
moduleDto.setExtraButtons(new ExtraButton[0]);
}
if (domainClass.isAnnotationPresent(Quicksearchable.class)) {
moduleDto.setQuickSearchItems(domainClass.getAnnotation(Quicksearchable.class).value());
}
if (domainClass.isAnnotationPresent(ListViewable.class)) {
moduleDto.setListFieldIds(domainClass.getAnnotation(ListViewable.class).value());
}
if (domainClass.isAnnotationPresent(DetailViewable.class)) {
final String[] rows = domainClass.getAnnotation(DetailViewable.class).value();
final String[][] fields = new String[rows.length][];
for (int i = 0; i < rows.length; i++) {
fields[i] = rows[i].split(",");
}
moduleDto.setFormFieldIds(fields);
}
moduleDto.setRelateFieldMappings(getRelateFieldMappings(domainClass));
moduleDto.setOneToManyMappings(getOneToManyMappings(domainClass));
moduleDto.setFulltextFields(getFulltextFields(domainClass));
return moduleDto;
}