use of ambit2.base.data.Property in project ambit-mirror by ideaconsult.
the class SubstancePropertyresourceTest method testCreateEntry2.
@Test
public void testCreateEntry2() throws Exception {
EffectRecord<String, IParams, String> effect = new EffectRecord<String, IParams, String>();
effect.setConditions(new Params());
effect.setEndpoint("EC10");
effect.setUnit("mg/L");
IParams conditions = new Params();
effect.setConditions(conditions);
/*
Value v = new Value();
v.setUnits("h");
v.setLoValue(48.0);
effect.getConditions().put("EC_DAPHNIATOX",v);
*/
// System.out.println(effect);
SubstanceProperty prop = new SubstanceProperty(null, null, effect.getEndpoint(), effect.getUnit(), null);
String key = prop.createHashedIdentifier(effect.getConditions());
UUID protocol_uuid = UUID.nameUUIDFromBytes("http://localhost:8080/ambit2/dataset/Method%3A+other%3A+Am.+Soc.+Test.+Mater.+%281980%29+and+U.S.+EPA+%281975%29".getBytes());
URL url = getClass().getClassLoader().getResource("feature.rdf");
FileRepresentation rep = new FileRepresentation(url.getFile(), MediaType.APPLICATION_RDF_XML, 0);
testAsyncPoll(new Reference(getTestURI()), MediaType.TEXT_URI_LIST, rep, Method.POST, new Reference(String.format("http://localhost:%d/property/ECOTOX/EC_DAPHNIATOX_SECTION/EC10/%s/NOTSPECIFIED/%s", port, key.toUpperCase(), protocol_uuid)));
}
use of ambit2.base.data.Property 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);
}
use of ambit2.base.data.Property 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 {
}
}
use of ambit2.base.data.Property 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 {
}
}
use of ambit2.base.data.Property in project ambit-mirror by ideaconsult.
the class ChartResource method createImage.
protected BufferedImage createImage() throws ResourceException {
BufferedImage image = null;
Connection connection = null;
try {
DBConnection dbc = new DBConnection(getContext());
connection = dbc.getConnection();
ambit2.base.data.Template profile = new ambit2.base.data.Template();
ProfileReader reader = new ProfileReader(getRequest().getRootRef(), profile, getApplication().getContext(), getToken(), getRequest().getCookies(), getRequest().getClientInfo() == null ? null : getRequest().getClientInfo().getAgent(), getRequest().getResourceRef().toString());
reader.setCloseConnection(false);
reader.setConnection(connection);
for (String p : property) reader.process(new Reference(p));
switch(mode) {
case pie:
{
Iterator<Property> i = profile.getProperties(true);
while (i.hasNext()) {
PieChartGenerator<ISourceDataset> chart = new PieChartGenerator<ISourceDataset>();
chart.setProperty(i.next());
chart.setConnection(connection);
chart.setLegend(legend);
chart.setThumbnail(thumbnail);
chart.setWidth(w);
chart.setHeight(h);
chart.setLogX(logX);
chart.setLogY(logY);
image = chart.process(dataset);
// ChartUtilities.writeImageMap(writer, name, info, useOverLibForToolTips)
break;
}
break;
}
case histogram:
{
Iterator<Property> i = profile.getProperties(true);
while (i.hasNext()) {
HistogramChartGenerator chart = new HistogramChartGenerator();
chart.setLogX(logX);
chart.setLogY(logY);
chart.setMinX(minX);
chart.setMaxX(maxX);
chart.setPropertyX(i.next());
chart.setConnection(connection);
chart.setLegend(legend);
chart.setThumbnail(thumbnail);
chart.setWidth(w);
chart.setHeight(h);
image = chart.process(dataset);
// ChartUtilities.writeImageMap(writer, name, info, useOverLibForToolTips)
break;
}
break;
}
case xy:
{
Property[] p = new Property[2];
int i = 0;
Iterator<Property> it = profile.getProperties(true);
while (it.hasNext()) {
p[i] = it.next();
i++;
if (i >= 2)
break;
}
PropertiesChartGenerator chart = new PropertiesChartGenerator();
chart.setLogX(logX);
chart.setLogY(logY);
chart.setThumbnail(thumbnail);
chart.setPropertyX(p[0]);
chart.setPropertyY(p.length < 2 ? p[0] : p[1]);
chart.setConnection(connection);
chart.setWidth(w);
chart.setHeight(h);
chart.setLegend(legend);
image = chart.process(dataset);
break;
}
case bar:
{
Property[] p = new Property[2];
int i = 0;
Iterator<Property> it = profile.getProperties(true);
while (it.hasNext()) {
p[i] = it.next();
i++;
if (i >= 2)
break;
}
if (i == 0) {
FingerprintHistogramDataset chart = new FingerprintHistogramDataset();
chart.setLogX(logX);
chart.setLogY(logY);
chart.setConnection(connection);
chart.setLegend(legend);
chart.setParam(param);
chart.setThumbnail(thumbnail);
chart.setWidth(w);
chart.setHeight(h);
image = chart.process(dataset);
} else {
BarChartGeneratorDataset chart = new BarChartGeneratorDataset();
chart.setLogX(logX);
chart.setLogY(logY);
chart.setPropertyX(p[0]);
chart.setPropertyY(p.length < 2 ? p[0] : p[1]);
chart.setConnection(connection);
chart.setLegend(legend);
chart.setThumbnail(thumbnail);
chart.setWidth(w);
chart.setHeight(h);
image = chart.process(dataset);
}
break;
}
default:
{
image = null;
}
}
} catch (Exception x) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, x.getMessage(), x);
} finally {
try {
connection.close();
} catch (Exception x) {
}
}
if (image == null)
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST);
return image;
}
Aggregations