Search in sources :

Example 1 with Dom4jTools

use of com.haulmont.cuba.core.sys.xmlparsing.Dom4jTools in project cuba by cuba-platform.

the class FakeFilterSupport method createFakeFilter.

public Filter createFakeFilter() {
    if (filter != null) {
        return filter;
    }
    Filter fakeFilter = AppBeans.get(ComponentsFactory.NAME, ComponentsFactory.class).createComponent(Filter.class);
    Dom4jTools dom4JTools = AppBeans.get(Dom4jTools.NAME);
    ((HasXmlDescriptor) fakeFilter).setXmlDescriptor(dom4JTools.readDocument("<filter/>").getRootElement());
    CollectionDatasourceImpl fakeDatasource = new CollectionDatasourceImpl();
    LegacyFrame legacyFrame = (LegacyFrame) this.frameOwner;
    DsContextImpl fakeDsContext = new DsContextImpl(legacyFrame.getDsContext().getDataSupplier());
    FrameContextImpl fakeFrameContext = new FrameContextImpl((Frame) legacyFrame);
    fakeDsContext.setFrameContext(fakeFrameContext);
    fakeDatasource.setDsContext(fakeDsContext);
    // Attention: this query should match the logic in com.haulmont.reports.wizard.ReportingWizardBean.createJpqlDataSet()
    fakeDatasource.setQuery("select queryEntity from " + metaClass.getName() + " queryEntity");
    fakeDatasource.setMetaClass(metaClass);
    fakeFilter.setDatasource(fakeDatasource);
    fakeFilter.setFrame(UiControllerUtils.getFrame(frameOwner));
    return fakeFilter;
}
Also used : ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) Dom4jTools(com.haulmont.cuba.core.sys.xmlparsing.Dom4jTools) Filter(com.haulmont.cuba.gui.components.Filter) HasXmlDescriptor(com.haulmont.cuba.gui.components.Component.HasXmlDescriptor) FrameContextImpl(com.haulmont.cuba.gui.sys.FrameContextImpl) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) CollectionDatasourceImpl(com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl) DsContextImpl(com.haulmont.cuba.gui.data.impl.DsContextImpl)

Example 2 with Dom4jTools

use of com.haulmont.cuba.core.sys.xmlparsing.Dom4jTools in project cuba by cuba-platform.

the class XmlInheritanceTest method setUp.

@BeforeEach
public void setUp() {
    addEntityPackage("com.haulmont.cuba");
    setupInfrastructure();
    resources = new ResourcesImpl(getClass().getClassLoader());
    screenXmlParser = new ScreenXmlParser() {

        {
            dom4JTools = new Dom4jTools(AppBeans.get(GlobalConfig.class), new Dom4jToolsConfig() {

                @Override
                public int getMaxPoolSize() {
                    return 10;
                }

                @Override
                public long getMaxBorrowWaitMillis() {
                    return 10000;
                }
            });
        }
    };
    beanLocator = new BeanLocatorImpl() {

        @Override
        public <T> T getPrototype(String name, Object... args) {
            if (XmlInheritanceProcessor.NAME.equals(name)) {
                XmlInheritanceProcessor processor = new XmlInheritanceProcessor((Document) args[0], (Map) args[1]) {

                    {
                        resources = XmlInheritanceTest.this.resources;
                        screenXmlParser = XmlInheritanceTest.this.screenXmlParser;
                        beanLocator = XmlInheritanceTest.this.beanLocator;
                    }
                };
                return (T) processor;
            }
            return super.getPrototype(name, args);
        }
    };
}
Also used : Dom4jTools(com.haulmont.cuba.core.sys.xmlparsing.Dom4jTools) ResourcesImpl(com.haulmont.cuba.core.sys.ResourcesImpl) Document(org.dom4j.Document) ScreenXmlParser(com.haulmont.cuba.gui.xml.layout.ScreenXmlParser) Collections.emptyMap(java.util.Collections.emptyMap) Map(java.util.Map) Dom4jToolsConfig(com.haulmont.cuba.core.sys.xmlparsing.Dom4jToolsConfig) BeanLocatorImpl(com.haulmont.cuba.core.sys.BeanLocatorImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Dom4jTools (com.haulmont.cuba.core.sys.xmlparsing.Dom4jTools)2 BeanLocatorImpl (com.haulmont.cuba.core.sys.BeanLocatorImpl)1 ResourcesImpl (com.haulmont.cuba.core.sys.ResourcesImpl)1 Dom4jToolsConfig (com.haulmont.cuba.core.sys.xmlparsing.Dom4jToolsConfig)1 HasXmlDescriptor (com.haulmont.cuba.gui.components.Component.HasXmlDescriptor)1 Filter (com.haulmont.cuba.gui.components.Filter)1 CollectionDatasourceImpl (com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl)1 DsContextImpl (com.haulmont.cuba.gui.data.impl.DsContextImpl)1 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)1 FrameContextImpl (com.haulmont.cuba.gui.sys.FrameContextImpl)1 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)1 ScreenXmlParser (com.haulmont.cuba.gui.xml.layout.ScreenXmlParser)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Map (java.util.Map)1 Document (org.dom4j.Document)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1