Search in sources :

Example 6 with PluginDriver

use of io.openk9.plugin.driver.manager.api.PluginDriver in project openk9 by smclab.

the class EnrichPipelineProcessor method _mapToEnrichProcessorContext.

private ObjectNode _mapToEnrichProcessorContext(Tuple3<DatasourceContext, ObjectNode, PluginDriverDTO> t3) {
    List<String> dependencies = t3.getT1().getEnrichItems().stream().map(EnrichItem::getServiceName).collect(Collectors.toList());
    ObjectNode objectNode = _jsonFactory.createObjectNode();
    objectNode.put("pluginDriver", _jsonFactory.fromObjectToJsonNode(t3.getT3()));
    objectNode.put("dependencies", _jsonFactory.fromObjectToJsonNode(dependencies));
    objectNode.put("datasourceContext", _jsonFactory.fromObjectToJsonNode(t3.getT1()));
    objectNode.put("payload", t3.getT2());
    return objectNode;
}
Also used : ObjectNode(io.openk9.json.api.ObjectNode)

Example 7 with PluginDriver

use of io.openk9.plugin.driver.manager.api.PluginDriver in project openk9 by smclab.

the class PluginDriverDTOServiceImpl method _findDocumentType.

private PluginDriverDTO _findDocumentType(PluginDriver pluginDriver) {
    String name = pluginDriver.getName();
    List<DocumentType> documentTypeList = _documentTypeProvider.getDocumentTypeList(name);
    DocumentType defaultDocumentType = _documentTypeProvider.getDefaultDocumentType(name);
    if (documentTypeList.isEmpty() && defaultDocumentType != null) {
        documentTypeList = List.of(defaultDocumentType);
    } else if (!documentTypeList.isEmpty() && defaultDocumentType == null) {
        defaultDocumentType = documentTypeList.get(0);
    }
    List<DocumentTypeDTO> documentTypeDTOS = documentTypeList.stream().map(documentType -> DocumentTypeDTO.of(documentType.getName(), documentType.getIcon(), _wrapSearchKeywords(documentType))).collect(Collectors.toList());
    return PluginDriverDTO.of(pluginDriver.getDriverServiceName(), pluginDriver.getName(), pluginDriver.schedulerEnabled(), documentTypeDTOS, defaultDocumentType == null ? null : DocumentTypeDTO.of(defaultDocumentType.getName(), defaultDocumentType.getIcon(), _wrapSearchKeywords(defaultDocumentType)));
}
Also used : PluginDriverDTO(io.openk9.plugin.driver.manager.model.PluginDriverDTO) SearchKeyword(io.openk9.plugin.driver.manager.api.SearchKeyword) FieldBoostDTO(io.openk9.plugin.driver.manager.model.FieldBoostDTO) PluginDriverDTOList(io.openk9.plugin.driver.manager.model.PluginDriverDTOList) Collection(java.util.Collection) DocumentTypeDTO(io.openk9.plugin.driver.manager.model.DocumentTypeDTO) PluginDriverDTOService(io.openk9.plugin.driver.manager.api.PluginDriverDTOService) PluginDriverRegistry(io.openk9.plugin.driver.manager.api.PluginDriverRegistry) DocumentType(io.openk9.plugin.driver.manager.api.DocumentType) SearchKeywordDTO(io.openk9.plugin.driver.manager.model.SearchKeywordDTO) Collectors(java.util.stream.Collectors) Component(org.osgi.service.component.annotations.Component) List(java.util.List) Optional(java.util.Optional) PluginDriver(io.openk9.plugin.driver.manager.api.PluginDriver) Reference(org.osgi.service.component.annotations.Reference) DocumentTypeProvider(io.openk9.plugin.driver.manager.api.DocumentTypeProvider) DocumentType(io.openk9.plugin.driver.manager.api.DocumentType) DocumentTypeDTO(io.openk9.plugin.driver.manager.model.DocumentTypeDTO)

Example 8 with PluginDriver

use of io.openk9.plugin.driver.manager.api.PluginDriver in project openk9 by smclab.

the class PluginDriverEndPoints method _invokeDataParser.

