private void initPossibleSortbyColumnList(EntityManager em) { Metamodel metamodel = em.getMetamodel(); EntityType<SLASummaryBean> slaSummaryBeanEntityType = metamodel.entity(SLASummaryBean.class); Set<Attribute<SLASummaryBean,?>> slaSummaryBeanAttributes = slaSummaryBeanEntityType.getDeclaredAttributes(); possibleSortbyColumns = new ArrayList<>(); for (Attribute<SLASummaryBean,?> attribute : slaSummaryBeanAttributes) { possibleSortbyColumns.add(attribute.getName()); } }
private void initPossibleSortbyColumnList(EntityManager em) { Metamodel metamodel = em.getMetamodel(); EntityType<SLASummaryBean> slaSummaryBeanEntityType = metamodel.entity(SLASummaryBean.class); Set<Attribute<SLASummaryBean,?>> slaSummaryBeanAttributes = slaSummaryBeanEntityType.getDeclaredAttributes(); possibleSortbyColumns = new ArrayList<>(); for (Attribute<SLASummaryBean,?> attribute : slaSummaryBeanAttributes) { possibleSortbyColumns.add(attribute.getName()); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private Map<PropertyDescriptor, Map<I, Object>> getAuditableProperties(BaseEntity<I> entity) { Map auditableProperties = AUDITABLE_PROPERTIES.computeIfAbsent(entity.getClass(), k -> { BaseEntityService<?, ?> baseEntityService = BaseEntityService.getCurrentInstance(); Set<String> auditablePropertyNames = baseEntityService.getMetamodel(entity).getDeclaredAttributes().stream() .filter(a -> a.getJavaMember() instanceof Field && ((Field) a.getJavaMember()).isAnnotationPresent(Audit.class)) .map(Attribute::getName) .collect(toSet()); try { return stream(getBeanInfo(baseEntityService.getProvider().getEntityType(entity)).getPropertyDescriptors()) .filter(p -> auditablePropertyNames.contains(p.getName())) .collect(toConcurrentMap(identity(), v -> new ConcurrentHashMap<>())); } catch (IntrospectionException e) { throw new UnsupportedOperationException(e); } }); return auditableProperties; }