use of ambit2.rest.task.tautomers.CallableTautomersGenerator in project ambit-mirror by ideaconsult.
the class ModelResource method createCallable.
@Override
protected CallableQueryProcessor createCallable(Form form, ModelQueryResults model) throws ResourceException {
try {
readVariables(model);
Object token = getToken();
final ModelPredictor thepredictor = ModelResource.getPredictor(model, getRequest());
if (model.getContentMediaType().equals(AlgorithmFormat.WWW_FORM.getMediaType())) {
if (thepredictor instanceof ExpertModelpredictor)
return new CallableModelPredictor<IStructureRecord, ExpertModelpredictor, Object>(form, getRequest().getRootRef(), getContext(), (ExpertModelpredictor) thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo()) {
@Override
protected void processForm(Reference applicationRootReference, Form form) {
super.processForm(applicationRootReference, form);
((ExpertModelpredictor) thepredictor).setValue(form.getFirstValue("value"));
}
};
else
return new CallableModelPredictor<IStructureRecord, ModelPredictor, Object>(form, getRequest().getRootRef(), getContext(), thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
} else if (model.getContentMediaType().equals(AlgorithmFormat.WEKA.getMediaType())) {
return // reads Instances, instead of IStructureRecord
new CallableWekaPredictor<Object, Object>(form, getRequest().getRootRef(), getContext(), thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
/*
* } else if (model.getContentMediaType().equals(
*
* AlgorithmFormat.WAFFLES_JSON.getMediaType())) { return new
* CallableWafflesPredictor(form, getRequest() .getRootRef(),
* getContext(), (WafflesPredictor) thepredictor,
* token,getRequest().getResourceRef().toString());
*/
} else if (model.getContentMediaType().equals(AlgorithmFormat.COVERAGE_SERIALIZED.getMediaType())) {
if (model.getPredictors().size() == 0) {
// based AD
if (thepredictor instanceof FingerprintsPredictor)
return new CallableModelPredictor<IStructureRecord, FingerprintsPredictor, Object>(form, getRequest().getRootRef(), getContext(), (FingerprintsPredictor) thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
else
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, String.format("Not supported %s", thepredictor.getClass().getName()));
} else {
return new CallableModelPredictor(form, getRequest().getRootRef(), getContext(), thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
/*
* return new CallableWekaPredictor<DataCoverage>( //reads
* Instances, instead of IStructureRecord form,
* getRequest().getRootRef(), getContext(), predictor) ;
*/
}
} else if (model.getContentMediaType().equals(AlgorithmFormat.Structure2D.getMediaType())) {
return new CallableStructureOptimizer(form, getRequest().getRootRef(), getContext(), (Structure2DProcessor) thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
} else if (model.getContentMediaType().equals(AlgorithmFormat.MOPAC.getMediaType())) {
return new CallableStructureOptimizer(form, getRequest().getRootRef(), getContext(), (StructureProcessor) thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
} else if (model.getContentMediaType().equals(AlgorithmFormat.TAUTOMERS.getMediaType())) {
return new CallableTautomersGenerator(form, getRequest().getRootRef(), getContext(), (TautomersGenerator) thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
} else if (model.getContentMediaType().equals(AlgorithmFormat.JAVA_CLASS.getMediaType())) {
return new CallableDescriptorCalculator(form, getRequest().getRootRef(), getContext(), (DescriptorPredictor) thepredictor, token, getRequest().getResourceRef().toString(), getClientInfo());
} else
throw new ResourceException(Status.CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE, model.getContentMediaType());
} catch (ResourceException x) {
throw x;
} catch (Exception x) {
throw new ResourceException(Status.SERVER_ERROR_INTERNAL, x.getMessage(), x);
} finally {
}
}
Aggregations