use of org.openrefine.wikidata.schema.WbReferenceExpr in project OpenRefine by OpenRefine.
the class SchemaPropertyExtractor method getAllProperties.
public Set<PropertyIdValue> getAllProperties(WikibaseSchema schema) {
Set<PropertyIdValue> properties = new HashSet<>();
List<WbEntityDocumentExpr> entityDocumentExprs = schema.getEntityDocumentExpressions();
for (WbEntityDocumentExpr entityDocumentExpr : entityDocumentExprs) {
List<WbStatementGroupExpr> statementGroups = entityDocumentExpr.getStatementGroups();
for (WbStatementGroupExpr statementGroup : statementGroups) {
WbExpression<? extends PropertyIdValue> statementGroupProperty = statementGroup.getProperty();
if (statementGroupProperty instanceof WbPropConstant) {
properties.add(Datamodel.makeWikidataPropertyIdValue(((WbPropConstant) statementGroupProperty).getPid()));
}
List<WbStatementExpr> statementExprs = statementGroup.getStatements();
for (WbStatementExpr statementExpr : statementExprs) {
List<WbSnakExpr> snakExprs = new ArrayList<>(statementExpr.getQualifiers());
List<WbReferenceExpr> referenceExprs = statementExpr.getReferences();
for (WbReferenceExpr referenceExpr : referenceExprs) {
snakExprs.addAll(referenceExpr.getSnaks());
}
for (WbSnakExpr snakExpr : snakExprs) {
WbExpression<? extends PropertyIdValue> qualifierProperty = snakExpr.getProp();
if (qualifierProperty instanceof WbPropConstant) {
properties.add(Datamodel.makeWikidataPropertyIdValue(((WbPropConstant) qualifierProperty).getPid()));
}
}
}
}
}
return properties;
}
Aggregations