@Override public Statement getStatement(Claim claim, List<Reference> references, StatementRank rank, String statementId) { return getStatement(claim.getSubject(), claim.getMainSnak(), claim.getQualifiers(), references, rank, statementId); }
/** * Checks if two claims are equivalent in the sense that they have the same * main snak and the same qualifiers, but possibly in a different order. * * @param claim1 * @param claim2 * @return true if claims are equivalent */ protected boolean equivalentClaims(Claim claim1, Claim claim2) { return claim1.getMainSnak().equals(claim2.getMainSnak()) && isSameSnakSet(claim1.getAllQualifiers(), claim2.getAllQualifiers()); }
void writeClaim(Resource claimResource, Claim claim) { this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.VALUE); claim.getMainSnak().accept(this.snakRdfConverter); this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.QUALIFIER); for (SnakGroup snakGroup : claim.getQualifiers()) { for (Snak snak : snakGroup.getSnaks()) { snak.accept(this.snakRdfConverter); } } }
if (s.getClaim().getMainSnak() instanceof ValueSnak) { Value value = ((ValueSnak) s.getClaim().getMainSnak()) .getValue(); if (value instanceof StringValue) {
.getStatements().size()); for (Statement s : sg.getStatements()) { for (SnakGroup q : s.getClaim().getQualifiers()) { countPropertyQualifier(usageStatistics, q.getProperty(), q .getSnaks().size());
/** * Get the URI for the given statement. * * @param statement * the statement for which to create a URI * @return the URI */ public static String getStatementUri(Statement statement) { int i = statement.getStatementId().indexOf('$') + 1; return statement.getClaim().getSubject().getIri() + "S" + statement.getStatementId().substring(i); }
void writeSimpleStatements(Resource subject, StatementDocument statementDocument) { for (StatementGroup statementGroup : statementDocument .getStatementGroups()) { for (Statement statement : statementGroup.getStatements()) { if (statement.getClaim().getQualifiers().size() == 0) { this.snakRdfConverter.setSnakContext(subject, PropertyContext.SIMPLE_CLAIM); statement.getClaim().getMainSnak() .accept(this.snakRdfConverter); } } } }
/** * Returns true if the given document should be included in the * serialization. * * @param itemDocument * the document to check * @return true if the document should be serialized */ private boolean includeDocument(ItemDocument itemDocument) { for (StatementGroup sg : itemDocument.getStatementGroups()) { // "P19" is "place of birth" on Wikidata if (!"P19".equals(sg.getProperty().getId())) { continue; } for (Statement s : sg.getStatements()) { if (s.getClaim().getMainSnak() instanceof ValueSnak) { Value v = ((ValueSnak) s.getClaim().getMainSnak()) .getValue(); // "Q1731" is "Dresden" on Wikidata if (v instanceof ItemIdValue && "Q1731".equals(((ItemIdValue) v).getId())) { return true; } } } } return false; } }
.forSubjectAndProperty(itemIdValue, property) .withValue(exactValue).withId(s.getStatementId()) .withQualifiers(s.getClaim().getQualifiers()) .withReferences(s.getReferences()) .withRank(s.getRank()).build();
Statement returnedStatement = preStatement.withSubject(statement.getClaim().getSubject()); long revisionId = getRevisionIdFromResponse(response);
@Override public Statement getStatement(Claim claim, List<Reference> references, StatementRank rank, String statementId) { return getStatement(claim.getSubject(), claim.getMainSnak(), claim.getQualifiers(), references, rank, statementId); }
void writeClaim(Resource claimResource, Claim claim) { // write main snak this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.VALUE); claim.getMainSnak().accept(this.snakRdfConverter); this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.VALUE_SIMPLE); claim.getMainSnak().accept(this.snakRdfConverter); // write qualifier this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.QUALIFIER); for (SnakGroup snakGroup : claim.getQualifiers()) { for (Snak snak : snakGroup) { snak.accept(this.snakRdfConverter); } } this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.QUALIFIER_SIMPLE); for (SnakGroup snakGroup : claim.getQualifiers()) { for (Snak snak : snakGroup) { snak.accept(this.snakRdfConverter); } } }
/** * Checks if two claims are equivalent in the sense that they have the same * main snak and the same qualifiers, but possibly in a different order. * * @param claim1 * @param claim2 * @return true if claims are equivalent */ protected boolean equivalentClaims(Claim claim1, Claim claim2) { return claim1.getMainSnak().equals(claim2.getMainSnak()) && isSameSnakSet(claim1.getAllQualifiers(), claim2.getAllQualifiers()); }
Statement returnedStatement = preStatement.withSubject(statement.getClaim().getSubject()); long revisionId = getRevisionIdFromResponse(response);
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(Claim o) { int result; result = o.getSubject().hashCode(); result = prime * result + o.getMainSnak().hashCode(); result = prime * result + o.getQualifiers().hashCode(); return result; }
void writeInstanceOfStatements(Resource subject, ItemDocument itemDocument) { for (StatementGroup statementGroup : itemDocument.getStatementGroups()) { if (!"P31".equals(statementGroup.getProperty().getId())) { continue; } for (Statement statement : statementGroup.getStatements()) { if (statement.getClaim().getMainSnak() instanceof ValueSnak && statement.getClaim().getQualifiers().size() == 0) { ValueSnak mainSnak = (ValueSnak) statement.getClaim() .getMainSnak(); Value value = this.valueRdfConverter .getRdfValue(mainSnak.getValue(), mainSnak.getPropertyId(), true); if (value == null) { logger.error("Could not serialize instance of snak: missing value (Snak: " + mainSnak.toString() + ")"); continue; } try { this.rdfWriter.writeTripleValueObject(subject, RdfWriter.RDF_TYPE, value); } catch (RDFHandlerException e) { throw new RuntimeException(e.toString(), e); } } } } }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(Claim o) { int result; result = o.getSubject().hashCode(); result = prime * result + o.getMainSnak().hashCode(); result = prime * result + o.getQualifiers().hashCode(); return result; }
if (statement.getClaim().getMainSnak() instanceof ValueSnak) { ValueSnak mainSnak = (ValueSnak) statement.getClaim() .getMainSnak(); if (statement.getClaim().getQualifiers().size() == 0 && isSubClassOf) { Value value = this.valueRdfConverter.getRdfValue(
/** * Returns true if the parameters are two {@link Claim} objects with exactly * the same data. It does not matter if they are different implementations * of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsClaim(Claim o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof Claim)) { return false; } Claim other = (Claim) o2; return o1.getSubject().equals(other.getSubject()) && o1.getMainSnak().equals(other.getMainSnak()) && o1.getQualifiers().equals(other.getQualifiers()); }
for (SnakGroup q : s.getClaim().getQualifiers()) { countPropertyQualifier(q.getProperty(), q.getSnaks().size()); if (s.getClaim().getQualifiers().size() > 0) { propertyRecord.statementWithQualifierCount++; && s.getClaim().getMainSnak() instanceof ValueSnak) { Value value = ((ValueSnak) s.getClaim().getMainSnak()) .getValue(); if (value instanceof EntityIdValue) {