/*
* Identify id field
*/
if (orm.isIdField(clazz, fieldName)) {
this.fields.add(new FieldDefinition(field, config));
this.idProperty = fieldName;
continue;
}
/*
* Create the field names for association id fields
*/
String extFieldName = field.getName();
if (orm.isOneToMany(clazz, fieldName) || orm.isManyToMany(clazz, fieldName)) {
extFieldName = Inflector.getInstance().singularize(fieldName) + "Ids";
} else if (orm.isManyToOne(clazz, fieldName)) {
extFieldName = fieldName + "Id";
}
/*
* Is this field included or excluded?
*/
if (isRoot) {
if (includes.size() > 0
&& (!includes.contains("*") && !includes.contains(extFieldName))) {
continue;
}
if (excludes.contains("*") || excludes.contains(extFieldName)) {
continue;
}
} else {
if (includes.size() > 0) {
if (entityClassIncludes.isEmpty()
|| (!entityClassIncludes.contains("*") && !entityClassIncludes.contains(extFieldName))) {
continue;
}
}
if (excludes.size() > 0) {
if (entityClassExcludes.contains("*") || entityClassExcludes.contains(extFieldName)) {
continue;
}
}
}
/*
* If we have a one to many association, add a field to hold an array
* of ID's for that association
*/
if (orm.isOneToMany(clazz, fieldName) || orm.isManyToMany(clazz, fieldName) || orm.isManyToOne(clazz, fieldName)) {
this.fields.add(new FieldDefinition(extFieldName, "auto"));
} else {
this.fields.add(new FieldDefinition(field, config));
}
}
}