Search in sources :

Example 1 with RDFStructuresIterator

use of ambit2.rest.rdf.RDFStructuresIterator in project ambit-mirror by ideaconsult.

the class StaXRDFTest method testRDFXML.

@Test
public void testRDFXML() throws Exception {
    // testGet(getTestURI(),MediaType.APPLICATION_RDF_XML);
    RDFStructuresIterator i = new RDFStructuresIterator(new Reference(getTestURI()), "test");
    i.setBaseReference(new Reference(String.format("http://localhost:%d", port)));
    int count = 0;
    boolean propertyfound = false;
    while (i.hasNext()) {
        IStructureRecord record = i.next();
        Assert.assertTrue(record.getIdchemical() > 0);
        Assert.assertTrue(record.getIdstructure() > 0);
        int props = 0;
        for (Property p : record.getRecordProperties()) {
            System.out.println(p.getName());
            propertyfound = propertyfound || "Property 1".equals(p.getName());
            props++;
        }
        System.out.println(props);
        count++;
    }
    i.close();
    Assert.assertEquals(4, count);
    Assert.assertTrue(propertyfound);
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) Reference(org.restlet.data.Reference) Property(ambit2.base.data.Property) RDFStructuresIterator(ambit2.rest.rdf.RDFStructuresIterator) Test(org.junit.Test) ResourceTest(ambit2.rest.test.ResourceTest)

Example 2 with RDFStructuresIterator

use of ambit2.rest.rdf.RDFStructuresIterator in project ambit-mirror by ideaconsult.

the class DatasetReporterTest method testRDFXML.

@Test
public void testRDFXML() throws Exception {
    Reference ref = new Reference(String.format("http://localhost:%d/dataset/1?%s=%s", port, OpenTox.params.feature_uris.toString(), Reference.encode(String.format("http://localhost:%d%s", port, PropertyResource.featuredef))));
    RDFStructuresIterator iterator = new RDFStructuresIterator(ref, "test");
    iterator.setBaseReference(new Reference(String.format("http://localhost:%d", port)));
    while (iterator.hasNext()) {
        IStructureRecord target = iterator.next();
        Assert.assertTrue(target.getIdchemical() > 0);
        Assert.assertTrue(target.getIdstructure() > 0);
        Assert.assertNotNull(target.getRecordProperties());
        for (Property p : target.getRecordProperties()) {
            System.out.println(p);
            System.out.println(p.getId());
            System.out.println(target.getRecordProperty(p));
        }
        Assert.assertNotNull(target.getContent());
        Assert.assertEquals(MOL_TYPE.SDF.toString(), target.getFormat());
    }
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) Reference(org.restlet.data.Reference) Property(ambit2.base.data.Property) RDFStructuresIterator(ambit2.rest.rdf.RDFStructuresIterator) Test(org.junit.Test) ResourceTest(ambit2.rest.test.ResourceTest)

Example 3 with RDFStructuresIterator

use of ambit2.rest.rdf.RDFStructuresIterator in project ambit-mirror by ideaconsult.

the class RDFStructuresReader method createObjectIterator.

@Override
protected RDFObjectIterator<IStructureRecord> createObjectIterator(Reference target, MediaType mediaType) throws ResourceException {
    try {
        RDFStructuresIterator i = new RDFStructuresIterator(target, mediaType, referer);
        i.setBaseReference(new Reference(baseReference));
        return i;
    } catch (ResourceException x) {
        throw x;
    } catch (Exception x) {
        throw new ResourceException(x);
    }
}
Also used : Reference(org.restlet.data.Reference) ResourceException(org.restlet.resource.ResourceException) ResourceException(org.restlet.resource.ResourceException) RDFStructuresIterator(ambit2.rest.rdf.RDFStructuresIterator)

Example 4 with RDFStructuresIterator

use of ambit2.rest.rdf.RDFStructuresIterator in project ambit-mirror by ideaconsult.

the class StaXRDFTest method testSmartsQueryStax.

