Search in sources :

Example 1 with CallableSubstancePropertyCreator

use of ambit2.rest.substance.property.CallableSubstancePropertyCreator in project ambit-mirror by ideaconsult.

the class CallableSubstancePropertyCreatorTest method testCreateSubstanceProperty.

@Test
public void testCreateSubstanceProperty() throws Exception {
    Form form = new Form();
    form.add("endpointcategory", Protocol._categories.ZETA_POTENTIAL_SECTION.name());
    form.add("name", "ZETA POTENTIAL");
    form.add("unit", "mV");
    form.add("protocol", "Method: other: no data");
    Params p = new Params();
    Value v = new Value();
    v.setLoValue(4.26);
    p.put("pH", v);
    Assert.assertEquals("{\"pH\":{\"loValue\":4.26}}", p.toString());
    try {
        PropertyURIReporter reporter = new PropertyURIReporter(new Reference("http://localhost:8081/ambit2"));
        CallableSubstancePropertyCreator callable = new CallableSubstancePropertyCreator(reporter, Method.POST, form, null, null);
        TaskResult task = callable.call();
        Assert.assertTrue(task.getUri().startsWith("http://localhost:8081/ambit2/property/P-CHEM/ZETA_POTENTIAL_SECTION/ZETA+POTENTIAL/A597EBC063D7A5A605B9535656E09149A72F0C23"));
    // "http://localhost:8081/ambit2/property/P-CHEM/ZETA_POTENTIAL_SECTION/ZETA+POTENTIAL/945DEEC24F876DEE6116F92646EF729107F5B5FD"
    } catch (Exception x) {
        throw x;
    } finally {
    }
}
Also used : Form(org.restlet.data.Form) Reference(org.restlet.data.Reference) Value(ambit2.base.data.study.Value) Params(ambit2.base.data.study.Params) IParams(ambit2.base.data.study.IParams) TaskResult(net.idea.restnet.i.task.TaskResult) CallableSubstancePropertyCreator(ambit2.rest.substance.property.CallableSubstancePropertyCreator) PropertyURIReporter(ambit2.rest.property.PropertyURIReporter) DbUnitTest(net.idea.restnet.db.test.DbUnitTest) Test(org.junit.Test)

Example 2 with CallableSubstancePropertyCreator

use of ambit2.rest.substance.property.CallableSubstancePropertyCreator in project ambit-mirror by ideaconsult.

the class CallableSubstancePropertyCreatorTest method testCreateSubstanceProperty_TO_BIODEG_WATER_SCREEN_SECTION.

/**
 * @throws Exception
 */
@Test
public void testCreateSubstanceProperty_TO_BIODEG_WATER_SCREEN_SECTION() throws Exception {
    Form form = new Form();
    form.add("endpointcategory", Protocol._categories.TO_BIODEG_WATER_SCREEN_SECTION.name());
    form.add("name", "% Degradation");
    form.add("unit", "%");
    form.add("protocol", "Method: other: no data");
    Params p = new Params();
    Value v = new Value();
    v.setUnits("d");
    v.setLoValue(7.0);
    p.put("Sampling time", v);
    form.add("conditions", p.toString());
    Assert.assertEquals("{\"Sampling time\":{\"loValue\":7,\"unit\":\"d\"}}", p.toString());
    try {
        PropertyURIReporter reporter = new PropertyURIReporter(new Reference("http://localhost:8081/ambit2"));
        CallableSubstancePropertyCreator callable = new CallableSubstancePropertyCreator(reporter, Method.POST, form, null, null);
        TaskResult task = callable.call();
        Assert.assertTrue(task.getUri().startsWith("http://localhost:8081/ambit2/property/ENV+FATE/TO_BIODEG_WATER_SCREEN_SECTION/%25+Degradation/3CF77D9EFE4E74744E691BF4880B4EF728B16FAE"));
    // /d4cd0dab-cf4c-3a22-ad92-fab40844c786
    /*
			 * "http://localhost:8080/ambit2/property/ENV+FATE/TO_BIODEG_WATER_SCREEN_SECTION/%25+Degradation/5FA6EFD4E83BEC47B626C6149DBBD3907084187F/1f255895-eb7d-37dc-8eb8-bc9580d8be25"
			 * :{
			 * 
			 * "type":"Feature", "title":"% Degradation", "units":"%",
			 * "isNominal":false, "isNumeric":false, "isMultiValue":true,
			 * "sameAs"
			 * :"http://www.opentox.org/echaEndpoints.owl#TO_BIODEG_WATER_SCREEN"
			 * , "isModelPredictionFeature":false,
			 * "creator":"Method: other: see below", "order":1087, "source":{
			 * "URI"
			 * :"http://localhost:8080/ambit2/dataset/Method%3A+other%3A+see+below"
			 * , "type":"Dataset" }, "annotation":[ { "p" : "Sampling time", "o"
			 * : "7.0 d"}]
			 * 
			 * },
			 */
    // http://localhost:8081/ambit2/property/P-CHEM/TO_BIODEG_WATER_SCREEN_SECTION/%25+Degradation/8C9DF1AF60CA3D8706C0156361E97E0DF4391C10/1f255895-eb7d-37dc-8eb8-bc9580d8be25
    } catch (Exception x) {
        throw x;
    } finally {
    }
}
Also used : Form(org.restlet.data.Form) Reference(org.restlet.data.Reference) Value(ambit2.base.data.study.Value) Params(ambit2.base.data.study.Params) IParams(ambit2.base.data.study.IParams) TaskResult(net.idea.restnet.i.task.TaskResult) CallableSubstancePropertyCreator(ambit2.rest.substance.property.CallableSubstancePropertyCreator) PropertyURIReporter(ambit2.rest.property.PropertyURIReporter) DbUnitTest(net.idea.restnet.db.test.DbUnitTest) Test(org.junit.Test)

