protected static final Resource resource(String name) { return ResourceFactory.createResource(name); } }
private static Resource firstOf(List<Resource> resultList) { return resultList.isEmpty() ? ResourceFactory.createResource("elda:missingEndpoint") : resultList.get(0) ; }
public static List<Resource> allReservedResouces() { List<Resource> result = new ArrayList<Resource>(); for (String r: "result item items".split( " " )) result.add( ResourceFactory.createResource( API.NS + r ) ); return result; }
/** Add metadata describing this source to a metdata model */ @Override public void addMetadata(Resource meta) { meta.addProperty(API.sparqlEndpoint, ResourceFactory.createResource(endpoint)); }
public static Object build(String assemblerFile, String typeURI) { Resource type = ResourceFactory.createResource(typeURI) ; return build(assemblerFile, type) ; }
public static Object build(String assemblerFile, String typeURI) { Resource type = ResourceFactory.createResource(typeURI) ; return build(assemblerFile, type) ; }
@Override public Resource asResource( String s ) { String u = expand( s ); return ResourceFactory.createResource( u ); } }
@Override public Resource asResource( String res ) { String uri = expand( res ); if (uri == null && RDFUtil.looksLikeURI(res)) { uri = res; } if (uri != null) return ResourceFactory.createResource(uri); throw new UnknownShortnameException( res ); }
@Override public List<Map<String, Collection<Object>>> apply(final RdfStream stream) { final LDPath<RDFNode> ldpathForResource = getLdpathResource(stream); final Resource context = createResource(stream.topic().getURI()); try { return ImmutableList.of(unsafeCast( ldpathForResource.programQuery(context, new InputStreamReader(query)))); } catch (final LDPathParseException e) { throw new RepositoryRuntimeException(e); } }
private RDFNode expand(Bindings b, RDFNode O) { if (O.isResource()) return O; String lex = O.asNode().getLiteralLexicalForm(); String typeURI = O.asNode().getLiteralDatatypeURI(); String expanded = b.expandVariables(lex); if (RDFS_Resource.equals(typeURI)) return ResourceFactory.createResource(expanded); return litModel.createTypedLiteral(expanded, typeURI); } }
@Test public void testBuildFromProperty() { View v = new View(); v.addViewFromRDFList( ResourceFactory.createResource( "eh:/p" ), sns ); List<PropertyChain> chains = v.chains(); assertEquals(1, chains.size()); List<ViewProperty> chain = chains.get(0).getProperties(); assertEquals(1, chain.size()); assertEquals("eh:/p", chain.get(0).toString()); }
@Test public void testShorten2() { List<Binding<Resource>> bindings = new ArrayList<Binding<Resource>>(); bindings.add( new Binding<Resource>( "foo1", ResourceFactory.createResource( "http://example/foo1" )) ); final ShortNameRenderer snr = new ShortNameRenderer( null, bindings ); assertEquals( "foo1", snr.shorten( "http://example/foo1" ) ); }
@Test public void testExpandWithBindings() { List<Binding<Resource>> bindings = new ArrayList<Binding<Resource>>(); bindings.add( new Binding<Resource>( "foo1", ResourceFactory.createResource( "http://example/foo1" )) ); bindings.add( new Binding<Resource>( "foo2", ResourceFactory.createResource( "http://example/foo2" )) ); final ShortNameRenderer snr = new ShortNameRenderer( null, bindings ); assertEquals( "http://example/foo1", snr.expand( "foo1" ) ); assertEquals( "http://example/foo2", snr.expand( "foo2" ) ); assertEquals( "foo3", snr.expand( "foo3" ) ); }
@Test public void testPageLinks() { assertEquals( ResourceFactory.createResource( "http://localhost:8080/standalone/hello/games.vhtml?_metadata=all&_page=0" ), page.firstPage() ); assertEquals( ResourceFactory.createResource( "http://localhost:8080/standalone/hello/games.vhtml?_metadata=all&_page=1" ), page.nextPage() ); assertNull( page.prevPage() ); assertNull( page.lastPage() ); }
/***********************************/ @Before public void before() { ResultsModel rm = new ResultsModel( Fixtures.mockResultSet( context, apiResultsModel, apiObjectModel, apiMetadataModel ) ); displayResource = new DisplayRdfNode( rm.page(), ResourceFactory.createResource( "http://www.treefroggames.com/a-few-acres-of-snow-2" ) ); }
@Test public void testTermBindings() { List<Binding<Resource>> bindings = page.termBindings(); boolean found = false; for (Binding<Resource> b: bindings) { if (b.label().equals( "playTimeMinutes")) { assertTrue( b.value().equals( ResourceFactory.createResource( "http://epimorphics.com/public/vocabulary/games.ttl#playTimeMinutes" ) )); found = true; } } assertTrue( found ); }
/***********************************/ @Before public void before() { rm = new ResultsModel( Fixtures.mockResultSet( context, apiResultsModel, apiObjectModel, apiMetadataModel ) ); view = new EldaView( rm.page(), ResourceFactory.createResource( view_uri ) ); }
@Test public void testChildren() { Resource r0 = ResourceFactory.createResource( "http://example/foo#r0"); DisplayHierarchyNode c1 = new DisplayHierarchyNode( new PropertyPath(), dhn, new DisplayRdfNode( rm.page(), r0 ), null ); assertEquals( 1, dhn.children().size() ); assertEquals( 0, c1.children().size() ); }
/** Test that asResource( RDFNode) is delegated correctly */ @Test public void testAsResourceRDFNode() { final ShortnameService sns = context.mock( ShortnameService.class ); final ShortNameRenderer snr = new ShortNameRenderer( sns, null ); final RDFNode n = ResourceFactory.createResource( "http//example/test" ); context.checking(new Expectations() {{ oneOf (sns).asResource( n ); }}); snr.asResource( n ); }
/***********************************/ private DisplayHierarchy.DisplayHierarchyContext contextFixture( final boolean isSeen, String mockName ) { final DisplayHierarchy.DisplayHierarchyContext dhContext = context.mock( DisplayHierarchy.DisplayHierarchyContext.class, mockName ); final RDFNodeWrapper r = new RDFNodeWrapper( rm.page().getModelW(), ResourceFactory.createResource( "http://example/foo#r0") ); context.checking(new Expectations() {{ atLeast(0).of (dhContext).isSeen( r ); will( returnValue( isSeen ) ); }}); return dhContext; }