final ObjectSpecification specification = object.getSpecification();
final List<ObjectAssociation> visibleFields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(getAuthenticationSession(), object, where));
for (int i = 0; i < visibleFields.size(); i++) {
final ObjectAssociation field = visibleFields.get(i);
final ComponentFactory factory = context.getComponentFactory();
final Block fieldBlock = factory.createBlock("field", field.getDescription());
fieldBlock.add(factory.createInlineBlock("label", field.getName(), null));
fieldBlock.add(factory.createInlineBlock("separator", ": ", null));
getPersistenceSession().resolveField(object, field);
// ordering is important here;
// look at parseable fields before objects
final ObjectAdapter associatedObject = field.get(object);
Component component = null;
if (field.getSpecification().isParseable()) {
component = factory.createParseableField(field, associatedObject, false);
} else if (field.isOneToOneAssociation()) {
if (associatedObject == null) {
component = factory.createInlineBlock("value", "", null);
fieldBlock.add(component);
} else {
// previously there was a called to resolveImmediately here
// on the
// associated object, but it has been removed (presumably we
// don't
// want to force eager loading).
final String elementId = context.mapObject(associatedObject);
component = factory.createObjectIcon(field, associatedObject, elementId, "value");
}
} else if (field.isOneToManyAssociation()) {
component = factory.createCollectionIcon(field, associatedObject, id);
} else {
throw new UnknownTypeException(field);
}
fieldBlock.add(component);