private Publisher<Void> _invokeDataParser(HttpServerRequest httpRequest, HttpServerResponse httpResponse) {
    return Mono.defer(() -> Mono.from(ReactorNettyUtils.aggregateBodyAsString(httpRequest)).map(json -> _jsonFactory.fromJson(json, InvokeDataParserDTO.class)).flatMap((invokeDataParserDTO) -> {
        String serviceDriverName = invokeDataParserDTO.getServiceDriverName();
        Optional<PluginDriver> optional = _pluginDriverRegistry.getPluginDriver(serviceDriverName);
        if (optional.isEmpty()) {
            throw new HttpException(404, "No Content. PluginDriver not found for serviceDriverName: " + serviceDriverName);
        } else {
            PluginDriver pluginDriver = optional.get();
            if (pluginDriver.schedulerEnabled()) {
                return Mono.from(pluginDriver.invokeDataParser(invokeDataParserDTO.getDatasource(), invokeDataParserDTO.getFromDate(), invokeDataParserDTO.getToDate()));
            } else {
                throw new HttpException(412, " Precondition Failed. PluginDriver scheduler is disabled for serviceDriverName: " + serviceDriverName);
            }
        }
    }).then());
}
Also used : HttpException(io.openk9.http.exception.HttpException) InvokeDataParserDTO(io.openk9.plugin.driver.manager.model.InvokeDataParserDTO) HttpServerResponse(reactor.netty.http.server.HttpServerResponse) PluginDriverDTO(io.openk9.plugin.driver.manager.model.PluginDriverDTO) SchedulerEnabledDTO(io.openk9.plugin.driver.manager.model.SchedulerEnabledDTO) PluginDriverDTOList(io.openk9.plugin.driver.manager.model.PluginDriverDTOList) Publisher(org.reactivestreams.Publisher) PluginDriverDTOService(io.openk9.plugin.driver.manager.api.PluginDriverDTOService) PluginDriverRegistry(io.openk9.plugin.driver.manager.api.PluginDriverRegistry) Mono(reactor.core.publisher.Mono) HttpResponseWriter(io.openk9.http.util.HttpResponseWriter) JsonFactory(io.openk9.json.api.JsonFactory) HttpServerRequest(reactor.netty.http.server.HttpServerRequest) ReactorNettyUtils(io.openk9.reactor.netty.util.ReactorNettyUtils) Component(org.osgi.service.component.annotations.Component) Optional(java.util.Optional) PluginDriver(io.openk9.plugin.driver.manager.api.PluginDriver) Reference(org.osgi.service.component.annotations.Reference) HttpServerRoutes(reactor.netty.http.server.HttpServerRoutes) RouterHandler(io.openk9.http.web.RouterHandler) PluginDriver(io.openk9.plugin.driver.manager.api.PluginDriver) HttpException(io.openk9.http.exception.HttpException)

Aggregations

PluginDriverDTO (io.openk9.plugin.driver.manager.model.PluginDriverDTO)5 PluginDriver (io.openk9.plugin.driver.manager.api.PluginDriver)3 HttpException (io.openk9.http.exception.HttpException)2 ObjectNode (io.openk9.json.api.ObjectNode)2 Datasource (io.openk9.model.Datasource)2 PluginDriverDTOService (io.openk9.plugin.driver.manager.api.PluginDriverDTOService)2 PluginDriverRegistry (io.openk9.plugin.driver.manager.api.PluginDriverRegistry)2 DocumentTypeDTO (io.openk9.plugin.driver.manager.model.DocumentTypeDTO)2 PluginDriverDTOList (io.openk9.plugin.driver.manager.model.PluginDriverDTOList)2 SearchKeywordDTO (io.openk9.plugin.driver.manager.model.SearchKeywordDTO)2 Collection (java.util.Collection)2 List (java.util.List)2 Optional (java.util.Optional)2 Component (org.osgi.service.component.annotations.Component)2 Reference (org.osgi.service.component.annotations.Reference)2 HttpClient (io.openk9.http.client.HttpClient)1 HttpResponseWriter (io.openk9.http.util.HttpResponseWriter)1 RouterHandler (io.openk9.http.web.RouterHandler)1 JsonFactory (io.openk9.json.api.JsonFactory)1 BasePluginDriver (io.openk9.plugin.driver.manager.api.BasePluginDriver)1