当前位置: 首页>>代码示例>>Java>>正文


Java JacksonItemDocument类代码示例

本文整理汇总了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;
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:22,代码来源:JsonNormalizer.java

示例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
	}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:18,代码来源:JsonNormalizerTest.java

示例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;
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:9,代码来源:JsonNormalizer.java

示例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);
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:28,代码来源:JsonNormalizerTest.java

示例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
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:16,代码来源:JsonNormalizerTest.java

示例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);
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:19,代码来源:JsonDumpFileProcessor.java


注:本文中的org.wikidata.wdtk.datamodel.json.jackson.JacksonItemDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。