Search in sources :

Example 1 with RetrieveDescriptor

use of ambit2.db.readers.RetrieveDescriptor in project ambit-mirror by ideaconsult.

the class RetrieveDescriptorTest method createQuery.

@Override
protected IQueryRetrieval<DescriptorValue> createQuery() {
    RetrieveDescriptor q = new RetrieveDescriptor();
    q.setValue(new StructureRecord(0, 100215, "", ""));
    return q;
}
Also used : RetrieveDescriptor(ambit2.db.readers.RetrieveDescriptor) StructureRecord(ambit2.base.data.StructureRecord)

Example 2 with RetrieveDescriptor

use of ambit2.db.readers.RetrieveDescriptor in project ambit-mirror by ideaconsult.

the class RetrieveDescriptorTest method testGetObject.

@Test
public void testGetObject() throws Exception {
    setUpDatabaseFromResource(getTestDatabase());
    IDatabaseConnection c = getConnection();
    ITable names = c.createQueryTable("EXPECTED_DATASETS", "SELECT id,idproperty,idstructure,value_num as value,status,user_name FROM property_values where value_num is not null");
    Assert.assertEquals(4, names.getRowCount());
    QueryExecutor<RetrieveDescriptor> qe = new QueryExecutor<RetrieveDescriptor>();
    qe.setConnection(c.getConnection());
    ResultSet rs = qe.process((RetrieveDescriptor) query);
    int count = 0;
    while (rs.next()) {
        DescriptorValue value = query.getObject(rs);
        double d = ((DoubleResult) value.getValue()).doubleValue();
        String[] descrnames = value.getNames();
        for (String name : descrnames) {
            String sql = "SELECT value_num,name FROM properties join property_values using(idproperty) where name='" + name + "' and value_num=" + d;
            names = c.createQueryTable("EXPECTED_DATASETS", sql);
            Assert.assertEquals(1, names.getRowCount());
        }
        count++;
    }
    Assert.assertEquals(2, count);
    rs.close();
    qe.close();
    c.close();
}
Also used : RetrieveDescriptor(ambit2.db.readers.RetrieveDescriptor) QueryExecutor(ambit2.db.search.QueryExecutor) ResultSet(java.sql.ResultSet) ITable(org.dbunit.dataset.ITable) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DoubleResult(org.openscience.cdk.qsar.result.DoubleResult) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Aggregations

RetrieveDescriptor (ambit2.db.readers.RetrieveDescriptor)2 StructureRecord (ambit2.base.data.StructureRecord)1 QueryExecutor (ambit2.db.search.QueryExecutor)1 ResultSet (java.sql.ResultSet)1 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)1 ITable (org.dbunit.dataset.ITable)1 Test (org.junit.Test)1 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)1 DoubleResult (org.openscience.cdk.qsar.result.DoubleResult)1