Search in sources :

Example 1 with QUALITY

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 !");
}
Also used : StoredQuery(ambit2.db.search.StoredQuery) QUALITY(ambit2.base.data.QLabel.QUALITY) Form(org.restlet.data.Form) QLabel(ambit2.base.data.QLabel) QueryStructureByQuality(ambit2.db.search.structure.QueryStructureByQuality) ResourceException(org.restlet.resource.ResourceException) SourceDataset(ambit2.base.data.SourceDataset) ResourceException(org.restlet.resource.ResourceException)

Example 2 with QUALITY

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;
}
Also used : MyRouter(ambit2.rest.routers.MyRouter) SubstanceRouter(ambit2.rest.routers.opentox.SubstanceRouter) AdminRouter(ambit2.rest.routers.misc.AdminRouter) CompoundInDatasetRouter(ambit2.rest.routers.opentox.CompoundInDatasetRouter) InvestigationRouter(ambit2.rest.routers.misc.InvestigationRouter) FeaturesRouter(ambit2.rest.routers.opentox.FeaturesRouter) CollectionsRouter(ambit2.rest.routers.opentox.CollectionsRouter) ProjectRouter(ambit2.user.groups.ProjectRouter) TaskRouter(ambit2.rest.routers.TaskRouter) CompoundsRouter(ambit2.rest.routers.opentox.CompoundsRouter) OrganisationRouter(ambit2.user.groups.OrganisationRouter) ChartRouter(ambit2.rest.routers.misc.ChartRouter) DepictDemoRouter(ambit2.rest.routers.misc.DepictDemoRouter) AlgorithmRouter(ambit2.rest.routers.opentox.AlgorithmRouter) BundleRouter(ambit2.rest.routers.opentox.BundleRouter) BookmarksRouter(ambit2.rest.routers.misc.BookmarksRouter) SubstanceOwnerRouter(ambit2.rest.routers.opentox.SubstanceOwnerRouter) Router(org.restlet.routing.Router) APIDocsRouter(ambit2.rest.routers.APIDocsRouter) LoomRouter(ambit2.rest.loom.LoomRouter) ModelRouter(ambit2.rest.routers.opentox.ModelRouter) UIRouter(ambit2.rest.routers.misc.UIRouter) MyRouter(ambit2.rest.routers.MyRouter) UserRouter(ambit2.user.rest.UserRouter) ProxyRouter(ambit2.rest.routers.misc.ProxyRouter) DatasetsRouter(ambit2.rest.routers.opentox.DatasetsRouter)

Aggregations

QLabel (ambit2.base.data.QLabel)1 QUALITY (ambit2.base.data.QLabel.QUALITY)1 SourceDataset (ambit2.base.data.SourceDataset)1 StoredQuery (ambit2.db.search.StoredQuery)1 QueryStructureByQuality (ambit2.db.search.structure.QueryStructureByQuality)1 LoomRouter (ambit2.rest.loom.LoomRouter)1 APIDocsRouter (ambit2.rest.routers.APIDocsRouter)1 MyRouter (ambit2.rest.routers.MyRouter)1 TaskRouter (ambit2.rest.routers.TaskRouter)1 AdminRouter (ambit2.rest.routers.misc.AdminRouter)1 BookmarksRouter (ambit2.rest.routers.misc.BookmarksRouter)1 ChartRouter (ambit2.rest.routers.misc.ChartRouter)1 DepictDemoRouter (ambit2.rest.routers.misc.DepictDemoRouter)1 InvestigationRouter (ambit2.rest.routers.misc.InvestigationRouter)1 ProxyRouter (ambit2.rest.routers.misc.ProxyRouter)1 UIRouter (ambit2.rest.routers.misc.UIRouter)1 AlgorithmRouter (ambit2.rest.routers.opentox.AlgorithmRouter)1 BundleRouter (ambit2.rest.routers.opentox.BundleRouter)1 CollectionsRouter (ambit2.rest.routers.opentox.CollectionsRouter)1 CompoundInDatasetRouter (ambit2.rest.routers.opentox.CompoundInDatasetRouter)1