use of com.haulmont.cuba.core.sys.MetadataBuildSupport.XmlAnnotations in project cuba by cuba-platform.
the class MetadataLoader method loadMetadata.
/**
* Loads metadata session.
*/
public void loadMetadata() {
List<MetadataBuildSupport.XmlFile> metadataXmlList = metadataBuildSupport.init();
initRootPackages(metadataXmlList);
initDatatypes(metadataBuildSupport.getDatatypeElements(metadataXmlList));
MetaModelLoader modelLoader = createModelLoader(session);
Map<String, List<EntityClassInfo>> entityPackages = metadataBuildSupport.getEntityPackages(metadataXmlList);
for (Map.Entry<String, List<EntityClassInfo>> entry : entityPackages.entrySet()) {
modelLoader.loadModel(entry.getKey(), entry.getValue());
}
for (MetaClass metaClass : session.getClasses()) {
postProcessClass(metaClass);
initMetaAnnotations(metaClass);
}
initStoreMetaAnnotations(entityPackages);
initExtensionMetaAnnotations();
List<XmlAnnotations> xmlAnnotations = metadataBuildSupport.getEntityAnnotations(metadataXmlList);
for (MetaClass metaClass : session.getClasses()) {
addMetaAnnotationsFromXml(xmlAnnotations, metaClass);
}
replaceExtendedMetaClasses();
}
use of com.haulmont.cuba.core.sys.MetadataBuildSupport.XmlAnnotations 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