當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。