[OTDev] Creation of a new feature

chung chvng at mail.ntua.gr
Wed Dec 23 16:22:57 CET 2009


Hi Nina,
 According to the API, one can post an rdf representation of a feature
to a feature service to have a new Feature created. So I made an
experiment using the following curl command:

curl -X POST -H 'Content-type:application/rdf+xml' --data-binary
@/path/to/feature.rdf http://ambit.uni-plovdiv.bg:8080/ambit2/feature

The content of feature RDF is:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:ot="http://www.opentox.org/api/1.1#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > 
  <rdf:Description rdf:about="http://purl.org/dc/elements/1.1/creator">
    <rdf:type
rdf:resource="http://www.w3.org/2002/07/owl#AnnotationProperty"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A0">
    <owl:sameAs rdf:resource="http://other.com/feature/200"/>
    <dc:creator
rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://opentox.ntua.gr</dc:creator>
    <rdf:type rdf:resource="http://www.opentox.org/api/1.1#Feature"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://other.com/feature/200">
    <rdf:type rdf:resource="http://www.opentox.org/api/1.1#Feature"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.opentox.org/api/1.1#Feature">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
</rdf:RDF>

This RDF was generated using the following code:



OntModel featureModel = OT.createModel();
        Individual feature =
featureModel.createIndividual(featureModel.getOntClass(OT.Class.Dataset.getURI()));

feature.addRDFType(OT.Class.Feature.createProperty(featureModel));

feature.addProperty(featureModel.createAnnotationProperty(DC.creator.getURI()), featureModel.createTypedLiteral("http://opentox.ntua.gr"));

feature.setSameAs(featureModel.createResource("http://other.com/feature/200", OT.Class.Feature.getResource()));
        OT.Class.Feature.createOntClass(featureModel);

*** The operation is successful (the server responds with a status code
200-OK), a URI is returned for the generated feature which is
http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%2Fother.com%
2Ffeature%2F200Default , but the result of the following request: 

curl -v -H 'Accept:application/rdf+xml'
http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%2Fother.com%
2Ffeature%2F200Default 

returns an empty representation and a status code 400 - Bad Request. 



Is there a problem with the RDF I posted? Could you provide an example
of how can one create a new Feature?

Best Regards,
Pantelis




More information about the Development mailing list