use of org.jowidgets.cap.service.spring.BeanTypeUtil in project jo-client-platform by jo-source.
the class JpaReaderAnnotationPostProcessor method postProcessAfterInitialization.
@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) {
try {
final ReaderBean beanAnnotation = beanFactory.findAnnotationOnBean(beanName, ReaderBean.class);
if (beanAnnotation != null) {
final Class<? extends IBean> beanType = beanAnnotation.type();
final List<String> propertyNames = new BeanTypeUtil(beanType).getPropertyNames();
final Set<Method> methods = getReaderMethods(bean);
for (final Method method : methods) {
final IPredicateCreator<Object> predicateCreator = createPredicateCreator(beanFactory, beanName, method);
final ICriteriaQueryCreatorBuilder<Object> queryCreatorBuilder = JpaQueryToolkit.criteriaQueryCreatorBuilder(beanType).setCaseSensitve(!beanAnnotation.caseInsensitive());
// TODO: MvR -> Check genericity...
if (ParentLinkHelper.hasParent(beanType)) {
queryCreatorBuilder.setParentPropertyName(beanAnnotation.parentPropertyName());
}
if (predicateCreator != null) {
queryCreatorBuilder.addPredicateCreator(predicateCreator);
}
for (final Map.Entry<String, ? extends ICustomFilterPredicateCreator<?>> entry : customFilterPredicateCreators.entrySet()) {
final String filterName = entry.getKey();
@SuppressWarnings("unchecked") final ICustomFilterPredicateCreator<Object> customFilterPredicateCreator = (ICustomFilterPredicateCreator<Object>) entry.getValue();
queryCreatorBuilder.addCustomFilterPredicateCreator(filterName, customFilterPredicateCreator);
}
final IQueryCreator<Object> queryCreator = queryCreatorBuilder.build();
final IReaderService<Object> readerService = JpaServiceToolkit.serviceFactory().readerService(beanType, queryCreator, propertyNames);
final Reader executorAnnotation = method.getAnnotation(Reader.class);
final IServiceId<IReaderService<Void>> serviceId = new ServiceId<IReaderService<Void>>(executorAnnotation.value(), IReaderService.class);
SpringServiceProvider.getInstance().addService(serviceId, readerService);
}
}
} catch (final NoSuchBeanDefinitionException e) {
}
return bean;
}
use of org.jowidgets.cap.service.spring.BeanTypeUtil in project jo-client-platform by jo-source.
the class JpaEntityService method afterPropertiesSet.
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
final EntityServiceBuilder entityServiceBuilder = new EntityServiceBuilder();
for (final EntityType<?> type : entityManagerFactory.getMetamodel().getEntities()) {
final Class<?> clazz = type.getBindableJavaType();
if (IBean.class.isAssignableFrom(clazz)) {
final Class<? extends IBean> beanType = (Class<? extends IBean>) clazz;
final Class<? extends IBean> beanInterface = new BeanTypeUtil(beanType).getBeanInterface();
addServicesProviderAndDescriptor(entityServiceBuilder, beanInterface, beanType);
}
}
entityService = entityServiceBuilder.build();
}
Aggregations