/**
 *<pre>
 *<rdf:RDF
 *    xmlns:ot="http://www.opentox.org/api/1.1#"
 *    xmlns:ac="http://localhost:8181/compound/"
 *    xmlns:bx="http://purl.org/net/nknouf/ns/bibtex#"
 *    xmlns:otee="http://www.opentox.org/echaEndpoints.owl#"
 *    xmlns:dc="http://purl.org/dc/elements/1.1/"
 *    xmlns:ar="http://localhost:8181/reference/"
 *    xmlns:ad="http://localhost:8181/dataset/"
 *    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 *    xmlns:am="http://localhost:8181/model/"
 *    xmlns:owl="http://www.w3.org/2002/07/owl#"
 *    xmlns:af="http://localhost:8181/feature/"
 *    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 *    xmlns:ota="http://www.opentox.org/algorithmTypes.owl#"
 *    xmlns="http://localhost:8181/"
 *    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
 *    xmlns:ag="http://localhost:8181/algorithm/"
 *  xml:base="http://localhost:8181/">
 *  <owl:Class rdf:about="http://www.opentox.org/api/1.1#Dataset"/>
 *  <owl:Class rdf:about="http://www.opentox.org/api/1.1#Compound"/>
 *  <owl:Class rdf:about="http://www.opentox.org/api/1.1#Feature"/>
 *  <owl:Class rdf:about="http://www.opentox.org/api/1.1#FeatureValue"/>
 *  <owl:Class rdf:about="http://www.opentox.org/api/1.1#DataEntry"/>
 *  <owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#dataEntry"/>
 *  <owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#compound"/>
 *  <owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/description"/>
 *  <ot:Dataset rdf:about="query/smarts">
 *    <ot:dataEntry>
 *      <ot:DataEntry>
 *        <ot:compound>
 *          <ot:Compound rdf:about="compound/11/conformer/100215"/>
 *        </ot:compound>
 *      </ot:DataEntry>
 *    </ot:dataEntry>
 *  </ot:Dataset>
 *  <owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/type"/>
 *  <owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/title"/>
 *</rdf:RDF>
 *</pre>
 *<pre>
 *<?xml version="1.0" ?>
 *<rdf:RDF xmlns:ot="http://www.opentox.org/api/1.1#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:dc="http://purl.org/dc/elements/1.1/">
 *<owl:Class rdf:about="http://www.opentox.org/api/1.1#Dataset">
 *</owl:Class><owl:Class rdf:about="http://www.opentox.org/api/1.1#DataEntry">
 *</owl:Class><owl:Class rdf:about="http://www.opentox.org/api/1.1#Feature">
 *</owl:Class><owl:Class rdf:about="http://www.opentox.org/api/1.1#FeatureValue">
 *</owl:Class><owl:Class rdf:about="http://www.opentox.org/api/1.1#Compound">
 *</owl:Class><owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#compound">
 *</owl:ObjectProperty><owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#dataEntry">
 *</owl:ObjectProperty><owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#values">
 *</owl:ObjectProperty><owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#feature">
 *</owl:ObjectProperty><owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#hasSource">
 *</owl:ObjectProperty><owl:ObjectProperty rdf:about="http://www.opentox.org/api/1.1#acceptValue">
 *</owl:ObjectProperty><owl:DatatypeProperty rdf:about="http://www.opentox.org/api/1.1#units">
 *</owl:DatatypeProperty><owl:DatatypeProperty rdf:about="http://www.opentox.org/api/1.1#value">
 *</owl:DatatypeProperty><owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/description">
 *</owl:AnnotationProperty><owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/creator">
 *</owl:AnnotationProperty><owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/type">
 *</owl:AnnotationProperty><owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/title">
 *</owl:AnnotationProperty>
 *<ot:Dataset rdf:about="http://localhost:8181/query/smarts"></ot:Dataset></rdf:RDF>
 *</pre>
 * @throws Exception
 */
@Test
public void testSmartsQueryStax() throws Exception {
    String rdfwriter = "stax";
    String uri = String.format("http://localhost:%d/query/smarts?rdfwriter=%s&search=%s", port, rdfwriter, Reference.encode("c1ccccc1"));
    RDFStructuresIterator i = new RDFStructuresIterator(new Reference(uri), "test");
    i.setBaseReference(new Reference(String.format("http://localhost:%d", port)));
    int count = 0;
    while (i.hasNext()) {
        IStructureRecord record = i.next();
        Assert.assertTrue(record.getIdchemical() > 0);
        Assert.assertTrue(record.getIdstructure() > 0);
        count++;
    }
    i.close();
    Assert.assertEquals(1, count);
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) Reference(org.restlet.data.Reference) RDFStructuresIterator(ambit2.rest.rdf.RDFStructuresIterator) Test(org.junit.Test) ResourceTest(ambit2.rest.test.ResourceTest)

Example 5 with RDFStructuresIterator

use of ambit2.rest.rdf.RDFStructuresIterator in project ambit-mirror by ideaconsult.

the class MissingFeatureValuesResourceTest method testRDFXML.

@Test
public void testRDFXML() throws Exception {
    RDFStructuresIterator iterator = new RDFStructuresIterator(createMissingValuesReference(), "test");
    iterator.setBaseReference(new Reference(String.format("http://localhost:%d", port)));
    int count = 0;
    while (iterator.hasNext()) {
        IStructureRecord target = iterator.next();
        Assert.assertTrue(target.getIdchemical() > 0);
        Assert.assertTrue(target.getIdstructure() > 0);
        Assert.assertNotNull(target.getRecordProperties());
        Assert.assertNotNull(target.getContent());
        Assert.assertEquals(MOL_TYPE.SDF.toString(), target.getFormat());
        count++;
    }
    Assert.assertEquals(3, count);
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) Reference(org.restlet.data.Reference) RDFStructuresIterator(ambit2.rest.rdf.RDFStructuresIterator) Test(org.junit.Test) ResourceTest(ambit2.rest.test.ResourceTest)

Aggregations

RDFStructuresIterator (ambit2.rest.rdf.RDFStructuresIterator)6 Reference (org.restlet.data.Reference)6 IStructureRecord (ambit2.base.interfaces.IStructureRecord)5 ResourceTest (ambit2.rest.test.ResourceTest)5 Test (org.junit.Test)5 Property (ambit2.base.data.Property)3 ResourceException (org.restlet.resource.ResourceException)1