use of ambit2.base.data.LiteratureEntry in project ambit-mirror by ideaconsult.
the class BundleChemicalsResource method setGroupProperties.
protected void setGroupProperties(Context context, Request request, Response response) throws ResourceException {
groupProperties = new Profile();
Form form = getParams();
String[] gp = OpenTox.params.sameas.getValuesArray(form);
if (gp == null || gp.length == 0)
gp = new String[] { "http://www.opentox.org/api/1.1#ChemicalName", "http://www.opentox.org/api/1.1#CASRN", "http://www.opentox.org/api/1.1#EINECS" };
for (String g : gp) {
Property p = new Property(g);
p.setEnabled(true);
p.setLabel(g);
groupProperties.add(p);
}
if (enableFeatures) {
LiteratureEntry ref = LiteratureEntry.getBundleReference(bundle);
Property p = new Property("tag", ref);
p.setEnabled(true);
groupProperties.add(p);
p = new Property("remarks", ref);
p.setEnabled(true);
groupProperties.add(p);
}
}
use of ambit2.base.data.LiteratureEntry in project ambit-mirror by ideaconsult.
the class PropertyResourceTest method testCreateEntry.
/**
* <pre>
* <rdf:RDF
* xmlns:j.0="http://purl.org/net/nknouf/ns/bibtex#"
* xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
* xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
* xmlns:ot="http://www.opentox.org/api/1.1#"
* xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
* xmlns:owl="http://www.w3.org/2002/07/owl#"
* xmlns:dc="http://purl.org/dc/elements/1.1/" >
* <rdf:Description rdf:about="http://www.opentox.org/api/1.1#units">
* <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
* </rdf:Description>
* <rdf:Description rdf:about="http://purl.org/net/nknouf/ns/bibtex#Entry">
* <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
* </rdf:Description>
* <rdf:Description rdf:about="http://www.opentox.org/api/1.1#hasSource">
* <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
* </rdf:Description>
* <rdf:Description rdf:nodeID="A0">
* <rdfs:seeAlso>bbb</rdfs:seeAlso>
* <dc:title>aaa</dc:title>
* <rdf:type rdf:resource="http://purl.org/net/nknouf/ns/bibtex#Entry"/>
* </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:Description rdf:nodeID="A1">
* <dc:type>http://www.w3.org/2001/XMLSchema#string</dc:type>
* <ot:hasSource rdf:nodeID="A0"/>
* <owl:sameAs>CasRN</owl:sameAs>
* <ot:units></ot:units>
* <dc:title>cas</dc:title>
* <rdf:type rdf:resource="http://www.opentox.org/api/1.1#Feature"/>
* </rdf:Description>
* </rdf:RDF>
* </pre>
*
* @throws Exception
*/
@Test
public void testCreateEntry() throws Exception {
OntModel model = OT.createModel();
Property p = new Property("cas", new LiteratureEntry("aaa", "bbb"));
p.setNominal(true);
PropertyRDFReporter.addToModel(model, p, new PropertyURIReporter(new Reference(String.format("http://localhost:%d%s", port, PropertyResource.featuredef))), new ReferenceURIReporter());
StringWriter writer = new StringWriter();
model.write(writer, "RDF/XML");
System.out.println(writer.toString());
Response response = testPost(String.format("http://localhost:%d%s", port, PropertyResource.featuredef), MediaType.APPLICATION_RDF_XML, writer.toString());
Assert.assertEquals(Status.SUCCESS_OK, response.getStatus());
// Assert.assertEquals("http://localhost:8181/feature/4",
// response.getLocationRef().toString());
IDatabaseConnection c = getConnection();
ITable table = c.createQueryTable("EXPECTED", String.format("SELECT * FROM properties join catalog_references using(idreference) where name='cas' and comments='%s' and title='aaa' and url='bbb' and isLocal=1", Property.opentox_CAS));
Assert.assertEquals(1, table.getRowCount());
c.close();
}
use of ambit2.base.data.LiteratureEntry in project ambit-mirror by ideaconsult.
the class PropertyResourceTest method testUpdateExistingEntry.
@Test
public void testUpdateExistingEntry() throws Exception {
// now we can only update by PUT, not POST
Property p = new Property("Property 1", new LiteratureEntry("Dummy", "NA"));
p.setLabel("Test");
p.setNominal(true);
OntModel model = OT.createModel();
PropertyRDFReporter.addToModel(model, p, new PropertyURIReporter(new Reference(String.format("http://localhost:%d%s", port, PropertyResource.featuredef))), new ReferenceURIReporter());
StringWriter writer = new StringWriter();
model.write(writer, "RDF/XML");
Response response = testPut(String.format("http://localhost:%d%s/1", port, PropertyResource.featuredef), MediaType.TEXT_URI_LIST, new StringRepresentation(writer.toString(), MediaType.APPLICATION_RDF_XML));
Assert.assertEquals(Status.SUCCESS_OK, response.getStatus());
IDatabaseConnection c = getConnection();
ITable table = c.createQueryTable("EXPECTED", String.format("SELECT isLocal FROM properties join catalog_references using(idreference) where name='Property 1' and comments='%s' and title='Dummy' and url='NA'", "http://www.opentox.org/api/1.1#Test"));
Assert.assertEquals(1, table.getRowCount());
Assert.assertEquals(true, table.getValue(0, "isLocal"));
c.close();
Assert.assertEquals("http://localhost:8181/feature/1", response.getLocationRef().toString());
}
use of ambit2.base.data.LiteratureEntry in project ambit-mirror by ideaconsult.
the class PropertyResourceTest method testUpdateExistingEntry1.
// this fails because of mysql foreign key constraints
public void testUpdateExistingEntry1() throws Exception {
Property p = new Property("Property 1", new LiteratureEntry("Dummy 1", "NA"));
p.setLabel("Test");
p.setId(1);
OntModel model = OT.createModel();
PropertyRDFReporter.addToModel(model, p, new PropertyURIReporter(new Reference(String.format("http://localhost:%d%s", port))), new ReferenceURIReporter());
StringWriter writer = new StringWriter();
model.write(writer, "RDF/XML");
Response response = testPost(String.format("http://localhost:%d%s/2", port, PropertyResource.featuredef), MediaType.APPLICATION_RDF_XML, writer.toString());
Assert.assertEquals(Status.SUCCESS_OK, response.getStatus());
IDatabaseConnection c = getConnection();
ITable table = c.createQueryTable("EXPECTED", String.format("SELECT * FROM properties join catalog_references using(idreference) where name='Property 1' and comments='%s' and title='Dummy' and url='NA'", "http://www.opentox.org/api/1.1#Test"));
Assert.assertEquals(1, table.getRowCount());
c.close();
Assert.assertEquals("http://localhost:8181/feature/2", response.getLocationRef().toString());
}
use of ambit2.base.data.LiteratureEntry in project ambit-mirror by ideaconsult.
the class MetaDatasetResourceTest method testUpdateExistingEntry.
@Test
public void testUpdateExistingEntry() throws Exception {
// name and license uri can be updated only (for now)
String name = "New dataset name";
String title = "AAAA";
String url = "BBBB";
SourceDataset p = new SourceDataset(name, new LiteratureEntry(title, url));
p.setLicenseURI(ISourceDataset.license.CC0_1_0.getURI());
OntModel model = OT.createModel();
DatasetURIReporter uriReporter = new DatasetURIReporter(new Reference(String.format("http://localhost:%d", port)));
MetadataRDFReporter.addToModel(model, p, uriReporter.getURI(p));
StringWriter writer = new StringWriter();
model.write(writer, "RDF/XML");
System.out.println(writer.toString());
Response response = testPut(getTestURI(), MediaType.TEXT_URI_LIST, new StringRepresentation(writer.toString(), MediaType.APPLICATION_RDF_XML));
Assert.assertEquals(Status.SUCCESS_OK, response.getStatus());
IDatabaseConnection c = getConnection();
ITable table = c.createQueryTable("EXPECTED", String.format("SELECT * FROM src_dataset join catalog_references using(idreference) where name='%s' and licenseURI='%s' ", name, ISourceDataset.license.CC0_1_0.getURI()));
Assert.assertEquals(1, table.getRowCount());
c.close();
Assert.assertEquals("http://localhost:8181/dataset/1/metadata", response.getLocationRef().toString());
}
Aggregations