private Optional<org.wikidata.wdtk.datamodel.interfaces.Statement> processGDMStatement( final Statement statement) { final Predicate gdmPredicate = statement.getPredicate(); final Node gdmObject = statement.getObject(); final String propertyValueDataType; final NodeType gdmObjectType = gdmObject.getType(); propertyValueDataType = determineWikidataPropertyValueDataType(gdmPredicate, gdmObjectType); final PropertyIdValue wikidataProperty = processGDMPredicate(gdmPredicate, propertyValueDataType); final Optional<Value> optionalWikidataValue = processGDMObject(gdmObject); if (!optionalWikidataValue.isPresent()) { return Optional.empty(); } final Value wikidataValue = optionalWikidataValue.get(); // create property value pair final ValueSnak snak = Datamodel.makeValueSnak(wikidataProperty, wikidataValue); // process qualified attributes at GDM statement final Optional<List<Snak>> wikidataQualifiers = processGDMQualifiedAttributes(statement); final List<SnakGroup> snakGroups = new ArrayList<>(); if (wikidataQualifiers.isPresent()) { final SnakGroup snakGroup = Datamodel.makeSnakGroup(wikidataQualifiers.get()); snakGroups.add(snakGroup); } final Claim claim = Datamodel.makeClaim(null, snak, snakGroups); final List<Reference> references = new ArrayList<>(); final StatementRank rank = StatementRank.NORMAL; // note: empty string for statement id (this should be utilised for statements that are created) // note: Statement references cannot be null // note: Statement rank cannot be null return Optional.ofNullable(Datamodel.makeStatement(claim, references, rank, "")); }
private static String printGDMStatement(final Statement statement) { final StringBuilder sb = new StringBuilder(); final Long id = statement.getId(); sb.append("{statement: id ='"); if (id != null) { sb.append(id); } else { sb.append("no statement id available"); } sb.append("' :: "); final String uuid = statement.getUUID(); sb.append("uuid = '"); if (uuid != null) { sb.append(uuid); } else { sb.append("no uuid available"); } sb.append("' :: "); final String subject = printGDMNode(statement.getSubject()); sb.append("subject = '").append(subject).append("' :: "); final String predicateURI = statement.getPredicate().getUri(); sb.append("predicate = '").append(predicateURI).append("' :: "); final String object = printGDMNode(statement.getObject()); sb.append("object = '").append(object).append("'}"); return sb.toString(); }