use of ambit2.base.data.QLabel.QUALITY in project ambit-mirror by ideaconsult.
the class QLabelQueryResource method createQuery.
@Override
protected IQueryRetrieval<IStructureRecord> createQuery(Context context, Request request, Response response) throws ResourceException {
QueryStructureByQuality q = new QueryStructureByQuality();
Form form = request.getResourceRef().getQueryAsForm();
try {
includeMol = "true".equals(form.getFirstValue("mol"));
} catch (Exception x) {
includeMol = false;
}
Object key = form.getFirstValue(QueryResource.search_param);
if (key != null) {
try {
q.setValue(new QLabel(QUALITY.valueOf(Reference.decode(key.toString()))));
} catch (Exception x) {
StringBuilder b = new StringBuilder();
b.append("Valid values are ");
for (QUALITY v : QUALITY.values()) {
b.append(v);
b.append('\t');
}
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, b.toString(), x);
}
} else {
q.setValue(new QLabel(QUALITY.OK));
}
Object id = request.getAttributes().get(OpenTox.URI.dataset.getKey());
if (id != null)
try {
datasetID = Integer.parseInt(id.toString());
SourceDataset dataset = new SourceDataset();
dataset.setId(datasetID);
q.setFieldname(dataset);
return q;
} catch (Exception x) {
if (id.toString().startsWith("R")) {
queryResultsID = Integer.parseInt(id.toString().substring(1));
StoredQuery dataset = new StoredQuery();
dataset.setId(queryResultsID);
q.setFieldname(dataset);
return q;
} else
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Invalid dataset id");
}
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No dataset !");
}
use of ambit2.base.data.QLabel.QUALITY in project ambit-mirror by ideaconsult.
the class AmbitApplication method createQueryRouter.
/**
* Everything under /query
*
* @return
*/
protected Router createQueryRouter() {
Router queryRouter = new MyRouter(getContext());
queryRouter.attachDefault(QueryListResource.class);
/**
* Quality labels
*/
queryRouter.attach(QLabelQueryResource.resource, QLabelQueryResource.class);
queryRouter.attach(StrucTypeQueryResource.resource, StrucTypeQueryResource.class);
queryRouter.attach(ConsensusLabelQueryResource.resource, ConsensusLabelQueryResource.class);
queryRouter.attach(DatasetStructureQualityStatsResource.resource, DatasetStructureQualityStatsResource.class);
queryRouter.attach(DatasetChemicalsQualityStatsResource.resource, DatasetChemicalsQualityStatsResource.class);
queryRouter.attach(DatasetStrucTypeStatsResource.resource, DatasetStrucTypeStatsResource.class);
queryRouter.attach(StudySearchResource.resource, StudySearchResource.class);
/**
* Missing features /missingValues - there is /filter now, may be this
* is redundant ?
*/
queryRouter.attach(MissingFeatureValuesResource.resource, MissingFeatureValuesResource.class);
/**
* Facets
*/
queryRouter.attach(CompoundsByPropertyValueInDatasetResource.resource, CompoundsByPropertyValueInDatasetResource.class);
queryRouter.attach(DatasetsByEndpoint.resource, DatasetsByEndpoint.class);
queryRouter.attach(DatasetsByNamePrefixResource.resource, DatasetsByNamePrefixResource.class);
queryRouter.attach(ExperimentsSearchResource.resource, ExperimentsSearchResource.class);
queryRouter.attach(InterpretationResultSearchResource.resource, InterpretationResultSearchResource.class);
/**
* PubChem query
*/
Router pubchem = new MyRouter(getContext());
queryRouter.attach(PubchemResource.resource, pubchem);
pubchem.attachDefault(PubchemResource.class);
pubchem.attach(PubchemResource.resourceID, PubchemResource.class);
/**
* CIR query
*/
Router cir = new MyRouter(getContext());
queryRouter.attach(CSLSResource.resource, cir);
cir.attachDefault(CSLSResource.class);
cir.attach(CSLSResource.resourceID, CSLSResource.class);
cir.attach(CSLSResource.resourceID + CSLSResource.representationID, CSLSResource.class);
/**
* Compound search /query/compound/lookup
*/
Router lookup = new MyRouter(getContext());
queryRouter.attach(CompoundLookup.resource, lookup);
lookup.attachDefault(CompoundLookup.class);
lookup.attach(CompoundLookup.resourceID, CompoundLookup.class);
lookup.attach(CompoundLookup.resourceID + CompoundLookup.representationID, CompoundLookup.class);
Router slookup = new MyRouter(getContext());
queryRouter.attach(OpenTox.URI.substance.getURI(), slookup);
slookup.attachDefault(SubstanceLookup.class);
slookup.attach("/{type}", SubstanceLookup.class);
slookup.attach("/{type}/{subtype}", SubstanceLookup.class);
slookup.attach("/{type}/{subtype}/{subsubtype}", SubstanceLookup.class);
queryRouter.attach(SubstanceTypeSearchResource.resource, SubstanceTypeSearchResource.class);
queryRouter.attach(DataAvailabilityResource.resource, DataAvailabilityResource.class);
return queryRouter;
}
Aggregations