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


Java StatementBuilder类代码示例

本文整理汇总了Java中org.wikidata.wdtk.datamodel.helpers.StatementBuilder的典型用法代码示例。如果您正苦于以下问题:Java StatementBuilder类的具体用法?Java StatementBuilder怎么用?Java StatementBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StatementBuilder类属于org.wikidata.wdtk.datamodel.helpers包,在下文中一共展示了StatementBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNoMergeDiffMainSnak

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testNoMergeDiffMainSnak() {
	Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withId("ID-s1").build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q2).build();

	ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1)
			.withStatement(s1).build();

	StatementUpdate su = new StatementUpdate(currentDocument,
			Arrays.asList(s2), Collections.<Statement> emptyList());

	assertEquals(0, su.toDelete.size());
	assertEquals(1, su.toKeep.size());
	assertTrue(su.toKeep.containsKey(P1));
	assertEquals(2, su.toKeep.get(P1).size());
	assertEquals(s2, su.toKeep.get(P1).get(0).statement);
	assertTrue(su.toKeep.get(P1).get(0).write);
	assertEquals(s1, su.toKeep.get(P1).get(1).statement);
	assertFalse(su.toKeep.get(P1).get(1).write);
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:23,代码来源:StatementUpdateTest.java

示例2: testNoMergeDiffQualifier

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testNoMergeDiffQualifier() {
	Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withQualifierValue(P3, Q2).withId("ID-s1")
			.build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withQualifierValue(P3, Q3).build();

	ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1)
			.withStatement(s1).build();

	StatementUpdate su = new StatementUpdate(currentDocument,
			Arrays.asList(s2), Collections.<Statement> emptyList());

	assertEquals(0, su.toDelete.size());
	assertEquals(1, su.toKeep.size());
	assertTrue(su.toKeep.containsKey(P1));
	assertEquals(2, su.toKeep.get(P1).size());
	assertEquals(s2, su.toKeep.get(P1).get(0).statement);
	assertTrue(su.toKeep.get(P1).get(0).write);
	assertEquals(s1, su.toKeep.get(P1).get(1).statement);
	assertFalse(su.toKeep.get(P1).get(1).write);
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:24,代码来源:StatementUpdateTest.java

示例3: testNoMergeRankConflict

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testNoMergeRankConflict() {
	Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withRank(StatementRank.PREFERRED)
			.withId("ID-s1").build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withRank(StatementRank.DEPRECATED).build();

	ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1)
			.withStatement(s1).build();

	StatementUpdate su = new StatementUpdate(currentDocument,
			Arrays.asList(s2), Collections.<Statement> emptyList());

	assertEquals(0, su.toDelete.size());
	assertEquals(1, su.toKeep.size());
	assertTrue(su.toKeep.containsKey(P1));
	assertEquals(2, su.toKeep.get(P1).size());
	assertEquals(s2, su.toKeep.get(P1).get(0).statement);
	assertTrue(su.toKeep.get(P1).get(0).write);
	assertEquals(s1, su.toKeep.get(P1).get(1).statement);
	assertFalse(su.toKeep.get(P1).get(1).write);
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:24,代码来源:StatementUpdateTest.java

示例4: testUpdateStatement

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testUpdateStatement() {

	Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withId("ID-s1").build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q2).withId("ID-s1").build();

	ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1)
			.withStatement(s1).build();

	StatementUpdate su = new StatementUpdate(currentDocument,
			Arrays.asList(s2), Collections.<Statement> emptyList());

	assertEquals(0, su.toDelete.size());
	assertEquals(1, su.toKeep.size());
	assertTrue(su.toKeep.containsKey(P1));
	assertEquals(1, su.toKeep.get(P1).size());
	assertEquals(s2, su.toKeep.get(P1).get(0).statement);
	assertTrue(su.toKeep.get(P1).get(0).write);
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:22,代码来源:StatementUpdateTest.java

示例5: testNullEdit

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testNullEdit() {
	Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withId("ID-s1").build();
	Statement s1dup = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1)
			.withValue(Q1).withId("ID-s2").build();
	
	ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1)
			.withStatement(s1).build();
	
	StatementUpdate su = new StatementUpdate(currentDocument,
			Arrays.asList(s1dup), Arrays.asList(s2));
	assertTrue(su.isEmptyEdit());
	
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:StatementUpdateTest.java

示例6: testMergeNew

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testMergeNew() {
	// Additions of duplicates are merged
	Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P3)
			.withValue(Q1).build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P3)
			.withValue(Q1).build();

	ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1)
			.build();

	StatementUpdate su = new StatementUpdate(currentDocument,
			Arrays.asList(s1, s2), Collections.<Statement> emptyList());

	assertEquals(0, su.toDelete.size());
	assertEquals(1, su.toKeep.size());
	assertTrue(su.toKeep.containsKey(P3));
	assertEquals(1, su.toKeep.get(P3).size());
	assertEquals(s1, su.toKeep.get(P3).get(0).statement);
	assertTrue(su.toKeep.get(P3).get(0).write);
	assertFalse(su.isEmptyEdit());
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:23,代码来源:StatementUpdateTest.java

示例7: testHasStatementValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testHasStatementValue() {
	Statement s1 = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(q1).build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(q2).build();
	Statement s3 = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withSomeValue().build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s1)
			.withStatement(s2).withStatement(s3).build();

	assertTrue(id.hasStatementValue(p1, q2));
	assertTrue(id.hasStatementValue("P1", q2));
	assertTrue(id.hasStatementValue(p1, Sets.newSet(q1, p3)));
	assertFalse(id.hasStatementValue(p1, p3));
	assertFalse(id.hasStatementValue("P2", q2));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:19,代码来源:StatementDocumentAccessTest.java

