Search in sources :

Example 81 with TermedStatementEntityEdit

use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.

the class QuickStatementsExporterTest method testDeleteStatement.

@Test
public void testDeleteStatement() throws IOException {
    TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addStatement(new StatementEdit(TestingData.generateStatement(qid1, qid2), StatementMerger.FORMER_DEFAULT_STRATEGY, StatementEditingMode.DELETE)).build();
    assertEquals("- Q1377\tP38\tQ865528\n", export(update));
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) StatementEdit(org.openrefine.wikidata.updates.StatementEdit) Test(org.testng.annotations.Test) WikidataRefineTest(org.openrefine.wikidata.testing.WikidataRefineTest)

Example 82 with TermedStatementEntityEdit

use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.

the class QuickStatementsExporterTest method testImpossibleScheduling.

@Test
public void testImpossibleScheduling() throws IOException {
    StatementEdit sNewAtoNewB = TestingData.generateStatementAddition(newIdA, newIdB);
    TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(newIdA).addStatement(sNewAtoNewB).build();
    assertEquals(QuickStatementsExporter.impossibleSchedulingErrorMessage, export(update));
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) StatementEdit(org.openrefine.wikidata.updates.StatementEdit) Test(org.testng.annotations.Test) WikidataRefineTest(org.openrefine.wikidata.testing.WikidataRefineTest)

Example 83 with TermedStatementEntityEdit

use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.

the class QuickStatementsExporterTest method testQualifier.

@Test
public void testQualifier() throws IOException {
    Statement baseStatement = TestingData.generateStatement(qid1, qid2);
    Statement otherStatement = TestingData.generateStatement(qid2, qid1);
    Snak qualifierSnak = otherStatement.getClaim().getMainSnak();
    SnakGroup group = Datamodel.makeSnakGroup(Collections.singletonList(qualifierSnak));
    Claim claim = Datamodel.makeClaim(qid1, baseStatement.getClaim().getMainSnak(), Collections.singletonList(group));
    Statement statement = Datamodel.makeStatement(claim, Collections.emptyList(), StatementRank.NORMAL, "");
    StatementEdit statementUpdate = new StatementEdit(statement, StatementMerger.FORMER_DEFAULT_STRATEGY, StatementEditingMode.ADD_OR_MERGE);
    TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addStatement(statementUpdate).build();
    assertEquals("Q1377\tP38\tQ865528\tP38\tQ1377\n", export(update));
}
Also used : Snak(org.wikidata.wdtk.datamodel.interfaces.Snak) TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) SnakGroup(org.wikidata.wdtk.datamodel.interfaces.SnakGroup) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Claim(org.wikidata.wdtk.datamodel.interfaces.Claim) StatementEdit(org.openrefine.wikidata.updates.StatementEdit) Test(org.testng.annotations.Test) WikidataRefineTest(org.openrefine.wikidata.testing.WikidataRefineTest)

Example 84 with TermedStatementEntityEdit

use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.

the class QuickStatementsExporterTest method testReferences.

/**
 * issue #2320
 *
 * A statement with different references should be duplicated, but each with a different reference.
 */
