/** * Gets the subject of the statement(s) with the specified predicate and object from the specified * contexts in the supplied graph. If the combination of predicate, object and contexts matches one or * more statements, all these statements should have the same subject. A {@link GraphUtilException} is * thrown if this is not the case. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a * description of the parameter values. * * @return The subject of the matched statement(s), or <tt>null</tt> if no matching statements were found. * @throws GraphUtilException * If the statements matched by the specified parameters have more than one unique subject. * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#subjectResource()} instead. */ @Deprecated public static Resource getOptionalSubject(Graph graph, IRI pred, Value obj, Resource... contexts) throws GraphUtilException { Set<Resource> subjects = getSubjects(graph, pred, obj, contexts); if (subjects.isEmpty()) { return null; } else if (subjects.size() == 1) { return subjects.iterator().next(); } else { throw new GraphUtilException("Multiple " + pred + " properties found"); } }
/** * Gets the subject of the statement(s) with the specified predicate and object from the specified * contexts in the supplied graph. If the combination of predicate, object and contexts matches one or * more statements, all these statements should have the same subject. A {@link GraphUtilException} is * thrown if this is not the case. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a * description of the parameter values. * * @return The subject of the matched statement(s), or <tt>null</tt> if no matching statements were found. * @throws GraphUtilException * If the statements matched by the specified parameters have more than one unique subject. * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#subjectResource()} instead. */ @Deprecated public static Resource getOptionalSubject(Graph graph, IRI pred, Value obj, Resource... contexts) throws GraphUtilException { Set<Resource> subjects = getSubjects(graph, pred, obj, contexts); if (subjects.isEmpty()) { return null; } else if (subjects.size() == 1) { return subjects.iterator().next(); } else { throw new GraphUtilException("Multiple " + pred + " properties found"); } }
/** * Gets the subject of the statement(s) with the specified predicate and object from the specified * contexts in the supplied graph. The combination of predicate, object and contexts must match at least * one statement. In case more than one statement matches -- for example statements from multiple contexts * -- all these statements should have the same subject. A {@link GraphUtilException} is thrown if these * conditions are not met. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a description of * the parameter values. * * @return The subject of the matched statement(s). * @throws GraphUtilException * If the statements matched by the specified parameters do not have exactly one unique subject. * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#subjectResource()} instead. */ @Deprecated public static Resource getUniqueSubject(Graph graph, IRI pred, Value obj, Resource... contexts) throws GraphUtilException { Set<Resource> subjects = getSubjects(graph, pred, obj, contexts); if (subjects.size() == 1) { return subjects.iterator().next(); } else if (subjects.isEmpty()) { throw new GraphUtilException("Missing property: " + pred); } else { throw new GraphUtilException("Multiple " + pred + " properties found"); } }
/** * Gets the subject of the statement(s) with the specified predicate and object from the specified * contexts in the supplied graph. The combination of predicate, object and contexts must match at least * one statement. In case more than one statement matches -- for example statements from multiple contexts * -- all these statements should have the same subject. A {@link GraphUtilException} is thrown if these * conditions are not met. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a description of * the parameter values. * * @return The subject of the matched statement(s). * @throws GraphUtilException * If the statements matched by the specified parameters do not have exactly one unique subject. * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#subjectResource()} instead. */ @Deprecated public static Resource getUniqueSubject(Graph graph, IRI pred, Value obj, Resource... contexts) throws GraphUtilException { Set<Resource> subjects = getSubjects(graph, pred, obj, contexts); if (subjects.size() == 1) { return subjects.iterator().next(); } else if (subjects.isEmpty()) { throw new GraphUtilException("Missing property: " + pred); } else { throw new GraphUtilException("Multiple " + pred + " properties found"); } }
Set<Resource> subjects = GraphUtil.getSubjects(bufferedStatements, null, null, context); for (Resource subject : subjects) { Set<IRI> processedPredicates = new HashSet<>();
Set<Resource> subjects = GraphUtil.getSubjects(bufferedStatements, null, null, context); for (Resource subject : subjects) { Set<IRI> processedPredicates = new HashSet<IRI>();
Set<Resource> subjects = GraphUtil.getSubjects(bufferedStatements, null, null, context); for (Resource subject : subjects) { Set<IRI> processedPredicates = new HashSet<IRI>();