Search in sources :

Example 21 with CliOptionAutocompleteIndicator

use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.

the class JmsCommands method returnApplicationPackages.

@CliOptionAutocompleteIndicator(command = "jms receiver", param = "endpoint", validate = false, includeSpaceOnFinish = false, help = "--endpoint parameter parameter is the service where will be added the " + "support to send emails.")
public List<String> returnApplicationPackages(ShellContext shellContext) {
    List<String> applicationPackages = new ArrayList<String>();
    // Get only application modules
    StringBuffer matcher = new StringBuffer("feature[");
    matcher.append(ModuleFeatureName.APPLICATION).append("]");
    JavaPackageConverter converter = (JavaPackageConverter) getJavaPackageConverterService().get(0);
    List<Completion> completions = new ArrayList<Completion>();
    converter.getAllPossibleValues(completions, String.class, shellContext.getParameters().get("endpoint"), matcher.toString(), null);
    for (Completion completion : completions) {
        applicationPackages.add(completion.getValue());
    }
    return applicationPackages;
}
Also used : Completion(org.springframework.roo.shell.Completion) JavaPackageConverter(org.springframework.roo.converters.JavaPackageConverter) ArrayList(java.util.ArrayList) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 22 with CliOptionAutocompleteIndicator

use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.

the class TestCommands method getClassPosibleValues.

@CliOptionAutocompleteIndicator(command = "test unit", help = "Option `--class` must " + "be a non-abstract valid type. Please, use auto-complete feature to select it.", param = "class")
public List<String> getClassPosibleValues(ShellContext shellContext) {
    // Get current value of class
    String currentText = shellContext.getParameters().get("class");
    // Create results to return
    List<String> results = new ArrayList<String>();
    // Look for all valid types for all available test creators
    for (TestCreatorProvider creator : getAllTestCreators()) {
        if (creator.isUnitTestCreationAvailable()) {
            for (JavaType annotationType : creator.getValidTypes()) {
                // Look for types with this annotation type
                Set<ClassOrInterfaceTypeDetails> types = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(annotationType);
                for (ClassOrInterfaceTypeDetails typeCid : types) {
                    String name = replaceTopLevelPackageString(typeCid.getType(), currentText);
                    if (!results.contains(name) && !typeCid.isAbstract()) {
                        results.add(name);
                    }
                }
            }
        }
    }
    return results;
}
Also used : JavaType(org.springframework.roo.model.JavaType) ArrayList(java.util.ArrayList) TestCreatorProvider(org.springframework.roo.addon.test.providers.TestCreatorProvider) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 23 with CliOptionAutocompleteIndicator

use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.

the class ControllerCommands method getAllAvailableViews.

