Search in sources :

Example 11 with FilterEntity

use of com.haulmont.cuba.security.entity.FilterEntity in project cuba by cuba-platform.

the class FilterDelegateImpl method saveFilterEntity.

protected void saveFilterEntity() {
    Boolean isDefault = filterEntity.getIsDefault();
    Boolean applyDefault = filterEntity.getApplyDefault();
    if (filterEntity.getFolder() == null) {
        CommitContext ctx = new CommitContext(Collections.singletonList(filterEntity));
        Set<Entity> result = dataService.commit(ctx);
        FilterEntity savedFilterEntity = (FilterEntity) result.iterator().next();
        filterEntities.remove(filterEntity);
        filterEntity = savedFilterEntity;
        filterEntities.add(filterEntity);
        filterEntity.setApplyDefault(applyDefault);
        filterEntity.setIsDefault(isDefault);
    } else {
        filterEntity.getFolder().setName(filterEntity.getName());
        filterEntity.getFolder().setFilterXml(filterEntity.getXml());
        AbstractSearchFolder folder = saveFolder(filterEntity.getFolder());
        filterEntity.setFolder(folder);
    }
    saveInitialFilterState();
    setFilterActionsEnabled();
    updateFilterModifiedIndicator();
}
Also used : FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Entity(com.haulmont.cuba.core.entity.Entity) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity)

Example 12 with FilterEntity

use of com.haulmont.cuba.security.entity.FilterEntity in project cuba by cuba-platform.

the class FilterSelectWindow method fillDatasource.

protected void fillDatasource(String nameFilterText) {
    filterEntitiesDs.clear();
    for (FilterEntity filterEntity : filterEntities) {
        if (passesFilter(filterEntity, nameFilterText)) {
            filterEntitiesDs.includeItem(filterEntity);
        }
    }
    filterEntitiesDs.refresh();
}
Also used : FilterEntity(com.haulmont.cuba.security.entity.FilterEntity)

Example 13 with FilterEntity

use of com.haulmont.cuba.security.entity.FilterEntity in project cuba by cuba-platform.

the class FilteringLookupAction method applyFilter.

protected void applyFilter(Filter filterComponent) {
    Metadata metadata = AppBeans.get(Metadata.class);
    FilterEntity filterEntity = metadata.create(FilterEntity.class);
    filterEntity.setComponentId(ComponentsHelper.getFilterComponentPath(filterComponent));
    filterEntity.setName(messages.getMainMessage("dynamicAttributes.entity.filter"));
    filterEntity.setXml(createFilterXml(filterComponent));
    filterEntity.setUser(userSession.getCurrentOrSubstitutedUser());
    filterComponent.setFilterEntity(filterEntity);
    filterComponent.apply(true);
}
Also used : FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Metadata(com.haulmont.cuba.core.global.Metadata)

Example 14 with FilterEntity

use of com.haulmont.cuba.security.entity.FilterEntity in project cuba by cuba-platform.

the class FoldersBean method openFolder.

