Search in sources :

Example 1 with SimpleDefaultValuesController

use of net.n2oapp.framework.ui.controller.query.SimpleDefaultValuesController in project n2o-framework by i-novus-llc.

the class DefaultValuesControllerTest method testQuery.

private GetDataResponse testQuery(String path, ReadCompileTerminalPipeline<ReadCompileBindTerminalPipeline> pipeline, Map<String, String[]> params) {
    N2oInvocationFactory invocationFactory = Mockito.mock(N2oInvocationFactory.class);
    TestDataProviderEngine testDataProviderEngine = new TestDataProviderEngine();
    testDataProviderEngine.setResourceLoader(new DefaultResourceLoader());
    Mockito.when(invocationFactory.produce(Mockito.any(Class.class))).thenReturn(testDataProviderEngine);
    ContextEngine contextEngine = Mockito.mock(ContextEngine.class);
    UserContext userContext = new UserContext(contextEngine);
    ContextProcessor contextProcessor = new ContextProcessor(userContext);
    N2oQueryProcessor queryProcessor = new N2oQueryProcessor(invocationFactory, new N2oQueryExceptionHandler());
    N2oEnvironment env = new N2oEnvironment();
    env.setContextProcessor(contextProcessor);
    queryProcessor.setEnvironment(env);
    N2oSubModelsProcessor subModelsProcessor = Mockito.mock(N2oSubModelsProcessor.class);
    Mockito.doNothing().when(subModelsProcessor);
    DataProcessingStack dataProcessingStack = Mockito.mock(SpringDataProcessingStack.class);
    SimpleDefaultValuesController valuesController = new SimpleDefaultValuesController(dataProcessingStack, queryProcessor, subModelsProcessor, null, null);
    Map<String, Object> map = new HashMap<>();
    map.put("SimpleDefaultValuesController", valuesController);
    N2oRouter router = new N2oRouter(builder.getEnvironment(), pipeline);
    N2oControllerFactory factory = new N2oControllerFactory(map);
    factory.setEnvironment(builder.getEnvironment());
    DataController controller = new DataController(factory, builder.getEnvironment(), router);
    return controller.getData(path, params, userContext);
}
Also used : N2oInvocationFactory(net.n2oapp.framework.engine.data.N2oInvocationFactory) SpringDataProcessingStack(net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack) DataProcessingStack(net.n2oapp.framework.engine.modules.stack.DataProcessingStack) SimpleDefaultValuesController(net.n2oapp.framework.ui.controller.query.SimpleDefaultValuesController) HashMap(java.util.HashMap) UserContext(net.n2oapp.framework.api.user.UserContext) N2oSubModelsProcessor(net.n2oapp.framework.config.util.N2oSubModelsProcessor) TestDataProviderEngine(net.n2oapp.framework.engine.data.json.TestDataProviderEngine) ContextEngine(net.n2oapp.framework.api.context.ContextEngine) N2oQueryProcessor(net.n2oapp.framework.engine.data.N2oQueryProcessor) N2oEnvironment(net.n2oapp.framework.config.compile.pipeline.N2oEnvironment) N2oRouter(net.n2oapp.framework.config.register.route.N2oRouter) ContextProcessor(net.n2oapp.framework.api.context.ContextProcessor) N2oQueryExceptionHandler(net.n2oapp.framework.engine.data.N2oQueryExceptionHandler) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader)

Example 2 with SimpleDefaultValuesController

use of net.n2oapp.framework.ui.controller.query.SimpleDefaultValuesController in project n2o-framework by i-novus-llc.

the class N2oController method createControllerFactory.

private ControllerFactory createControllerFactory(MetadataEnvironment environment) {
    N2oSubModelsProcessor subModelsProcessor = new N2oSubModelsProcessor(queryProcessor, domainProcessor);
    subModelsProcessor.setEnvironment(environment);
    Map<String, Object> beans = new HashMap<>();
    beans.put("queryController", new QueryController(dataProcessingStack, queryProcessor, subModelsProcessor, messageBuilder, environment));
    beans.put("operationController", new OperationController(dataProcessingStack, operationProcessor, messageBuilder, environment));
    beans.put("copyValuesController", new CopyValuesController(dataProcessingStack, queryProcessor, subModelsProcessor, messageBuilder, environment));
    beans.put("simpleDefaultValuesController", new SimpleDefaultValuesController(dataProcessingStack, queryProcessor, subModelsProcessor, messageBuilder, environment));
    return new N2oControllerFactory(beans);
}
Also used : N2oControllerFactory(net.n2oapp.framework.ui.controller.N2oControllerFactory) CopyValuesController(net.n2oapp.framework.ui.controller.query.CopyValuesController) SimpleDefaultValuesController(net.n2oapp.framework.ui.controller.query.SimpleDefaultValuesController) HashMap(java.util.HashMap) N2oSubModelsProcessor(net.n2oapp.framework.config.util.N2oSubModelsProcessor) QueryController(net.n2oapp.framework.ui.controller.query.QueryController) OperationController(net.n2oapp.framework.ui.controller.action.OperationController)

Aggregations

HashMap (java.util.HashMap)2 N2oSubModelsProcessor (net.n2oapp.framework.config.util.N2oSubModelsProcessor)2 SimpleDefaultValuesController (net.n2oapp.framework.ui.controller.query.SimpleDefaultValuesController)2 ContextEngine (net.n2oapp.framework.api.context.ContextEngine)1 ContextProcessor (net.n2oapp.framework.api.context.ContextProcessor)1 UserContext (net.n2oapp.framework.api.user.UserContext)1 N2oEnvironment (net.n2oapp.framework.config.compile.pipeline.N2oEnvironment)1 N2oRouter (net.n2oapp.framework.config.register.route.N2oRouter)1 N2oInvocationFactory (net.n2oapp.framework.engine.data.N2oInvocationFactory)1 N2oQueryExceptionHandler (net.n2oapp.framework.engine.data.N2oQueryExceptionHandler)1 N2oQueryProcessor (net.n2oapp.framework.engine.data.N2oQueryProcessor)1 TestDataProviderEngine (net.n2oapp.framework.engine.data.json.TestDataProviderEngine)1 DataProcessingStack (net.n2oapp.framework.engine.modules.stack.DataProcessingStack)1 SpringDataProcessingStack (net.n2oapp.framework.engine.modules.stack.SpringDataProcessingStack)1 N2oControllerFactory (net.n2oapp.framework.ui.controller.N2oControllerFactory)1 OperationController (net.n2oapp.framework.ui.controller.action.OperationController)1 CopyValuesController (net.n2oapp.framework.ui.controller.query.CopyValuesController)1 QueryController (net.n2oapp.framework.ui.controller.query.QueryController)1 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)1