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;
}
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)));
}
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());
}
Aggregations