Search in sources :

Example 11 with IBeanDto

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

the class LinkCreatorServiceImpl method createSyncImpl.

private List<IBeanDto> createSyncImpl(final Collection<? extends ILinkCreation> links, final IExecutionCallback executionCallback) {
    final Set<IBeanDto> result = new LinkedHashSet<IBeanDto>();
    for (final ILinkCreation link : links) {
        CapServiceToolkit.checkCanceled(executionCallback);
        result.addAll(createLinks(link, executionCallback));
    }
    return new LinkedList<IBeanDto>(result);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ILinkCreation(org.jowidgets.cap.common.api.link.ILinkCreation) LinkedList(java.util.LinkedList)

Example 12 with IBeanDto

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

the class LinkCreatorServiceImpl method createDirectLinks.

private List<IBeanDto> createDirectLinks(final ILinkCreation link, final IExecutionCallback executionCallback) {
    final List<IBeanDto> result = new LinkedList<IBeanDto>();
    final List<IBeanDto> sourceBeans = createSourceBeans(link, executionCallback);
    final List<IBeanDto> linkedBeans = createDirectLinkedBeans(sourceBeans, link, executionCallback);
    if (EmptyCheck.isEmpty(linkedBeans)) {
        // no linked beans, so create links from additional properties
        for (final IBeanDto sourceBean : sourceBeans) {
            result.add(createLink(sourceBean, null, link.getAdditionalLinkProperties(), executionCallback));
        }
    } else {
        // direct link with linked beans
        result.addAll(linkedBeans);
    }
    return result;
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) LinkedList(java.util.LinkedList)

Example 13 with IBeanDto

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

the class LinkCreatorServiceImpl method createStandardLinks.

private List<IBeanDto> createStandardLinks(final ILinkCreation link, final IExecutionCallback executionCallback) {
    final List<IBeanDto> result = new LinkedList<IBeanDto>();
    final List<IBeanDto> sourceBeans = createSourceBeans(link, executionCallback);
    final List<IBeanDto> linkedBeans = createLinkedBeans(link, executionCallback);
    for (final IBeanDto sourceBean : sourceBeans) {
        for (final IBeanDto linkedBean : linkedBeans) {
            result.add(createLink(sourceBean, linkedBean, link.getAdditionalLinkProperties(), executionCallback));
        }
    }
    return result;
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) LinkedList(java.util.LinkedList)

Example 14 with IBeanDto

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

the class LinkCreatorServiceImpl method createDirectLinkSourceBeans.

private List<IBeanDto> createDirectLinkSourceBeans(final List<IBeanDto> linkedBeans, final ILinkCreation link, final IExecutionCallback executionCallback) {
    if (linkedBeans.size() == 1) {
        final IBeanDto linkedBean = linkedBeans.iterator().next();
        final List<IBeanDto> result = getBeans(linkedBean, destinationProperties, link.getSourceBeans(), sourceBeanAccess, sourceDtoFactory, executionCallback);
        result.addAll(createInverseDirectLinkBeans(linkedBean, link.getTransientSourceBeans(), sourceCreatorService, executionCallback));
        return result;
    } else {
        throw new IllegalArgumentException("A inverse direct link must have exactly one linked bean!");
    }
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto)

Example 15 with IBeanDto

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

the class AbstractSimpleBeanReader method read.

@Override
public final List<BEAN_TYPE> read(final List<? extends IBeanKey> parentBeans, final IFilter filter, final List<? extends ISort> sortedProperties, final int firstRow, final int maxRows, final PARAM_TYPE parameter, final IExecutionCallback executionCallback) {
    final IFilter decoratedFilter = getDecoratedFilter(filter);
    if (decoratedFilter == null && (sortedProperties == null || sortedProperties.size() == 0)) {
        return getBeans(parentBeans, parameter, firstRow, maxRows, executionCallback);
    } else {
        final List<BEAN_TYPE> beans = getBeans(parentBeans, parameter, firstRow, maxRows, executionCallback);
        ArrayList<IBeanDto> result = createBeanDtos(beans, executionCallback);
        if (decoratedFilter != null) {
            result = CapServiceToolkit.beanDtoCollectionFilter().filter(result, decoratedFilter, executionCallback);
        }
        if (sortedProperties != null && sortedProperties.size() > 0) {
            result = collectionSorter.sort(result, sortedProperties, executionCallback);
        }
        if (result.size() >= firstRow) {
            return createBeansSubList(result, firstRow, Math.min(firstRow + maxRows, result.size()), executionCallback);
        } else {
            return Collections.emptyList();
        }
    }
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IFilter(org.jowidgets.cap.common.api.filter.IFilter)

Aggregations

IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)40 LinkedList (java.util.LinkedList)20 ArrayList (java.util.ArrayList)16 List (java.util.List)12 Test (org.junit.Test)12 IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)8 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)7 IBeanDtosUpdate (org.jowidgets.cap.common.api.bean.IBeanDtosUpdate)5 IExecutorService (org.jowidgets.cap.common.api.service.IExecutorService)5 BeanDtosInsertionUpdate (org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate)5 SyncResultCallback (org.jowidgets.cap.common.tools.execution.SyncResultCallback)5 IBeanData (org.jowidgets.cap.common.api.bean.IBeanData)4 BeanKey (org.jowidgets.cap.common.tools.bean.BeanKey)4 HashMap (java.util.HashMap)3 ISort (org.jowidgets.cap.common.api.sort.ISort)3 AbstractUiResultCallback (org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback)3 TableCellBluePrint (org.jowidgets.tools.model.table.TableCellBluePrint)3 ServiceCanceledException (org.jowidgets.cap.common.api.exception.ServiceCanceledException)2 BeanDtosChangeUpdate (org.jowidgets.cap.common.tools.bean.BeanDtosChangeUpdate)2 IBeanSelectionClipboard (org.jowidgets.cap.ui.api.clipboard.IBeanSelectionClipboard)2