use of org.broadleafcommerce.openadmin.server.dao.provider.metadata.request.LateStageAddMetadataRequest in project BroadleafCommerce by BroadleafCommerce.
the class DynamicEntityDaoImpl method getMergedProperties.
@Override
public Map<String, FieldMetadata> getMergedProperties(String ceilingEntityFullyQualifiedClassname, Class<?>[] entities, ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, String[] includeFields, String[] excludeFields, String configurationKey, String prefix) {
Map<String, FieldMetadata> mergedProperties = getMergedPropertiesRecursively(ceilingEntityFullyQualifiedClassname, entities, foreignField, additionalNonPersistentProperties, additionalForeignFields, mergedPropertyType, populateManyToOneFields, includeFields, excludeFields, configurationKey, new ArrayList<Class<?>>(), prefix, false, "");
final List<String> removeKeys = new ArrayList<>();
for (final String key : mergedProperties.keySet()) {
if (mergedProperties.get(key).getExcluded() != null && mergedProperties.get(key).getExcluded()) {
removeKeys.add(key);
}
}
for (String removeKey : removeKeys) {
mergedProperties.remove(removeKey);
}
// Allow field metadata providers to contribute additional fields here. These latestage handlers take place
// after any cached lookups occur, and are ideal for adding in dynamic properties that are not globally cacheable
// like properties gleaned from reflection typically are.
Set<String> keys = new HashSet<>(mergedProperties.keySet());
for (Class<?> targetClass : entities) {
for (String key : keys) {
LateStageAddMetadataRequest amr = new LateStageAddMetadataRequest(key, null, targetClass, this, "");
boolean foundOneOrMoreHandlers = false;
for (FieldMetadataProvider fieldMetadataProvider : fieldMetadataProviders) {
MetadataProviderResponse response = fieldMetadataProvider.lateStageAddMetadata(amr, mergedProperties);
if (MetadataProviderResponse.NOT_HANDLED != response) {
foundOneOrMoreHandlers = true;
}
if (MetadataProviderResponse.HANDLED_BREAK == response) {
break;
}
}
if (!foundOneOrMoreHandlers) {
defaultFieldMetadataProvider.lateStageAddMetadata(amr, mergedProperties);
}
}
}
return mergedProperties;
}
Aggregations