/** * Tries to obtain JavaType indicated in command or which has the focus in the * Shell * * @param shellContext the Roo Shell context * @return JavaType or null if no class has the focus or no class is specified * in the command */ private JavaType getTypeFromEntityParam(ShellContext shellContext) { // Try to get 'class' from ShellContext String typeString = shellContext.getParameters().get("entity"); JavaType type = null; if (typeString != null) { JavaTypeConverter converter = (JavaTypeConverter) getJavaTypeConverter().get(0); type = converter.convertFromText(typeString, JavaType.class, PROJECT); } return type; }
final String basePackage = resolveTopLevelPackageSymbol(typeName, topLevelPackage); addCompletionsForOtherModuleNames(completions, targetModule); addCompletionsForTypesInTargetModule(completions, optionContext, targetModule, heading, prefix, formattedPrefix, topLevelPackage, basePackage);
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, String existingData, final String optionContext, final MethodTarget target) { existingData = StringUtils.stripToEmpty(existingData); if (StringUtils.isBlank(optionContext) || optionContext.contains(PROJECT) || optionContext.contains(SUPERCLASS) || optionContext.contains(INTERFACE) || optionContext.contains(ENUMERATION)) { completeProjectSpecificPaths(completions, existingData, optionContext); } if (StringUtils.contains(optionContext, "java")) { completeJavaSpecificPaths(completions, existingData, optionContext); } return false; }
return getNumberPrimitiveType(value); String newValue = locateExisting(value, topLevelPath); if (newValue == null) { newValue = locateNew(value, topLevelPath);
private void addCompletionsForTypesInTargetModule(final List<Completion> completions, final String optionContext, final Pom targetModule, final String heading, final String prefix, final String formattedPrefix, final String topLevelPackage, final String basePackage) { final Collection<JavaType> typesInModule = getTypesForModule(optionContext, targetModule); completions.add(new Completion(prefix + topLevelPackage, formattedPrefix + topLevelPackage, heading, 1)); for (final JavaType javaType : typesInModule) { String type = javaType.getFullyQualifiedTypeName(); if (type.startsWith(basePackage)) { type = StringUtils.replace(type, topLevelPackage, TOP_LEVEL_PACKAGE_SYMBOL, 1); completions.add(new Completion(prefix + type, formattedPrefix + type, heading, 1)); } } }
/** * Tries to obtain JavaType indicated in command or which has the focus * in the Shell * * @param shellContext the Roo Shell context * @return JavaType or null if no class has the focus or no class is * specified in the command */ private JavaType getTypeFromEntityParam(ShellContext shellContext) { // Try to get 'entity' from ShellContext String typeString = shellContext.getParameters().get("entity"); JavaType type = null; if (typeString != null) { JavaTypeConverter converter = (JavaTypeConverter) getJavaTypeConverter().get(0); type = converter.convertFromText(typeString, JavaType.class, PROJECT); } else { type = lastUsed.getJavaType(); } return type; }
@CliOptionMandatoryIndicator(command = "finder add", params = {"formBean"}) public boolean isFormBeanMandatory(ShellContext shellContext) { // Get current value of 'entity' JavaType entity = getTypeFromEntityParam(shellContext); if (entity == null) { return false; } // Get current value of returnType String returnType = shellContext.getParameters().get("returnType"); // This parameter is not mandatory if returnType has not been specified if (StringUtils.isBlank(returnType)) { return false; } // If returnType has been specified, but it's an entity, this parameter is not // mandatory JavaTypeConverter converter = (JavaTypeConverter) getJavaTypeConverter().get(0); JavaType type = converter.convertFromText(returnType, JavaType.class, PROJECT); if (type == null) { return false; } ClassOrInterfaceTypeDetails details = getTypeLocationService().getTypeDetails(type); if (details == null) { return false; } AnnotationMetadata entityAnnotation = details.getAnnotation(RooJavaType.ROO_JPA_ENTITY); if (entityAnnotation != null) { return false; } return true; }
/** * Tries to obtain JavaType indicated in command or which has the focus * in the Shell * * @param shellContext the Roo Shell context * @return JavaType or null if no class has the focus or no class is * specified in the command */ private JavaType getTypeFromEntityParam(ShellContext shellContext) { // Try to get 'entity' from ShellContext String typeString = shellContext.getParameters().get("entity"); JavaType type = null; if (typeString != null) { JavaTypeConverter converter = (JavaTypeConverter) getJavaTypeConverter().get(0); type = converter.convertFromText(typeString, JavaType.class, PROJECT); } else { type = lastUsed.getJavaType(); } return type; }
@CliOptionMandatoryIndicator(command = "finder add", params = {"formBean"}) public boolean isFormBeanMandatory(ShellContext shellContext) { // Get current value of 'entity' JavaType entity = getTypeFromEntityParam(shellContext); if (entity == null) { return false; } // Get current value of returnType String returnType = shellContext.getParameters().get("returnType"); // This parameter is not mandatory if returnType has not been specified if (StringUtils.isBlank(returnType)) { return false; } // If returnType has been specified, but it's an entity, this parameter is not // mandatory JavaTypeConverter converter = (JavaTypeConverter) getJavaTypeConverter().get(0); JavaType type = converter.convertFromText(returnType, JavaType.class, PROJECT); if (type == null) { return false; } ClassOrInterfaceTypeDetails details = getTypeLocationService().getTypeDetails(type); if (details == null) { return false; } AnnotationMetadata entityAnnotation = details.getAnnotation(RooJavaType.ROO_JPA_ENTITY); if (entityAnnotation != null) { return false; } return true; }