Example usage for com.mongodb BasicDBObject getString

List of usage examples for com.mongodb BasicDBObject getString

Introduction

In this page you can find the example usage for com.mongodb BasicDBObject getString.

Prototype

public String getString(final String key) 

Source Link

Document

Returns the value of a field as a string

Usage

From source file:tango.plugin.filter.PostFilterSequence.java

License:Open Source License

public PostFilterSequence(BasicDBObject type, int nbCPUs, boolean verbose) {
    if (type == null || !type.containsField("postFilters"))
        return;//from  w  w  w  . jav  a  2 s  . com
    BasicDBList prefilters = (BasicDBList) type.get("postFilters");
    filters = new ArrayList<PostFilter>(prefilters.size());
    for (int i = 0; i < prefilters.size(); i++) {
        Object o = prefilters.get(i);
        if (o != null) {
            BasicDBObject data = (BasicDBObject) o;
            if (!data.getBoolean("isActivated", true)) {
                filters.add(new DummyPostFilter());
                continue;
            }
            PostFilter f = PluginFactory.getPostFilter(data.getString("method"));
            if (f != null) {
                Parameter[] parameters = f.getParameters();
                for (Parameter p : parameters)
                    p.dbGet(data);
                filters.add(f);
                f.setMultithread(nbCPUs);
                f.setVerbose(verbose);
            }
        }
    }
}

From source file:tango.plugin.filter.PreFilterSequence.java

License:Open Source License

public PreFilterSequence(BasicDBObject settings, int nbCPUs, boolean verbose) {
    if (settings == null || !settings.containsField("preFilters"))
        return;//from ww w  .  j a  va2 s  .  c  om
    BasicDBList prefilters = (BasicDBList) settings.get("preFilters");
    filters = new ArrayList<PreFilter>(prefilters.size());
    for (int i = 0; i < prefilters.size(); i++) {
        //IJ.log(i+"");
        Object o = prefilters.get(i);
        if (o != null) {
            BasicDBObject data = (BasicDBObject) o;
            //IJ.log("preFilter:"+data);
            if (!data.getBoolean("isActivated", true)) {
                filters.add(new DummyPreFilter());
                continue;
            }
            PreFilter f = PluginFactory.getPreFilter(data.getString("method"));
            if (f != null) {
                //IJ.log("preFilter loaded:"+f.getId());
                Parameter[] parameters = f.getParameters();
                for (Parameter p : parameters)
                    p.dbGet(data);
                filters.add(f);
                f.setMultithread(nbCPUs);
                f.setVerbose(verbose);
            }
        }
    }
}

From source file:tango.plugin.measurement.MeasurementSequence.java

License:Open Source License

protected void addMeasurement(Object o) {
    if (o != null) {
        BasicDBObject data = (BasicDBObject) o;
        if (!data.getBoolean("isActivated", true))
            return;
        Measurement m = PluginFactory.getMeasurement(data.getString("method"));
        if (m != null) {
            for (Parameter p : m.getParameters()) {
                //System.out.println("parameter:"+p.getClass()+ " id:"+p.getId()+ " label:"+p.getLabel());
                p.dbGet(data);/*from  w  w  w .j  av  a  2  s.  c o  m*/
            }
            Parameter[] keys = m.getKeys();
            Object kData = data.get("keys");
            if (keys != null && kData != null) {
                BasicDBObject keysData = (BasicDBObject) kData;
                for (Parameter p : keys)
                    p.dbGet(keysData);
            }
            if (m instanceof MeasurementObject) {
                mO.add((MeasurementObject) m);
            } else if (m instanceof MeasurementStructure) {
                mS.add((MeasurementStructure) m);
            }

        }
    }
}

From source file:tango.plugin.sampler.SampleRunner.java

License:Open Source License

