Search in sources :

Example 1 with IBeanKey

use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.

the class SyncNeo4JSimpleTraversalReaderServiceImpl method getAllRelatedBeans.

private Set<? extends BEAN_TYPE> getAllRelatedBeans(final List<? extends IBeanKey> parentBeans, final PARAM_TYPE parameter, 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 TraversalDescription traversalDescription : traversalDescriptions) {
                for (final Node resultNode : traversalDescription.traverse(parentNode).nodes()) {
                    CapServiceToolkit.checkCanceled(executionCallback);
                    if (resultNode.hasProperty(beanTypePropertyName) && beanTypeIdString.equals(resultNode.getProperty(beanTypePropertyName))) {
                        result.add(beanFactory.createNodeBean(beanType, beanTypeId, resultNode));
                    }
                }
            }
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) Node(org.neo4j.graphdb.Node) TraversalDescription(org.neo4j.graphdb.traversal.TraversalDescription)

Example 2 with IBeanKey

use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.

the class Neo4JBeanAccessImpl 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) {
        CapServiceToolkit.checkCanceled(executionCallback);
        final BEAN_TYPE bean = findBean(key.getId());
        if (bean != null) {
            result.add(bean);
        }
    }
    return result;
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) LinkedList(java.util.LinkedList)

Example 3 with IBeanKey

use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.

the class SyncDeleterService method delete.

@Override
public void delete(final Collection<? extends IBeanKey> keys, final IExecutionCallback executionCallback) {
    for (final IBeanKey key : keys) {
        final IBean bean = data.getData(key.getId());
        if (!allowDeletedData && bean == null) {
            throw new DeletedBeanException(key.getId());
        }
        if (!allowStaleData && bean != null && bean.getVersion() != key.getVersion()) {
            throw new StaleBeanException(key.getId());
        }
        data.deleteData(key.getId());
    }
}
Also used : DeletedBeanException(org.jowidgets.cap.common.api.exception.DeletedBeanException) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) StaleBeanException(org.jowidgets.cap.common.api.exception.StaleBeanException) IBean(org.jowidgets.cap.common.api.bean.IBean)

Example 4 with IBeanKey

use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.

the class BeanRepositoryBeanAccess method getBeans.

@Override
public List<BEAN_TYPE> getBeans(final Collection<? extends IBeanKey> keys, final IExecutionCallback executionCallback) {
    final List<BEAN_TYPE> result = new LinkedList<BEAN_TYPE>();
    for (final IBeanKey key : keys) {
        final BEAN_TYPE bean = repository.find(key.getId(), executionCallback);
        if (bean != null) {
            result.add(bean);
        }
        CapServiceToolkit.checkCanceled(executionCallback);
    }
    return result;
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) LinkedList(java.util.LinkedList)

Example 5 with IBeanKey

use of org.jowidgets.cap.common.api.bean.IBeanKey in project jo-client-platform by jo-source.

the class CachedBeanListReaderService method addBeans.

void addBeans(final List<? extends IBeanKey> parentBeanKeys, final Set<IBeanProxy<BEAN_TYPE>> beans) {
    if (!useCache) {
        return;
    }
    final IBeanKey parentBeanKey = getParentBeanKey(parentBeanKeys);
    ReadCacheEntry readCacheEntry = readCache.get(parentBeanKey);
    if (readCacheEntry == null) {
        readCacheEntry = new ReadCacheEntry(beans);
        readCache.put(parentBeanKey, readCacheEntry);
    } else {
        readCacheEntry.addBeans(beans);
    }
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey)

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