Hey,

I have just committed a bunch of really cool fixes to the REST stuff. 
Both Entities and Entity descriptors are now output as RDF. Here's an 
example RDF (/entity/org.qi4j.rest.TestEntity.rdf) for a type:
?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
        xmlns:qi4j="http://www.qi4j.org/rdf/model/1.0/";
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";>
<rdfs:Class rdf:about="urn:qi4j:org.qi4j.rest.TestEntity">
        <rdfs:subClassOf rdf:resource="urn:qi4j:org.qi4j.entity.Lifecycle"/>
        <rdfs:subClassOf rdf:resource="urn:qi4j:org.qi4j.entity.Entity"/>
        <rdfs:subClassOf 
rdf:resource="urn:qi4j:org.qi4j.entity.EntityComposite"/>
        <rdfs:subClassOf rdf:resource="urn:qi4j:org.qi4j.entity.Identity"/>
        <rdfs:subClassOf rdf:resource="urn:qi4j:java.io.Serializable"/>
        <rdfs:subClassOf rdf:resource="urn:qi4j:org.qi4j.composite.Composite"/>
</rdfs:Class>
<rdf:Property rdf:about="urn:qi4j:property:org.qi4j.rest.TestEntity:name">

        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</rdf:Property>
<rdf:Property rdf:about="urn:qi4j:property:org.qi4j.rest.TestEntity:age">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/>
</rdf:Property>
<rdf:Property 
rdf:about="urn:qi4j:property:org.qi4j.rest.TestEntity:unsetName">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</rdf:Property>
<rdf:Property 
rdf:about="urn:qi4j:property:org.qi4j.entity.Identity:identity">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</rdf:Property>
<rdf:Property 
rdf:about="urn:qi4j:association:org.qi4j.rest.TestEntity:association">
        <rdfs:domain rdf:resource="urn:qi4j:urn:qi4j:"/>

        <rdfs:range rdf:resource="urn:qi4j:org.qi4j.rest.TestEntity"/>
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>
</rdf:Property>
<rdf:Property 
rdf:about="urn:qi4j:association:org.qi4j.rest.TestEntity:unsetAssociation">
        <rdfs:domain rdf:resource="urn:qi4j:urn:qi4j:"/>
        <rdfs:range rdf:resource="urn:qi4j:org.qi4j.rest.TestEntity"/>
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>
</rdf:Property>
<rdfs:Container 
rdf:about="urn:qi4j:association:org.qi4j.rest.TestEntity:manyAssociation">
        <rdfs:range rdf:resource="urn:qi4j:org.qi4j.rest.TestEntity"/>
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>

</rdfs:Container>
<rdf:Seq 
rdf:about="urn:qi4j:association:org.qi4j.rest.TestEntity:listAssociation">
        <rdfs:range rdf:resource="urn:qi4j:org.qi4j.rest.TestEntity"/>
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>
</rdf:Seq>
<rdf:Bag 
rdf:about="urn:qi4j:association:org.qi4j.rest.TestEntity:setAssociation">
        <rdfs:range rdf:resource="urn:qi4j:org.qi4j.rest.TestEntity"/>
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>
</rdf:Bag>

</rdf:RDF>
---
Which includes quite a lot of the "schema" for the type.

RDF output of an Entity (/entity/org.qi4j.test.TestEntity/test2.rdf) of 
the above type looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
        xmlns:qi4j="http://www.qi4j.org/rdf/model/1.0/";
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";>
<org.qi4j.rest.TestEntity xmlns="urn:qi4j:" rdf:about="urn:qi4j:test2">
        <age xmlns="urn:qi4j:property:org.qi4j.rest.TestEntity:">12</age>
        <name xmlns="urn:qi4j:property:org.qi4j.rest.TestEntity:">Xyzzy</name>
        <identity 
xmlns="urn:qi4j:property:org.qi4j.entity.Identity:">test2</identity>
        <association xmlns="urn:qi4j:association:org.qi4j.rest.TestEntity:" 
rdf:resource="urn:qi4j:org.qi4j.rest.TestEntity/test1"/>
</org.qi4j.rest.TestEntity>

</rdf:RDF>
---
ManyAssociation output is not yet implemented, but other than that it 
works pretty well.

The HTML version of the output shows an HTML form where properties, 
assocs and manyassocs can be viewed and updated. The form parsing need 
to convert the form strings to native objects like longs and ints, which 
is now done using an if-statement, which could be replaced by a real 
converter plugin thingy.

Anyway, all in all pretty cool, and very useful for debugging I think. 
If you wanna try it out, fire up the "Main" test class in the REST 
extension, and browse to 
http://localhost:8080/entity/org.qi4j.rest.TestEntity

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to