private Map<String, Object> serialiseDocumentAnnotation(final DocumentAnnotation da) { final Map<String, Object> map = new HashMap<>(); map.put(JsonJCas.DA_DOCUMENT_TYPE, da.getDocType()); map.put(JsonJCas.DA_LANGUAGE, da.getLanguage()); map.put(JsonJCas.DA_SOURCE_URI, da.getSourceUri()); map.put(JsonJCas.DA_CLASSIFICATION, da.getDocumentClassification()); final String[] caveats = da.getDocumentCaveats() != null ? da.getDocumentCaveats().toArray() : new String[0]; map.put(JsonJCas.DA_CAVEATS, caveats); final String[] rels = da.getDocumentReleasability() != null ? da.getDocumentReleasability().toArray() : new String[0]; map.put(JsonJCas.DA_RELEASABILITY, rels); return map; }
private void addDocumentAnnotationToProperties( final Map<String, Object> properties, final DocumentAnnotation da) { properties.put(AnalysisConstants.DOCUMENT_TYPE, da.getDocType()); properties.put(AnalysisConstants.CAVEATS, UimaTypesUtils.toList(da.getDocumentCaveats())); properties.put(AnalysisConstants.CLASSIFICATION, da.getDocumentClassification()); properties.put( AnalysisConstants.RELEASABILITY, UimaTypesUtils.toList(da.getDocumentReleasability())); properties.put(AnalysisConstants.LANGUAGE, da.getLanguage()); properties.put(AnalysisConstants.HASH, da.getHash()); properties.put(AnalysisConstants.SOURCE, da.getSourceUri()); properties.put(AnalysisConstants.TIMESTAMP, new Date(da.getTimestamp())); }
/** Create a map containing information from the DocumentAnnotation object */ public static Map<String, Object> createDocumentAnnotationMap(DocumentAnnotation da) { Map<String, Object> map = new HashMap<>(); if (!Strings.isNullOrEmpty(da.getSourceUri())) { map.put("sourceUri", da.getSourceUri()); } map.put("dateAccessed", da.getTimestamp()); if (!Strings.isNullOrEmpty(da.getDocType())) { map.put("docType", da.getDocType()); } if (!Strings.isNullOrEmpty(da.getDocumentClassification())) { map.put("classification", da.getDocumentClassification().toUpperCase()); } if (da.getDocumentCaveats() != null) { String[] caveats = da.getDocumentCaveats().toArray(); if (caveats.length > 0) { map.put("caveats", caveats); } } if (da.getDocumentReleasability() != null) { String[] rels = da.getDocumentReleasability().toArray(); if (rels.length > 0) { map.put("releasability", rels); } } return map; }
if (da.getDocumentReleasability() != null) { String[] rels = da.getDocumentReleasability().toArray(); if (rels.length > 0) { document.put("releasability", rels);
private Integer executeDocInsert(JCas jCas) throws SQLException, BaleenException { DocumentAnnotation da = getDocumentAnnotation(jCas); String documentId = ConsumerUtils.getExternalId(da, contentHashAsId); insertDocStatement.clearParameters(); insertDocStatement.setString(1, documentId); insertDocStatement.setString(2, da.getDocType()); insertDocStatement.setString(3, da.getSourceUri()); insertDocStatement.setString(4, jCas.getDocumentText()); insertDocStatement.setString(5, jCas.getDocumentLanguage()); insertDocStatement.setTimestamp(6, new Timestamp(da.getTimestamp())); insertDocStatement.setString(7, da.getDocumentClassification()); insertDocStatement.setArray( 8, createVarcharArray(postgresResource.getConnection(), da.getDocumentCaveats())); insertDocStatement.setArray( 9, createVarcharArray(postgresResource.getConnection(), da.getDocumentReleasability())); insertDocStatement.executeUpdate(); Integer docKey = getKey(insertDocStatement); if (docKey == null) { throw new BaleenException("No document key returned"); } return docKey; }
variables, FIELD_DOCUMENT_RELEASABILITY, UimaTypesUtils.toList(da.getDocumentReleasability()));
variables, FIELD_DOCUMENT_RELEASABILITY, UimaTypesUtils.toList(da.getDocumentReleasability()));
head, "document.releasability", String.join(",", UimaTypesUtils.toArray(da.getDocumentReleasability())));
private void saveDocument(String documentId, JCas jCas) { Document doc = new Document(); DocumentAnnotation da = getDocumentAnnotation(jCas); doc.append(fields.getExternalId(), documentId) .append( FIELD_DOCUMENT, new Document() .append(FIELD_DOCUMENT_TYPE, da.getDocType()) .append(FIELD_DOCUMENT_SOURCE, da.getSourceUri()) .append(FIELD_DOCUMENT_LANGUAGE, da.getLanguage()) .append(FIELD_DOCUMENT_TIMESTAMP, new Date(da.getTimestamp())) .append(FIELD_DOCUMENT_CLASSIFICATION, da.getDocumentClassification()) .append(FIELD_DOCUMENT_CAVEATS, toList(da.getDocumentCaveats())) .append(FIELD_DOCUMENT_RELEASABILITY, toList(da.getDocumentReleasability()))); addPublishedIds(jCas, doc); addMetadata(jCas, doc); if (outputContent) { doc.append(FIELD_CONTENT, jCas.getDocumentText()); } documentsCollection.insertOne(doc); }
addProperty(vDoc, "classification", da.getDocumentClassification()); addListProperty(vDoc, "caveats", UimaTypesUtils.toList(da.getDocumentCaveats())); addListProperty(vDoc, "releasablity", UimaTypesUtils.toList(da.getDocumentReleasability()));