/** Find and process datasets and services in a configuration file * starting from {@code server} which can have a {@code fuseki:services ( .... )} * but, if not found, all {@code rtdf:type fuseki:services} are processed. */ public static List<DataAccessPoint> servicesAndDatasets(Resource server) { Objects.requireNonNull(server); return servicesAndDatasets$(server, server.getModel()); }
/** 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() ) ); }
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; }
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 ) ); }
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 ) ); }
private Set<Resource> resources( Resource root, String items ) { List<String> L = listOfStrings( items ); Set<Resource> result = new HashSet<>(); for ( String aL : L ) { result.add( resource( root.getModel(), aL ) ); } return result; }
/** 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 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 ; }
public Gremlin( Resource root ) { assertEquals( resource( "eh:Wossname" ), root ); assertIsoModels( gremlinModel, root.getModel() ); gremlinInvoked = true; }
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 + "]"; }
public void testGetModel() { Assert.assertSame(model, model.createResource("eh:/wossname") .getModel()); }
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); }
public void testClosureFootprint() { Resource root = resourceInModel( "x ja:reasoner y" ); Statement footprint = root.getModel().createStatement( JA.This, RDF.type, JA.Expanded ); assertFalse( root.getModel().contains( footprint ) ); Resource expanded = AssemblerHelp.withFullModel( root ); assertTrue( expanded.getModel().contains( footprint ) ); }
public void testFootprintPreventsClosure() { Resource root = resourceInModel( "x ja:reasoner y; ja:this rdf:type ja:Expanded" ); Model original = model( "" ).add( root.getModel() ); Resource expanded = AssemblerHelp.withFullModel( root ); assertSame( root, expanded ); assertIsoModels( original, expanded.getModel() ); }
private void testSpecificType( String expected, String specification ) { // TODO relies on fullModel, would be nice to remove this dependency Resource root = resourceInModel( specification ); Resource rooted = root.inModel( AssemblerHelp.fullModel( root.getModel() ) ); Resource mst = AssemblerHelp.findSpecificType( rooted ); assertEquals( resource( root.getModel(), expected ), mst ); }
public void testAsToOwnClassWithNoModel() { Resource r = ResourceFactory.createResource(); assertEquals( null, r.getModel() ); assertTrue( r.canAs( Resource.class ) ); assertSame( r, r.as( Resource.class ) ); }
public void testCreatesWithCorrectContent() { // TODO should really have some mroe of these Resource root = resourceInModel( "r rdf:type ja:LocationMapper; r lm:mapping _m; _m lm:name 'alpha'; _m lm:altName 'beta'" ); Assembler a = new LocationMapperAssembler(); Object x = a.open( root ); assertInstanceOf( LocationMapper.class, x ); assertEqualMaps( new LocationMapper( root.getModel() ), (LocationMapper) x ); }
private void testTrapsBadPolicyPath( String path ) { Resource root = resourceInModel( "x rdf:type ja:DocumentManager; x ja:policyPath <policy>".replaceAll( "<policy>", path ) ); Assembler a = new DocumentManagerAssembler(); try { a.open( root ); fail( "should trap illegal policy path object " + path ); } catch (BadObjectException e) { assertEquals( resource( "x" ), e.getRoot() ); assertEquals( rdfNode( root.getModel(), path ), e.getObject() ); } }