private static List<Resource> equivalentTypes( Resource type ) { List<Resource> types = new ArrayList<>(); types.add( type ); for (StmtIterator it = type.getModel().listStatements( ANY, OWL.equivalentClass, type ); it.hasNext();) types.add( it.nextStatement().getSubject() ); return types; }
/** Load all the classes which are objects of any (t, ja:assembler, S) statements in <code>m</code>. <code>group.implementWIth(t,c)</code> is called for each statement, where <code>c</code> is an instance of the class named by <code>S</code>. The order in which the classes are loaded is not specified, and loading stops immediately if any class cannot be loaded. */ public static void loadAssemblerClasses( AssemblerGroup group, Model m ) { StmtIterator it = m.listStatements( ANY, JA.assembler, ANY ); while (it.hasNext()) loadAssemblerClass( group, it.nextStatement() ); }
private static Statement getOne(Model m, Resource s, Property p, RDFNode o) { StmtIterator iter = m.listStatements(s, p, o) ; if ( ! iter.hasNext() ) return null ; Statement stmt = iter.next() ; if ( iter.hasNext() ) return null ; return stmt ; }
public static void addStatements(Model model, Statement s) { if(!IGNORED_PROPERTIES.contains(s.getPredicate())) { model.add(s); } if(s.getObject().isAnon()) { for(Statement t : s.getModel().listStatements(s.getResource(), null, (RDFNode)null).toList()) { addStatements(model, t); } } }
@Override public Set<RDFNode> vertexSet() { Set<RDFNode> result = new LinkedHashSet<>(); model.listStatements(null, confinementProperty, (RDFNode)null).forEachRemaining(stmt -> { result.add(stmt.getSubject()); result.add(stmt.getObject()); }); return result; }
public static void enrichTestCasesWithLabels(Model model) { Set<Statement> stmts = model.listStatements(null, RDF.type, SparqlQcVocab.ContainmentTest).toSet(); for (Statement stmt : stmts) { Resource s = stmt.getSubject(); String str = s.getURI(); int x = str.lastIndexOf('/') + 1; String id = str.substring(x).replace('#', '_'); model.add(s, RDFS.label, id); } }
public void readKeyReferences(Model model, Set<String> keyRefs) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException { Property typeProp = model.createProperty(Ontology.getSigIri(), "hasVerificationCertificate"); StmtIterator si = model.listStatements(null, typeProp, RdfUtils.EMPTY_RDF_NODE); if (si.hasNext()) { keyRefs.add(si.next().getObject().asResource().getURI()); } }
/** * <p>Answer a property that is the sub-property of this property. If there is * more than one such property, an arbitrary selection is made.</p> * @return A sub-property of this property * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public OntProperty getSubProperty() { checkProfile( getProfile().SUB_PROPERTY_OF(), "SUB_PROPERTY_OF" ); return getModel().listStatements( null, getProfile().SUB_PROPERTY_OF(), this ) .nextStatement() .getSubject() .as( OntProperty.class ); }
private static List<Resource> equivalentTypes( Resource type ) { List<Resource> types = new ArrayList<>(); types.add( type ); for (StmtIterator it = type.getModel().listStatements( ANY, OWL.equivalentClass, type ); it.hasNext();) types.add( it.nextStatement().getSubject() ); return types; }
/** Load all the classes which are objects of any (t, ja:assembler, S) statements in <code>m</code>. <code>group.implementWIth(t,c)</code> is called for each statement, where <code>c</code> is an instance of the class named by <code>S</code>. The order in which the classes are loaded is not specified, and loading stops immediately if any class cannot be loaded. */ public static void loadAssemblerClasses( AssemblerGroup group, Model m ) { StmtIterator it = m.listStatements( ANY, JA.assembler, ANY ); while (it.hasNext()) loadAssemblerClass( group, it.nextStatement() ); }
public static void addStatements(Model model, Statement s) { if(!IGNORED_PROPERTIES.contains(s.getPredicate())) { model.add(s); } if(s.getObject().isAnon()) { for(Statement t : s.getModel().listStatements(s.getResource(), null, (RDFNode)null).toList()) { addStatements(model, t); } } }
public static MetricMapper createDefault() { Model model; try { model = RdfReaderFactory.createResourceReader("/org/aksw/rdfunit/dqv/metricMappings.ttl").read(); } catch (RdfReaderException e) { throw new IllegalArgumentException("Cannot read default metric mappings", e); } ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>(); model.listStatements().toList().stream() .filter(smt -> smt.getPredicate().equals(RDFUNITv.metric)) .filter(smt -> smt.getObject().isResource()) .forEach(smt -> builder.put(smt.getSubject().getURI(), smt.getObject().asResource().getURI())); return new MetricMapper(builder.build()); }
public static void enrichTestCasesWithLabels(Model model) { Set<Statement> stmts = model.listStatements(null, RDF.type, SparqlQcVocab.ContainmentTest).toSet(); for (Statement stmt : stmts) { Resource s = stmt.getSubject(); String str = s.getURI(); int x = str.lastIndexOf('/') + 1; String id = str.substring(x).replace('#', '_'); model.add(s, RDFS.label, id); } }
public void testRemoveProperties() { r.removeProperties(); Assert.assertEquals(false, model .listStatements(r, null, (RDFNode) null).hasNext()); }
private void prune(Model m) { StmtIterator iter = m.listStatements(null, RDF.type, (RDFNode) null); while(iter.hasNext()) { Statement st = iter.next(); if(st.getObject().isAnon() && !m.contains(st.getObject().asResource(), null)) { iter.remove(); }; } }
/** * <p>Answer a property that is the sub-property of this property. If there is * more than one such property, an arbitrary selection is made.</p> * @return A sub-property of this property * @exception ProfileException If the {@link Profile#SUB_PROPERTY_OF()} property is not supported in the current language profile. */ @Override public OntProperty getSubProperty() { checkProfile( getProfile().SUB_PROPERTY_OF(), "SUB_PROPERTY_OF" ); return getModel().listStatements( null, getProfile().SUB_PROPERTY_OF(), this ) .nextStatement() .getSubject() .as( OntProperty.class ); }
protected static void addDomainTypes( Model result, Model schema ) { for (StmtIterator it = schema.listStatements( ANY, RDFS.domain, ANY ); it.hasNext();) { Statement s = it.nextStatement(); Property property = s.getSubject().as( Property.class ); RDFNode type = s.getObject(); for (StmtIterator x = result.listStatements( ANY, property, ANY ); x.hasNext();) { Statement t = x.nextStatement(); result.add( t.getSubject(), RDF.type, type ); } } }
private static void addIntersections( Model result, Model schema ) { StmtIterator it = schema.listStatements( ANY, OWL.intersectionOf, ANY ); while (it.hasNext()) addIntersections( result, schema, it.nextStatement() ); }
@Test public final void thereIsOneFrench() { final StmtIterator it = TestListStatements.m.listStatements( TestListStatements.s, TestListStatements.p, null, "fr"); final List<Statement> lis = it.toList(); Assert.assertTrue(lis.size() == 1); Assert.assertTrue(lis.get(0).getObject().toString().equals("texte@fr")); }
public static void renameProperty(Model model, Property p, String uri) { List<Statement> stmts = model.listStatements(null, p, (RDFNode)null).toList(); model.remove(stmts); for(Statement stmt : stmts) { Property newProperty = model.createProperty(uri); model.add(stmt.getSubject(), newProperty, stmt.getObject()); } }