Example 3 with CallableSubstancePropertyCreator

use of ambit2.rest.substance.property.CallableSubstancePropertyCreator in project ambit-mirror by ideaconsult.

the class CallableSubstancePropertyCreatorTest method testCreateSubstancePropertyFromRDF.

@Test
public void testCreateSubstancePropertyFromRDF() throws Exception {
    URL url = getClass().getClassLoader().getResource("feature.rdf");
    File file = new File(url.getFile());
    Assert.assertTrue(file.exists());
    try {
        PropertyURIReporter reporter = new PropertyURIReporter(new Reference("http://localhost:8081/ambit2"));
        CallableSubstancePropertyCreator callable = new CallableSubstancePropertyCreator(reporter, Method.POST, file, MediaType.APPLICATION_RDF_XML, null, null);
        TaskResult task = callable.call();
        ProtocolEffectRecord2SubstanceProperty p = new ProtocolEffectRecord2SubstanceProperty();
        ProtocolEffectRecord<String, IParams, String> effect = new ProtocolEffectRecord<String, IParams, String>();
        Protocol protocol = new Protocol(null);
        Protocol._categories category = Protocol._categories.EC_DAPHNIATOX_SECTION;
        protocol.setCategory(category.name());
        protocol.setTopCategory(category.getTopCategory());
        protocol.addGuideline("http://localhost:8080/ambit2/dataset/Method%3A+other%3A+Am.+Soc.+Test.+Mater.+%281980%29+and+U.S.+EPA+%281975%29");
        effect.setProtocol(protocol);
        effect.setEndpoint("EC10");
        effect.setUnit("mg/L");
        effect.setConditions(new Params());
        /*
			 * Value value = new Value(); value.setLoValue(48.0);
			 * value.setUnits("h"); effect.getConditions().put("Exposure",
			 * value);
			 */
        SubstanceProperty prop = p.process(effect);
        prop.setIdentifier(prop.createHashedIdentifier(effect.getConditions()));
        Assert.assertEquals(reporter.getURI(prop), task.getUri());
    } catch (Exception x) {
        throw x;
    } finally {
    }
}
Also used : Reference(org.restlet.data.Reference) ProtocolEffectRecord2SubstanceProperty(ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty) Params(ambit2.base.data.study.Params) IParams(ambit2.base.data.study.IParams) URL(java.net.URL) PropertyURIReporter(ambit2.rest.property.PropertyURIReporter) ProtocolEffectRecord(ambit2.base.data.study.ProtocolEffectRecord) TaskResult(net.idea.restnet.i.task.TaskResult) IParams(ambit2.base.data.study.IParams) SubstanceProperty(ambit2.base.data.substance.SubstanceProperty) ProtocolEffectRecord2SubstanceProperty(ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty) CallableSubstancePropertyCreator(ambit2.rest.substance.property.CallableSubstancePropertyCreator) Protocol(ambit2.base.data.study.Protocol) File(java.io.File) DbUnitTest(net.idea.restnet.db.test.DbUnitTest) Test(org.junit.Test)

Aggregations

IParams (ambit2.base.data.study.IParams)3 Params (ambit2.base.data.study.Params)3 PropertyURIReporter (ambit2.rest.property.PropertyURIReporter)3 CallableSubstancePropertyCreator (ambit2.rest.substance.property.CallableSubstancePropertyCreator)3 DbUnitTest (net.idea.restnet.db.test.DbUnitTest)3 TaskResult (net.idea.restnet.i.task.TaskResult)3 Test (org.junit.Test)3 Reference (org.restlet.data.Reference)3 Value (ambit2.base.data.study.Value)2 Form (org.restlet.data.Form)2 Protocol (ambit2.base.data.study.Protocol)1 ProtocolEffectRecord (ambit2.base.data.study.ProtocolEffectRecord)1 SubstanceProperty (ambit2.base.data.substance.SubstanceProperty)1 ProtocolEffectRecord2SubstanceProperty (ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty)1 File (java.io.File)1 URL (java.net.URL)1