Search in sources :

Example 21 with IBeanKey

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;
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) LinkedList(java.util.LinkedList)

Example 22 with IBeanKey

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"));
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) ArrayList(java.util.ArrayList) List(java.util.List) IExecutorService(org.jowidgets.cap.common.api.service.IExecutorService) SyncResultCallback(org.jowidgets.cap.common.tools.execution.SyncResultCallback) Test(org.junit.Test)

Example 23 with IBeanKey

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;
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 24 with IBeanKey

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;
}
Also used : BeanKey(org.jowidgets.cap.common.tools.bean.BeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) LinkedList(java.util.LinkedList) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy)

Example 25 with IBeanKey

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;
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IFilter(org.jowidgets.cap.common.api.filter.IFilter) LinkedList(java.util.LinkedList) Predicate(javax.persistence.criteria.Predicate)

Aggregations

IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)27 LinkedList (java.util.LinkedList)15 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)5 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)4 DeletedBeanException (org.jowidgets.cap.common.api.exception.DeletedBeanException)4 BeanKey (org.jowidgets.cap.common.tools.bean.BeanKey)4 List (java.util.List)3 ILinkDeletion (org.jowidgets.cap.common.api.link.ILinkDeletion)3 SyncResultCallback (org.jowidgets.cap.common.tools.execution.SyncResultCallback)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 BeanException (org.jowidgets.cap.common.api.exception.BeanException)2 StaleBeanException (org.jowidgets.cap.common.api.exception.StaleBeanException)2 IFilter (org.jowidgets.cap.common.api.filter.IFilter)2 IFilterFactory (org.jowidgets.cap.common.api.filter.IFilterFactory)2 IBeanKeyFactory (org.jowidgets.cap.ui.api.bean.IBeanKeyFactory)2 IExecutionTask (org.jowidgets.cap.ui.api.execution.IExecutionTask)2 Node (org.neo4j.graphdb.Node)2