use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.
the class QLabelQueryResource method createQuery.
@Override
protected IQueryRetrieval<IStructureRecord> createQuery(Context context, Request request, Response response) throws ResourceException {
QueryStructureByQuality q = new QueryStructureByQuality();
Form form = request.getResourceRef().getQueryAsForm();
try {
includeMol = "true".equals(form.getFirstValue("mol"));
} catch (Exception x) {
includeMol = false;
}
Object key = form.getFirstValue(QueryResource.search_param);
if (key != null) {
try {
q.setValue(new QLabel(QUALITY.valueOf(Reference.decode(key.toString()))));
} catch (Exception x) {
StringBuilder b = new StringBuilder();
b.append("Valid values are ");
for (QUALITY v : QUALITY.values()) {
b.append(v);
b.append('\t');
}
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, b.toString(), x);
}
} else {
q.setValue(new QLabel(QUALITY.OK));
}
Object id = request.getAttributes().get(OpenTox.URI.dataset.getKey());
if (id != null)
try {
datasetID = Integer.parseInt(id.toString());
SourceDataset dataset = new SourceDataset();
dataset.setId(datasetID);
q.setFieldname(dataset);
return q;
} catch (Exception x) {
if (id.toString().startsWith("R")) {
queryResultsID = Integer.parseInt(id.toString().substring(1));
StoredQuery dataset = new StoredQuery();
dataset.setId(queryResultsID);
q.setFieldname(dataset);
return q;
} else
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid dataset id");
}
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No dataset !");
}
use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.
the class QueryQLabel method getObject.
public QLabel getObject(ResultSet rs) throws AmbitException {
try {
QLabel label = new QLabel();
label.setUser(new AmbitUser(rs.getString(2)));
label.setLabel(QUALITY.valueOf(rs.getString(3)));
label.setText(rs.getString(4));
return label;
} catch (SQLException x) {
throw new AmbitException(x);
}
}
use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.
the class QueryStructurebyQualityTest method verify.
@Override
protected void verify(QueryStructureByQuality query, ResultSet rs) throws Exception {
while (rs.next()) {
IStructureRecord record = query.getObject(rs);
Assert.assertEquals(10, record.getIdchemical());
Assert.assertEquals(100214, record.getIdstructure());
Assert.assertEquals(new QLabel(QUALITY.OK), query.retrieveValue(rs));
}
}
use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.
the class QueryQLabelTest method verify.
@Override
protected void verify(QueryQLabel query, ResultSet rs) throws Exception {
while (rs.next()) {
QLabel q = query.getObject(rs);
Assert.assertEquals(QUALITY.OK, q.getLabel());
Assert.assertEquals("guest", q.getUser().getName());
}
}
use of ambit2.base.data.QLabel in project ambit-mirror by ideaconsult.
the class StructureQLabel_crud_test method createQuery.
@Override
protected IQueryUpdate<IStructureRecord, QLabel> createQuery() throws Exception {
CreateStructureQLabel q = new CreateStructureQLabel();
q.setGroup(new StructureRecord(-1, 100211, null, null));
q.setObject(new QLabel(QUALITY.ProbablyOK));
return q;
}
Aggregations