Search in sources :

Example 1 with LoadContext

use of io.jmix.core.LoadContext in project jmix by jmix-framework.

the class SingleValueOwningPropertyHolder method loadValue.

protected Object loadValue() {
    MetaClass metaClass = getMetadata().getClass(getPropertyInfo().getJavaType());
    LoadOptions loadOptions = getLoadOptions();
    LoadContext<?> loadContext = new LoadContext<>(metaClass).setId(getEntityId()).setHint(PersistenceHints.SOFT_DELETION, false).setHints(loadOptions.getHints()).setAccessConstraints(loadOptions.getAccessConstraints());
    Object value = getDataManager().load(loadContext);
    if (value == null) {
        getSecurityState(getOwner()).addErasedId(getPropertyInfo().getName(), getEntityId());
    }
    return value;
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) LoadContext(io.jmix.core.LoadContext)

Example 2 with LoadContext

use of io.jmix.core.LoadContext in project jmix by jmix-framework.

the class ListPrintFormAction method printAll.

protected void printAll() {
    ContainerDataUnit unit = (ContainerDataUnit) target.getItems();
    CollectionContainer container = unit.getContainer();
    if (container instanceof CollectionPropertyContainer) {
        // as CollectionPropertyContainer does not have loader it always fetches all records,
        // so print these records as selected
        printSelected(new HashSet(container.getMutableItems()));
        return;
    }
    CollectionLoader loader = (CollectionLoader) ((HasLoader) unit.getContainer()).getLoader();
    MetaClass metaClass = container.getEntityMetaClass();
    LoadContext loadContext = loader.createLoadContext();
    ParameterPrototype parameterPrototype = new ParameterPrototype(metaClass.getName());
    parameterPrototype.setMetaClassName(metaClass.getName());
    LoadContext.Query query = loadContext.getQuery();
    parameterPrototype.setQueryString(query.getQueryString());
    parameterPrototype.setQueryParams(query.getParameters());
    parameterPrototype.setCondition(query.getCondition());
    parameterPrototype.setSort(query.getSort());
    if (!Strings.isNullOrEmpty(loadContext.getFetchPlan().getName())) {
        parameterPrototype.setFetchPlanName(loadContext.getFetchPlan().getName());
    } else {
        parameterPrototype.setFetchPlan(loadContext.getFetchPlan());
    }
    Window window = ComponentsHelper.getWindowNN(target);
    openRunReportScreen(window.getFrameOwner(), parameterPrototype, metaClass);
}
Also used : Window(io.jmix.ui.component.Window) ParameterPrototype(io.jmix.reports.app.ParameterPrototype) MetaClass(io.jmix.core.metamodel.model.MetaClass) LoadContext(io.jmix.core.LoadContext) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) HashSet(java.util.HashSet)

Aggregations

LoadContext (io.jmix.core.LoadContext)2 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 ParameterPrototype (io.jmix.reports.app.ParameterPrototype)1 Window (io.jmix.ui.component.Window)1 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)1 HashSet (java.util.HashSet)1