private static Object3D[][][] runCell(Cell cell, int nbSamples) {
    BasicDBList sampleChannels = cell.getExperiment().getSampleChannels();
    int nbSampleChannels = sampleChannels.size();
    Object3D[][][] objects = new Object3D[nbSampleChannels][nbSamples][];
    for (int i = 0; i < nbSampleChannels; i++) {
        BasicDBObject sampleSettings = (BasicDBObject) sampleChannels.get(i);
        Sampler s = PluginFactory.getSampler(sampleSettings.getString("method"));
        for (Parameter p : s.getParameters())
            p.dbGet(sampleSettings);/*from w w  w.j av  a  2  s.c  o m*/
        s.initSampler(cell.getRawImages(), cell.getSegmentedImages());
        for (int j = 0; j < nbSamples; j++)
            objects[i][j] = s.getSample();
    }
    return objects;
}

From source file:tango.plugin.segmenter.NucleusSegmenterRunner.java

License:Open Source License

public NucleusSegmenterRunner(BasicDBObject settings, int nbCPUs, boolean verbose) {
    if (settings == null)
        return;/*from   w ww  .  j  a v a  2s .c o  m*/
    Object o = settings.get("segmentation");
    if (o != null) {
        BasicDBObject data = (BasicDBObject) o;

        segmenter = PluginFactory.getNucleiSegmenter(data.getString("method"));
        if (segmenter != null) {
            Parameter[] parameters = segmenter.getParameters();
            for (Parameter p : parameters)
                p.dbGet(data);
            segmenter.setMultithread(nbCPUs);
            segmenter.setVerbose(verbose);
        }
    }
}

From source file:tango.plugin.segmenter.SpotSegmenterRunner.java

License:Open Source License

public SpotSegmenterRunner(BasicDBObject type, int nbCPUs, boolean verbose) {
    if (type == null)
        return;//from   ww  w.j  ava 2 s  .c  om
    Object o = type.get("segmentation");
    if (o != null) {
        BasicDBObject data = (BasicDBObject) o;
        segmenter = PluginFactory.getSpotSegmenter(data.getString("method"));
        if (segmenter != null) {
            Parameter[] parameters = segmenter.getParameters();
            for (Parameter p : parameters)
                p.dbGet(data);
            segmenter.setMultithread(nbCPUs);
            segmenter.setVerbose(verbose);
        }
    }
}

From source file:uk.ac.ebi.eva.server.ws.StudyWSServer.java

License:Apache License

@RequestMapping(value = "/{study}/files", method = RequestMethod.GET)
//    @ApiOperation(httpMethod = "GET", value = "Retrieves all the files from a study", response = QueryResponse.class)
public QueryResponse getFilesByStudy(@PathVariable("study") String study,
        @RequestParam("species") String species, HttpServletResponse response)
        throws UnknownHostException, IllegalOpenCGACredentialsException, IOException {
    initializeQueryOptions();/* w  ww . java2s.  c  o  m*/

    StudyDBAdaptor studyMongoDbAdaptor = DBAdaptorConnector.getStudyDBAdaptor(species);
    VariantSourceDBAdaptor variantSourceDbAdaptor = DBAdaptorConnector.getVariantSourceDBAdaptor(species);

    QueryResult idQueryResult = studyMongoDbAdaptor.findStudyNameOrStudyId(study, queryOptions);
    if (idQueryResult.getNumResults() == 0) {
        QueryResult queryResult = new QueryResult();
        queryResult.setErrorMsg("Study identifier not found");
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        return setQueryResponse(queryResult);
    }

    BasicDBObject id = (BasicDBObject) idQueryResult.getResult().get(0);
    QueryResult finalResult = variantSourceDbAdaptor
            .getAllSourcesByStudyId(id.getString(DBObjectToVariantSourceConverter.STUDYID_FIELD), queryOptions);
    finalResult.setDbTime(finalResult.getDbTime() + idQueryResult.getDbTime());

    return setQueryResponse(finalResult);
}

From source file:uk.ac.ebi.eva.server.ws.StudyWSServer.java

License:Apache License

