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