use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class FinderCommands method getFormBeanPossibleResults.
@CliOptionAutocompleteIndicator(command = "finder add", includeSpaceOnFinish = false, param = "formBean", help = "--formBean option should be a DTO.")
public List<String> getFormBeanPossibleResults(ShellContext shellContext) {
// Get current value of entity
String currentText = shellContext.getParameters().get("formBean");
List<String> allPossibleValues = new ArrayList<String>();
Set<ClassOrInterfaceTypeDetails> dtosInProject = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_DTO);
for (ClassOrInterfaceTypeDetails dto : dtosInProject) {
String name = replaceTopLevelPackageString(dto, currentText);
if (!allPossibleValues.contains(name)) {
allPossibleValues.add(name);
}
}
return allPossibleValues;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class FinderCommands method getClassPossibleResults.
@CliOptionAutocompleteIndicator(command = "finder add", includeSpaceOnFinish = false, param = "entity", help = "--entity option should be an entity.")
public List<String> getClassPossibleResults(ShellContext shellContext) {
// ROO-3763: Clear current cache during --entity autocompletion.
// With that, Spring Roo will maintain cache during --name autocompletion
// but if --entity is autocomplete, cache should be refreshed to obtain
// last changes on entities
entitiesDetails = new HashMap<JavaType, MemberDetails>();
// Get current value of entity
String currentText = shellContext.getParameters().get("entity");
List<String> allPossibleValues = new ArrayList<String>();
Set<ClassOrInterfaceTypeDetails> entities = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_JPA_ENTITY);
for (ClassOrInterfaceTypeDetails entity : entities) {
String name = replaceTopLevelPackageString(entity, currentText);
if (!allPossibleValues.contains(name)) {
allPossibleValues.add(name);
}
}
return allPossibleValues;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class PushInCommands method getAllPossibleMethods.
/**
* Method that returns all defined methods for provided class on --class parameter.
*
* @param context context
* ShellContext used to obtain specified parameters
* @return List with available methods. Empty List if class has not been specified.
*/
@CliOptionAutocompleteIndicator(command = "push-in", param = "method", validate = false, help = "Provides possible methods names if some class parameter has been specified")
public List<String> getAllPossibleMethods(ShellContext context) {
List<String> allPossibleMethods = new ArrayList<String>();
// Getting all introduces parameters
Map<String, String> specifiedParameters = context.getParameters();
String specifiedClass = specifiedParameters.get("class");
// Check if class parameter has been specified
if (StringUtils.isNotEmpty(specifiedClass)) {
JavaType klass = getJavaTypeConverter().convertFromText(specifiedClass, JavaType.class, PROJECT);
// TODO: Class details should be cached to prevent load MemberDetails everytime.
// The problem is that if some element is cached, and then, new method is added
// to .aj file, this parameter will not autocomplete it.
MemberDetails klassDetails = memberDetailsScanner.getMemberDetails(getClass().getName(), typeLocationService.getTypeDetails(klass));
if (klassDetails != null) {
List<MethodMetadata> definedMethods = klassDetails.getMethods();
for (MethodMetadata method : definedMethods) {
// Check if method has been defined on current class and check
// if current method has been pushed before.
String declaredByMetadataID = method.getDeclaredByMetadataId();
if (StringUtils.isNotBlank(declaredByMetadataID) && declaredByMetadataID.split("\\?").length > 1 && declaredByMetadataID.split("\\#").length > 0 && !declaredByMetadataID.split("\\#")[0].equals("MID:org.springframework.roo.classpath.PhysicalTypeIdentifier") && declaredByMetadataID.split("\\?")[1].equals(klass.getFullyQualifiedTypeName())) {
String methodName = method.getMethodName().getSymbolName();
List<AnnotatedJavaType> parameterTypes = method.getParameterTypes();
methodName = methodName.concat("(");
for (int i = 0; i < parameterTypes.size(); i++) {
String paramType = parameterTypes.get(i).getJavaType().getSimpleTypeName();
methodName = methodName.concat(paramType).concat(",");
}
if (!parameterTypes.isEmpty()) {
methodName = methodName.substring(0, methodName.length() - 1).concat(")");
} else {
methodName = methodName.concat(")");
}
allPossibleMethods.add(methodName);
}
}
}
}
return allPossibleMethods;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class SecurityCommands method getAllSecurityProviders.
@CliOptionAutocompleteIndicator(command = "security setup", param = "provider", help = "You must select a valid security provider.", validate = true)
public List<String> getAllSecurityProviders(ShellContext context) {
List<String> results = new ArrayList<String>();
List<SecurityProvider> securityProviders = securityOperations.getAllSecurityProviders();
for (SecurityProvider provider : securityProviders) {
if (provider.isInstallationAvailable()) {
results.add(provider.getName());
}
}
return results;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class WebFinderCommands method getAllQueryMethodValues.
@CliOptionAutocompleteIndicator(param = "queryMethod", command = "web mvc finder", help = "--queryMethod parameter should be completed with related repository finders.")
public List<String> getAllQueryMethodValues(ShellContext context) {
List<String> finders = new ArrayList<String>();
if (context.getParameters().containsKey("entity")) {
// Extract entity
String providedEntity = context.getParameters().get("entity");
// Getting the JavaType converter
if (getJavaTypeConverter() != null && StringUtils.isNotBlank(providedEntity)) {
JavaType entity = getJavaTypeConverter().convertFromText(providedEntity, JavaType.class, "");
// Get finders
finders = getFinders(entity, null);
}
}
if (finders.isEmpty()) {
finders.add("");
}
return finders;
}
Aggregations