}
return descriptor;
}
private DataSourceDescriptor createDataSourceDescriptor(Class<?> clazz) {
DataSourceDescriptor dataSourceDescriptor = new DataSourceDescriptor();
String name = clazz.getSimpleName().toLowerCase();
dataSourceDescriptor.put("name", name);
// dataSourceDescriptor.put("dataFormat", DSDataFormat.JSON.getValue());
dataSourceDescriptor.put("dataFormat", "json");
for (Field field : clazz.getDeclaredFields()) {
if (!TypeUtils.isSaveable(field))
continue;
boolean original = field.isAccessible();
field.setAccessible(true);
String fieldName = field.getName();
Map<String, String> map = new HashMap<String, String>();
dataSourceDescriptor.getFields().put(fieldName, map);
System.out.println("getting type for " + fieldName + " "
+ field.getType().getSimpleName());
String fieldType;
if (isCollection(field.getType())) {
map.put("multiple", "true");
fieldType = convertToDataSourceFieldType((Class<?>) getTypeInCollection(field));
} else
fieldType = convertToDataSourceFieldType(field.getType());
map.put("type", fieldType);
if (field.isAnnotationPresent(Id.class)) {
map.put("primaryKey", "true");
dataSourceDescriptor.setId(fieldName);
}
field.setAccessible(original);
}
return dataSourceDescriptor;