Search in sources :

Example 1 with QueryField

use of ambit2.db.search.structure.QueryField in project ambit-mirror by ideaconsult.

the class CompoundLookup method getTextQuery.

protected QueryField getTextQuery(Property property, boolean caseSensitive, boolean retrieveProperties, String value) {
    if (value.startsWith(chebiuri))
        value = value.replace(chebiuri, "");
    StringCondition sc = StringCondition.getInstance(getCondition());
    // TODO check for regexp validity
    QueryField q_by_name = new QueryField();
    q_by_name.setFieldname(property);
    q_by_name.setCaseSensitive(caseSensitive);
    q_by_name.setRetrieveProperties(retrieveProperties);
    q_by_name.setSearchByAlias(true);
    q_by_name.setNameCondition(StringCondition.getInstance(StringCondition.C_EQ));
    q_by_name.setCondition(sc);
    q_by_name.setChemicalsOnly(true);
    q_by_name.setValue(value == null ? null : value.toString());
    return q_by_name;
}
Also used : QueryField(ambit2.db.search.structure.QueryField) StringCondition(net.idea.modbcum.q.conditions.StringCondition)

Example 2 with QueryField

use of ambit2.db.search.structure.QueryField in project ambit-mirror by ideaconsult.

the class CompoundResource method createSingleQuery.

protected IQueryRetrieval<IStructureRecord> createSingleQuery(String property, String cond, String key, boolean chemicalsOnly, boolean byAlias, boolean caseSens) {
    AbstractStructureQuery query;
    try {
        key = Reference.decode(key.toString().trim());
        query = new QueryFieldNumeric(key, cond, byAlias, chemicalsOnly, (property == null) ? null : new Property(property, null));
    } catch (Exception x) {
        QueryField q_by_name = new QueryField();
        q_by_name.setCaseSensitive(caseSens);
        q_by_name.setRetrieveProperties(true);
        q_by_name.setSearchByAlias(byAlias);
        q_by_name.setNameCondition(StringCondition.getInstance(StringCondition.C_EQ));
        q_by_name.setChemicalsOnly(chemicalsOnly);
        // q_by_name.setChemicalsOnly(true);
        StringCondition condition = StringCondition.getInstance(StringCondition.C_EQ);
        try {
            condition = (cond == null) || ("".equals(cond)) ? StringCondition.getInstance(StringCondition.C_EQ) : StringCondition.getInstance(cond);
        } catch (Exception xx) {
            condition = StringCondition.getInstance(StringCondition.C_EQ);
        } finally {
            q_by_name.setCondition(condition);
            q_by_name.setValue(String.format("%s%s", Reference.decode(key.toString()), condition.toString().equals(StringCondition.C_LIKE) ? "%" : ""));
            if ((property != null) && (!"".equals(property)))
                q_by_name.setFieldname(new Property(String.format("%s%s", property, condition.toString().equals(StringCondition.C_LIKE) ? "%" : ""), null));
        }
        query = q_by_name;
    }
    return query;
}
Also used : QueryField(ambit2.db.search.structure.QueryField) QueryFieldNumeric(ambit2.db.search.structure.QueryFieldNumeric) Property(ambit2.base.data.Property) AbstractStructureQuery(ambit2.db.search.structure.AbstractStructureQuery) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) ResourceException(org.restlet.resource.ResourceException) NotFoundException(net.idea.modbcum.i.exceptions.NotFoundException) StringCondition(net.idea.modbcum.q.conditions.StringCondition)

Example 3 with QueryField

use of ambit2.db.search.structure.QueryField in project ambit-mirror by ideaconsult.

the class PropertyImporter method setPropertyKey.

public void setPropertyKey(IStructureKey propertyKey) {
    this.queryKey = propertyKey;
    if ((propertyKey instanceof SmilesKey) || (propertyKey instanceof InchiKey)) {
        query_property = new QueryStructure();
    } else if ((propertyKey.getType() == Number.class) || (propertyKey.getType() == Integer.class) || (propertyKey.getType() == Double.class))
        query_property = new QueryFieldNumeric();
    else
        query_property = new QueryField();
    query_property.setId(-1);
}
Also used : QueryField(ambit2.db.search.structure.QueryField) QueryStructure(ambit2.db.search.structure.QueryStructure) SmilesKey(ambit2.core.processors.structure.key.SmilesKey) QueryFieldNumeric(ambit2.db.search.structure.QueryFieldNumeric) InchiKey(ambit2.core.processors.structure.key.InchiKey)

Example 4 with QueryField

use of ambit2.db.search.structure.QueryField in project ambit-mirror by ideaconsult.

the class QueryInfo2Query method createQueryField.

protected QueryField createQueryField(Property field, String value, String condition) {
    if (value == null)
        return null;
    if ("".equals(value.trim()))
        return null;
    QueryField f = new QueryField();
    if (condition == null)
        f.setCondition(StringCondition.getInstance(StringCondition.C_EQ));
    else
        f.setCondition(StringCondition.getInstance(condition));
    f.setFieldname(field);
    f.setValue(value);
    return f;
}
Also used : QueryField(ambit2.db.search.structure.QueryField)

Example 5 with QueryField

use of ambit2.db.search.structure.QueryField in project ambit-mirror by ideaconsult.

the class QueryFieldsTest method createQuery.

@Override
protected QueryField createQuery() throws Exception {
    QueryField qf = new QueryField();
    qf.setFieldname(null);
    qf.setValue("abietic acid");
    qf.setCondition(StringCondition.getInstance("="));
    qf.setId(1);
    return qf;
}
Also used : QueryField(ambit2.db.search.structure.QueryField)

Aggregations

QueryField (ambit2.db.search.structure.QueryField)11 QueryDataset (ambit2.db.search.structure.QueryDataset)3 QueryFieldNumeric (ambit2.db.search.structure.QueryFieldNumeric)3 QueryStructure (ambit2.db.search.structure.QueryStructure)3 QueryParam (net.idea.modbcum.i.query.QueryParam)3 IAmbitEditor (ambit2.base.interfaces.IAmbitEditor)2 QueryCombinedStructure (ambit2.db.search.structure.QueryCombinedStructure)2 QueryStoredResults (ambit2.db.search.structure.QueryStoredResults)2 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)2 StringCondition (net.idea.modbcum.q.conditions.StringCondition)2 Test (org.junit.Test)2 Property (ambit2.base.data.Property)1 SourceDataset (ambit2.base.data.SourceDataset)1 InchiKey (ambit2.core.processors.structure.key.InchiKey)1 SmilesKey (ambit2.core.processors.structure.key.SmilesKey)1 QueryInfo2Query (ambit2.db.processors.QueryInfo2Query)1 QueryCombined (ambit2.db.search.QueryCombined)1 QueryInfo (ambit2.db.search.QueryInfo)1 AbstractStructureQuery (ambit2.db.search.structure.AbstractStructureQuery)1 QueryPrescreenBitSet (ambit2.db.search.structure.QueryPrescreenBitSet)1