@CliOptionAutocompleteIndicator(command = "web mvc detail", param = "views", includeSpaceOnFinish = false, help = "--views parameter could be autocomplete with a separated comma list including 'list' and 'show'. If --entity parameter " + "has been specified, is possible to autocomplete with existing finder views too.")
public List<String> getAllAvailableViews(ShellContext shellContext) {
    List<String> viewsValuesToReturn = new ArrayList<String>();
    // Get current views in --views value
    String currentViewsValue = shellContext.getParameters().get("views");
    String[] views = StringUtils.split(currentViewsValue, ",");
    // Check for bad written separators and return no options
    if (currentViewsValue.contains(",.") || currentViewsValue.contains(".,")) {
        return viewsValuesToReturn;
    }
    // Check if --entity parameter has been specified
    JavaType currentEntity = getTypeFromEntityParam(shellContext);
    List<String> finderViews = new ArrayList<String>();
    if (currentEntity != null) {
        // Obtain search controllers for the current entity
        Collection<ClassOrInterfaceTypeDetails> searchControllers = getControllerLocator().getControllers(currentEntity, ControllerType.SEARCH, RooJavaType.ROO_THYMELEAF);
        for (ClassOrInterfaceTypeDetails searchController : searchControllers) {
            SearchAnnotationValues searchAnnotationValues = new SearchAnnotationValues(searchController);
            if (searchAnnotationValues.getFinders() != null && searchAnnotationValues.getFinders().length > 0) {
                finderViews.addAll(Arrays.asList(searchAnnotationValues.getFinders()));
            }
        }
    }
    // Check if it is first view
    if (currentViewsValue.equals("")) {
        viewsValuesToReturn.add("list");
        viewsValuesToReturn.add("show");
        viewsValuesToReturn.addAll(finderViews);
    } else if (currentViewsValue.endsWith(",")) {
        String finishedViews = "";
        for (int i = 0; i < views.length; i++) {
            finishedViews += views[i] + ",";
        }
        if (!finishedViews.contains("list,")) {
            viewsValuesToReturn.add(finishedViews + "list");
        }
        if (!finishedViews.contains("show,")) {
            viewsValuesToReturn.add(finishedViews + "show");
        }
        for (String finderView : finderViews) {
            if (!finishedViews.contains(finderView + ",")) {
                viewsValuesToReturn.add(finishedViews + finderView);
            }
        }
    } else if (views.length == 1) {
        viewsValuesToReturn.add("list");
        viewsValuesToReturn.add("show");
        viewsValuesToReturn.addAll(finderViews);
    } else {
        String finishedViews = "";
        for (int i = 0; i < views.length - 1; i++) {
            finishedViews += views[i] + ",";
        }
        if (!finishedViews.contains("list,")) {
            viewsValuesToReturn.add(finishedViews + "list");
        }
        if (!finishedViews.contains("show,")) {
            viewsValuesToReturn.add(finishedViews + "show");
        }
        for (String finderView : finderViews) {
            if (!finishedViews.contains(finderView + ",")) {
                viewsValuesToReturn.add(finishedViews + finderView);
            }
        }
    }
    return viewsValuesToReturn;
}
Also used : RooJavaType(org.springframework.roo.model.RooJavaType) JpaJavaType(org.springframework.roo.model.JpaJavaType) JavaType(org.springframework.roo.model.JavaType) SearchAnnotationValues(org.springframework.roo.addon.web.mvc.controller.addon.finder.SearchAnnotationValues) ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 24 with CliOptionAutocompleteIndicator

use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.

the class ControllerCommands method getAllControllerForOperationCommandValues.

// operation command
@CliOptionAutocompleteIndicator(param = "controller", command = "web mvc operation", help = "--controller parameter should be completed with an controller generated previously or with a name that will be used to create a new controller.")
public List<String> getAllControllerForOperationCommandValues(ShellContext context) {
    // Get the actual controller selected
    String currentText = context.getParameters().get("controller");
    // Create results to return
    List<String> results = new ArrayList<String>();
    // Get controllers full qualified names
    Set<ClassOrInterfaceTypeDetails> controllers = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_CONTROLLER);
    for (ClassOrInterfaceTypeDetails controller : controllers) {
        String name = getClasspathOperations().replaceTopLevelPackageString(controller, currentText);
        if (!results.contains(name)) {
            results.add(name);
        }
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliOptionAutocompleteIndicator(org.springframework.roo.shell.CliOptionAutocompleteIndicator)

Example 25 with CliOptionAutocompleteIndicator

use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.

the class ControllerCommands method getAllEntitiesForDetailCommands.

@CliOptionAutocompleteIndicator(command = "web mvc detail", param = "entity", help = "--entity parameter must be an existing class annotated with @RooJpaEntity. Please, assign a valid one.")
public List<String> getAllEntitiesForDetailCommands(ShellContext shellContext) {
    // Get current value of class
    String currentText = shellContext.getParameters().get("entity");
    // Create results to return
    List<String> results = new ArrayList<String>();
    // Get entity full qualified names
    Set<ClassOrInterfaceTypeDetails> entities = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_JPA_ENTITY);
    for (ClassOrInterfaceTypeDetails entity : entities) {
        String name = getClasspathOperations().replaceTopLevelPackageString(entity, currentText);
        if (!results.contains(name)) {
            results.add(name);
        }
    }
    return results;
}
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