Search in sources :

Example 6 with CliOptionAutocompleteIndicator

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;
}
Also used : ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 7 with CliOptionAutocompleteIndicator

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;
}
Also used : ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 8 with CliOptionAutocompleteIndicator

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;
}
Also used : ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 9 with CliOptionAutocompleteIndicator

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;
}
Also used : JdkJavaType(org.springframework.roo.model.JdkJavaType) RooJavaType(org.springframework.roo.model.RooJavaType) JavaType(org.springframework.roo.model.JavaType) ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 10 with CliOptionAutocompleteIndicator

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;
}
Also used : ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Aggregations

ArrayList (java.util.ArrayList)35 CliOptionAutocompleteIndicator (org.springframework.roo.shell.CliOptionAutocompleteIndicator)35 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)24 JavaType (org.springframework.roo.model.JavaType)14 RooJavaType (org.springframework.roo.model.RooJavaType)11 MemberDetails (org.springframework.roo.classpath.scanner.MemberDetails)4 MethodMetadata (org.springframework.roo.classpath.details.MethodMetadata)3 AnnotatedJavaType (org.springframework.roo.classpath.details.annotations.AnnotatedJavaType)3 TestCreatorProvider (org.springframework.roo.addon.test.providers.TestCreatorProvider)2 JpaJavaType (org.springframework.roo.model.JpaJavaType)2 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 List (java.util.List)1 PartTree (org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree)1 SecurityProvider (org.springframework.roo.addon.security.addon.security.providers.SecurityProvider)1 SearchAnnotationValues (org.springframework.roo.addon.web.mvc.controller.addon.finder.SearchAnnotationValues)1 FieldMetadata (org.springframework.roo.classpath.details.FieldMetadata)1 AnnotationMetadata (org.springframework.roo.classpath.details.annotations.AnnotationMetadata)1 JavaPackageConverter (org.springframework.roo.converters.JavaPackageConverter)1