private static Model modelFromRoots(List<Resource> roots) { if (roots != null && ! roots.isEmpty()) { return roots.get(0).getModel(); } else { return ModelFactory.createDefaultModel(); } }
/** Answer a Resource .equals() to <code>root</code>, but in the expanded model. */ public static Resource withFullModel( Resource root ) { return root.inModel( fullModel( root.getModel() ) ); }
public static String stringForRDFNode(RDFNode obj) { Model m = null ; if ( obj instanceof Resource ) m = ((Resource)obj).getModel() ; return stringForRDFNode(obj, newSerializationContext(m)) ; }
public static String stringForRDFNode(RDFNode obj) { Model m = null ; if ( obj instanceof Resource ) m = ((Resource)obj).getModel() ; return stringForRDFNode(obj, newSerializationContext(m)) ; }
private void renderExampleRequestPath( StringBuilder sb, String api_base, URI base, Resource ep ) { Property API_exampleRequestPath = ep.getModel().createProperty( API.NS, "exampleRequestPath" ); List<Statement> examples = ep.listProperties( API_exampleRequestPath ).toList(); if (examples.size() > 0) { sb.append( "<h3>example request path(s)</h3>" ); for (Statement exs: examples) { sb.append( "<div class='indent'>" ); sb.append( linkTo( api_base, base, exs.getString() ) ); sb.append( "</div>\n" ); } } }
@GET @Produces("application/rdf+xml") public Response requestHandlerRDF_XML ( @PathParam("path") String pathstub, @Context ServletContext config, @Context UriInfo ui) { SpecRecord rec = lookupRequest(config, pathstub, ui); if (rec == null) { return returnNotFound("No specification corresponding to path: /" + pathstub); } else { Resource meta = createMetadata(ui, pathstub, "rdf", rec); return returnAs(RouterRestlet.NO_EXPIRY, ModelIOUtils.renderModelAs(meta.getModel(), "RDF/XML-ABBREV"), "application/rdf+xml"); } }
private static List<Resource> equivalentTypes( Resource type ) { List<Resource> types = new ArrayList<Resource>(); types.add( type ); for (StmtIterator it = type.getModel().listStatements( ANY, OWL.equivalentClass, type ); it.hasNext();) types.add( it.nextStatement().getSubject() ); return types; }
@GET @Produces("text/turtle") public Response requestHandlerTurtle ( @PathParam("path") String pathstub, @Context ServletContext config, @Context UriInfo ui) { SpecRecord rec = lookupRequest(config, pathstub, ui); if (rec == null) { return returnNotFound("No specification corresponding to path: /" + pathstub); } else { Resource meta = createMetadata(ui, pathstub, "ttl", rec); return returnAs(RouterRestlet.NO_EXPIRY, ModelIOUtils.renderModelAs(meta.getModel(), "Turtle"), "text/turtle"); } }
private Resource completedClone( Resource root, Resource newRoot, Model fragment ) { Model typed = fragment.add( newRoot, RDF.type, JA.Content ); return newRoot.inModel( ModelFactory.createUnion( root.getModel(), typed ) ); }
/** Answer a "nice" representation of <code>r</code>, suitable for appearance within an exception message. */ protected static String nice( Resource r ) { String rString = r.asNode().toString( r.getModel() ); return r.isAnon() ? rString + getLabels( r ) : rString; }
protected Content getContent( Assembler a, Resource root ) { final Resource newRoot = oneLevelClone( root ); final Model fragment = newRoot.getModel(); return fragment.isEmpty() ? Content.empty : (Content) a.open( a, completedClone( root, newRoot, fragment ) ); }
protected int countArcsTo(Property prop, Resource resource) { int numArcs = 0 ; StmtIterator sIter = resource.getModel().listStatements(null, prop, resource) ; for ( ; sIter.hasNext() ; ) { sIter.nextStatement() ; numArcs++ ; } sIter.close() ; return numArcs ; }
private static String getLabels( Resource r ) { Model m = r.getModel(); String labels = "", prefix = "labels: "; for (StmtIterator it = r.listProperties( RDFS.label ); it.hasNext();) { String label = it.nextStatement().getObject().asNode().toString( m, true ); labels += prefix + label; prefix = ", "; } return labels.equals( "" ) ? getIncomingProperty( r ) : " [" + labels + "]"; }
private static String getIncomingProperty( Resource r ) { String incomings = "", prefix = ""; StmtIterator it = r.getModel().listStatements( null, null, r ); while (it.hasNext()) { Statement s = it.nextStatement(); incomings += prefix + nice( s.getPredicate() ) + " of " + nice( s.getSubject() ); prefix = ", "; } return incomings.equals( "" ) ? "" : " [" + incomings + "]"; }
private void buildOneResource(Resource root) { buildVariables(root) ; int count = buildPreprocess(root) ; if ( root.getModel().contains(null, ResultSetGraphVocab.index, (RDFNode)null) ) buildRowsOrdered(root, count) ; else buildRows(root) ; }
private void buildOneResource(Resource root) { buildVariables(root) ; int count = buildPreprocess(root) ; if ( root.getModel().contains(null, ResultSetGraphVocab.index, (RDFNode)null) ) buildRowsOrdered(root, count) ; else buildRows(root) ; }
public ThingActionFilter findOrCreate(Ident compID) { ThingActionFilter taf = getCache().getCachedComponent(compID); if (taf != null) return taf; getLogger().debug("Assembler[{}] is opening component at: {}", this, compID); Resource res = builderConfResource.getModel().createResource(compID.getAbsUriString()); JenaResourceItem wrapperItem = new SerialJenaResItem(res); MKC comp = fetchOrMakeComponent(wrapperItem, wrapperItem, this, Mode.REUSE); return comp; }
public RDFNode rename( RDFNode n ) { if (n.isAnon()) return n; if (n.isLiteral()) return rename( (Literal) n ); Resource r = n.asResource(); String givenURI = r.getURI(); String uri = pe.rename( givenURI ); return uri == givenURI ? n : r.getModel().createResource( uri ); }
@Test public void testTermbindsIncludesMetaproperties() throws URISyntaxException { Integer totalResults = null; Resource thisMetaPage = createMetadata(false, totalResults); for (Property p: expectedTermboundProperties) { Model model = thisMetaPage.getModel(); if (!model.contains(null, API.property, p)) { fail("term bindings should include " + model.shortForm(p.getURI())); } } }