final ClassOrInterfaceTypeDetails entityTypeDetails = typeLocationService
.getTypeDetails(entity);
Validate.notNull(entityTypeDetails,
"The type '%s' could not be resolved", entity);
final PluralMetadata pluralMetadata = (PluralMetadata) metadataService
.get(PluralMetadata.createIdentifier(entity,
PhysicalTypeIdentifier.getPath(entityTypeDetails
.getDeclaredByMetadataId())));
Validate.notNull(pluralMetadata,
"The plural for type '%s' could not be resolved", entity);
// Create type annotation for new managed bean
final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
ROO_JSF_MANAGED_BEAN);
annotationBuilder.addClassAttribute("entity", entity);
if (StringUtils.isBlank(beanName)) {
beanName = StringUtils
.uncapitalize(managedBean.getSimpleTypeName());
}
annotationBuilder.addStringAttribute("beanName", beanName);
if (!includeOnMenu) {
annotationBuilder.addBooleanAttribute("includeOnMenu",
includeOnMenu);
}
final LogicalPath managedBeanPath = pathResolver
.getFocusedPath(Path.SRC_MAIN_JAVA);
final String resourceIdentifier = typeLocationService
.getPhysicalTypeCanonicalPath(managedBean, managedBeanPath);
final String declaredByMetadataId = PhysicalTypeIdentifier
.createIdentifier(managedBean,
pathResolver.getPath(resourceIdentifier));
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
declaredByMetadataId, Modifier.PUBLIC, managedBean,
PhysicalTypeCategory.CLASS);
cidBuilder
.addAnnotation(new AnnotationMetadataBuilder(ROO_SERIALIZABLE));
cidBuilder.addAnnotation(annotationBuilder);
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
shell.flash(Level.FINE,
"Created " + managedBean.getFullyQualifiedTypeName(),
JsfOperationsImpl.class.getName());
shell.flash(Level.FINE, "", JsfOperationsImpl.class.getName());
copyEntityTypePage(entity, beanName, pluralMetadata.getPlural());
// Create a javax.faces.convert.Converter class for the entity
createConverter(new JavaPackage(managedBeanTypeName + ".converter"),
entity);
}