示例8: testFindValueSnaks

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testFindValueSnaks() {
	Statement s1 = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(q1).build();
	Statement s2 = StatementBuilder.forSubjectAndProperty(q1, p2)
			.withSomeValue().build();
	Statement s3 = StatementBuilder.forSubjectAndProperty(q1, p3)
			.withNoValue().build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s1)
			.withStatement(s2).withStatement(s3).build();

	assertEquals(s1, id.findStatement(p1));
	assertEquals(s1, id.findStatement("P1"));
	assertEquals(s2, id.findStatement(p2));
	assertEquals(s2, id.findStatement("P2"));
	assertEquals(s3, id.findStatement(p3));
	assertEquals(s3, id.findStatement("P3"));

	assertEquals(q1, id.findStatementValue(p1));
	assertEquals(null, id.findStatementValue(p2));
	assertEquals(null, id.findStatementValue(p3));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:24,代码来源:StatementDocumentAccessTest.java

示例9: testFindStatementItemIdValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testFindStatementItemIdValue() {
	Statement s = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(q1).build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s)
			.build();

	assertEquals(q1, id.findStatementValue(p1));
	assertEquals(q1, id.findStatementValue("P1"));
	assertEquals(q1, id.findStatementEntityIdValue(p1));
	assertEquals(q1, id.findStatementEntityIdValue("P1"));
	assertEquals(q1, id.findStatementItemIdValue(p1));
	assertEquals(q1, id.findStatementItemIdValue("P1"));
	assertEquals(null, id.findStatementPropertyIdValue(p1));
	assertEquals(null, id.findStatementPropertyIdValue("P1"));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:StatementDocumentAccessTest.java

示例10: testFindStatementPropertyIdValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testFindStatementPropertyIdValue() {
	Statement s = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(p2).build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s)
			.build();

	assertEquals(p2, id.findStatementValue(p1));
	assertEquals(p2, id.findStatementValue("P1"));
	assertEquals(p2, id.findStatementEntityIdValue(p1));
	assertEquals(p2, id.findStatementEntityIdValue("P1"));
	assertEquals(p2, id.findStatementPropertyIdValue(p1));
	assertEquals(p2, id.findStatementPropertyIdValue("P1"));
	assertEquals(null, id.findStatementItemIdValue(p1));
	assertEquals(null, id.findStatementItemIdValue("P1"));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:StatementDocumentAccessTest.java

示例11: testFindStatementTimeValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testFindStatementTimeValue() {
	TimeValue v = Datamodel.makeTimeValue((byte) 2015, (byte) 10,
			(byte) 16, (byte) 16, (byte) 51, (byte) 23,
			TimeValue.PREC_SECOND, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);

	Statement s = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(v).build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s)
			.build();

	assertEquals(v, id.findStatementValue(p1));
	assertEquals(v, id.findStatementValue("P1"));
	assertEquals(v, id.findStatementTimeValue(p1));
	assertEquals(v, id.findStatementTimeValue("P1"));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:StatementDocumentAccessTest.java

示例12: testFindStatementGlobeCoordinatesValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testFindStatementGlobeCoordinatesValue() {
	GlobeCoordinatesValue v = Datamodel.makeGlobeCoordinatesValue(1.2, 2.3,
			1, GlobeCoordinatesValue.GLOBE_MOON);

	Statement s = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(v).build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s)
			.build();

	assertEquals(v, id.findStatementValue(p1));
	assertEquals(v, id.findStatementValue("P1"));
	assertEquals(v, id.findStatementGlobeCoordinatesValue(p1));
	assertEquals(v, id.findStatementGlobeCoordinatesValue("P1"));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:17,代码来源:StatementDocumentAccessTest.java

示例13: testFindStatementMonolingualTextValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testFindStatementMonolingualTextValue() {
	MonolingualTextValue v = Datamodel.makeMonolingualTextValue("Test",
			"en");

	Statement s = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(v).build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s)
			.build();

	assertEquals(v, id.findStatementValue(p1));
	assertEquals(v, id.findStatementValue("P1"));
	assertEquals(v, id.findStatementMonolingualTextValue(p1));
	assertEquals(v, id.findStatementMonolingualTextValue("P1"));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:17,代码来源:StatementDocumentAccessTest.java

示例14: testFindStatementDatatypeIdValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testFindStatementDatatypeIdValue() {
	DatatypeIdValue v = Datamodel
			.makeDatatypeIdValue(DatatypeIdValue.DT_STRING);

	Statement s = StatementBuilder.forSubjectAndProperty(q1, p1)
			.withValue(v).build();

	ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s)
			.build();

	assertEquals(v, id.findStatementValue(p1));
	assertEquals(v, id.findStatementValue("P1"));
	assertEquals(v, id.findStatementDatatypeIdValue(p1));
	assertEquals(v, id.findStatementDatatypeIdValue("P1"));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:17,代码来源:StatementDocumentAccessTest.java

示例15: testStatementComplexValue

import org.wikidata.wdtk.datamodel.helpers.StatementBuilder; //导入依赖的package包/类
@Test
public void testStatementComplexValue() throws RDFHandlerException,
		RDFParseException, IOException {
	GlobeCoordinatesValue value = Datamodel.makeGlobeCoordinatesValue(51,
			13, GlobeCoordinatesValue.PREC_DEGREE,
			GlobeCoordinatesValue.GLOBE_EARTH);
	Statement statement = StatementBuilder
			.forSubjectAndProperty(ItemIdValue.NULL, PropertyIdValue.NULL)
			.withValue(value).build();
	this.rdfConverter.writeStatement(statement);
	this.rdfWriter.finish();
	Model model = RdfTestHelpers.parseRdf(this.out.toString());
	assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
			.getResourceFromFile("StatementCplx.rdf")));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:16,代码来源:RdfConverterTest.java


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