public Set<JavaType> getPersistentFieldTypes(
      final JavaType thisType, final PersistenceMemberLocator persistenceMemberLocator) {
    final MethodMetadata identifierAccessor =
        persistenceMemberLocator.getIdentifierAccessor(thisType);
    final MethodMetadata versionAccessor = persistenceMemberLocator.getVersionAccessor(thisType);

    final Set<JavaType> fieldTypes = new LinkedHashSet<JavaType>();
    for (final MethodMetadata method : getMethods()) {
      // Not interested in non-accessor methods or persistence identifiers
      // and version fields
      if (!BeanInfoUtils.isAccessorMethod(method)
          || method.hasSameName(identifierAccessor, versionAccessor)) {
        continue;
      }

      // Not interested in fields that are JPA transient fields or
      // immutable fields
      final FieldMetadata field = BeanInfoUtils.getFieldForJavaBeanMethod(this, method);
      if (field == null
          || field.getCustomData().keySet().contains(CustomDataKeys.TRANSIENT_FIELD)
          || !BeanInfoUtils.hasAccessorAndMutator(field, this)) {
        continue;
      }
      final JavaType returnType = method.getReturnType();
      if (returnType.isCommonCollectionType()) {
        for (final JavaType genericType : returnType.getParameters()) {
          fieldTypes.add(genericType);
        }
      } else {
        if (!field.getCustomData().keySet().contains(EMBEDDED_FIELD)) {
          fieldTypes.add(returnType);
        }
      }
    }
    return fieldTypes;
  }
  public MetadataItem get(String metadataIdentificationString) {
    ProjectMetadata projectMetadata = projectOperations.getProjectMetadata();
    if (projectMetadata == null) {
      return null;
    }

    ClassOrInterfaceTypeDetails proxy = getGovernor(metadataIdentificationString);
    if (proxy == null) {
      return null;
    }

    AnnotationMetadata proxyAnnotation =
        GwtUtils.getFirstAnnotation(proxy, GwtUtils.PROXY_ANNOTATIONS);
    if (proxyAnnotation == null) {
      return null;
    }

    String locatorType = GwtUtils.getStringValue(proxyAnnotation.getAttribute("locator"));
    if (!StringUtils.hasText(locatorType)) {
      return null;
    }

    ClassOrInterfaceTypeDetails entity = gwtTypeService.lookupEntityFromProxy(proxy);
    if (entity == null) {
      return null;
    }

    MethodMetadata idAccessor = persistenceMemberLocator.getIdentifierAccessor(entity.getName());
    MethodMetadata versionAccessor = persistenceMemberLocator.getVersionAccessor(entity.getName());
    if (idAccessor == null || versionAccessor == null) {
      return null;
    }

    final JavaType idType = GwtUtils.convertPrimitiveType(idAccessor.getReturnType(), true);
    String locatorIdentifier = PhysicalTypeIdentifier.createIdentifier(new JavaType(locatorType));
    ClassOrInterfaceTypeDetailsBuilder locatorBuilder =
        new ClassOrInterfaceTypeDetailsBuilder(locatorIdentifier);
    AnnotationMetadataBuilder annotationMetadataBuilder =
        new AnnotationMetadataBuilder(RooJavaType.ROO_GWT_LOCATOR);
    annotationMetadataBuilder.addStringAttribute(
        "value", entity.getName().getFullyQualifiedTypeName());
    locatorBuilder.addAnnotation(annotationMetadataBuilder);
    annotationMetadataBuilder = new AnnotationMetadataBuilder(SpringJavaType.COMPONENT);
    locatorBuilder.addAnnotation(annotationMetadataBuilder);
    locatorBuilder.setName(new JavaType(locatorType));
    locatorBuilder.setModifier(Modifier.PUBLIC);
    locatorBuilder.setPhysicalTypeCategory(PhysicalTypeCategory.CLASS);
    locatorBuilder.addExtendsTypes(
        new JavaType(
            GwtUtils.LOCATOR.getFullyQualifiedTypeName(),
            0,
            DataType.TYPE,
            null,
            Arrays.asList(entity.getName(), idType)));
    locatorBuilder.addMethod(getCreateMethod(locatorIdentifier, entity.getName()));
    locatorBuilder.addMethod(
        getFindMethod(locatorBuilder, locatorIdentifier, entity.getName(), idType));
    locatorBuilder.addMethod(getDomainTypeMethod(locatorIdentifier, entity.getName()));
    locatorBuilder.addMethod(getIdMethod(locatorIdentifier, entity.getName(), idAccessor));
    locatorBuilder.addMethod(getIdTypeMethod(locatorIdentifier, entity.getName(), idType));
    locatorBuilder.addMethod(
        getVersionMethod(locatorIdentifier, entity.getName(), versionAccessor));

    typeManagementService.createOrUpdateTypeOnDisk(locatorBuilder.build());
    return null;
  }