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;
}
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();
}
Aggregations