/** * 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(ItemDocument o) { int result; result = hashCodeForTermedDocument(o); result = prime * result + o.getStatementGroups().hashCode(); result = prime * result + o.getSiteLinks().hashCode(); return result; }
/** * 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(ItemDocument o) { int result; result = hashCodeForTermedDocument(o); result = prime * result + o.getStatementGroups().hashCode(); result = prime * result + o.getSiteLinks().hashCode(); return result; }
/** * Returns true if the parameters are two {@link ItemDocument} 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 equalsItemDocument(ItemDocument o1, Object o2) { if (o2 == o1) { return true; } if (!(o2 instanceof ItemDocument)) { return false; } ItemDocument other = (ItemDocument) o2; // Note: item id already compared by equalsTermedDocument() return equalsTermedDocument(o1, other) && o1.getSiteLinks().equals(other.getSiteLinks()) && o1.getStatementGroups().equals(other.getStatementGroups()); }
/** * Returns true if the parameters are two {@link ItemDocument} 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 equalsItemDocument(ItemDocument o1, Object o2) { if (o2 == o1) { return true; } if (!(o2 instanceof ItemDocument)) { return false; } ItemDocument other = (ItemDocument) o2; // Note: item id already compared by equalsTermedDocument() return equalsTermedDocument(o1, other) && o1.getSiteLinks().equals(other.getSiteLinks()) && o1.getStatementGroups().equals(other.getStatementGroups()); }
private void countCooccurringProperties(ItemDocument itemDocument, UsageRecord usageRecord, PropertyIdValue thisPropertyIdValue) { for (StatementGroup sg : itemDocument.getStatementGroups()) { if (!sg.getProperty().equals(thisPropertyIdValue)) { if (!usageRecord.propertyCoCounts.containsKey(sg.getProperty())) { usageRecord.propertyCoCounts.put(sg.getProperty(), 1); } else { usageRecord.propertyCoCounts .put(sg.getProperty(), usageRecord.propertyCoCounts .get(sg.getProperty()) + 1); } } } }
private void countCooccurringProperties(ItemDocument itemDocument, UsageRecord usageRecord, PropertyIdValue thisPropertyIdValue) { for (StatementGroup sg : itemDocument.getStatementGroups()) { if (!sg.getProperty().equals(thisPropertyIdValue)) { if (!usageRecord.propertyCoCounts.containsKey(sg.getProperty())) { usageRecord.propertyCoCounts.put(sg.getProperty(), 1); } else { usageRecord.propertyCoCounts .put(sg.getProperty(), usageRecord.propertyCoCounts .get(sg.getProperty()) + 1); } } } }
@Override public void processItemDocument(ItemDocument itemDocument) { for (StatementGroup sg : itemDocument.getStatementGroups()) { if (COORD_PROPERTY.equals(sg.getProperty().getId())) { for (Statement s : sg) { countCoordinateStatement(s, itemDocument); } } } }
@Override public void processItemDocument(ItemDocument itemDocument) { for (StatementGroup sg : itemDocument.getStatementGroups()) { if (COORD_PROPERTY.equals(sg.getProperty().getId())) { for (Statement s : sg.getStatements()) { countCoordinateStatement(s, itemDocument); } } } }
/** * 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) { if (s.getMainSnak() instanceof ValueSnak) { Value v = s.getValue(); // "Q1731" is "Dresden" on Wikidata if (v instanceof ItemIdValue && "Q1731".equals(((ItemIdValue) v).getId())) { return true; } } } } return false; } }
for (StatementGroup sg : itemDocument.getStatementGroups()) { boolean isImage = "P18".equals(sg.getProperty().getId()); if (!isImage) {
for (StatementGroup sg : itemDocument.getStatementGroups()) { boolean isImage = "P18".equals(sg.getProperty().getId()); if (!isImage) {
public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); }
public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); }
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); } } } } }
boolean isHuman = false; for (StatementGroup statementGroup : itemDocument.getStatementGroups()) { switch (statementGroup.getProperty().getId()) { case "P21": // P21 is "sex or gender"
/** * 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; } }
boolean isHuman = false; for (StatementGroup statementGroup : itemDocument.getStatementGroups()) { switch (statementGroup.getProperty().getId()) { case "P21": // P21 is "sex or gender"
/** * Copies an {@link ItemDocument}. * * @param object * object to copy * @return copied object */ public ItemDocument copy(ItemDocument object) { return dataObjectFactory.getItemDocument( copy(object.getEntityId()), copyMonoLingualTextValues(object.getLabels().values()), copyMonoLingualTextValues(object.getDescriptions().values()), copyAliasMap(object.getAliases()), copyStatementGroups(object.getStatementGroups()), copySiteLinks(object.getSiteLinks()), object.getRevisionId()); }
/** * Copies an {@link ItemDocument}. * * @param object * object to copy * @return copied object */ public ItemDocument copy(ItemDocument object) { return dataObjectFactory.getItemDocument( copy(object.getEntityId()), copyMonoLingualTextValues(object.getLabels().values()), copyMonoLingualTextValues(object.getDescriptions().values()), copyAliasMap(object.getAliases()), copyStatementGroups(object.getStatementGroups()), copySiteLinks(object.getSiteLinks()), object.getRevisionId()); }
void writeSubclassOfStatements(Resource subject, ItemDocument itemDocument) { for (StatementGroup statementGroup : itemDocument.getStatementGroups()) { boolean isSubClassOf = "P279".equals(statementGroup.getProperty() .getId());