Package org.springframework.roo.classpath.details.annotations

Examples of org.springframework.roo.classpath.details.annotations.AnnotationMetadata


                + fieldValueId + "Validator);");
        return bodyBuilder.getOutput();
    }

    private AnnotationMetadata getManagedBeanAnnotation(final String beanName) {
        final AnnotationMetadata annotation = getTypeAnnotation(MANAGED_BEAN);
        if (annotation == null) {
            return null;
        }
        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                annotation);
View Full Code Here


        return annotationBuilder.build();
    }

    private BigDecimal getMinOrMaxValue(final FieldMetadata field,
            final JavaType annotationType) {
        final AnnotationMetadata annotation = MemberFindingUtils
                .getAnnotationOfType(field.getAnnotations(), annotationType);
        if (annotation != null
                && annotation.getAttribute(new JavaSymbolName("value")) != null) {
            return new BigDecimal(String.valueOf(annotation.getAttribute(
                    new JavaSymbolName("value")).getValue()));
        }
        return null;
    }
View Full Code Here

                    + fieldValueId + "\");";
            final String requiredStr = fieldValueId + ".setRequired("
                    + required + ");";

            if (field.getAnnotation(ROO_UPLOADED_FILE) != null) {
                final AnnotationMetadata annotation = field
                        .getAnnotation(ROO_UPLOADED_FILE);
                final String contentType = (String) annotation.getAttribute(
                        "contentType").getValue();
                final String allowedType = UploadedFileContentType
                        .getFileExtension(contentType).name();
                if (action == Action.VIEW) {
                    builder.getImportRegistrationResolver().addImports(
                            UI_COMPONENT,
                            PRIMEFACES_FILE_DOWNLOAD_ACTION_LISTENER,
                            PRIMEFACES_COMMAND_BUTTON,
                            PRIMEFACES_STREAMED_CONTENT);

                    // bodyBuilder.appendFormalLine("CommandButton " +
                    // fieldValueId + " = " +
                    // getComponentCreation("CommandButton"));
                    // bodyBuilder.appendFormalLine(fieldValueId +
                    // ".addActionListener(new FileDownloadActionListener(expressionFactory.createValueExpression(elContext, \"#{"
                    // + beanName + "." +
                    // fieldName +
                    // "StreamedContent}\", StreamedContent.class), null));");
                    // bodyBuilder.appendFormalLine(fieldValueId +
                    // ".setValue(\"Download\");");
                    // bodyBuilder.appendFormalLine(fieldValueId +
                    // ".setAjax(false);");

                    // TODO Make following code work as currently the view panel
                    // is not refreshed and the download field is always seen as
                    // null
                    bodyBuilder.appendFormalLine("UIComponent " + fieldValueId
                            + ";");
                    bodyBuilder.appendFormalLine("if (" + entityName
                            + " != null && " + entityName + ".get"
                            + StringUtils.capitalize(fieldName)
                            + "() != null && " + entityName + ".get"
                            + StringUtils.capitalize(fieldName)
                            + "().length > 0) {");
                    bodyBuilder.indent();
                    bodyBuilder.appendFormalLine(fieldValueId + " = "
                            + getComponentCreation("CommandButton"));
                    bodyBuilder
                            .appendFormalLine("((CommandButton) "
                                    + fieldValueId
                                    + ").addActionListener(new FileDownloadActionListener(expressionFactory.createValueExpression(elContext, \"#{"
                                    + beanName
                                    + "."
                                    + fieldName
                                    + "StreamedContent}\", StreamedContent.class), null));");
                    bodyBuilder.appendFormalLine("((CommandButton) "
                            + fieldValueId + ").setValue(\"Download\");");
                    bodyBuilder.appendFormalLine("((CommandButton) "
                            + fieldValueId + ").setAjax(false);");
                    bodyBuilder.indentRemove();
                    bodyBuilder.appendFormalLine("} else {");
                    bodyBuilder.indent();
                    bodyBuilder.appendFormalLine(fieldValueId + " = "
                            + getComponentCreation("HtmlOutputText"));
                    bodyBuilder.appendFormalLine("((HtmlOutputText) "
                            + fieldValueId + ").setValue(\"\");");
                    bodyBuilder.indentRemove();
                    bodyBuilder.appendFormalLine("}");
                }
                else {
                    builder.getImportRegistrationResolver().addImports(
                            PRIMEFACES_FILE_UPLOAD,
                            PRIMEFACES_FILE_UPLOAD_EVENT);

                    bodyBuilder.appendFormalLine("FileUpload " + fieldValueId
                            + " = " + getComponentCreation("FileUpload"));
                    bodyBuilder.appendFormalLine(componentIdStr);
                    bodyBuilder
                            .appendFormalLine(fieldValueId
                                    + ".setFileUploadListener(expressionFactory.createMethodExpression(elContext, \"#{"
                                    + beanName
                                    + "."
                                    + getFileUploadMethodName(fieldName)
                                    + "}\", void.class, new Class[] { FileUploadEvent.class }));");
                    bodyBuilder.appendFormalLine(fieldValueId
                            + ".setMode(\"advanced\");");
                    bodyBuilder.appendFormalLine(fieldValueId
                            + ".setAllowTypes(\"/(\\\\.|\\\\/)("
                            + getAllowTypeRegex(allowedType) + ")$/\");");
                    bodyBuilder.appendFormalLine(fieldValueId
                            + ".setUpdate(\":growlForm:growl\");");

                    final AnnotationAttributeValue<?> autoUploadAttr = annotation
                            .getAttribute("autoUpload");
                    if (autoUploadAttr != null
                            && (Boolean) autoUploadAttr.getValue()) {
                        bodyBuilder.appendFormalLine(fieldValueId
                                + ".setAuto(true);");
View Full Code Here

                + "}\", " + className + ".class));";
    }

    private Integer getSizeMinOrMax(final FieldMetadata field,
            final String attrName) {
        final AnnotationMetadata annotation = MemberFindingUtils
                .getAnnotationOfType(field.getAnnotations(), SIZE);
        if (annotation != null
                && annotation.getAttribute(new JavaSymbolName(attrName)) != null) {
            return (Integer) annotation.getAttribute(
                    new JavaSymbolName(attrName)).getValue();
        }
        return null;
    }
View Full Code Here

    }

    private boolean isInverseSideOfRelationship(final FieldMetadata field,
            final JavaType... annotationTypes) {
        for (final JavaType annotationType : annotationTypes) {
            final AnnotationMetadata annotation = MemberFindingUtils
                    .getAnnotationOfType(field.getAnnotations(), annotationType);
            if (annotation != null
                    && annotation.getAttribute(new JavaSymbolName("mappedBy")) != null) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

    }

    private void setRegexPatternValidationString(final FieldMetadata field,
            final String fieldValueId,
            final InvocableMemberBodyBuilder bodyBuilder) {
        final AnnotationMetadata patternAnnotation = MemberFindingUtils
                .getAnnotationOfType(field.getAnnotations(), PATTERN);
        if (patternAnnotation != null) {
            builder.getImportRegistrationResolver().addImport(REGEX_VALIDATOR);

            final AnnotationAttributeValue<?> regexpAttr = patternAnnotation
                    .getAttribute(new JavaSymbolName("regexp"));
            bodyBuilder.appendFormalLine("RegexValidator " + fieldValueId
                    + "RegexValidator = new RegexValidator();");
            bodyBuilder.appendFormalLine(fieldValueId
                    + "RegexValidator.setPattern(\"" + regexpAttr.getValue()
View Full Code Here

    }

    private String getDataOnDemandMetadataId(final JavaType javaType,
            final Iterable<ClassOrInterfaceTypeDetails> dataOnDemandTypes) {
        for (final ClassOrInterfaceTypeDetails cid : dataOnDemandTypes) {
            final AnnotationMetadata dodAnnotation = cid
                    .getAnnotation(ROO_DATA_ON_DEMAND);
            final AnnotationAttributeValue<JavaType> entityAttribute = dodAnnotation
                    .getAttribute("entity");
            if (entityAttribute != null
                    && entityAttribute.getValue().equals(javaType)) {
                // Found the DoD type for the given field's type
                return DataOnDemandMetadata.createIdentifier(cid.getName(),
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    private static <T> T getAnnotationAttribute(
            final MemberHoldingTypeDetails type, final JavaType annotationType,
            final JavaSymbolName attributeName) {
        final AnnotationMetadata typeAnnotation = type
                .getTypeAnnotation(annotationType);
        if (typeAnnotation == null) {
            return null;
        }
        final AnnotationAttributeValue<?> attributeValue = typeAnnotation
                .getAttribute(attributeName);
        if (attributeValue == null) {
            return null;
        }
        return (T) attributeValue.getValue();
View Full Code Here

                        if (parameterTypeCid == null) {
                            continue;
                        }

                        for (final ClassOrInterfaceTypeDetails managedBeanType : managedBeanTypes) {
                            final AnnotationMetadata managedBeanAnnotation = managedBeanType
                                    .getAnnotation(ROO_JSF_MANAGED_BEAN);
                            if (((JavaType) managedBeanAnnotation.getAttribute(
                                    "entity").getValue()).equals(parameter)) {
                                customDataBuilder.put(PARAMETER_TYPE_KEY,
                                        parameter);
                                customDataBuilder.put(
                                        PARAMETER_TYPE_MANAGED_BEAN_NAME_KEY,
                                        managedBeanAnnotation.getAttribute(
                                                "beanName").getValue());

                                final LogicalPath logicalPath = PhysicalTypeIdentifier
                                        .getPath(parameterTypeCid
                                                .getDeclaredByMetadataId());
View Full Code Here

                    REQUEST_PARAM, attributes);
            annotations.add(requestParamAnnotation.build());
            if (field.getFieldType().equals(DATE)
                    || field.getFieldType().equals(CALENDAR)) {
                dateFieldPresent = true;
                final AnnotationMetadata annotation = MemberFindingUtils
                        .getAnnotationOfType(field.getAnnotations(),
                                DATE_TIME_FORMAT);
                if (annotation != null) {
                    getShortName(DATE_TIME_FORMAT);
                    annotations.add(annotation);
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.details.annotations.AnnotationMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.