use of ambit2.pubchem.rest.PubChemRestFinder in project ambit-mirror by ideaconsult.
the class CallableFinder method createProcessors.
@Override
protected ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> createProcessors() throws Exception {
ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> p = new ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor>();
// exactly our
RetrieveStructure r = new RetrieveStructure(false);
// structure,
// nothing else
r.setPageSize(1);
r.setPage(0);
p.add(new ProcessorStructureRetrieval(r));
IProcessor<IStructureRecord, IStructureRecord> valuesReader = getValuesReader();
if (valuesReader != null)
p.add(valuesReader);
IProcessor<String, String> request;
LiteratureEntry le;
switch(searchSite) {
case PUBCHEM_CID:
{
p.add(new PubChemRestFinder(getProfile(), mode, COMPOUND_DOMAIN_INPUT.cid));
le = new LiteratureEntry(PUGRestRequest.PUGREST_URL, PUGRestRequest.PUGREST_COMPOUND_URL);
break;
}
case PUBCHEM_SID:
{
p.add(new PubChemRestFinder(getProfile(), mode, COMPOUND_DOMAIN_INPUT.sid));
le = new LiteratureEntry(PUGRestRequest.PUGREST_URL, PUGRestRequest.PUGREST_COMPOUND_URL);
break;
}
case PUBCHEM_NAME:
{
p.add(new PubChemRestFinder(getProfile(), mode, COMPOUND_DOMAIN_INPUT.name));
le = new LiteratureEntry(PUGRestRequest.PUGREST_URL, PUGRestRequest.PUGREST_COMPOUND_URL);
break;
}
case PUBCHEM_INCHIKEY:
{
p.add(new PubChemRestFinder(getProfile(), mode, COMPOUND_DOMAIN_INPUT.inchikey));
le = new LiteratureEntry(PUGRestRequest.PUGREST_URL, PUGRestRequest.PUGREST_COMPOUND_URL);
break;
}
/*
* case PUBCHEM: { p.add(new PubchemFinder(profile,mode)); le = new
* LiteratureEntry("PubChem",EntrezSearchProcessor.entrezURL); break; }
*/
case OPENTOX:
{
request = new OpenToxRequest(searchSite.getURI());
p.add(new AllSourcesFinder(getProfile(), request, mode));
le = new LiteratureEntry(request.toString(), request.toString());
break;
}
case AMBITLRI:
{
request = new OpenToxRequest(searchSite.getURI());
p.add(new AllSourcesFinder(getProfile(), request, mode));
le = new LiteratureEntry(request.toString(), request.toString());
break;
}
case NAME2STRUCTURE:
{
p.add(new Name2StructureFinder(getProfile(), mode));
le = new LiteratureEntry(searchSite.getTitle(), searchSite.getURI());
break;
}
/*
* case CHEMBL: { p.add(new ChemBLFinder(profile,mode)); le = new
* LiteratureEntry(searchSite.name(),"https://www.ebi.ac.uk/chemblws"); break; }
*/
case CHEMIDPLUS:
{
request = new ChemIdPlusRequest();
p.add(new AllSourcesFinder(getProfile(), request, mode));
le = new LiteratureEntry(request.toString(), request.toString());
break;
}
/*
* case TBWIKI: { mode = MODE.propertyonly; le = new LiteratureEntry("TBWIKI",
* "http://wiki.toxbank.net/wiki/Special:SPARQLEndpoint"); p.add(new
* TBWikiFinder(profile, le)); break; }
*/
default:
{
request = new CSLSStringRequest();
p.add(new AllSourcesFinder(getProfile(), request, mode));
le = new LiteratureEntry(request.toString(), request.toString());
break;
}
}
// don't duplicate if there is already a hit
SourceDataset dataset = new SourceDataset(searchSite.toString(), le);
dataset = getDataset(dataset);
QueryStructureByID q = new QueryStructureByID();
q.setChemicalsOnly(true);
q.setFieldname(dataset);
q.setPageSize(1);
q.setPage(0);
p.add(new ProcessorStructureRetrieval(q) {
/**
*/
private static final long serialVersionUID = 621841537224691538L;
@Override
public IStructureRecord process(IStructureRecord target) throws AmbitException {
if (target == null)
return null;
if (((QueryStructureByID) getQuery()).getFieldname().getID() >= 0) {
IStructureRecord record = super.process(target);
target.setIdchemical(record.getIdchemical());
target.setIdstructure(record.getIdstructure());
return target;
} else
return target;
}
});
RepositoryWriter writer = new RepositoryWriter() {
/**
*/
private static final long serialVersionUID = 7175414487857418817L;
@Override
public List<IStructureRecord> process(IStructureRecord target) throws AmbitException {
if (target == null)
return null;
return super.process(target);
}
};
if (MODE.propertyonly.equals(mode)) {
writer.setPropertyKey(new NoneKey());
writer.setUseExistingStructure(true);
writer.setOperation(OP.CREATE);
} else
writer.setOperation(OP.UPDATE);
writer.setDataset(dataset);
p.add(writer);
return p;
}
Aggregations