Package org.springframework.roo.classpath.details

Examples of org.springframework.roo.classpath.details.FieldMetadata


                                            .getSymbolName().substring(3))));
                }
                else {
                    fieldName = parameterNames.get(i);
                }
                final FieldMetadata field = BeanInfoUtils
                        .getFieldForPropertyName(formBackingTypeDetails,
                                fieldName);
                if (field != null) {
                    final FieldMetadataBuilder fieldMd = new FieldMetadataBuilder(
                            field);
View Full Code Here


                .getMostConcreteMethodWithTag(IDENTIFIER_ACCESSOR_METHOD);
        if (idAccessor == null) {
            return null;
        }

        final FieldMetadata idField = CollectionUtils
                .firstElementOf(persistenceMemberLocator
                        .getIdentifierFields(javaType));
        if (idField == null) {
            return null;
        }

        final JavaType idType = persistenceMemberLocator
                .getIdentifierType(javaType);
        if (idType == null) {
            return null;
        }

        registerDependency(idAccessor.getDeclaredByMetadataId(),
                metadataIdentificationString);
        registerDependency(idField.getDeclaredByMetadataId(),
                metadataIdentificationString);

        final MethodParameter entityParameter = new MethodParameter(javaType,
                JavaSymbolName.getReservedWordSafeName(javaType));
        final MethodParameter idParameter = new MethodParameter(idType, idField
                .getFieldName().getSymbolName());
        final MethodMetadata versionAccessor = memberDetails
                .getMostConcreteMethodWithTag(VERSION_ACCESSOR_METHOD);
        final MemberTypeAdditions persistMethod = layerService
                .getMemberTypeAdditions(metadataIdentificationString,
View Full Code Here

            if (!BeanInfoUtils.isAccessorMethod(method)
                    || method.hasSameName(identifierAccessor, versionAccessor)) {
                continue;
            }

            final FieldMetadata field = BeanInfoUtils
                    .getFieldForJavaBeanMethod(memberDetails, method);
            if (field == null
                    || !BeanInfoUtils.hasAccessorAndMutator(field,
                            memberDetails)) {
                continue;
            }
            final JavaSymbolName fieldName = field.getFieldName();
            registerDependency(method.getDeclaredByMetadataId(),
                    metadataIdentificationString);
            if (!fields.containsKey(fieldName)) {
                fields.put(fieldName, field);
            }
View Full Code Here

            // Not interested in fields that are not exposed via a mutator and
            // accessor and in identifiers and version fields
            if (method.hasSameName(identifierAccessor, versionAccessor)) {
                continue;
            }
            final FieldMetadata field = BeanInfoUtils
                    .getFieldForJavaBeanMethod(memberDetails, method);
            if (field == null
                    || !BeanInfoUtils.hasAccessorAndMutator(field,
                            memberDetails)) {
                continue;
            }
            final JavaType returnType = method.getReturnType();
            if (!JdkJavaType.isDateField(returnType)) {
                continue;
            }
            final AnnotationMetadata annotation = MemberFindingUtils
                    .getAnnotationOfType(field.getAnnotations(),
                            DATE_TIME_FORMAT);
            final JavaSymbolName patternSymbol = new JavaSymbolName("pattern");
            final JavaSymbolName styleSymbol = new JavaSymbolName("style");
            DateTimeFormatDetails dateTimeFormat = null;
            if (annotation != null) {
                if (annotation.getAttributeNames().contains(styleSymbol)) {
                    dateTimeFormat = DateTimeFormatDetails.withStyle(annotation
                            .getAttribute(styleSymbol).getValue().toString());
                }
                else if (annotation.getAttributeNames().contains(patternSymbol)) {
                    dateTimeFormat = DateTimeFormatDetails
                            .withPattern(annotation.getAttribute(patternSymbol)
                                    .getValue().toString());
                }
            }
            if (dateTimeFormat != null) {
                registerDependency(field.getDeclaredByMetadataId(),
                        metadataIdentificationString);
                dates.put(field.getFieldName(), dateTimeFormat);
                if (javaTypePersistenceMetadataDetails != null) {
                    for (final String finder : javaTypePersistenceMetadataDetails
                            .getFinderNames()) {
                        if (finder.contains(StringUtils.capitalize(field
                                .getFieldName().getSymbolName()) + "Between")) {
                            dates.put(
                                    new JavaSymbolName("min"
                                            + StringUtils.capitalize(field
                                                    .getFieldName()
                                                    .getSymbolName())),
                                    dateTimeFormat);
                            dates.put(
                                    new JavaSymbolName("max"
                                            + StringUtils.capitalize(field
                                                    .getFieldName()
                                                    .getSymbolName())),
                                    dateTimeFormat);
                        }
                    }
                }
            }
            else {
                LOGGER.warning("It is recommended to use @DateTimeFormat(style=\"M-\") on "
                        + field.getFieldType().getFullyQualifiedTypeName()
                        + "."
                        + field.getFieldName()
                        + " to use automatic date conversion in Spring MVC");
            }
        }
        return Collections.unmodifiableMap(dates);
    }
