use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class PluralServiceImpl method getPlural.
@Override
public String getPlural(JavaType type, Locale locale) {
Validate.notNull(type, "ERROR: You must provide a valid JavaType");
Validate.notNull(locale, "ERROR: You must provide a valid Locale");
// Getting ClassOrInterfaceTypeDetails
ClassOrInterfaceTypeDetails cid = getTypeLocationService().getTypeDetails(type);
Validate.notNull(cid, "ERROR: You must provide an existing JavaType");
return getPlural(cid, locale);
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class RepositoryJpaCommands method getEntityPossibleResults.
@CliOptionAutocompleteIndicator(command = "repository jpa", param = "entity", help = "--entity option should be an entity.")
public List<String> getEntityPossibleResults(ShellContext shellContext) {
// Get current value of class
String currentText = shellContext.getParameters().get("entity");
List<String> allPossibleValues = new ArrayList<String>();
// Getting all existing entities
Set<ClassOrInterfaceTypeDetails> entitiesInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_JPA_ENTITY);
for (ClassOrInterfaceTypeDetails entity : entitiesInProject) {
String name = replaceTopLevelPackageString(entity, currentText);
if (!allPossibleValues.contains(name)) {
allPossibleValues.add(name);
}
}
return allPossibleValues;
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class RepositoryJpaCommands method getAssociatedProjectionResults.
/**
* This indicator return all Projection classes associated to an entity specified
* in the 'entity' parameter.
*
* @param shellContext the Roo ShellContext.
* @return List<String> with fullyQualifiedNames of each associated Projection.
*/
@CliOptionAutocompleteIndicator(command = "repository jpa", param = "defaultReturnType", help = "--defaultReturnType option should be a Projection class associated to the entity specified in --entity.")
public List<String> getAssociatedProjectionResults(ShellContext shellContext) {
List<String> allPossibleValues = new ArrayList<String>();
// Get current value of 'defaultReturnType'
String currentText = shellContext.getParameters().get("defaultReturnType");
// Get current value of 'entity'
JavaType entity = getTypeFromEntityParam(shellContext);
Set<ClassOrInterfaceTypeDetails> projectionsInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_ENTITY_PROJECTION);
for (ClassOrInterfaceTypeDetails projection : projectionsInProject) {
// Add only projections associated to the entity specified in the command
if (projection.getAnnotation(RooJavaType.ROO_ENTITY_PROJECTION).getAttribute("entity").getValue().equals(entity)) {
String name = replaceTopLevelPackageString(projection, currentText);
if (!allPossibleValues.contains(name)) {
allPossibleValues.add(name);
}
}
}
return allPossibleValues;
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class RepositoryJpaCommands method isDefaultReturnTypeParameterVisible.
/**
* This indicator says if --defaultReturnType parameter should be visible or not.
*
* @param context ShellContext
* @return false if domain entity specified in --entity parameter has no associated Projections.
*/
@CliOptionVisibilityIndicator(params = "defaultReturnType", command = "repository jpa", help = "--defaultReturnType parameter is not visible if domain entity specified in --entity parameter has no associated Projections.")
public boolean isDefaultReturnTypeParameterVisible(ShellContext shellContext) {
// Get current value of 'entity'
JavaType entity = getTypeFromEntityParam(shellContext);
if (entity == null) {
return false;
}
Set<ClassOrInterfaceTypeDetails> projectionsInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_ENTITY_PROJECTION);
boolean visible = false;
for (ClassOrInterfaceTypeDetails projection : projectionsInProject) {
// Add only projections associated to the entity specified in the command
if (projection.getAnnotation(RooJavaType.ROO_ENTITY_PROJECTION).getAttribute("entity").getValue().equals(entity)) {
visible = true;
break;
}
}
return visible;
}
use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.
the class DbreDatabaseListenerImpl method deleteManagedType.
private void deleteManagedType(final ClassOrInterfaceTypeDetails managedEntity, final String reason) {
if (!isEntityDeletable(managedEntity)) {
return;
}
deleteJavaType(managedEntity.getName(), reason);
final JavaType identifierType = getIdentifierType(managedEntity.getName());
for (final ClassOrInterfaceTypeDetails managedIdentifier : getManagedIdentifiers()) {
if (managedIdentifier.getName().equals(identifierType)) {
deleteJavaType(identifierType, "managed identifier of deleted type " + managedEntity.getName());
break;
}
}
}
Aggregations