use of ambit2.db.readers.RetrieveFieldPropertyValue in project ambit-mirror by ideaconsult.
the class PropertyValueResource method createQuery.
@Override
protected IQueryRetrieval<T> createQuery(Context context, Request request, Response response) throws ResourceException {
RetrieveFieldPropertyValue field = new RetrieveFieldPropertyValue();
field.setSearchByAlias(true);
IStructureRecord record = new StructureRecord();
try {
record.setIdchemical(Integer.parseInt(Reference.decode(request.getAttributes().get(DataResources.idcompound_resource).toString())));
} catch (NumberFormatException x) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, String.format("Invalid resource id %d", request.getAttributes().get(DataResources.idcompound_resource)), x);
}
try {
record.setIdstructure(Integer.parseInt(Reference.decode(request.getAttributes().get(DataResources.idconformer_resource).toString())));
field.setChemicalsOnly(false);
} catch (Exception x) {
field.setChemicalsOnly(true);
} finally {
field.setValue(record);
}
try {
field.setFieldname(null);
Object name = request.getAttributes().get("name");
if (name != null) {
name = Reference.decode(name.toString());
field.setFieldname(Property.getInstance(name.toString(), LiteratureEntry.getInstance()));
}
} catch (Exception x) {
field.setFieldname(null);
}
return (IQueryRetrieval) field;
}
Aggregations