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

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


                }
                else {
                    current = null;
                }
            }
            return new StringAttributeValue(annotationName, result);
        }

        if (expression instanceof StringLiteralExpr) {
            final String value = ((StringLiteralExpr) expression).getValue();
            return new StringAttributeValue(annotationName, value);
        }

        if (expression instanceof FieldAccessExpr) {
            final FieldAccessExpr field = (FieldAccessExpr) expression;
            final String fieldName = field.getField();
View Full Code Here


            annotations.add(new AnnotationMetadataBuilder(TEMPORAL, attrs));
        }
        // Always add a DateTimeFormat annotation
        final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>();
        if (pattern != null) {
            attributes.add(new StringAttributeValue(new JavaSymbolName(
                    "pattern"), pattern));
        }
        else {
            final String dateStyle = null != dateFormat ? String
                    .valueOf(dateFormat.getShortKey()) : "M";
            final String timeStyle = null != timeFormat ? String
                    .valueOf(timeFormat.getShortKey()) : "-";
            attributes.add(new StringAttributeValue(
                    new JavaSymbolName("style"), dateStyle + timeStyle));
        }
        annotations.add(new AnnotationMetadataBuilder(DATE_TIME_FORMAT,
                attributes));
    }
View Full Code Here

            return null;
        }

        final List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        final List<StringAttributeValue> arrayValues = new ArrayList<StringAttributeValue>();
        arrayValues.add(new StringAttributeValue(new JavaSymbolName("value"),
                "find="
                        + finder.getFinderMethodMetadata()
                                .getMethodName()
                                .getSymbolName()
                                .replaceFirst(
                                        "find"
                                                + javaTypeMetadataHolder
                                                        .getPlural(), "")));
        arrayValues.add(new StringAttributeValue(new JavaSymbolName("value"),
                "form"));
        requestMappingAttributes
                .add(new ArrayAttributeValue<StringAttributeValue>(
                        new JavaSymbolName("params"), arrayValues));
        requestMappingAttributes.add(new EnumAttributeValue(new JavaSymbolName(
View Full Code Here

        for (final FieldMetadata field : finderMetadataDetails
                .getFinderMethodParamFields()) {
            final JavaSymbolName fieldName = field.getFieldName();
            final List<AnnotationMetadata> annotations = new ArrayList<AnnotationMetadata>();
            final List<AnnotationAttributeValue<?>> attributes = new ArrayList<AnnotationAttributeValue<?>>();
            attributes.add(new StringAttributeValue(
                    new JavaSymbolName("value"), uncapitalize(fieldName
                            .getSymbolName())));
            if (field.getFieldType().equals(JavaType.BOOLEAN_PRIMITIVE)
                    || field.getFieldType().equals(JavaType.BOOLEAN_OBJECT)) {
                attributes.add(new BooleanAttributeValue(new JavaSymbolName(
                        "required"), false));
            }
            final AnnotationMetadataBuilder requestParamAnnotation = new AnnotationMetadataBuilder(
                    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);
                }
            }
            parameterNames.add(fieldName);
            parameterTypes.add(new AnnotatedJavaType(field.getFieldType(),
                    annotations));

            if (field.getFieldType().equals(JavaType.BOOLEAN_OBJECT)) {
                methodParams.append(fieldName + " == null ? Boolean.FALSE : "
                        + fieldName + ", ");
            }
            else {
                methodParams.append(fieldName + ", ");
            }
        }

        if (methodParams.length() > 0) {
            methodParams.delete(methodParams.length() - 2,
                    methodParams.length());
        }
       
        final List<AnnotationAttributeValue<?>> firstResultAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        firstResultAttributes.add(new StringAttributeValue(new JavaSymbolName(
                "value"), "page"));
        firstResultAttributes.add(new BooleanAttributeValue(new JavaSymbolName(
                "required"), false));
        final AnnotationMetadataBuilder firstResultAnnotation = new AnnotationMetadataBuilder(
                REQUEST_PARAM, firstResultAttributes);

        final List<AnnotationAttributeValue<?>> maxResultsAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        maxResultsAttributes.add(new StringAttributeValue(new JavaSymbolName(
                "value"), "size"));
        maxResultsAttributes.add(new BooleanAttributeValue(new JavaSymbolName(
                "required"), false));
        final AnnotationMetadataBuilder maxResultAnnotation = new AnnotationMetadataBuilder(
                REQUEST_PARAM, maxResultsAttributes);
       
        final List<AnnotationAttributeValue<?>> sortFieldNameAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        sortFieldNameAttributes.add(new StringAttributeValue(new JavaSymbolName(
                "value"), "sortFieldName"));
        sortFieldNameAttributes.add(new BooleanAttributeValue(new JavaSymbolName(
                "required"), false));
        final AnnotationMetadataBuilder sortFieldNameAnnotation = new AnnotationMetadataBuilder(
                REQUEST_PARAM, sortFieldNameAttributes);
       
        final List<AnnotationAttributeValue<?>> sortOrderAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        sortOrderAttributes.add(new StringAttributeValue(new JavaSymbolName(
                "value"), "sortOrder"));
        sortOrderAttributes.add(new BooleanAttributeValue(new JavaSymbolName(
                "required"), false));
        final AnnotationMetadataBuilder sortOrderAnnotation = new AnnotationMetadataBuilder(
                REQUEST_PARAM, sortOrderAttributes);
       
       
        parameterTypes.add(new AnnotatedJavaType(
                new JavaType(Integer.class.getName()),
                firstResultAnnotation.build()));
        parameterTypes.add(new AnnotatedJavaType(
                new JavaType(Integer.class.getName()),
                maxResultAnnotation.build()));
        parameterTypes.add(new AnnotatedJavaType(
                new JavaType(String.class.getName()),
                sortFieldNameAnnotation.build()));
        parameterTypes.add(new AnnotatedJavaType(
                new JavaType(String.class.getName()),
                sortOrderAnnotation.build()));
       
        parameterTypes.add(new AnnotatedJavaType(MODEL));
        if (getGovernorMethod(finderMethodName,
                AnnotatedJavaType.convertFromAnnotatedJavaTypes(parameterTypes)) != null) {
            return null;
        }

        final List<JavaSymbolName> newParamNames = new ArrayList<JavaSymbolName>();
        newParamNames.addAll(parameterNames);
        newParamNames.add(new JavaSymbolName("page"));
        newParamNames.add(new JavaSymbolName("size"));
        newParamNames.add(new JavaSymbolName("sortFieldName"));
        newParamNames.add(new JavaSymbolName("sortOrder"));
        newParamNames.add(new JavaSymbolName("uiModel"));    
       
        final List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        requestMappingAttributes.add(new StringAttributeValue(
                new JavaSymbolName("params"), "find="
                        + finderMetadataDetails
                                .getFinderMethodMetadata()
                                .getMethodName()
                                .getSymbolName()
View Full Code Here

        cidBuilder.addAnnotation(getAnnotation(jsonEntity));
        cidBuilder.addAnnotation(new AnnotationMetadataBuilder(
                SpringJavaType.CONTROLLER));
        final AnnotationMetadataBuilder requestMapping = new AnnotationMetadataBuilder(
                SpringJavaType.REQUEST_MAPPING);
        requestMapping.addAttribute(new StringAttributeValue(
                new JavaSymbolName("value"), "/"
                        + pluralMetadata.getPlural().toLowerCase()));
        cidBuilder.addAnnotation(requestMapping);
        typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
    }
View Full Code Here

            break;
        }

        if (joinColumnName != null) {
            final List<AnnotationAttributeValue<?>> joinColumnAttrs = new ArrayList<AnnotationAttributeValue<?>>();
            joinColumnAttrs.add(new StringAttributeValue(new JavaSymbolName(
                    "name"), joinColumnName));

            if (referencedColumnName != null) {
                joinColumnAttrs.add(new StringAttributeValue(
                        new JavaSymbolName("referencedColumnName"),
                        referencedColumnName));
            }
            annotations.add(new AnnotationMetadataBuilder(JOIN_COLUMN,
                    joinColumnAttrs));
View Full Code Here

        final String errMsg = "@RooToString attribute 'excludeFields' must be an array of strings";
        Validate.isInstanceOf(ArrayAttributeValue.class, value, errMsg);
        final ArrayAttributeValue<?> arrayVal = (ArrayAttributeValue<?>) value;
        for (final Object obj : arrayVal.getValue()) {
            Validate.isInstanceOf(StringAttributeValue.class, obj, errMsg);
            final StringAttributeValue sv = (StringAttributeValue) obj;
            if (sv.getValue().equals(fieldName)) {
                alreadyAdded = true;
            }
            ignoreFields.add(sv);
        }

        // Add the desired field to ignore to the end
        if (!alreadyAdded) {
            ignoreFields.add(new StringAttributeValue(new JavaSymbolName(
                    "ignored"), fieldName));
        }

        attributes.add(new ArrayAttributeValue<StringAttributeValue>(
                new JavaSymbolName("excludeFields"), ignoreFields));
View Full Code Here

                    .createIdentifier(controller,
                            pathResolver.getPath(resourceIdentifier));

            // Create annotation @RequestMapping("/myobject/**")
            final List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>();
            requestMappingAttributes.add(new StringAttributeValue(VALUE, "/"
                    + path));
            annotations = new ArrayList<AnnotationMetadataBuilder>();
            annotations.add(new AnnotationMetadataBuilder(REQUEST_MAPPING,
                    requestMappingAttributes));

View Full Code Here

        // Add @JoinTable annotation
        final AnnotationMetadataBuilder joinTableBuilder = new AnnotationMetadataBuilder(
                JOIN_TABLE);
        final List<AnnotationAttributeValue<?>> joinTableAnnotationAttributes = new ArrayList<AnnotationAttributeValue<?>>();
        joinTableAnnotationAttributes.add(new StringAttributeValue(
                new JavaSymbolName(NAME), joinTable.getName()));

        final Iterator<ForeignKey> iter = joinTable.getImportedKeys()
                .iterator();
View Full Code Here

                            + cid.getName().getFullyQualifiedTypeName()
                            + "' as it contains more than one path");
                    continue;
                }
                else if (mappingAttribute.getValue().size() == 1) {
                    final StringAttributeValue attr = (StringAttributeValue) mappingAttribute
                            .getValue().get(0);
                    final String mapping = attr.getValue();
                    if (StringUtils.isNotBlank(mapping)
                            && mapping.equalsIgnoreCase("/" + path)) {
                        return cid;
                    }
                }
            }
            else if (attribute instanceof StringAttributeValue) {
                final StringAttributeValue mappingAttribute = (StringAttributeValue) attribute;
                if (mappingAttribute != null) {
                    final String mapping = mappingAttribute.getValue();
                    if (StringUtils.isNotBlank(mapping)
                            && mapping.equalsIgnoreCase("/" + path)) {
                        return cid;
                    }
                }
View Full Code Here

TOP

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

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.