Refine search
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("contentType"), contentType .getContentType())); if (autoUpload) { attrs.add(new BooleanAttributeValue(new JavaSymbolName("autoUpload"), autoUpload)); } annotations.add(new AnnotationMetadataBuilder(ROO_UPLOADED_FILE, attrs)); annotations.add(new AnnotationMetadataBuilder(LOB)); }
public JavaSymbolName getEmbeddedIdMutatorMethodName() { final List<JavaSymbolName> fieldNames = new ArrayList<JavaSymbolName>(); for (final FieldMetadata field : fieldInitializers.keySet()) { fieldNames.add(field.getFieldName()); } int index = -1; JavaSymbolName embeddedIdField; while (true) { // Compute the required field name index++; embeddedIdField = new JavaSymbolName("embeddedIdClass" + StringUtils.repeat("_", index)); if (!fieldNames.contains(embeddedIdField)) { // Found a usable name break; } } return BeanInfoUtils.getMutatorMethodName(embeddedIdField); }
/** * This method obtains the servlet field that will be used in some different methods * * @return FieldMetadata that contains all the necessary information * about the servlet field */ private FieldMetadata getServletField() { // Check if already exists if (this.servletField != null) { return this.servletField; } // Create the field FieldMetadataBuilder servlet = new FieldMetadataBuilder(getId(), Modifier.PRIVATE, new JavaSymbolName("cxfServletPath"), JavaType.STRING, null); AnnotationMetadataBuilder valueAnnotation = new AnnotationMetadataBuilder(SpringJavaType.VALUE); valueAnnotation.addStringAttribute("value", "${cxf.path}"); servlet.addAnnotation(valueAnnotation); servletField = servlet.build(); return servletField; }
new JavaSymbolName(addToMethod.getMethodName().getSymbolName() + "Batch"); parameterTypes.add(new AnnotatedJavaType(addToMethod.getParameterTypes().get(0).getJavaType(), ANN_MODEL_ATTRIBUTE)); parameterTypes.add(new AnnotatedJavaType(addToMethod.getParameterTypes().get(1).getJavaType(), ANN_REQUEST_BODY)); AnnotationMetadataBuilder postMappingAnnotation = new AnnotationMetadataBuilder(POST_MAPPING); postMappingAnnotation.addStringAttribute("name", methodName.getSymbolName()); postMappingAnnotation.addStringAttribute("value", "/batch"); annotations.add(postMappingAnnotation);
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); if (sizeMin != null || sizeMax != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); if (sizeMin != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("min"), sizeMin)); } if (sizeMax != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("max"), sizeMax)); } annotations.add(new AnnotationMetadataBuilder(SIZE, attrs)); } }
/** * Method that generates count methods for custom finders. * * @param formBean the object containing the properties to search to * @param javaSymbolName the finder name * @return */ private MethodMetadata getCustomCount(JavaType formBean, JavaSymbolName finderName) { // Define method parameter types and parameter names List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); parameterTypes.add(AnnotatedJavaType.convertFromJavaType(formBean)); List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName("formBean")); // Create count method name String countName = finderName.getSymbolName(); if (StringUtils.startsWith(countName, "find")) { countName = StringUtils.removeStart(countName, "find"); } else if (StringUtils.startsWith(countName, "query")) { countName = StringUtils.removeStart(countName, "query"); } else if (StringUtils.startsWith(countName, "read")) { countName = StringUtils.removeStart(countName, "read"); } countName = "count".concat(countName); JavaSymbolName countMethodName = new JavaSymbolName(countName); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, countMethodName, JavaType.LONG_PRIMITIVE, parameterTypes, parameterNames, null); return methodBuilder.build(); // Build and return a MethodMetadata }
/** * This method obtains the service field that will be used in some different * methods. * * @param service JavaType with the information about the service related with the new Service field * * @return FieldMetadata with the necessary information about the service */ private FieldMetadata getServiceField(JavaType service) { // Check if already exists if (serviceFields.get(service) != null) { return serviceFields.get(service); } // Create the field FieldMetadataBuilder serviceField = new FieldMetadataBuilder(getId(), Modifier.PRIVATE, new JavaSymbolName( StringUtils.uncapitalize(service.getSimpleTypeName())), service, null); serviceField.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.AUTOWIRED)); serviceFields.put(service, serviceField.build()); return serviceField.build(); }
/** * This method provides @RooWsClient annotation with all the necessary attributes * * @param endpoint * @param targetNamespace * @param bindingType * @return */ private AnnotationMetadataBuilder getWsClientAnnotation(final String endpoint, final String targetNamespace, final EnumDetails bindingType) { final List<AnnotationAttributeValue<?>> wsClientAttributes = new ArrayList<AnnotationAttributeValue<?>>(); wsClientAttributes.add(new StringAttributeValue(new JavaSymbolName("endpoint"), endpoint)); wsClientAttributes.add(new StringAttributeValue(new JavaSymbolName("targetNamespace"), targetNamespace)); wsClientAttributes.add(new EnumAttributeValue(new JavaSymbolName("binding"), bindingType)); return new AnnotationMetadataBuilder(RooJavaType.ROO_WS_CLIENT, wsClientAttributes); }
/** * Method that generates the findAll method on current interface. * * @return */ private MethodMetadata getFindAllGlobalSearchMethod() { // Define method parameter types and parameter names List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); //Global search parameter parameterTypes.add(GLOBAL_SEARCH_PARAMETER); parameterNames.add(GOBAL_SEARCH_PARAMETER_NAME); // Pageable parameter parameterTypes.add(PAGEABLE_PARAMETER); parameterNames.add(PAGEABLE_PARAMETER_NAME); // Method name JavaSymbolName methodName = new JavaSymbolName("findAll"); // Return type JavaType returnType = new JavaType("org.springframework.data.domain.Page", 0, DataType.TYPE, null, Arrays.asList(defaultReturnType)); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, methodName, returnType, parameterTypes, parameterNames, null); return methodBuilder.build(); // Build and return a MethodMetadata }
/** * Returns the JPA @Inheritance annotation to be applied to the entity, if * applicable * * @param annotationValues the values of the {@link RooJpaEntity} annotation * (required) * @return <code>null</code> if it's already present or not required */ private AnnotationMetadata getInheritanceAnnotation() { if (governorTypeDetails.getAnnotation(INHERITANCE) != null) { return null; } if (StringUtils.isNotBlank(annotationValues.getInheritanceType())) { final AnnotationMetadataBuilder inheritanceBuilder = new AnnotationMetadataBuilder(INHERITANCE); inheritanceBuilder.addEnumAttribute("strategy", new EnumDetails(INHERITANCE_TYPE, new JavaSymbolName(annotationValues.getInheritanceType()))); return inheritanceBuilder.build(); } return null; }
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); if (decimalMin != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("value"), decimalMin)); annotations.add(new AnnotationMetadataBuilder(DECIMAL_MIN, attrs)); } if (decimalMax != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("value"), decimalMax)); annotations.add(new AnnotationMetadataBuilder(DECIMAL_MAX, attrs)); } }
parameterTypes.add(AnnotatedJavaType.convertFromJavaType(JavaType.wrapperOf(JavaType.LIST, identifierType))); parameterNames.add(new JavaSymbolName("ids")); parameterTypes.add(GLOBAL_SEARCH_PARAMETER); parameterNames.add(GOBAL_SEARCH_PARAMETER_NAME); JavaSymbolName methodName = new JavaSymbolName("findAllByIdsIn");
/** * This method obtains the bus field that will be used in some different methods * * @return FieldMetadata that contains all the necessary information * about the bus field */ private FieldMetadata getBusField() { // Check if already exists if (this.busField != null) { return this.busField; } // Create the field FieldMetadataBuilder bus = new FieldMetadataBuilder(getId(), Modifier.PRIVATE, new JavaSymbolName("bus"), new JavaType("org.apache.cxf.Bus"), null); bus.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.AUTOWIRED)); busField = bus.build(); return busField; }
/** * This method provides @RooWsClient annotation with all the necessary attributes * * @param endpoint * @param targetNamespace * @param bindingType * @return */ private AnnotationMetadataBuilder getWsClientAnnotation(final String endpoint, final String targetNamespace, final SoapBindingType bindingType) { final List<AnnotationAttributeValue<?>> wsClientAttributes = new ArrayList<AnnotationAttributeValue<?>>(); wsClientAttributes.add(new StringAttributeValue(new JavaSymbolName("endpoint"), endpoint)); wsClientAttributes.add(new StringAttributeValue(new JavaSymbolName("targetNamespace"), targetNamespace)); wsClientAttributes.add(new EnumAttributeValue(new JavaSymbolName("binding"), new EnumDetails( RooJavaType.ROO_ENUM_SOAP_BINDING_TYPE, new JavaSymbolName(bindingType.name())))); return new AnnotationMetadataBuilder(RooJavaType.ROO_WS_CLIENT, wsClientAttributes); }
/** * Method that generates finder methods whose return types are projections. * * @param finderReturnType * @param finderName * @param parameterType * * @return */ private MethodMetadata getCustomFinder(JavaType finderReturnType, JavaSymbolName finderName, JavaType parameterType) { // Define method parameter types and parameter names List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); parameterTypes.add(AnnotatedJavaType.convertFromJavaType(parameterType)); parameterTypes.add(GLOBAL_SEARCH_PARAMETER); parameterTypes.add(PAGEABLE_PARAMETER); List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName("formBean")); parameterNames.add(GOBAL_SEARCH_PARAMETER_NAME); parameterNames.add(PAGEABLE_PARAMETER_NAME); // Return type JavaType returnType = new JavaType(SpringJavaType.PAGE.getFullyQualifiedTypeName(), 0, DataType.TYPE, null, Arrays.asList(finderReturnType)); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.ABSTRACT, finderName, returnType, parameterTypes, parameterNames, null); return methodBuilder.build(); // Build and return a MethodMetadata }
/** * Builds and returns the entity service field, annotated with @MockBean * * @param the service {@link JavaType} * @return {@link FieldMetadataBuilder} */ private FieldMetadataBuilder getEntityServiceField(JavaType service) { JavaSymbolName fieldName = new JavaSymbolName(String.format("%sService", StringUtils.uncapitalize(service.getSimpleTypeName()))); FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(this.getId(), Modifier.PUBLIC, fieldName, service, null); // Add @Autowired fieldBuilder.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.MOCK_BEAN)); return fieldBuilder; }
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); if (sizeMin != null || sizeMax != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); if (sizeMin != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("min"), sizeMin)); } if (sizeMax != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("max"), sizeMax)); } annotations.add(new AnnotationMetadataBuilder(SIZE, attrs)); } if (regexp != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("regexp"), regexp)); annotations.add(new AnnotationMetadataBuilder(PATTERN, attrs)); } }
parameter.setName(new JavaSymbolName(name.concat(count.toString()))); } else { count = 1; parameters.add(parameter);
/** * Returns the additions that the caller needs to make in order to invoke * the given method * * @param callerMID the caller's metadata ID (required) * @param method the method being called (required) * @param repositoryType the type of repository being called * @param parameterNames the parameter names used by the caller * @return a non-<code>null</code> set of additions */ private MemberTypeAdditions getMethodAdditions(final String callerMID, final RepositoryJpaLayerMethod method, final JavaType repositoryType, final List<MethodParameter> parameters) { // Create a builder to hold the repository field to be copied into the // caller final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(callerMID); final AnnotationMetadataBuilder autowiredAnnotation = new AnnotationMetadataBuilder(AUTOWIRED); final String repositoryFieldName = StringUtils.uncapitalize(repositoryType.getSimpleTypeName()); cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays.asList(autowiredAnnotation), new JavaSymbolName(repositoryFieldName), repositoryType)); // Create the additions to invoke the given method on this field final String methodCall = repositoryFieldName + "." + method.getCall(parameters); return new MemberTypeAdditions(cidBuilder, method.getName(), methodCall, false, parameters); }
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>(); if (enumType != null) { JavaSymbolName value = new JavaSymbolName("ORDINAL"); if (enumType == EnumType.STRING) { value = new JavaSymbolName("STRING"); } attributes.add(new EnumAttributeValue(new JavaSymbolName("value"), new EnumDetails(ENUM_TYPE, value))); } annotations.add(new AnnotationMetadataBuilder(ENUMERATED, attributes)); }