[OTDev] How to upload a dataset ...

Nina Jeliazkova jeliazkova.nina at gmail.com
Fri Sep 3 19:04:29 CEST 2010


Hi Surajit,

I assume resultDataset variable is a Jena Model?

Here is one of the RDF files you've tried to upload

http://www.ideaconsult.net/downloads/maxtox/ambit2_22761.rdf
<http://www.ideaconsult.net/downloads/maxtox/ambit2_22761.rdf%20>

First observation there is no any ot:Dataset instance. There are multile
ot:DataEntry, but no dataset to where they belong.  This is definitely a
reason the dataset could not be imported - the parser simply doesn't find a
dataset to work with and does nothing.

Second observation - you have defined value of type double, but the value
itself is a string of 0 and 1s (the fingerprint).  This is at least not
correct and will most probably result in errors when parsing values.

       <ot:FeatureValue>
            <ot:value rdf:datatype="http://www.w3.org/2001/XMLSchema#double"

>0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0</ot:value>
            <ot:feature rdf:resource="
http://localhost:8080/MaxtoxTest/feature/1_fingerprint"/>
          </ot:FeatureValue>

Ah, and (relatively minor)  issue - the feature URI
http://localhost:8080/MaxtoxTest/feature/1_fingerprint will not be
dereferencable, even if you are running feature service at your machine -
just because "localhost" means your machine for you, but my machine to me.

