Search in sources :

Example 6 with IBeanKey

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

the class BeanTabFolderModelImpl 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 7 with IBeanKey

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

the class BeanKeyFactoryImpl method createKeysFromDtos.

@Override
public List<IBeanKey> createKeysFromDtos(final Collection<? extends IBeanDto> beanDtos) {
    Assert.paramNotNull(beanDtos, "beanDtos");
    final List<IBeanKey> result = new LinkedList<IBeanKey>();
    for (final IBeanDto dto : beanDtos) {
        result.add(createKeyFromDto(dto));
    }
    return result;
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) LinkedList(java.util.LinkedList)

Example 8 with IBeanKey

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

the class UniqueConstraintCheckerImpl method checkCreation.

@Override
public void checkCreation(final Collection<? extends IBeanData> beansData, final IExecutionCallback executionCallback) {
    final IFilter filter = createFilter(beansData);
    final SyncResultCallback<Integer> resultCallback = new SyncResultCallback<Integer>();
    final List<IBeanKey> parentBeanKeys = Collections.emptyList();
    this.readerService.count(resultCallback, parentBeanKeys, filter, null, executionCallback);
    final Integer result = resultCallback.getResultSynchronious();
    if (result != null && result.intValue() > 0) {
        throw new UniqueConstraintViolationException(propertyNames);
    }
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IFilter(org.jowidgets.cap.common.api.filter.IFilter) SyncResultCallback(org.jowidgets.cap.common.tools.execution.SyncResultCallback) UniqueConstraintViolationException(org.jowidgets.cap.common.api.exception.UniqueConstraintViolationException)

Example 9 with IBeanKey

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

the class SyncExecutorServiceImpl method checkBeans.

private void checkBeans(final Collection<? extends IBeanKey> keys, final List<BEAN_TYPE> beans, final IExecutionCallback executionCallback) {
    // put beans into map to access them faster at the next step
    final Map<Object, BEAN_TYPE> beanMap = new HashMap<Object, BEAN_TYPE>();
    for (final BEAN_TYPE bean : beans) {
        beanMap.put(getId(bean), bean);
        CapServiceToolkit.checkCanceled(executionCallback);
    }
    // check if beans are deleted or stale
    for (final IBeanKey key : keys) {
        final BEAN_TYPE bean = beanMap.get(key.getId());
        if (!allowDeletedBeans && bean == null) {
            throw new DeletedBeanException(key.getId());
        } else {
            if (!allowStaleBeans && key.getVersion() != getVersion(bean)) {
                throw new StaleBeanException(key.getId());
            }
        }
        CapServiceToolkit.checkCanceled(executionCallback);
    }
}
Also used : DeletedBeanException(org.jowidgets.cap.common.api.exception.DeletedBeanException) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) HashMap(java.util.HashMap) StaleBeanException(org.jowidgets.cap.common.api.exception.StaleBeanException)

Example 10 with IBeanKey

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

the class LinkDeleterServiceImpl method deleteDirectLinks.

private void deleteDirectLinks(final Collection<? extends ILinkDeletion> linksDeletions, final IExecutionCallback executionCallback) {
    for (final ILinkDeletion linkDeletion : linksDeletions) {
        final IBeanKey destinationKey = linkDeletion.getDestinationKey();
        resetDirectLink(sourceProperties, destinationKey, linkedBeanAccess, executionCallback);
    }
}
Also used : IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) ILinkDeletion(org.jowidgets.cap.common.api.link.ILinkDeletion)

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