View Full Code Here

        final List<JavaTypeMetadataDetails> dependentTypes = new ArrayList<JavaTypeMetadataDetails>();
        for (final MethodMetadata method : memberDetails.getMethods()) {
            final JavaType type = method.getReturnType();
            if (BeanInfoUtils.isAccessorMethod(method)
                    && isApplicationType(type)) {
                final FieldMetadata field = BeanInfoUtils
                        .getFieldForJavaBeanMethod(memberDetails, method);
                if (field != null
                        && MemberFindingUtils.getAnnotationOfType(
                                field.getAnnotations(), NOT_NULL) != null) {
                    final MemberDetails typeMemberDetails = getMemberDetails(type);
                    if (getJavaTypePersistenceMetadataDetails(type,
                            typeMemberDetails, metadataIdentificationString) != null) {
                        dependentTypes
                                .add(getJavaTypeMetadataDetails(type,
View Full Code Here

        }
        final MemberDetails memberDetails = memberDetailsScanner
                .getMemberDetails(getClass().getName(), cid);
        final List<FieldMetadata> idFields = persistenceMemberLocator
                .getIdentifierFields(javaType);
        final FieldMetadata versionField = persistenceMemberLocator
                .getVersionField(javaType);

        // Compute the finders (excluding the ID, version, and EM fields)
        final Set<JavaSymbolName> exclusions = new HashSet<JavaSymbolName>();
        exclusions.add(jpaActiveRecordMetadata.getEntityManagerField()
                .getFieldName());
        for (final FieldMetadata idField : idFields) {
            exclusions.add(idField.getFieldName());
        }

        if (versionField != null) {
            exclusions.add(versionField.getFieldName());
        }

        final SortedSet<String> result = new TreeSet<String>();

        final List<JavaSymbolName> finders = dynamicFinderServices.getFinders(
View Full Code Here

        attributeValues.add(locatorAttributeValue);
        cidBuilder.updateTypeAnnotation(new AnnotationMetadataBuilder(
                PROXY_FOR_NAME, attributeValues));
        attributeValues.remove(locatorAttributeValue);
        final List<StringAttributeValue> readOnlyValues = new ArrayList<StringAttributeValue>();
        final FieldMetadata versionField = persistenceMemberLocator
                .getVersionField(entity.getName());
        if (versionField != null) {
            readOnlyValues.add(new StringAttributeValue(VALUE, versionField
                    .getFieldName().getSymbolName()));
        }
        final List<FieldMetadata> idFields = persistenceMemberLocator
                .getIdentifierFields(entity.getName());
        if (!CollectionUtils.isEmpty(idFields)) {
View Full Code Here

                    + ".java is invalid");
        }

        final SortedSet<FieldToken> fieldTokens = new TreeSet<FieldToken>();
        for (final MethodMetadata method : getLocatedMutators(memberDetails)) {
            final FieldMetadata field = BeanInfoUtils.getFieldForPropertyName(
                    memberDetails, method.getParameterNames().get(0));

            // If we did find a field matching the first parameter name of the
            // mutator method we can add it to the finder ITD
            if (field != null) {
View Full Code Here

                        CustomDataKeys.FIND_METHOD.name(), entity,
                        identifierType, LAYER_POSITION, !useXmlConfiguration,
                        new MethodParameter(identifierType, "id"));

        JavaType potentialService = null;
        FieldMetadata fieldMetadata = findMethodAdditions.getInvokedField();
        if (fieldMetadata != null) {
            potentialService = fieldMetadata.getFieldType();
        }

        Validate.notNull(findMethodAdditions,
                "Find method not available for entity '%s'",
                entity.getFullyQualifiedTypeName());
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.details.FieldMetadata

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.