If you are not running feature service elsewehere it would be better to
either have anonymous node for it, or create it beforehand  (POST to
http://{host}/ambit2/feature)
and provide the URI in the dataset RDF.  TUM and NTUA developers can share
their experience/code as well.

Third,  this  code will not work as you might expect:

this.uploaded_URI = output.getText(); ,

because task RDF will be returned, not a single URI (you have specified
request.getClientInfo().getAcceptedMediaTypes().add(new
Preference<MediaType>(MediaType.APPLICATION_RDF_XML));

Hope this helps,
Nina


On Fri, Sep 3, 2010 at 6:33 PM, surajit ray <mr.surajit.ray at gmail.com>wrote:

> Hi,
>
> Tried uploading using this piece of code
>
> ************************************
> System.out.println(result_dataset_URI);
>            Representation representation = new
> OutputRepresentation(MediaType.APPLICATION_RDF_XML) {
>
>                @Override
>                public void write(OutputStream out) throws IOException {
>                    resultDataset.write(out, "RDF/XML-ABBREV");
>                }
>            };
>
>            Request request = new Request();
>            Client client = new Client(Protocol.HTTP);
>            request.setResourceRef(result_dataset_URI);
>
>  request.setReferrerRef(MaxtoxApplicationSettings.getServerRootPath());
>            request.setMethod(Method.POST);
>            request.getClientInfo().getAcceptedMediaTypes().add(new
> Preference<MediaType>(MediaType.APPLICATION_RDF_XML));
>            request.setEntity(representation);
>
>
>            Response response = client.handle(request);
>            // Get the output from the response
>            Representation output = response.getEntity();
>            this.uploaded_URI = output.getText();
> ************************************
>
>
>
>
>
> I got this as the result
>
>
>
>
> *************************************
> 0.0 Error 1283527568408 File import application/rdf+xml [-1] The
> server has fulfilled the request but does not need to return an
> entity-body, and might want to return updated metainformation The
> server has fulfilled the request but does not need to return an
> entity-body, and might want to return updated metainformation 500
> *************************************
>
> Could you clarify ?
>
> I am using the http://apps.ideaconsult.net:8080/ambit2/dataset for
> testing as the other server was down - sorry for that.





> I just uploaded
> twice so you can delete 2 vague looking databases ...
>




> Regards
> Surajit
>
>
>
> On 3 September 2010 11:46, Nina Jeliazkova <jeliazkova.nina at gmail.com>
> wrote:
> > Hi Surajit,
> >
> > On Fri, Sep 3, 2010 at 1:50 AM, surajit ray <mr.surajit.ray at gmail.com>
> > wrote:
> >>
> >> From your previous example I gathered this
> >>
> >> RDFRepresentation r = new RDFRepresentation();
> >> Representation rep = r.createRepresentation(rdfDataset,
> >> MediaType.APPLICATION_RDF_XML);
> >>
> >> The problem is this representation does not exist in the stable
> >> version of Restlets !
> >
> > If you refer to opentox-client examples, then RDFRepresentation is not a
> > Restlet class at all, but custom one, using Jena writers for serializing
> > RDF.
> >
> >
> https://ambit.svn.sourceforge.net/svnroot/ambit/branches/opentox/opentox-client/src/main/java/org/opentox/rdf/representation/RDFRepresentation.java
> >
> > Restlet RDF support is rather minimalistic (graph representation, no
> > querying, let alone reasoning), I am not sure if any of the partners
> > actually uses it. If you are working with 1.x Restlet , there is indeed
> no
> > RDF support there. But Restlet RDF support can be safely ignored if you
> are
> > already using Jena (though I would be curious to see performance
> comparison
> > between the two).
> >
> > Using StringRepresentation/ FileRepresentation with media type
> > "application/rdf+xml" does the same job.  RDFRepresentation class
> discussed
> > above actually creates OutputStreamRepresentation.
> >
> > Upload examples can be found here
> >
> >
> https://ambit.svn.sourceforge.net/svnroot/ambit/branches/opentox/opentox-client/src/test/java/org/opentox/dataset/test/DatasetTest.java
> >
> https://ambit.svn.sourceforge.net/svnroot/ambit/branches/opentox/opentox-client/src/test/java/org/opentox/dataset/test/FeatureTest.java
> >
> > The examples above are cleaned up versions of ambit code. JUnit tests of
> > ambit dataset services can be found here
> >
> >
> https://ambit.svn.sourceforge.net/svnroot/ambit/trunk/ambit2-all/ambit2-www/src/test/java/ambit2/rest/test/dataset/DatasetsResourceTest.java
> >
> >
> >
> >>
> >> Also the example uses a RemoteTask to achieve the actual upload.
> >> Therefore I could not exactly fathom how to do the upload.
> >
> > Here is a summary
> >
> > curl -X POST -d "@filecontent" -H "Content-type:application/rdf+xml"
> > http://datasetservice/dataset
> >
> > This returns Task object (either URI, if -H "Accept:text/uri-list" is
> > specified or Task RDF representation if -H "Accept:application/rdf+xml"
> is
> > specified).  Task RDF representation is defined in
> > http://opentox.org/api/1_1/opentox.owl
> >
> > If the task is still running you'll get result codes 201 or 202 , this
> means
> > you need to query again the returned task URI.  If code 200 is returned,
> the
> > URI returned is where the result should be found.   In the examples there
> is
> > a RemoteTask class that handles all this.
> >
> >
> https://ambit.svn.sourceforge.net/svnroot/ambit/branches/opentox/opentox-client/src/main/java/org/opentox/task/RemoteTask.java
> >>
> >> On 3 September 2010 03:47, surajit ray <mr.surajit.ray at gmail.com>
> wrote:
> >> > Hi,
> >> >
> >> > I have managed to get a dataset (RDF) made using the results of a
> >> > model prediction run. Could you please tell me a dataset service where
> >> > I could upload the same ?
> >
> > For testing
> >
> > http://ambit-uni-plovdiv.bg:8080/ambit2/dataset
> >
> > For your final models/results , especially if you would like them
> appearing
> > in ToxPredict.
> >
> > http://apps.ideaconsult.net:8080/ambit2/dataset
> >
> >
> >>
> >> Also it would be very helpful if you could
> >> > give an example of an upload request using restlets ...
> >
> > See above.
> >
> > Hope this helps,
> > Nina
> >
> >
> >> >
> >> > Thanx
> >> > Surajit
> >> >
> >
> >
> >
>



-- 

Dr. Nina Jeliazkova
Technical Manager
4 A.Kanchev str.
IdeaConsult Ltd.
1000 Sofia, Bulgaria
Phone: +359 886 802011



More information about the Development mailing list