@Override
public void openFolder(AbstractSearchFolder folder) {
    if (StringUtils.isBlank(folder.getFilterComponentId())) {
        log.warn("Unable to open folder: componentId is blank");
        return;
    }
    String[] strings = ValuePathHelper.parse(folder.getFilterComponentId());
    String screenId = strings[0];
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
    Map<String, Object> params = new HashMap<>();
    WindowParams.DISABLE_AUTO_REFRESH.set(params, true);
    WindowParams.DISABLE_RESUME_SUSPENDED.set(params, true);
    if (!StringUtils.isBlank(folder.getTabName())) {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getTabName()));
    } else {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getName()));
    }
    WindowParams.FOLDER_ID.set(params, folder.getId());
    com.haulmont.cuba.gui.components.Window window = App.getInstance().getWindowManager().openWindow(windowInfo, OpenType.NEW_TAB, params);
    Filter filterComponent = null;
    if (strings.length > 1) {
        String filterComponentId = StringUtils.join(Arrays.copyOfRange(strings, 1, strings.length), '.');
        filterComponent = (Filter) window.getComponentNN(filterComponentId);
        FilterEntity filterEntity = metadata.create(FilterEntity.class);
        filterEntity.setFolder(folder);
        filterEntity.setComponentId(folder.getFilterComponentId());
        filterEntity.setName(folder.getLocName());
        filterEntity.setXml(folder.getFilterXml());
        filterEntity.setApplyDefault(BooleanUtils.isNotFalse(folder.getApplyDefault()));
        if (folder instanceof SearchFolder) {
            filterEntity.setIsSet(((SearchFolder) folder).getIsSet());
        }
        filterComponent.setFilterEntity(filterEntity);
        filterComponent.switchFilterMode(FilterDelegate.FilterMode.GENERIC_MODE);
    }
    if (filterComponent != null && folder instanceof SearchFolder) {
        final SearchFolder searchFolder = (SearchFolder) folder;
        if (searchFolder.getPresentation() != null) {
            ((com.haulmont.cuba.gui.components.Component.HasPresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentation().getId());
        }
    }
    ((DsContextImplementation) window.getDsContext()).resumeSuspended();
}
Also used : DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) HashMap(java.util.HashMap) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Filter(com.haulmont.cuba.gui.components.Filter)

Example 15 with FilterEntity

use of com.haulmont.cuba.security.entity.FilterEntity in project cuba by cuba-platform.

the class RelatedEntitiesBean method applyFilter.

protected void applyFilter(Filter component, Collection<? extends Entity> selectedParents, RelatedScreenDescriptor descriptor, MetaDataDescriptor metaDataDescriptor) {
    FilterEntity filterEntity = metadata.create(FilterEntity.class);
    filterEntity.setComponentId(ComponentsHelper.getFilterComponentPath(component));
    if (StringUtils.isNotEmpty(descriptor.getFilterCaption())) {
        filterEntity.setName(descriptor.getFilterCaption());
    } else {
        MetaProperty metaProperty = metaDataDescriptor.getMetaProperty();
        filterEntity.setName(messages.getMainMessage("actions.Related.Filter") + " " + messageTools.getPropertyCaption(metaProperty.getDomain(), metaProperty.getName()));
    }
    MetaClass effectiveMetaClass = extendedEntities.getEffectiveMetaClass(metaDataDescriptor.getRelatedMetaClass());
    filterEntity.setXml(getRelatedEntitiesFilterXml(effectiveMetaClass, selectedParents, component, metaDataDescriptor));
    filterEntity.setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
    component.setFilterEntity(filterEntity);
    component.apply(true);
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) MetaProperty(com.haulmont.chile.core.model.MetaProperty)

Aggregations

FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)15 Element (org.dom4j.Element)4 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)3 ConditionsTree (com.haulmont.cuba.gui.components.filter.ConditionsTree)3 MetaClass (com.haulmont.chile.core.model.MetaClass)2 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)2 Entity (com.haulmont.cuba.core.entity.Entity)2 Metadata (com.haulmont.cuba.core.global.Metadata)2 SecurityJpqlGenerator (com.haulmont.cuba.core.global.filter.SecurityJpqlGenerator)2 FakeFilterSupport (com.haulmont.cuba.gui.components.filter.FakeFilterSupport)2 FilterHelper (com.haulmont.cuba.gui.components.filter.FilterHelper)2 FilterParser (com.haulmont.cuba.gui.components.filter.FilterParser)2 FilterEditor (com.haulmont.cuba.gui.components.filter.edit.FilterEditor)2 FilterSelectWindow (com.haulmont.cuba.gui.components.filter.filterselect.FilterSelectWindow)2 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)2 ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)2 StrBuilder (org.apache.commons.lang.text.StrBuilder)2 Node (com.haulmont.bali.datastruct.Node)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 ClientConfig (com.haulmont.cuba.client.ClientConfig)1