use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.
the class JpaBeanAccessImpl method getBeans.
@SuppressWarnings("unchecked")
@Override
public List<BEAN_TYPE> getBeans(final Collection<? extends IBeanKey> keys, final IExecutionCallback executionCallback) {
if (EmptyCheck.isEmpty(keys)) {
return Collections.emptyList();
} else {
final Collection<Object> ids = new HashSet<Object>(keys.size());
for (final IBeanKey beanKey : keys) {
ids.add(beanKey.getId());
}
final EntityManager entityManager = EntityManagerProvider.get();
final CriteriaQuery<? extends BEAN_TYPE> query = entityManager.getCriteriaBuilder().createQuery(beanType);
final Root<? extends BEAN_TYPE> bean = query.from(beanType);
query.where(bean.get(IBean.ID_PROPERTY).in(ids));
CapServiceToolkit.checkCanceled(executionCallback);
final List<? extends BEAN_TYPE> result = entityManager.createQuery(query).getResultList();
CapServiceToolkit.checkCanceled(executionCallback);
return (List<BEAN_TYPE>) result;
}
}
use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.
the class SyncNeo4JSimpleRelatedReaderServiceImpl method getAllRelatedBeans.
private List<? extends BEAN_TYPE> getAllRelatedBeans(final List<? extends IBeanKey> parentBeans, final IExecutionCallback executionCallback) {
final Set<BEAN_TYPE> result = new LinkedHashSet<BEAN_TYPE>();
for (final IBeanKey beanKey : parentBeans) {
CapServiceToolkit.checkCanceled(executionCallback);
final Node parentNode = NodeAccess.findNode(parentBeanTypeId, beanKey.getId());
if (parentNode != null) {
for (final Tuple<Node, Relationship> tuple : getAllRelatedNodes(parentNode, executionCallback)) {
CapServiceToolkit.checkCanceled(executionCallback);
result.add(beanFactory.createRelatedNodeBean(beanType, beanTypeId, tuple.getFirst(), tuple.getSecond()));
}
}
}
return new LinkedList<BEAN_TYPE>(result);
}
Aggregations