本文整理汇总了Java中org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument类的典型用法代码示例。如果您正苦于以下问题:Java JacksonItemDocument类的具体用法?Java JacksonItemDocument怎么用?Java JacksonItemDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JacksonItemDocument类属于org.wikidata.wdtk.datamodel.json.jackson包,在下文中一共展示了JacksonItemDocument类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNewJacksonItemDocument
import org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument; //导入依赖的package包/类
private static JacksonItemDocument getNewJacksonItemDocument(
OldJacksonItemDocument oldItemDocument) {
JacksonItemDocument result = new JacksonItemDocument();
result.setJsonId(oldItemDocument.getEntity().getId());
Map<String, JacksonMonolingualTextValue> labels = getNewLabels(oldItemDocument.getLabels());
Map<String, JacksonMonolingualTextValue> descriptions = getNewDescriptions(oldItemDocument.getDescriptions());
Map<String, List<JacksonMonolingualTextValue>> aliases = getNewAliases(oldItemDocument.getAliases());
Map<String, List<JacksonStatement>> claims = getNewStatements(oldItemDocument.getClaims());
Map<String, JacksonSiteLink> sitelinks = getNewSiteLinks(oldItemDocument.getSiteLinks());
result.setLabels(labels);
result.setDescriptions(descriptions);
result.setAliases(aliases);
result.setJsonClaims(claims);
result.setSiteLinks(sitelinks);
return result;
}
示例2: testWDTKParsing
import org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument; //导入依赖的package包/类
private void testWDTKParsing(String filename) throws IOException {
String jsonString = readFile(filename, StandardCharsets.UTF_8);
SimpleModule module = new SimpleModule();
module.setDeserializerModifier(new MapDeserializerModifier());
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(module);
// JsonNode root = mapper.readTree(jsonString);
// mapper.readValue(mapper.treeAsTokens(root), JacksonItemDocument.class);
JacksonItemDocument itemDocument =
mapper.readValue(jsonString, JacksonItemDocument.class);
itemDocument.setSiteIri(Datamodel.SITE_WIKIDATA);
itemDocument.toString(); // raises an exception if information is missing
}
示例3: normalizeFormat
import org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument; //导入依赖的package包/类
public static JacksonItemDocument normalizeFormat(
OldJacksonItemDocument oldDocument)
throws JsonParseException, JsonMappingException, IOException {
JacksonItemDocument newDocument = getNewJacksonItemDocument(oldDocument);
return newDocument;
}
示例4: testNormalizedJsonParsing2
import org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument; //导入依赖的package包/类
@Test
public void testNormalizedJsonParsing2() throws IOException {
String jsonString =
readFile("src/test/resources/oldJson02.json", StandardCharsets.UTF_8);
ObjectMapper mapper = new ObjectMapper();
OldJacksonItemDocument oldDoc =
mapper.readValue(jsonString, OldJacksonItemDocument.class);
Assert.assertNotNull(oldDoc.getLabels());
Assert.assertNotNull(oldDoc.getDescriptions());
Assert.assertNotNull(oldDoc.getAliases());
Assert.assertNotNull(oldDoc.getClaims());
Assert.assertNotNull(oldDoc.getSiteLinks());
JacksonItemDocument doc = JsonNormalizer.normalizeFormat(oldDoc);
Assert.assertNotNull(doc.getLabels());
Assert.assertNotNull(doc.getDescriptions());
Assert.assertNotNull(doc.getAliases());
Assert.assertNotNull(doc.getJsonClaims());
Assert.assertNotNull(doc.getSiteLinks());
JsonNode node = mapper.valueToTree(doc);
mapper.readValue(mapper.treeAsTokens(node), JacksonItemDocument.class);
}
示例5: testOldFormatParsing
import org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument; //导入依赖的package包/类
private void testOldFormatParsing(String filename) throws IOException {
String jsonString = readFile(filename, StandardCharsets.UTF_8);
ObjectMapper mapper = new ObjectMapper();
OldJacksonItemDocument oldDoc =
mapper.readValue(jsonString, OldJacksonItemDocument.class);
JacksonItemDocument itemDocument = JsonNormalizer.normalizeFormat(oldDoc);
JsonNode node = mapper.valueToTree(itemDocument);
mapper.readValue(mapper.treeAsTokens(node), JacksonItemDocument.class);
itemDocument.setSiteIri(Datamodel.SITE_WIKIDATA);
itemDocument.toString(); // raises an exception if information is missing
}
示例6: handleDocument
import org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument; //导入依赖的package包/类
/**
* Handles a {@link JacksonTermedStatementDocument} that was retrieved by
* parsing the JSON input. It will call appropriate processing methods
* depending on the type of document.
*
* @param document
* the document to process
*/
private void handleDocument(JacksonTermedStatementDocument document) {
document.setSiteIri(siteIri);
if (document instanceof JacksonItemDocument) {
this.entityDocumentProcessor
.processItemDocument((JacksonItemDocument) document);
} else if (document instanceof JacksonPropertyDocument) {
this.entityDocumentProcessor
.processPropertyDocument((JacksonPropertyDocument) document);
}
}