1) I resorted to using TypeWrapper to discover the serialised URIs for
my object properties, along the lines of these methods. Useful for
generating the sparql required. Should be able to extend this to create
a method that works from a skeleton bean and then calls jena's
subjectWithProperties()/listResourcesWithProperty() method.
/**
* answer properties map<name,uri> of this Bean that are of a
certain type
* @return
*/
protected Map<String,String> getPropertiesAsUris(){
Map<String,String> propMap = new HashMap<String, String>();
for (ValuesContext p : TypeWrapper.valueContexts(this)){
propMap.put(p.getName(), p.uri() );
}
return propMap;
}
/**
* answer properties map<name,uri> of this Bean that are of a
certain type
* @param <R>
* @param r
* @return
*/
protected <R> Map<String,String> getTypedPropertiesAsUris(Class<R> r){
Map<String,String> propMap = new HashMap<String, String>();
for (ValuesContext p : TypeWrapper.valueContexts(this)){
if ( p.type().isAssignableFrom(r) )
propMap.put(p.getName(), p.uri() );
}
return propMap;
}
2) I came across this niggle (perhaps obvious to you) : If you make a
call to RDF2Bean.loadDeep(Class<T> c, Object id) and c is an interface
(I have several subclasses of another concrete class, subclasses
implementing an interface the parentclass doesnt) then the interface
needs to also declare the @Id field, or you get nothing back. Reasonable
enough, just took me 4 days to work out why tho.
On 06/05/2010 05:33, Taylor Cowan wrote: