use of org.wikidata.wdtk.datamodel.interfaces.StatementGroup in project OpenRefine by OpenRefine.
the class ConstraintFetcher method getConstraintStatements.
/**
* Gets all the constraint statements for a given property
*
* @param pid
* the id of the property to retrieve the constraints for
* @return the list of constraint statements
*/
private List<Statement> getConstraintStatements(PropertyIdValue pid) {
PropertyDocument doc = (PropertyDocument) entityCache.get(pid);
StatementGroup group = doc.findStatementGroup(wikibaseConstraintPid);
if (group != null) {
return group.getStatements().stream().filter(s -> s.getValue() != null && s.getValue() instanceof EntityIdValue).collect(Collectors.toList());
} else {
return Collections.emptyList();
}
}
use of org.wikidata.wdtk.datamodel.interfaces.StatementGroup 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();
}
Aggregations