Package org.springframework.roo.classpath.details

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


            // Compute the required field name
            index++;
            final JavaSymbolName fieldName = new JavaSymbolName("rnd"
                    + StringUtils.repeat("_", index));
            rndFieldName = fieldName;
            final FieldMetadata candidate = governorTypeDetails
                    .getField(fieldName);
            if (candidate != null) {
                // Verify if candidate is suitable
                if (!Modifier.isPrivate(candidate.getModifier())) {
                    // Candidate is not private, so we might run into naming
                    // clashes if someone subclasses this (therefore go onto the
                    // next possible name)
                    continue;
                }
                if (!candidate.getFieldType().equals(RANDOM)) {
                    // Candidate isn't a java.util.Random, so it isn't suitable
                    continue;
                }
                // If we got this far, we found a valid candidate
                // We don't check if there is a corresponding initializer, but
View Full Code Here


        while (true) {
            // Compute the required field name
            index++;
            final JavaSymbolName fieldSymbolName = new JavaSymbolName(
                    StringUtils.repeat("_", index) + "entityManager");
            final FieldMetadata candidate = governorTypeDetails
                    .getField(fieldSymbolName);
            if (candidate != null) {
                // Verify if candidate is suitable

                if (!Modifier.isPublic(candidate.getModifier())
                        && !Modifier.isProtected(candidate.getModifier())
                        && Modifier.TRANSIENT != candidate.getModifier()) {
                    // Candidate is not public and not protected and not simply
                    // a transient field (in which case subclasses
                    // will see the inherited field), so any subsequent
                    // subclasses won't be able to see it. Give up!
                    continue;
                }

                if (!candidate.getFieldType().equals(ENTITY_MANAGER)) {
                    // Candidate isn't an EntityManager, so give up
                    continue;
                }

                if (MemberFindingUtils.getAnnotationOfType(
                        candidate.getAnnotations(), PERSISTENCE_CONTEXT) == null) {
                    // Candidate doesn't have a PersistenceContext annotation,
                    // so give up
                    continue;
                }
View Full Code Here

     
      JavaSymbolName fieldName = new JavaSymbolName("fieldNames4OrderClauseFilter");
      JavaType fieldType = JavaType.listOf(JavaType.STRING);
     
        // Locate user-defined method
        final FieldMetadata userField = governorTypeDetails.getField(fieldName);
        if (userField != null) {
            return userField;
        }
       
      List<String> listOfFieldNames = new ArrayList<String>();    
View Full Code Here

                .getIdentifierFields(entity);
        if (idFields.size() != 1) {
            // The ID field metadata is either unavailable or not stable yet
            return null;
        }
        final FieldMetadata idField = idFields.get(0);

        final String entityName = StringUtils.defaultIfEmpty(
                jpaEntityAnnotationValues.getEntityName(),
                entity.getSimpleTypeName());
View Full Code Here

    List<FieldMetadata> fieldsNamesList = new ArrayList<FieldMetadata>();
    // Getting all declared fields in entity
    List<? extends FieldMetadata> fieldList = cid.getDeclaredFields();
    Iterator<? extends FieldMetadata> it = fieldList.iterator();
    while (it.hasNext()) {
      FieldMetadata currentField = it.next();
      if (typeLocationService.isInProject(currentField.getFieldType())) {
        fieldsNamesList.add(currentField);
      }
    }

    return fieldsNamesList;
View Full Code Here

                }
                if (method.hasSameName(identifierAccessor, versionAccessor)) {
                    continue;
                }

                final FieldMetadata field = BeanInfoUtils
                        .getFieldForJavaBeanMethod(memberDetails, method);
                if (field == null) {
                    continue;
                }

                facetFields
                        .append(formbackingObject.getSimpleTypeName()
                                .toLowerCase())
                        .append(".")
                        .append(field.getFieldName())
                        .append(SolrUtils.getSolrDynamicFieldPostFix(field
                                .getFieldType())).append(",");

                final Element columnElement = new XmlElementBuilder(
                        "fields:column", document)
                        .addAttribute(
                                "id",
                                XmlUtils.convertId("c:"
                                        + formbackingObject
                                                .getFullyQualifiedTypeName()
                                        + "."
                                        + field.getFieldName().getSymbolName()))
                        .addAttribute(
                                "property",
                                formbackingObject.getSimpleTypeName()
                                        .toLowerCase()
                                        + "."
                                        + field.getFieldName().getSymbolName()
                                                .toLowerCase()
                                        + SolrUtils
                                                .getSolrDynamicFieldPostFix(field
                                                        .getFieldType()))
                        .build();
                columnElement.setAttribute("z",
                        XmlRoundTripUtils.calculateUniqueKeyFor(columnElement));
                resultTable.appendChild(columnElement);
View Full Code Here

                + "());");
        final StringBuilder textField = new StringBuilder("new StringBuilder()");

        for (final Entry<MethodMetadata, FieldMetadata> entry : accessorDetails
                .entrySet()) {
            final FieldMetadata field = entry.getValue();
            if (versionField != null
                    && field.getFieldName().equals(versionField.getFieldName())) {
                continue;
            }
            if (field.getFieldType().isCommonCollectionType()) {
                continue;
            }
            if (!textField.toString().endsWith("StringBuilder()")) {
                textField.append(".append(\" \")");
            }
            final JavaSymbolName accessorMethod = entry.getKey()
                    .getMethodName();
            if (field.getFieldType().equals(CALENDAR)) {
                textField.append(".append(").append(javaBeanFieldName)
                        .append(".").append(accessorMethod)
                        .append("().getTime()").append(")");
            }
            else {
                textField.append(".append(").append(javaBeanFieldName)
                        .append(".").append(accessorMethod).append("()")
                        .append(")");
            }
            String fieldName = javaBeanFieldName
                    + "."
                    + field.getFieldName().getSymbolName().toLowerCase()
                    + SolrUtils
                            .getSolrDynamicFieldPostFix(field.getFieldType());
            for (final AnnotationMetadata annotation : field.getAnnotations()) {
                if (annotation.getAnnotationType()
                        .equals(new JavaType(
                                "org.apache.solr.client.solrj.beans.Field"))) {
                    final AnnotationAttributeValue<?> value = annotation
                            .getAttribute(new JavaSymbolName("value"));
                    if (value != null) {
                        fieldName = value.getValue().toString();
                    }
                }
            }
            if (field.getFieldType().equals(CALENDAR)) {
                bodyBuilder.appendFormalLine("sid.addField(\"" + fieldName
                        + "\", " + javaBeanFieldName + "."
                        + accessorMethod.getSymbolName() + "().getTime());");
            }
            else {
View Full Code Here

                    && !propertyType.getParameters().isEmpty()) {
                ptmd = typeLocationService.getTypeDetails(propertyType
                        .getParameters().get(0));
            }

            final FieldMetadata field = proxy.getDeclaredField(propertyName);
            final List<AnnotationMetadata> annotations = field != null ? field
                    .getAnnotations() : Collections
                    .<AnnotationMetadata> emptyList();

            final GwtProxyProperty gwtProxyProperty = new GwtProxyProperty(
                    topLevelPackage, ptmd, propertyType,
View Full Code Here

        final MemberDetails memberDetails = getMemberDetails(governorPhysicalTypeMetadata);
        final Map<MethodMetadata, FieldMetadata> accessorDetails = new LinkedHashMap<MethodMetadata, FieldMetadata>();
        for (final MethodMetadata method : memberDetails.getMethods()) {
            if (BeanInfoUtils.isAccessorMethod(method)
                    && !method.getMethodName().getSymbolName().startsWith("is")) {
                final FieldMetadata field = BeanInfoUtils
                        .getFieldForJavaBeanMethod(memberDetails, method);
                if (field != null) {
                    accessorDetails.put(method, field);
                }
                // Track any changes to that method (eg it goes away)
                metadataDependencyRegistry.registerDependency(
                        method.getDeclaredByMetadataId(),
                        metadataIdentificationString);
            }
        }
        final MethodMetadata identifierAccessor = persistenceMemberLocator
                .getIdentifierAccessor(javaType);
        if (identifierAccessor == null) {
            return null;
        }

        final FieldMetadata versionField = persistenceMemberLocator
                .getVersionField(javaType);

        return new SolrMetadata(metadataIdentificationString, aspectName,
                annotationValues, governorPhysicalTypeMetadata,
                identifierAccessor, versionField, accessorDetails, beanPlural);
View Full Code Here

        for (final MethodMetadata method : memberDetails.getMethods()) {
            if (!BeanInfoUtils.isAccessorMethod(method)) {
                continue;
            }

            final FieldMetadata field = BeanInfoUtils
                    .getFieldForJavaBeanMethod(memberDetails, method);
            if (field == null) {
                continue;
            }
           
         
            final JavaSymbolName fieldName = field.getFieldName();
            final String fieldResourceId = XmlUtils.convertId(resourceId + "."
                    + fieldName.getSymbolName().toLowerCase());
            if (typeLocationService.isInProject(method.getReturnType())
                    && webMetadataService.isRooIdentifier(method
                            .getReturnType(), webMetadataService
                            .getMemberDetails(method.getReturnType()))) {
                final JavaTypePersistenceMetadataDetails typePersistenceMetadataDetails = webMetadataService
                        .getJavaTypePersistenceMetadataDetails(method
                                .getReturnType(), webMetadataService
                                .getMemberDetails(method.getReturnType()),
                                jspMetadataId);
                if (typePersistenceMetadataDetails != null) {
                    for (final FieldMetadata f : typePersistenceMetadataDetails
                            .getRooIdentifierFields()) {
                        final String sb = f.getFieldName()
                                .getReadableSymbolName();
                        properties.put(
                                XmlUtils.convertId(resourceId
                                        + "."
                                        + javaTypePersistenceMetadataDetails
                                                .getIdentifierField()
                                                .getFieldName().getSymbolName()
                                        + "."
                                        + f.getFieldName().getSymbolName()
                                                .toLowerCase()),
                                StringUtils.isNotBlank(sb) ? sb : fieldName
                                        .getSymbolName());
                    }
                }
            }
            else if (!method.getMethodName().equals(
                    javaTypePersistenceMetadataDetails
                            .getIdentifierAccessorMethod().getMethodName())
                    || javaTypePersistenceMetadataDetails
                            .getVersionAccessorMethod() != null
                    && !method
                            .getMethodName()
                            .equals(javaTypePersistenceMetadataDetails
                                    .getVersionAccessorMethod().getMethodName())) {
                final String sb = fieldName.getReadableSymbolName();
                properties.put(fieldResourceId, StringUtils.isNotBlank(sb) ? sb
                        : fieldName.getSymbolName());
            }
           
            // Checking if current field is embeddable
            // If is embeddable, add properties for every embeddable class field
            AnnotationMetadata embeddedAnnotation = field.getAnnotation(EMBEDDED_ANNOTATION);
            if(embeddedAnnotation != null){
              // Getting embeddable class
              JavaType embeddableClass = field.getFieldType();
              ClassOrInterfaceTypeDetails embeddableClassDetails = typeLocationService.getTypeDetails(embeddableClass);
              if(embeddableClassDetails != null){
                AnnotationMetadata embeddableAnnotation = embeddableClassDetails.getAnnotation(EMBEDDABLE_ANNOTATION);
                if(embeddableAnnotation != null){
                  // Getting embeddable fields
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.