output.putAll(createDocumentAnnotationMap(da)); output.put("publishedId", createPublishedIdList(publishedIds)); output.put("metadata", createMetadataMap(metadata));
@Override protected void doProcess(JCas jCas) throws AnalysisEngineProcessException { Map<String, Object> json = SingleDocumentConsumerFormat.formatCas( jCas, fields, contentHashAsId, getMonitor(), getSupport()); String id = (String) json.getOrDefault("externalId", ""); // Persist to ElasticSearch addDocument(id, json); }
@Override protected void writeRecords( JCas jCas, String documentSourceName, Map<String, Collection<ExtractedRecord>> records) throws AnalysisEngineProcessException { Collection<Metadata> metadata = JCasUtil.select(jCas, Metadata.class); Map<String, Object> metadataMap = SingleDocumentConsumerFormat.createMetadataMap(metadata); Map<String, ?> fields = mapFields(records); Map<String, Object> mustacheContext = new HashMap<>(fields); mustacheContext.put("metadata", metadataMap); mustacheContext.put("content", jCas.getDocumentText()); writeRecords(documentSourceName, jCas, records, mustacheContext); }
m.add(m3); Map<String, Object> metadata = SingleDocumentConsumerFormat.createMetadataMap(m);
@Override protected void doProcess(final JCas jCas) throws AnalysisEngineProcessException { Map<String, Object> output = SingleDocumentConsumerFormat.formatCas( jCas, new DefaultFields(), contentHashAsId, getMonitor(), getSupport()); // Persist to ActiveMQ try { String json = MAPPER.writeValueAsString(output); String id = (String) output.getOrDefault("externalId", ""); Message msg = samr.getSession().createTextMessage(json); Destination destination = samr.getSession().createTopic(endpoint); samr.getProducer().send(destination, msg); getMonitor().debug("Document with id {} sent to ActiveMQ", id); } catch (JsonProcessingException e) { getMonitor() .error("Unable to parse object to JSON - document will not be sent to ActiveMQ", e); } catch (final JMSException e) { getMonitor().error("Unable to send document to ActiveMQ", e); } } }
@Override protected void doProcess(final JCas jCas) throws AnalysisEngineProcessException { Map<String, Object> output = SingleDocumentConsumerFormat.formatCas( jCas, new DefaultFields(), contentHashAsId, getMonitor(), getSupport()); // Persist to ActiveMQ try { String json = MAPPER.writeValueAsString(output); String id = (String) output.getOrDefault("externalId", ""); Message msg = samr.getSession().createTextMessage(json); Destination destination = samr.getSession().createTopic(endpoint); samr.getProducer().send(destination, msg); getMonitor().debug("Document with id {} sent to ActiveMQ", id); } catch (JsonProcessingException e) { getMonitor() .error("Unable to parse object to JSON - document will not be sent to ActiveMQ", e); } catch (final JMSException e) { getMonitor().error("Unable to send document to ActiveMQ", e); } } }