Search in sources :

Example 1 with AddFieldMetadataRequest

use of org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.AddFieldMetadataRequest in project BroadleafCommerce by BroadleafCommerce.

the class Metadata method getFieldMetadataForTargetClass.

public Map<String, FieldMetadata> getFieldMetadataForTargetClass(Class<?> parentClass, Class<?> targetClass, DynamicEntityDao dynamicEntityDao, String prefix) {
    Map<String, FieldMetadata> metadata = new HashMap<>();
    Field[] fields = dynamicEntityDao.getAllFields(targetClass);
    for (Field field : fields) {
        boolean foundOneOrMoreHandlers = false;
        for (FieldMetadataProvider fieldMetadataProvider : fieldMetadataProviders) {
            MetadataProviderResponse response = fieldMetadataProvider.addMetadata(new AddFieldMetadataRequest(field, parentClass, targetClass, dynamicEntityDao, prefix), metadata);
            if (MetadataProviderResponse.NOT_HANDLED != response) {
                foundOneOrMoreHandlers = true;
            }
            if (MetadataProviderResponse.HANDLED_BREAK == response) {
                break;
            }
        }
        if (!foundOneOrMoreHandlers) {
            defaultFieldMetadataProvider.addMetadata(new AddFieldMetadataRequest(field, parentClass, targetClass, dynamicEntityDao, prefix), metadata);
        }
    }
    return metadata;
}
Also used : Field(java.lang.reflect.Field) DefaultFieldMetadataProvider(org.broadleafcommerce.openadmin.server.dao.provider.metadata.DefaultFieldMetadataProvider) FieldMetadataProvider(org.broadleafcommerce.openadmin.server.dao.provider.metadata.FieldMetadataProvider) FieldMetadata(org.broadleafcommerce.openadmin.dto.FieldMetadata) HashMap(java.util.HashMap) MetadataProviderResponse(org.broadleafcommerce.openadmin.server.service.type.MetadataProviderResponse) AddFieldMetadataRequest(org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.AddFieldMetadataRequest)

Aggregations

Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)1 DefaultFieldMetadataProvider (org.broadleafcommerce.openadmin.server.dao.provider.metadata.DefaultFieldMetadataProvider)1 FieldMetadataProvider (org.broadleafcommerce.openadmin.server.dao.provider.metadata.FieldMetadataProvider)1 AddFieldMetadataRequest (org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.AddFieldMetadataRequest)1 MetadataProviderResponse (org.broadleafcommerce.openadmin.server.service.type.MetadataProviderResponse)1