Search in sources :

Example 1 with SimpleEcoMapper

use of owltools.gaf.eco.SimpleEcoMapper in project minerva by geneontology.

the class StartUpTool method startUp.

public static Server startUp(UndoAwareMolecularModelManager models, MinervaStartUpConfig conf, Map<IRI, Set<OWLAnnotation>> ont_annos) throws Exception {
    LOGGER.info("Setup Jetty config.");
    // Configuration: Use an already existing handler instance
    // Configuration: Use custom JSON renderer (GSON)
    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.register(GsonMessageBodyHandler.class);
    resourceConfig.register(RequireJsonpFilter.class);
    resourceConfig.register(SPARQLResultsMessageBodyWriter.class);
    resourceConfig.register(SPARQLGraphMessageBodyWriter.class);
    if (conf.useRequestLogging) {
        resourceConfig.register(LoggingApplicationEventListener.class);
    }
    // resourceConfig.register(AuthorizationRequestFilter.class);
    LOGGER.info("BatchHandler config inference provider: " + conf.reasonerOpt);
    LOGGER.info("BatchHandler config importantRelations: " + conf.importantRelations);
    LOGGER.info("BatchHandler config lookupService: " + conf.lookupService);
    LOGGER.info("BatchHandler config checkLiteralIds: " + conf.checkLiteralIds);
    LOGGER.info("BatchHandler config useRequestLogging: " + conf.useRequestLogging);
    if (conf.golrSeedUrl == null) {
        // default fall back to normal golr URL
        conf.golrSeedUrl = conf.golrUrl;
    }
    LOGGER.info("SeedHandler config golrUrl: " + conf.golrSeedUrl);
    InferenceProviderCreator ipc = createInferenceProviderCreator(conf.reasonerOpt, models, conf.shex);
    JsonOrJsonpBatchHandler batchHandler = new JsonOrJsonpBatchHandler(models, conf.defaultModelState, ipc, conf.importantRelations, conf.lookupService);
    // conf.checkLiteralIds;
    batchHandler.CHECK_LITERAL_IDENTIFIERS = false;
    SimpleEcoMapper ecoMapper = EcoMapperFactory.createSimple();
    // JsonOrJsonpSeedHandler seedHandler = new JsonOrJsonpSeedHandler(models, conf.defaultModelState, conf.golrSeedUrl, ecoMapper );
    // SPARQLHandler sparqlHandler = new SPARQLHandler(models, conf.sparqlEndpointTimeout);
    ModelSearchHandler searchHandler = new ModelSearchHandler(models);
    ModelARTHandler artHandler = new ModelARTHandler(models, ipc);
    LocalDate d = LocalDate.now();
    LocalTime t = LocalTime.now();
    String startup = d.toString() + " " + t.toString();
    StatusHandler statusHandler = new StatusHandler(conf, ont_annos, startup);
    TaxonHandler taxonHandler = new TaxonHandler(models);
    resourceConfig = resourceConfig.registerInstances(batchHandler, searchHandler, artHandler, statusHandler, taxonHandler);
    // setup jetty server port, buffers and context path
    Server server = new Server();
    // create connector with port and custom buffer sizes
    // old jetty
    // SelectChannelConnector connector = new SelectChannelConnector();
    // old jetty - they must be configured somewhere else in new jetty
    // connector.setRequestHeaderSize(conf.requestHeaderSize);
    // connector.setRequestBufferSize(conf.requestBufferSize);
    // new jetty - does not have setRequestBufferSize at all
    // seems to push defaults harder here.
    // to change request header size need to create a new connector and manipulate httpconfiguration
    HttpConfiguration http_config = new HttpConfiguration();
    http_config.setRequestHeaderSize(conf.requestHeaderSize);
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
    connector.setPort(conf.port);
    server.addConnector(connector);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(conf.contextString);
    server.setHandler(context);
    ServletHolder h = new ServletHolder(new ServletContainer(resourceConfig));
    context.addServlet(h, "/*");
    // start jetty server
    LOGGER.info("Start server on port: " + conf.port + " context: " + conf.contextString);
    server.start();
    return server;
}
Also used : LocalTime(java.time.LocalTime) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) InferenceProviderCreator(org.geneontology.minerva.server.inferences.InferenceProviderCreator) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) LocalDate(java.time.LocalDate) ServerConnector(org.eclipse.jetty.server.ServerConnector) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) SimpleEcoMapper(owltools.gaf.eco.SimpleEcoMapper) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Aggregations

LocalDate (java.time.LocalDate)1 LocalTime (java.time.LocalTime)1 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)1 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)1 Server (org.eclipse.jetty.server.Server)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 InferenceProviderCreator (org.geneontology.minerva.server.inferences.InferenceProviderCreator)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)1 SimpleEcoMapper (owltools.gaf.eco.SimpleEcoMapper)1