use of org.broadleafcommerce.common.presentation.AdminPresentationClass 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;
}
use of org.broadleafcommerce.common.presentation.AdminPresentationClass in project BroadleafCommerce by BroadleafCommerce.
the class AbstractFieldMetadataProvider method setClassOwnership.
protected void setClassOwnership(Class<?> parentClass, Class<?> targetClass, Map<String, FieldMetadata> attributes, FieldInfo field) {
FieldMetadata metadata = attributes.get(field.getName());
if (metadata != null) {
AdminPresentationClass adminPresentationClass;
if (parentClass != null) {
metadata.setOwningClass(parentClass.getName());
adminPresentationClass = AnnotationUtils.findAnnotation(parentClass, AdminPresentationClass.class);
} else {
adminPresentationClass = AnnotationUtils.findAnnotation(targetClass, AdminPresentationClass.class);
}
if (adminPresentationClass != null) {
String friendlyName = adminPresentationClass.friendlyName();
if (!StringUtils.isEmpty(friendlyName) && StringUtils.isEmpty(metadata.getOwningClassFriendlyName())) {
metadata.setOwningClassFriendlyName(friendlyName);
}
}
}
}
use of org.broadleafcommerce.common.presentation.AdminPresentationClass in project BroadleafCommerce by BroadleafCommerce.
the class DynamicEntityDaoImpl method getClassTree.
@Override
public ClassTree getClassTree(Class<?>[] polymorphicClasses) {
String ceilingClass = null;
for (Class<?> clazz : polymorphicClasses) {
AdminPresentationClass classPresentation = AnnotationUtils.findAnnotation(clazz, AdminPresentationClass.class);
if (classPresentation != null) {
String ceilingEntity = classPresentation.ceilingDisplayEntity();
if (!StringUtils.isEmpty(ceilingEntity)) {
ceilingClass = ceilingEntity;
break;
}
}
}
if (ceilingClass != null) {
int pos = -1;
int j = 0;
for (Class<?> clazz : polymorphicClasses) {
if (clazz.getName().equals(ceilingClass)) {
pos = j;
break;
}
j++;
}
if (pos >= 0) {
Class<?>[] temp = new Class<?>[pos + 1];
System.arraycopy(polymorphicClasses, 0, temp, 0, j + 1);
polymorphicClasses = temp;
}
}
ClassTree classTree = null;
if (!ArrayUtils.isEmpty(polymorphicClasses)) {
Class<?> topClass = polymorphicClasses[polymorphicClasses.length - 1];
classTree = new ClassTree(topClass.getName(), isExcludeClassFromPolymorphism(topClass));
createClassTreeFromAnnotation(topClass, classTree);
for (int j = polymorphicClasses.length - 1; j >= 0; j--) {
addClassToTree(polymorphicClasses[j], classTree);
}
classTree.finalizeStructure(1);
}
return classTree;
}
Aggregations