use of ambit2.base.interfaces.IStructureRecord.STRUC_TYPE in project ambit-mirror by ideaconsult.
the class AbstractFinder method process.
@Override
public IStructureRecord process(IStructureRecord target) throws AmbitException {
try {
if (target == null)
return null;
if ((AbstractFinder.MODE.emptyonly.equals(mode) || AbstractFinder.MODE.emptyadd.equals(mode)) && !STRUC_TYPE.NA.equals(target.getType()))
return null;
Iterator<Property> keys = profile.getProperties(true);
Object value = null;
while (keys.hasNext()) {
Property key = keys.next();
try {
value = retrieveValue(target, key);
if ((value == null) || "".equals(value.toString().trim()))
continue;
RESULT content = query(value.toString());
if (content != null) {
STRUC_TYPE originalType = target.getType();
target = transform(target, content);
switch(mode) {
case emptyonly:
{
if (!STRUC_TYPE.NA.equals(originalType)) {
target.setIdstructure(-1);
}
break;
}
case emptyadd:
{
target.setIdstructure(-1);
target.setUsePreferedStructure(false);
break;
}
case replace:
{
target.setUsePreferedStructure(false);
break;
}
case propertyonly:
{
break;
}
default:
// add
target.setIdstructure(-1);
target.setUsePreferedStructure(false);
break;
}
return target;
}
} catch (HttpException x) {
if (x.getCode() == 404)
logger.log(Level.WARNING, value == null ? x.getMessage() : value.toString(), x);
} catch (Exception x) {
logger.log(Level.SEVERE, value == null ? x.getMessage() : value.toString(), x);
}
}
} catch (Exception x) {
logger.log(Level.SEVERE, x.getMessage(), x);
}
return null;
}
use of ambit2.base.interfaces.IStructureRecord.STRUC_TYPE in project ambit-mirror by ideaconsult.
the class RetrieveStructure method getObject.
public IStructureRecord getObject(ResultSet rs) throws AmbitException {
try {
IStructureRecord r = getValue();
r.clear();
r.setIdchemical(rs.getInt(_sqlids.idchemical.name()));
r.setIdstructure(rs.getInt(_sqlids.idstructure.name()));
r.setContent(rs.getString(_sqlids.ustructure.name()));
r.setFormat(rs.getString(_sqlids.format.name()));
try {
r.setSelected(rs.getBoolean("selected"));
} catch (Exception x) {
r.setSelected(true);
}
try {
String t = rs.getString(_sqlids.type_structure.name());
for (STRUC_TYPE type : STRUC_TYPE.values()) if (type.toString().equals(t)) {
r.setType(type);
break;
}
} catch (Exception x) {
r.setType(STRUC_TYPE.NA);
}
try {
Object ts = rs.getString(_sqlids.atomproperties.name());
if ((ts == null) || "".equals(ts.toString().trim()))
r.removeRecordProperty(Property.getInstance(CMLUtilities.SMARTSProp, CMLUtilities.SMARTSProp));
else
r.setRecordProperty(Property.getInstance(CMLUtilities.SMARTSProp, CMLUtilities.SMARTSProp), ts);
} catch (Exception x) {
r.removeRecordProperty(Property.getInstance(CMLUtilities.SMARTSProp, CMLUtilities.SMARTSProp));
}
return r;
} catch (SQLException x) {
throw new AmbitException(x);
}
}
use of ambit2.base.interfaces.IStructureRecord.STRUC_TYPE in project ambit-mirror by ideaconsult.
the class RetrieveStructurePair method getObject.
protected void getObject(ResultSet rs, IStructureRecord r, int offset) throws SQLException {
r.clear();
r.setIdchemical(rs.getInt(rs_index.idchemical.ordinal() + offset));
r.setIdstructure(rs.getInt(rs_index.idstructure.ordinal() + offset));
r.setContent(rs.getString(rs_index.ustructure.ordinal() + offset));
r.setFormat(rs.getString(rs_index.format.ordinal() + offset));
try {
String t = rs.getString(rs_index.type_structure.ordinal() + offset);
for (STRUC_TYPE type : STRUC_TYPE.values()) if (type.toString().equals(t)) {
r.setType(type);
break;
}
} catch (Exception x) {
r.setType(STRUC_TYPE.NA);
}
if ((rs.getString(rs_index.atomproperties.ordinal() + offset) == null) || "".equals(rs.getString(rs_index.atomproperties.ordinal() + offset).trim()))
r.removeRecordProperty(Property.getInstance(CMLUtilities.SMARTSProp, CMLUtilities.SMARTSProp));
else
r.setRecordProperty(Property.getInstance(CMLUtilities.SMARTSProp, CMLUtilities.SMARTSProp), rs.getString(rs_index.atomproperties.ordinal() + offset));
}
use of ambit2.base.interfaces.IStructureRecord.STRUC_TYPE in project ambit-mirror by ideaconsult.
the class QueryStrucType method getParameters.
public List<QueryParam> getParameters() throws AmbitException {
if (getValue() == null)
throw new AmbitException("Structure type not defined");
else {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam<Integer>(Integer.class, getId()));
for (STRUC_TYPE st : getValue()) params.add(new QueryParam<String>(String.class, st.toString()));
return params;
}
}
use of ambit2.base.interfaces.IStructureRecord.STRUC_TYPE in project ambit-mirror by ideaconsult.
the class QueryStrucType method getSQL.
public String getSQL() throws AmbitException {
if (getValue() == null)
throw new AmbitException("Structure type not defined");
else {
StringBuilder b = new StringBuilder();
String or = "";
for (STRUC_TYPE st : getValue()) {
b.append(or);
b.append(String.format(where, getCondition().getSQL()));
or = " or ";
}
return String.format(sql, b.toString());
}
}
Aggregations