use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.
the class EntityDataImpl method getBeans.
@Override
public List<BEAN_TYPE> getBeans(final Collection<? extends IBeanKey> keys, final IExecutionCallback executionCallback) {
Assert.paramNotNull(keys, "keys");
final List<BEAN_TYPE> result = new LinkedList<BEAN_TYPE>();
for (final IBeanKey key : keys) {
final BEAN_TYPE bean = getBean(key);
if (bean != null) {
result.add(bean);
}
}
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.
the class ExecutorAnnotationPostProcessorTest method testCreateUser.
@Test
public void testCreateUser() {
final IExecutorService<String> service = ServiceProvider.getService(new ServiceId<IExecutorService<String>>("createUser", IExecutorService.class));
Assert.assertNotNull(service);
final SyncResultCallback<List<IBeanDto>> result = new SyncResultCallback<List<IBeanDto>>();
service.execute(result, new ArrayList<IBeanKey>(), "Hans Meier", null);
final List<IBeanDto> dtos = result.getResultSynchronious();
Assert.assertNotNull(dtos);
Assert.assertEquals(1, dtos.size());
final IBeanDto dto = dtos.get(0);
Assert.assertEquals(1, dto.getId());
Assert.assertEquals("Hans Meier", dto.getValue("name"));
}
use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.
the class UserAccess method getBeans.
@Override
public List<User> getBeans(final Collection<? extends IBeanKey> keys, final IExecutionCallback executionCallback) {
final Set<Object> ids = new HashSet<Object>();
for (final IBeanKey key : keys) {
ids.add(key.getId());
}
final List<User> result = new LinkedList<User>();
for (final Object id : ids) {
result.add(new User(id));
}
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.
the class SingleBeanModelImpl method getParentBeanKeys.
private List<IBeanKey> getParentBeanKeys() {
if (parent == null) {
return null;
}
final IBeanSelection<Object> beanSelection = parent.getBeanSelection();
List<IBeanProxy<Object>> selection = beanSelection.getSelection();
if (EmptyCheck.isEmpty(selection)) {
return null;
} else if (linkType == LinkType.SELECTION_FIRST) {
selection = selection.subList(0, 1);
}
final List<IBeanKey> beanKeys = new LinkedList<IBeanKey>();
for (final IBeanProxy<Object> proxy : selection) {
if (proxy != null && !proxy.isDummy() && !proxy.isTransient()) {
beanKeys.add(new BeanKey(proxy.getId(), proxy.getVersion()));
}
}
return beanKeys;
}
use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.
the class CriteriaQueryCreator method fillQuery.
@SuppressWarnings("unchecked")
private Root<?> fillQuery(final CriteriaQuery<?> query, final CriteriaBuilder criteriaBuilder, final Class<?> persistenceClass, final List<? extends IBeanKey> parentBeanKeys, final IFilter filter, final PARAM_TYPE parameter) {
final Root<?> bean = query.from(persistenceClass);
final List<Predicate> predicates = new LinkedList<Predicate>();
final List<Object> parentIds = new LinkedList<Object>();
if (parentBeanKeys != null) {
for (final IBeanKey parentBeanKey : parentBeanKeys) {
parentIds.add(parentBeanKey.getId());
}
}
for (final IPredicateCreator<PARAM_TYPE> predicateCreator : predicateCreators) {
final Predicate predicate = predicateCreator.createPredicate(criteriaBuilder, bean, query, (List<IBeanKey>) parentBeanKeys, parentIds, parameter);
if (predicate != null) {
predicates.add(predicate);
}
}
for (final IFilter customFilter : filters) {
predicates.add(createFilterPredicate(criteriaBuilder, bean, query, customFilter, parameter));
}
if (filter != null) {
predicates.add(createFilterPredicate(criteriaBuilder, bean, query, filter, parameter));
}
query.where(predicates.toArray(new Predicate[predicates.size()]));
return bean;
}
Aggregations