}
metadataDependencyRegistry.registerDependency(
field.getDeclaredByMetadataId(),
metadataIdentificationString);
final CustomDataBuilder customDataBuilder = new CustomDataBuilder(
field.getCustomData());
final JavaType fieldType = field.getFieldType();
if (fieldType.equals(DATE)
&& field.getFieldName().getSymbolName().equals("created")) {
continue;
}
final ClassOrInterfaceTypeDetails fieldTypeCid = typeLocationService
.getTypeDetails(fieldType);
// Check field is to be displayed in the entity's list view
if (listViewFields < MAX_LIST_VIEW_FIELDS
&& isFieldOfInterest(field) && fieldTypeCid == null) {
listViewFields++;
customDataBuilder.put(LIST_VIEW_FIELD_KEY, field);
}
final boolean enumerated = field.getCustomData().keySet()
.contains(CustomDataKeys.ENUMERATED_FIELD)
|| isEnum(fieldTypeCid);
if (enumerated) {
customDataBuilder.put(ENUMERATED_KEY, null);
}
else {
if (fieldType.isCommonCollectionType()) {
parameterTypeLoop: for (final JavaType parameter : fieldType
.getParameters()) {
final ClassOrInterfaceTypeDetails parameterTypeCid = typeLocationService
.getTypeDetails(parameter);
if (parameterTypeCid == null) {
continue;
}
for (final ClassOrInterfaceTypeDetails managedBeanType : managedBeanTypes) {
final AnnotationMetadata managedBeanAnnotation = managedBeanType
.getAnnotation(ROO_JSF_MANAGED_BEAN);
if (((JavaType) managedBeanAnnotation.getAttribute(
"entity").getValue()).equals(parameter)) {
customDataBuilder.put(PARAMETER_TYPE_KEY,
parameter);
customDataBuilder.put(
PARAMETER_TYPE_MANAGED_BEAN_NAME_KEY,
managedBeanAnnotation.getAttribute(
"beanName").getValue());
final LogicalPath logicalPath = PhysicalTypeIdentifier
.getPath(parameterTypeCid
.getDeclaredByMetadataId());
final PluralMetadata pluralMetadata = (PluralMetadata) metadataService
.get(PluralMetadata.createIdentifier(
parameter, logicalPath));
if (pluralMetadata != null) {
customDataBuilder.put(
PARAMETER_TYPE_PLURAL_KEY,
pluralMetadata.getPlural());
}
// Only support one generic type parameter
break parameterTypeLoop;
}
// Parameter type is not an entity - test for an
// enum
if (isEnum(parameterTypeCid)) {
customDataBuilder.put(PARAMETER_TYPE_KEY,
parameter);
}
}
}
}
else {
if (fieldTypeCid != null
&& !customDataBuilder.keySet().contains(
CustomDataKeys.EMBEDDED_FIELD)) {
customDataBuilder.put(APPLICATION_TYPE_KEY, null);
final MethodMetadata applicationTypeIdentifierAccessor = persistenceMemberLocator
.getIdentifierAccessor(entity);
final MethodMetadata applicationTypeVersionAccessor = persistenceMemberLocator
.getVersionAccessor(entity);
final List<FieldMetadata> applicationTypeFields = new ArrayList<FieldMetadata>();
int dropDownFields = 0;
final MemberDetails applicationTypeMemberDetails = getMemberDetails(fieldType);
for (final MethodMetadata applicationTypeMethod : applicationTypeMemberDetails
.getMethods()) {
if (!BeanInfoUtils
.isAccessorMethod(applicationTypeMethod)) {
continue;
}
if (applicationTypeMethod.hasSameName(
applicationTypeIdentifierAccessor,
applicationTypeVersionAccessor)) {
continue;
}
final FieldMetadata applicationTypeField = BeanInfoUtils
.getFieldForJavaBeanMethod(
applicationTypeMemberDetails,
applicationTypeMethod);
if (applicationTypeField == null) {
continue;
}
if (dropDownFields < MAX_DROP_DOWN_FIELDS
&& isFieldOfInterest(applicationTypeField)
&& !typeLocationService
.isInProject(applicationTypeField
.getFieldType())) {
dropDownFields++;
applicationTypeFields.add(applicationTypeField);
}
}
if (applicationTypeFields.isEmpty()) {
applicationTypeFields.add(BeanInfoUtils
.getFieldForJavaBeanMethod(
applicationTypeMemberDetails,
applicationTypeIdentifierAccessor));
}
customDataBuilder.put(APPLICATION_TYPE_FIELDS_KEY,
applicationTypeFields);
customDataBuilder.put(
CRUD_ADDITIONS_KEY,
getCrudAdditions(fieldType,
metadataIdentificationString));
}
}