/** Answer a Set of the objects in the full expansion of the assembler specification <code>model</code> which have rdf:type <code>type</code>, which <i>must</i> be a subtype of <code>ja:Object</code>. */ public static Set<Resource> findAssemblerRoots( Model model, Resource type ) { return fullModel( model ).listResourcesWithProperty( RDF.type, type ).toSet(); }
public void setContents(String contentsAsString) { if (contentsAsString.startsWith("<rdf:RDF")) { Model model = ModelFactory.createDefaultModel(); model.read(new StringReader(contentsAsString), null); Set<Resource> subjects = model.listSubjects().toSet(); Set<RDFNode> objects = model.listObjects().toSet(); subjects.removeAll(objects); node = subjects.iterator().next(); } else { node = RdfUtils.createTypedLiteral(contentsAsString); } }
public static RDFNode convert(InputStream stream) { Model model = ModelFactory.createDefaultModel().read(stream, null); Set<Resource> subjects = model.listSubjects().toSet(); Set<RDFNode> objects = model.listObjects().toSet(); subjects.removeAll(objects); return subjects.iterator().next(); }
public Set<Resource> runLicenceQuery(String licenceQuery) { Source dataSource = spec.getAPISpec().getDataSource(); final Set<Resource> licences = new HashSet<Resource>(); if (licenceQuery != null) { Model cons = dataSource.executeConstruct(QueryFactory.create(licenceQuery)); licences.addAll(cons.listSubjects().toSet()); } return licences; }
private List<EIInstance> create(final Model model) { if ( model == null ) { return Collections.emptyList(); } final List<EIInstance> instances = new ArrayList<EIInstance>(); final Set<Resource> subjects = model.listSubjects().toSet(); // create an EIInstance per subject for (final Resource r : subjects) { final Model subModel = model.query( new SimpleSelector( r, null, (RDFNode)null ) ); final EIInstance ei = jenaIntanceFactory.create( EIURI.create( r.getURI() ), subModel ); if ( ei != null && !EIInstance.NULL_INSTANCE.equals( ei ) ) { instances.add( ei ); } } return instances; }