use of com.haulmont.cuba.core.sys.persistence.mapping.MappingProcessorContext in project cuba by cuba-platform.
the class EclipseLinkSessionEventListener method preLogin.
@Override
public void preLogin(SessionEvent event) {
Session session = event.getSession();
boolean useJoinSubclasses = useJoinSubclasses();
boolean hasMultipleTableConstraintDependency = hasMultipleTableConstraintDependency();
setPrintInnerJoinOnClause(session);
if (useJoinSubclasses) {
setJoinSubclasses(session);
}
List<Pair<Class, String>> missingEnhancements = new ArrayList<>();
Map<String, ClassDescriptor> mappedSuperclassDescriptorMap = session.getProject().getMappedSuperclassDescriptors();
for (Map.Entry<String, ClassDescriptor> entry : mappedSuperclassDescriptorMap.entrySet()) {
try {
Class javaClass = getClass().getClassLoader().loadClass(entry.getKey());
enhancementCheck(javaClass, missingEnhancements);
} catch (ClassNotFoundException e) {
log.warn("MappedSuperclass {} was not found by ClassLoader", entry.getKey());
}
}
Map<Class, ClassDescriptor> descriptorMap = session.getDescriptors();
for (Map.Entry<Class, ClassDescriptor> entry : descriptorMap.entrySet()) {
MetaClass metaClass = metadata.getSession().getClassNN(entry.getKey());
ClassDescriptor desc = entry.getValue();
enhancementCheck(entry.getKey(), missingEnhancements);
setCacheable(metaClass, desc, session);
if (hasMultipleTableConstraintDependency) {
setMultipleTableConstraintDependency(metaClass, desc);
}
if (useJoinSubclasses) {
setJoinSubclasses(metaClass, desc);
}
if (Entity.class.isAssignableFrom(desc.getJavaClass())) {
// set DescriptorEventManager that doesn't invoke listeners for base classes
desc.setEventManager(new DescriptorEventManagerWrapper(desc.getDescriptorEventManager()));
desc.getEventManager().addListener(descriptorEventListener);
}
setAdditionalCriteria(desc);
if (SoftDelete.class.isAssignableFrom(desc.getJavaClass())) {
desc.setDeletePredicate(entity -> entity instanceof SoftDelete && PersistenceHelper.isLoaded(entity, "deleteTs") && ((SoftDelete) entity).isDeleted());
}
Map<String, MappingProcessor> mappingProcessors = AppBeans.getAll(MappingProcessor.class);
for (DatabaseMapping mapping : desc.getMappings()) {
MappingProcessorContext mappingProcessorCtx = new MappingProcessorContext(mapping, session);
for (MappingProcessor mp : mappingProcessors.values()) {
log.debug("{} mapping processor is started", mp.getClass());
mp.process(mappingProcessorCtx);
log.debug("{} mapping processor is finished", mp.getClass());
}
}
}
logCheckResult(missingEnhancements);
}
Aggregations