Search in sources :

Example 1 with OverrideViaAnnotationRequest

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

the class Metadata method applyTabAndGroupMetadataOverrides.

public void applyTabAndGroupMetadataOverrides(Class<?>[] entities, Map<String, TabMetadata> mergedTabAndGroupMetadata) {
    // Go in reverse order since we want the lowest subclass to come last to guarantee that it takes effect
    for (int i = entities.length - 1; i >= 0; i--) {
        basicEntityMetadataProvider.overrideMetadataViaAnnotation(new OverrideViaAnnotationRequest(entities[i], true, null, ""), mergedTabAndGroupMetadata);
        basicEntityMetadataProvider.overrideMetadataViaXml(new OverrideViaXmlRequest("", entities[i].getCanonicalName(), "", true, null), mergedTabAndGroupMetadata);
    }
}
Also used : OverrideViaXmlRequest(org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.OverrideViaXmlRequest) OverrideViaAnnotationRequest(org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.OverrideViaAnnotationRequest)

Example 2 with OverrideViaAnnotationRequest

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

the class Metadata method overrideMetadata.

public Map<String, FieldMetadata> overrideMetadata(Class<?>[] entities, PropertyBuilder propertyBuilder, String prefix, Boolean isParentExcluded, String ceilingEntityFullyQualifiedClassname, String configurationKey, DynamicEntityDao dynamicEntityDao) {
    Boolean classAnnotatedPopulateManyToOneFields = null;
    // go in reverse order since I want the lowest subclass override to come last to guarantee that it takes effect
    for (int i = entities.length - 1; i >= 0; i--) {
        AdminPresentationClass adminPresentationClass = AnnotationUtils.findAnnotation(entities[i], AdminPresentationClass.class);
        if (adminPresentationClass != null && adminPresentationClass.populateToOneFields() != PopulateToOneFieldsEnum.NOT_SPECIFIED) {
            classAnnotatedPopulateManyToOneFields = adminPresentationClass.populateToOneFields() == PopulateToOneFieldsEnum.TRUE;
            break;
        }
    }
    Map<String, FieldMetadata> mergedProperties = propertyBuilder.execute(classAnnotatedPopulateManyToOneFields);
    for (int i = entities.length - 1; i >= 0; i--) {
        boolean handled = false;
        for (FieldMetadataProvider fieldMetadataProvider : fieldMetadataProviders) {
            MetadataProviderResponse response = fieldMetadataProvider.overrideViaAnnotation(new OverrideViaAnnotationRequest(entities[i], isParentExcluded, dynamicEntityDao, prefix), mergedProperties);
            if (MetadataProviderResponse.NOT_HANDLED != response) {
                handled = true;
            }
            if (MetadataProviderResponse.HANDLED_BREAK == response) {
                break;
            }
        }
        if (!handled) {
            defaultFieldMetadataProvider.overrideViaAnnotation(new OverrideViaAnnotationRequest(entities[i], isParentExcluded, dynamicEntityDao, prefix), mergedProperties);
        }
    }
    ((DefaultFieldMetadataProvider) defaultFieldMetadataProvider).overrideExclusionsFromXml(new OverrideViaXmlRequest(configurationKey, ceilingEntityFullyQualifiedClassname, prefix, isParentExcluded, dynamicEntityDao), mergedProperties);
    boolean handled = false;
    for (FieldMetadataProvider fieldMetadataProvider : fieldMetadataProviders) {
        MetadataProviderResponse response = fieldMetadataProvider.overrideViaXml(new OverrideViaXmlRequest(configurationKey, ceilingEntityFullyQualifiedClassname, prefix, isParentExcluded, dynamicEntityDao), mergedProperties);
        if (MetadataProviderResponse.NOT_HANDLED != response) {
            handled = true;
        }
        if (MetadataProviderResponse.HANDLED_BREAK == response) {
            break;
        }
    }
    if (!handled) {
        defaultFieldMetadataProvider.overrideViaXml(new OverrideViaXmlRequest(configurationKey, ceilingEntityFullyQualifiedClassname, prefix, isParentExcluded, dynamicEntityDao), mergedProperties);
    }
    return mergedProperties;
}
Also used : AdminPresentationClass(org.broadleafcommerce.common.presentation.AdminPresentationClass) DefaultFieldMetadataProvider(org.broadleafcommerce.openadmin.server.dao.provider.metadata.DefaultFieldMetadataProvider) DefaultFieldMetadataProvider(org.broadleafcommerce.openadmin.server.dao.provider.metadata.DefaultFieldMetadataProvider) FieldMetadataProvider(org.broadleafcommerce.openadmin.server.dao.provider.metadata.FieldMetadataProvider) FieldMetadata(org.broadleafcommerce.openadmin.dto.FieldMetadata) OverrideViaXmlRequest(org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.OverrideViaXmlRequest) MetadataProviderResponse(org.broadleafcommerce.openadmin.server.service.type.MetadataProviderResponse) OverrideViaAnnotationRequest(org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.OverrideViaAnnotationRequest)

Aggregations

OverrideViaAnnotationRequest (org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.OverrideViaAnnotationRequest)2 OverrideViaXmlRequest (org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.OverrideViaXmlRequest)2 AdminPresentationClass (org.broadleafcommerce.common.presentation.AdminPresentationClass)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 MetadataProviderResponse (org.broadleafcommerce.openadmin.server.service.type.MetadataProviderResponse)1