Search in sources :

Example 1 with RetrieveFieldPropertyValue

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;
}
Also used : RetrieveFieldPropertyValue(ambit2.db.readers.RetrieveFieldPropertyValue) IStructureRecord(ambit2.base.interfaces.IStructureRecord) IStructureRecord(ambit2.base.interfaces.IStructureRecord) StructureRecord(ambit2.base.data.StructureRecord) ResourceException(org.restlet.resource.ResourceException) IQueryRetrieval(net.idea.modbcum.i.IQueryRetrieval) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) ResourceException(org.restlet.resource.ResourceException)

Aggregations

StructureRecord (ambit2.base.data.StructureRecord)1 IStructureRecord (ambit2.base.interfaces.IStructureRecord)1 RetrieveFieldPropertyValue (ambit2.db.readers.RetrieveFieldPropertyValue)1 IQueryRetrieval (net.idea.modbcum.i.IQueryRetrieval)1 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)1 ResourceException (org.restlet.resource.ResourceException)1