Search in sources :

Example 1 with FormConfigProcessor

use of com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor in project conquery by bakdata.

the class FormConfigTest method setupTestClass.

@BeforeAll
public void setupTestClass() throws Exception {
    datasetId = dataset.getId();
    datasetId1 = dataset1.getId();
    // Mock DatasetRegistry for translation
    namespacesMock = Mockito.mock(DatasetRegistry.class);
    doAnswer(invocation -> {
        throw new UnsupportedOperationException("Not yet implemented");
    }).when(namespacesMock).getOptional(any());
    doAnswer(invocation -> {
        final DatasetId id = invocation.getArgument(0);
        Namespace namespaceMock = Mockito.mock(Namespace.class);
        if (id.equals(datasetId)) {
            when(namespaceMock.getDataset()).thenReturn(dataset);
        } else if (id.equals(datasetId1)) {
            when(namespaceMock.getDataset()).thenReturn(dataset1);
        } else {
            throw new IllegalStateException("Unkown dataset id.");
        }
        return namespaceMock;
    }).when(namespacesMock).get(any(DatasetId.class));
    when(namespacesMock.getAllDatasets()).thenReturn(List.of(dataset, dataset1));
    when(namespacesMock.injectIntoNew(any(ObjectMapper.class))).thenCallRealMethod();
    when(namespacesMock.inject(any(MutableInjectableValues.class))).thenCallRealMethod();
    storage = new NonPersistentStoreFactory().createMetaStorage();
    ((MutableInjectableValues) FormConfigProcessor.getMAPPER().getInjectableValues()).add(IdResolveContext.class, namespacesMock);
    processor = new FormConfigProcessor(validator, storage, namespacesMock);
    controller = new AuthorizationController(storage, new DevelopmentAuthorizationConfig());
    controller.start();
}
Also used : AuthorizationController(com.bakdata.conquery.models.auth.AuthorizationController) DevelopmentAuthorizationConfig(com.bakdata.conquery.models.config.auth.DevelopmentAuthorizationConfig) FormConfigProcessor(com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) NonPersistentStoreFactory(com.bakdata.conquery.util.NonPersistentStoreFactory) Namespace(com.bakdata.conquery.models.worker.Namespace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with FormConfigProcessor

use of com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor in project conquery by bakdata.

the class ApiV1 method registerResources.

@Override
public void registerResources(ManagerNode manager) {
    DatasetRegistry datasets = manager.getDatasetRegistry();
    JerseyEnvironment environment = manager.getEnvironment().jersey();
    environment.setUrlPattern("/api");
    // inject required services
    environment.register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(manager.getConfig()).to(ConqueryConfig.class);
            bind(manager.getDatasetRegistry()).to(DatasetRegistry.class);
            bind(manager.getStorage()).to(MetaStorage.class);
            bind(new ConceptsProcessor(manager.getDatasetRegistry())).to(ConceptsProcessor.class);
            bind(new MeProcessor(manager.getStorage(), datasets)).to(MeProcessor.class);
            bind(new QueryProcessor(datasets, manager.getStorage(), manager.getConfig())).to(QueryProcessor.class);
            bind(new FormConfigProcessor(manager.getValidator(), manager.getStorage(), datasets)).to(FormConfigProcessor.class);
        }
    });
    environment.register(CORSPreflightRequestFilter.class);
    environment.register(CORSResponseFilter.class);
    environment.register(new ActiveUsersFilter(manager.getStorage(), Duration.ofMinutes(manager.getConfig().getMetricsConfig().getUserActiveDuration().toMinutes())));
    /*
		 * Register the authentication filter which protects all resources registered in this servlet.
		 * We use the same instance of the filter for the api servlet and the admin servlet to have a single
		 * point for authentication.
		 */
    environment.register(manager.getAuthController().getAuthenticationFilter());
    environment.register(QueryResource.class);
    environment.register(IdParamConverter.Provider.INSTANCE);
    environment.register(new ConfigResource(manager.getConfig()));
    environment.register(FormConfigResource.class);
    environment.register(DatasetsResource.class);
    environment.register(ConceptResource.class);
    environment.register(DatasetResource.class);
    environment.register(FilterResource.class);
    environment.register(MeResource.class);
    for (ResultRendererProvider resultProvider : manager.getConfig().getResultProviders()) {
        resultProvider.registerResultResource(environment, manager);
    }
    environment.register(new IdRefPathParamConverterProvider(manager.getDatasetRegistry(), manager.getDatasetRegistry().getMetaRegistry()));
}
Also used : FormConfigProcessor(com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor) AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) ActiveUsersFilter(com.bakdata.conquery.metrics.ActiveUsersFilter) FormConfigResource(com.bakdata.conquery.resources.api.FormConfigResource) ConfigResource(com.bakdata.conquery.resources.api.ConfigResource) JerseyEnvironment(io.dropwizard.jersey.setup.JerseyEnvironment) IdRefPathParamConverterProvider(com.bakdata.conquery.io.jackson.IdRefPathParamConverterProvider) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) ResultRendererProvider(com.bakdata.conquery.io.result.ResultRender.ResultRendererProvider) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) ConceptsProcessor(com.bakdata.conquery.resources.api.ConceptsProcessor)

Aggregations

FormConfigProcessor (com.bakdata.conquery.models.forms.frontendconfiguration.FormConfigProcessor)2 DatasetRegistry (com.bakdata.conquery.models.worker.DatasetRegistry)2 IdRefPathParamConverterProvider (com.bakdata.conquery.io.jackson.IdRefPathParamConverterProvider)1 MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)1 ResultRendererProvider (com.bakdata.conquery.io.result.ResultRender.ResultRendererProvider)1 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)1 ActiveUsersFilter (com.bakdata.conquery.metrics.ActiveUsersFilter)1 AuthorizationController (com.bakdata.conquery.models.auth.AuthorizationController)1 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)1 DevelopmentAuthorizationConfig (com.bakdata.conquery.models.config.auth.DevelopmentAuthorizationConfig)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 Namespace (com.bakdata.conquery.models.worker.Namespace)1 ConceptsProcessor (com.bakdata.conquery.resources.api.ConceptsProcessor)1 ConfigResource (com.bakdata.conquery.resources.api.ConfigResource)1 FormConfigResource (com.bakdata.conquery.resources.api.FormConfigResource)1 NonPersistentStoreFactory (com.bakdata.conquery.util.NonPersistentStoreFactory)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JerseyEnvironment (io.dropwizard.jersey.setup.JerseyEnvironment)1 AbstractBinder (org.glassfish.hk2.utilities.binding.AbstractBinder)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1