use of com.haulmont.cuba.core.sys.MetadataBuildSupport.XmlAnnotation in project cuba by cuba-platform.
the class MetadataLoader method addMetaAnnotationsFromXml.
/**
* Initialize entity annotations from definition in <code>metadata.xml</code>.
* <p>Can be overridden in application projects to handle application-specific annotations.</p>
*
* @param xmlAnnotations map of class name to annotations map
* @param metaClass MetaClass instance to assign annotations
*/
protected void addMetaAnnotationsFromXml(List<XmlAnnotations> xmlAnnotations, MetaClass metaClass) {
for (XmlAnnotations xmlAnnotation : xmlAnnotations) {
MetaClass metaClassFromXml = session.getClassNN(ReflectionHelper.getClass(xmlAnnotation.entityClass));
Class extendedClass = extendedEntities.getExtendedClass(metaClassFromXml);
MetaClass effectiveMetaClass = extendedClass != null ? session.getClassNN(extendedClass) : metaClassFromXml;
if (effectiveMetaClass.equals(metaClass)) {
for (Map.Entry<String, XmlAnnotation> entry : xmlAnnotation.annotations.entrySet()) {
assignMetaAnnotationValueFromXml(entry.getKey(), entry.getValue(), metaClass.getAnnotations());
}
for (XmlAnnotations attributeAnnotation : xmlAnnotation.attributeAnnotations) {
MetaProperty property = metaClass.getPropertyNN(attributeAnnotation.entityClass);
for (Map.Entry<String, XmlAnnotation> entry : attributeAnnotation.annotations.entrySet()) {
assignMetaAnnotationValueFromXml(entry.getKey(), entry.getValue(), property.getAnnotations());
}
}
break;
}
}
}
Aggregations