/** * Compares two RDF models, and returns <tt>true</tt> if the first model is a subset of the second model, * using graph isomorphism to map statements between models. */ public static boolean isSubset(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { // Filter duplicates Model set1 = toModel(model1); Model set2 = toModel(model2); return isSubset(set1, set2); }
/** * Compares two RDF models, and returns <tt>true</tt> if the first model is a subset of the second model, * using graph isomorphism to map statements between models. */ public static boolean isSubset(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { // Filter duplicates Model set1 = toModel(model1); Model set2 = toModel(model2); return isSubset(set1, set2); }
/** * Compares the models of the default context of two repositories and returns true if rep1 is a subset of * rep2. Note that the method pulls the entire default context of both repositories into main memory. Use * with caution. */ public static boolean isSubset(Repository rep1, Repository rep2) throws RepositoryException { Set<Statement> model1, model2; try (RepositoryConnection con1 = rep1.getConnection()) { model1 = Iterations.asSet(con1.getStatements(null, null, null, true)); } try (RepositoryConnection con2 = rep2.getConnection()) { model2 = Iterations.asSet(con2.getStatements(null, null, null, true)); } return Models.isSubset(model1, model2); }
/** * Compares the models of the default context of two repositories and returns true if rep1 is a subset of * rep2. Note that the method pulls the entire default context of both repositories into main memory. Use * with caution. */ public static boolean isSubset(Repository rep1, Repository rep2) throws RepositoryException { Set<Statement> model1, model2; RepositoryConnection con1 = rep1.getConnection(); try { model1 = Iterations.asSet(con1.getStatements(null, null, null, true)); } finally { con1.close(); } RepositoryConnection con2 = rep2.getConnection(); try { model2 = Iterations.asSet(con2.getStatements(null, null, null, true)); } finally { con2.close(); } return Models.isSubset(model1, model2); }