Search in sources :

Example 1 with StatementUpdateBuilder

use of org.wikidata.wdtk.datamodel.helpers.StatementUpdateBuilder in project OpenRefine by OpenRefine.

the class TermedStatementEntityEdit method toStatementUpdate.

/**
 * Generates the statement update given the current statement groups on the entity.
 * @param currentDocument
 * @return
 */
protected StatementUpdate toStatementUpdate(StatementDocument currentDocument) {
    Map<PropertyIdValue, List<StatementEdit>> groupedEdits = statements.stream().collect(Collectors.groupingBy(StatementEdit::getPropertyId));
    StatementUpdateBuilder builder = StatementUpdateBuilder.create(currentDocument.getEntityId());
    for (Entry<PropertyIdValue, List<StatementEdit>> entry : groupedEdits.entrySet()) {
        StatementGroupEdit statementGroupEdit = new StatementGroupEdit(entry.getValue());
        StatementGroup statementGroup = currentDocument.findStatementGroup(entry.getKey().getId());
        statementGroupEdit.contributeToStatementUpdate(builder, statementGroup);
    }
    return builder.build();
}
Also used : PropertyIdValue(org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue) StatementGroup(org.wikidata.wdtk.datamodel.interfaces.StatementGroup) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) StatementUpdateBuilder(org.wikidata.wdtk.datamodel.helpers.StatementUpdateBuilder)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 StatementUpdateBuilder (org.wikidata.wdtk.datamodel.helpers.StatementUpdateBuilder)1 PropertyIdValue (org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue)1 StatementGroup (org.wikidata.wdtk.datamodel.interfaces.StatementGroup)1