@Test
public void testReferences() throws IOException {
    Statement baseStatement = TestingData.generateStatement(qid1, qid2);
    Statement otherStatement = TestingData.generateStatement(qid2, qid1);
    Snak snak1 = baseStatement.getClaim().getMainSnak();
    Snak snak2 = otherStatement.getClaim().getMainSnak();
    SnakGroup group1 = Datamodel.makeSnakGroup(Collections.singletonList(snak1));
    SnakGroup group2 = Datamodel.makeSnakGroup(Collections.singletonList(snak2));
    Claim claim = Datamodel.makeClaim(qid1, baseStatement.getClaim().getMainSnak(), Collections.singletonList(group2));
    Reference reference1 = Datamodel.makeReference(Collections.singletonList(group1));
    Reference reference2 = Datamodel.makeReference(Collections.singletonList(group2));
    Statement statement = Datamodel.makeStatement(claim, Arrays.asList(reference1, reference2), StatementRank.NORMAL, "");
    StatementEdit statementUpdate = new StatementEdit(statement, StatementMerger.FORMER_DEFAULT_STRATEGY, StatementEditingMode.ADD_OR_MERGE);
    TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addStatement(statementUpdate).build();
    assertEquals("Q1377\tP38\tQ865528\tP38\tQ1377\tS38\tQ865528\n" + "Q1377\tP38\tQ865528\tP38\tQ1377\tS38\tQ1377\n", export(update));
}
Also used : Snak(org.wikidata.wdtk.datamodel.interfaces.Snak) TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) Statement(org.wikidata.wdtk.datamodel.interfaces.Statement) Reference(org.wikidata.wdtk.datamodel.interfaces.Reference) SnakGroup(org.wikidata.wdtk.datamodel.interfaces.SnakGroup) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Claim(org.wikidata.wdtk.datamodel.interfaces.Claim) StatementEdit(org.openrefine.wikidata.updates.StatementEdit) Test(org.testng.annotations.Test) WikidataRefineTest(org.openrefine.wikidata.testing.WikidataRefineTest)

Example 85 with TermedStatementEntityEdit

use of org.openrefine.wikidata.updates.TermedStatementEntityEdit in project OpenRefine by OpenRefine.

the class QuickStatementsExporterTest method testNameDesc.

@Test
public void testNameDesc() throws IOException {
    /**
     * Adding labels and description without overriding is not supported by QS, so we fall back on adding them with
     * overriding.
     */
    TermedStatementEntityEdit update = new TermedStatementEntityEditBuilder(qid1).addLabel(Datamodel.makeMonolingualTextValue("some label", "en"), true).addDescription(Datamodel.makeMonolingualTextValue("some description", "en"), true).build();
    assertEquals("Q1377\tLen\t\"some label\"\n" + "Q1377\tDen\t\"some description\"\n", export(update));
}
Also used : TermedStatementEntityEditBuilder(org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder) TermedStatementEntityEdit(org.openrefine.wikidata.updates.TermedStatementEntityEdit) Test(org.testng.annotations.Test) WikidataRefineTest(org.openrefine.wikidata.testing.WikidataRefineTest)

Aggregations

TermedStatementEntityEdit (org.openrefine.wikidata.updates.TermedStatementEntityEdit)109 TermedStatementEntityEditBuilder (org.openrefine.wikidata.updates.TermedStatementEntityEditBuilder)102 Test (org.testng.annotations.Test)97 ItemIdValue (org.wikidata.wdtk.datamodel.interfaces.ItemIdValue)59 Statement (org.wikidata.wdtk.datamodel.interfaces.Statement)57 ConstraintFetcher (org.openrefine.wikidata.qa.ConstraintFetcher)52 Snak (org.wikidata.wdtk.datamodel.interfaces.Snak)49 StatementImpl (org.wikidata.wdtk.datamodel.implementation.StatementImpl)44 SnakGroup (org.wikidata.wdtk.datamodel.interfaces.SnakGroup)34 ValueSnak (org.wikidata.wdtk.datamodel.interfaces.ValueSnak)18 WikidataRefineTest (org.openrefine.wikidata.testing.WikidataRefineTest)13 ArrayList (java.util.ArrayList)12 StatementEdit (org.openrefine.wikidata.updates.StatementEdit)9 EntityIdValue (org.wikidata.wdtk.datamodel.interfaces.EntityIdValue)6 ReconEntityIdValue (org.openrefine.wikidata.schema.entityvalues.ReconEntityIdValue)5 NoValueSnak (org.wikidata.wdtk.datamodel.interfaces.NoValueSnak)5 PropertyIdValue (org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue)5 IOException (java.io.IOException)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4