@RequestMapping(value = "/{study}/view", method = RequestMethod.GET)
//    @ApiOperation(httpMethod = "GET", value = "The info of a study", response = QueryResponse.class)
public QueryResponse getStudy(@PathVariable("study") String study,
        @RequestParam(name = "species") String species, HttpServletResponse response)
        throws UnknownHostException, IllegalOpenCGACredentialsException, IOException {
    initializeQueryOptions();//w  ww .  ja  v a2 s . c om

    StudyDBAdaptor studyMongoDbAdaptor = DBAdaptorConnector.getStudyDBAdaptor(species);

    QueryResult idQueryResult = studyMongoDbAdaptor.findStudyNameOrStudyId(study, queryOptions);
    if (idQueryResult.getNumResults() == 0) {
        QueryResult queryResult = new QueryResult();
        queryResult.setErrorMsg("Study identifier not found");
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        return setQueryResponse(queryResult);
    }

    BasicDBObject id = (BasicDBObject) idQueryResult.getResult().get(0);
    QueryResult finalResult = studyMongoDbAdaptor
            .getStudyById(id.getString(DBObjectToVariantSourceConverter.STUDYID_FIELD), queryOptions);
    finalResult.setDbTime(finalResult.getDbTime() + idQueryResult.getDbTime());

    return setQueryResponse(finalResult);
}

From source file:uk.ac.ebi.variation.eva.server.ws.StudyWSServer.java

License:Apache License

@GET
@Path("/{study}/files")
//    @ApiOperation(httpMethod = "GET", value = "Retrieves all the files from a study", response = QueryResponse.class)
public Response getFilesByStudy(@PathParam("study") String study, @QueryParam("species") String species)
        throws UnknownHostException, IllegalOpenCGACredentialsException, IOException {
    try {/*from www.  j  a va 2s .c om*/
        checkParams();
    } catch (VersionException | SpeciesException ex) {
        return createErrorResponse(ex.toString());
    }

    StudyDBAdaptor studyMongoDbAdaptor = DBAdaptorConnector.getStudyDBAdaptor(species);
    VariantSourceDBAdaptor variantSourceDbAdaptor = DBAdaptorConnector.getVariantSourceDBAdaptor(species);

    QueryResult idQueryResult = studyMongoDbAdaptor.findStudyNameOrStudyId(study, queryOptions);
    if (idQueryResult.getNumResults() == 0) {
        QueryResult queryResult = new QueryResult();
        queryResult.setErrorMsg("Study identifier not found");
        return createOkResponse(queryResult);
    }

    BasicDBObject id = (BasicDBObject) idQueryResult.getResult().get(0);
    QueryResult finalResult = variantSourceDbAdaptor
            .getAllSourcesByStudyId(id.getString(DBObjectToVariantSourceConverter.STUDYID_FIELD), queryOptions);
    finalResult.setDbTime(finalResult.getDbTime() + idQueryResult.getDbTime());

    return createOkResponse(finalResult);
}

From source file:uk.ac.ebi.variation.eva.server.ws.StudyWSServer.java

License:Apache License

@GET
@Path("/{study}/view")
//    @ApiOperation(httpMethod = "GET", value = "The info of a study", response = QueryResponse.class)
public Response getStudy(@PathParam("study") String study, @QueryParam("species") String species)
        throws UnknownHostException, IllegalOpenCGACredentialsException, IOException {
    try {//w  w w .j  av a  2 s.  co m
        checkParams();
    } catch (VersionException | SpeciesException ex) {
        return createErrorResponse(ex.toString());
    }

    StudyDBAdaptor studyMongoDbAdaptor = DBAdaptorConnector.getStudyDBAdaptor(species);

    QueryResult idQueryResult = studyMongoDbAdaptor.findStudyNameOrStudyId(study, queryOptions);
    if (idQueryResult.getNumResults() == 0) {
        QueryResult queryResult = new QueryResult();
        queryResult.setErrorMsg("Study identifier not found");
        return createOkResponse(queryResult);
    }

    BasicDBObject id = (BasicDBObject) idQueryResult.getResult().get(0);
    QueryResult finalResult = studyMongoDbAdaptor
            .getStudyById(id.getString(DBObjectToVariantSourceConverter.STUDYID_FIELD), queryOptions);
    finalResult.setDbTime(finalResult.getDbTime() + idQueryResult.getDbTime());

    return createOkResponse(finalResult);
}