/** * Helper method that extracts the list of all {@link ItemIdValue} objects * that are used as values in the given statement group. * * @param statementGroup * the {@link StatementGroup} to extract the data from * @return the list of values */ private List<EntityIdValue> getItemIdValueList(StatementGroup statementGroup) { List<EntityIdValue> result = new ArrayList<>(statementGroup.size()); for (Statement s : statementGroup) { Value v = s.getValue(); if (v instanceof EntityIdValue) { result.add((EntityIdValue) v); } } return result; }
/** * Returns the unique {@link Statement} for the given property, or null if * there are zero or many statements for this property. This is a * convenience method for accessing the data that can be obtained via * {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link Statement} or null */ default Statement findStatement(PropertyIdValue propertyIdValue) { StatementGroup statementGroup = findStatementGroup(propertyIdValue); return (statementGroup != null && statementGroup.size() == 1) ? statementGroup.getStatements().get(0) : null; }
/** * Returns the unique {@link Statement} for the given property, or null if * there are zero or many statements for this property. This is a * convenience method for accessing the data that can be obtained via * {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link Statement} or null */ default Statement findStatement(PropertyIdValue propertyIdValue) { StatementGroup statementGroup = findStatementGroup(propertyIdValue); return (statementGroup != null && statementGroup.size() == 1) ? statementGroup.getStatements().get(0) : null; }
/** * Returns the unique {@link Statement} for the given property, or null if * there are zero or many statements for this property. Only the string id * of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return {@link Statement} or null */ default Statement findStatement(String propertyId) { StatementGroup statementGroup = findStatementGroup(propertyId); return (statementGroup != null && statementGroup.size() == 1) ? statementGroup.getStatements().get(0) : null; }
/** * Returns the unique {@link Statement} for the given property, or null if * there are zero or many statements for this property. Only the string id * of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return {@link Statement} or null */ default Statement findStatement(String propertyId) { StatementGroup statementGroup = findStatementGroup(propertyId); return (statementGroup != null && statementGroup.size() == 1) ? statementGroup.getStatements().get(0) : null; }
entityStatistics.countStatements += sg.size(); PropertyRecord propertyRecord = getPropertyRecord(sg.getProperty()); propertyRecord.itemCount++;
/** * Count the statements and property uses of an item or property document. * * @param usageStatistics * statistics object to store counters in * @param statementDocument * document to count the statements of */ protected void countStatements(UsageStatistics usageStatistics, StatementDocument statementDocument) { // Count Statement data: for (StatementGroup sg : statementDocument.getStatementGroups()) { // Count Statements: usageStatistics.countStatements += sg.size(); // Count uses of properties in Statements: countPropertyMain(usageStatistics, sg.getProperty(), sg.size()); for (Statement s : sg) { for (SnakGroup q : s.getQualifiers()) { countPropertyQualifier(usageStatistics, q.getProperty(), q.size()); } for (Reference r : s.getReferences()) { usageStatistics.countReferencedStatements++; for (SnakGroup snakGroup : r.getSnakGroups()) { countPropertyReference(usageStatistics, snakGroup.getProperty(), snakGroup.size()); } } } } }
PropertyRecord propertyRecord = getPropertyRecord(sg.getProperty()); propertyRecord.itemCount++; propertyRecord.statementCount += sg.size();