use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class SecurityCommands method getAllServiceClassesAndInterfacesForAuthorize.
@CliOptionAutocompleteIndicator(command = "security authorize", param = "class", help = "You must select a valid Service class", validate = true)
public List<String> getAllServiceClassesAndInterfacesForAuthorize(ShellContext context) {
List<String> results = new ArrayList<String>();
Set<ClassOrInterfaceTypeDetails> services = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_SERVICE, RooJavaType.ROO_SERVICE_IMPL);
for (ClassOrInterfaceTypeDetails service : services) {
results.add(replaceTopLevelPackageString(service, context.getParameters().get("class")));
}
return results;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class SecurityCommands method getAllServiceClassesAndInterfacesForFiltering.
@CliOptionAutocompleteIndicator(command = "security filtering", param = "class", help = "You must select a valid Service class", validate = true)
public List<String> getAllServiceClassesAndInterfacesForFiltering(ShellContext context) {
List<String> results = new ArrayList<String>();
Set<ClassOrInterfaceTypeDetails> services = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_SERVICE, RooJavaType.ROO_SERVICE_IMPL);
for (ClassOrInterfaceTypeDetails service : services) {
results.add(replaceTopLevelPackageString(service, context.getParameters().get("class")));
}
return results;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class JpaCommands method getIdentifierTypePossibleValues.
@CliOptionAutocompleteIndicator(command = "entity jpa", param = "identifierType", help = "--identifierType option should be a wrapper of a primitive type or an embeddable class.")
public List<String> getIdentifierTypePossibleValues(ShellContext shellContext) {
String currentText = shellContext.getParameters().get("identifierType");
List<String> allPossibleValues = new ArrayList<String>();
// Add java-lang and java-number classes
allPossibleValues.add(Number.class.getName());
allPossibleValues.add(Short.class.getName());
allPossibleValues.add(Byte.class.getName());
allPossibleValues.add(Integer.class.getName());
allPossibleValues.add(Long.class.getName());
allPossibleValues.add(Float.class.getName());
allPossibleValues.add(Double.class.getName());
allPossibleValues.add(BigDecimal.class.getName());
allPossibleValues.add(BigInteger.class.getName());
// Getting all existing embeddable classes
Set<ClassOrInterfaceTypeDetails> embeddableClassesInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(JpaJavaType.EMBEDDABLE);
for (ClassOrInterfaceTypeDetails embeddableClass : embeddableClassesInProject) {
String name = replaceTopLevelPackageString(embeddableClass, 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 WebFlowCommands method getClassPossibleValues.
@CliOptionAutocompleteIndicator(command = "web flow", param = "class", help = "You should specify an existing and serializable class for option " + "'--class'.", validate = false)
public List<String> getClassPossibleValues(ShellContext shellContext) {
// Get current value of class
String currentText = shellContext.getParameters().get("class");
List<String> allPossibleValues = new ArrayList<String>();
// Getting all existing entities
Set<ClassOrInterfaceTypeDetails> domainClassesInProject = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_JPA_ENTITY, RooJavaType.ROO_DTO);
for (ClassOrInterfaceTypeDetails classDetails : domainClassesInProject) {
// Check if class implements serializable (needed for WebFlow)
boolean isSerializable = false;
// First, chech for @RooSerializable
if (classDetails.getAnnotation(RooJavaType.ROO_SERIALIZABLE) != null) {
isSerializable = true;
}
// Check for the explicit 'implements Serializable'
if (!isSerializable) {
List<JavaType> implementsTypes = classDetails.getImplementsTypes();
for (JavaType type : implementsTypes) {
if (type.equals(JdkJavaType.SERIALIZABLE)) {
isSerializable = true;
break;
}
}
}
if (isSerializable) {
// Add to possible values
String name = replaceTopLevelPackageString(classDetails, currentText);
if (!allPossibleValues.contains(name)) {
allPossibleValues.add(name);
}
}
}
if (allPossibleValues.isEmpty()) {
// Any entity or DTO in project is serializable
LOGGER.info("Any auto-complete value offered because the project hasn't any entity " + "or DTO which implement Serializable");
}
return allPossibleValues;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class WsCommands method existingServicesInterfaces.
/**
* This method is an autocomplete indicator of the 'ws endpoint' command.
*
* This method provides all existing classes annotated with @RooService
*
* @param context
* @return
*/
@CliOptionAutocompleteIndicator(command = "ws endpoint", param = "service", help = "--service parameter should be autocomplete with some existing class annotated with @RooService.")
public List<String> existingServicesInterfaces(ShellContext context) {
// Getting currentText
String currentText = context.getParameters().get("service");
List<String> existingServicesInterfaces = new ArrayList<String>();
Set<ClassOrInterfaceTypeDetails> allServices = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_SERVICE);
for (ClassOrInterfaceTypeDetails service : allServices) {
String name = getClasspathOperations().replaceTopLevelPackageString(service, currentText);
if (!existingServicesInterfaces.contains(name)) {
existingServicesInterfaces.add(name);
}
}
return existingServicesInterfaces;
}
Aggregations