List of usage examples for org.apache.solr.client.solrj SolrQuery set
public ModifiableSolrParams set(String name, String... val)
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public Map<String, Long> getColoniesNoMPHit(List<String> resourceName, ZygosityType zygosity) throws SolrServerException, IOException { Map<String, Long> res = new HashMap<>(); SolrQuery q = new SolrQuery(); if (resourceName != null) { q.setQuery(GenotypePhenotypeDTO.RESOURCE_NAME + ":" + StringUtils.join(resourceName, " OR " + GenotypePhenotypeDTO.RESOURCE_NAME + ":")); } else {//from ww w . j a v a 2s .c o m q.setQuery("*:*"); } if (zygosity != null) { q.addFilterQuery(GenotypePhenotypeDTO.ZYGOSITY + ":" + zygosity.name()); } q.addFilterQuery( GenotypePhenotypeDTO.P_VALUE + ":[" + StatisticalResultService.P_VALUE_THRESHOLD + " TO 1]"); q.addFacetField(StatisticalResultDTO.COLONY_ID); q.setFacetMinCount(1); q.setFacet(true); q.setRows(1); q.set("facet.limit", -1); logger.info( "Solr url for getColoniesNoMPHit " + SolrUtils.getBaseURL(statisticalResultCore) + "/select?" + q); QueryResponse response = statisticalResultCore.query(q); for (Count facet : response.getFacetField(StatisticalResultDTO.COLONY_ID).getValues()) { res.put(facet.getName(), facet.getCount()); } return res; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
/** * * @param geneAccessionId// w ww . j av a 2 s . c om * @return Basic information for allele pages in an AllelePageDTO */ public AllelePageDTO getAllelesInfo(String geneAccessionId, List<String> alleleSymbol, List<String> phenotypingCenter, List<String> pipelineName, List<String> procedureStableId, List<String> procedureName, List<String> mpTermIds, ArrayList<String> resource) { AllelePageDTO dto = new AllelePageDTO(); SolrQuery q = buildQuery(geneAccessionId, procedureName, alleleSymbol, phenotypingCenter, pipelineName, procedureStableId, resource, mpTermIds, null, null, null, null, null, null, null, null); q.addField(StatisticalResultDTO.MARKER_SYMBOL); q.addField(StatisticalResultDTO.MARKER_ACCESSION_ID); q.addFilterQuery(StatisticalResultDTO.P_VALUE + ":[* TO *]"); q.setFacet(true); q.setFacetLimit(-1); q.setFacetMinCount(1); q.addFacetField(StatisticalResultDTO.PHENOTYPING_CENTER); q.addFacetField(StatisticalResultDTO.PIPELINE_NAME); q.addFacetField(StatisticalResultDTO.ALLELE_SYMBOL); q.setRows(1); String pivotFacet = StatisticalResultDTO.PROCEDURE_NAME + "," + StatisticalResultDTO.PARAMETER_STABLE_ID; q.set("facet.pivot", pivotFacet); q.set("facet.pivot.mincount", 1); try { QueryResponse res = statisticalResultCore.query(q); FacetField phenotypingCenters = res.getFacetField(StatisticalResultDTO.PHENOTYPING_CENTER); for (Count facet : phenotypingCenters.getValues()) { dto.addPhenotypingCenter(facet.getName()); } FacetField alleles = statisticalResultCore.query(q).getFacetField(StatisticalResultDTO.ALLELE_SYMBOL); for (Count facet : alleles.getValues()) { dto.addAlleleSymbol(facet.getName()); } FacetField pipelines = statisticalResultCore.query(q).getFacetField(StatisticalResultDTO.PIPELINE_NAME); for (Count facet : pipelines.getValues()) { dto.addPipelineName(facet.getName()); } for (PivotField pivot : res.getFacetPivot().get(pivotFacet)) { if (pivot.getPivot() != null) { List<String> lst = new ArrayList<>(); for (PivotField gene : pivot.getPivot()) { lst.add(gene.getValue().toString()); } dto.addParametersByProcedure(pivot.getValue().toString(), new ArrayList<>(lst)); dto.addProcedureNames(pivot.getValue().toString()); } } SolrDocument doc = res.getResults().get(0); dto.setGeneSymbol(doc.getFieldValue(StatisticalResultDTO.MARKER_SYMBOL).toString()); dto.setGeneAccession(geneAccessionId); } catch (SolrServerException | IOException e) { e.printStackTrace(); } return dto; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public List<String> getCenters(String pipelineStableId, String observationType, String resource, String status) throws SolrServerException, IOException { List<String> res = new ArrayList<>(); SolrQuery query = new SolrQuery().setQuery("*:*"); query.set("facet", true); query.set("facet.field", StatisticalResultDTO.PHENOTYPING_CENTER); query.setRows(0);/* ww w .j av a2 s . c o m*/ query.set("facet.limit", -1); query.set("facet.mincount", 1); if (pipelineStableId != null) { query.addFilterQuery(StatisticalResultDTO.PIPELINE_STABLE_ID + ":" + pipelineStableId); } if (observationType != null) { query.addFilterQuery(StatisticalResultDTO.DATA_TYPE + ":" + observationType); } if (resource != null) { query.addFilterQuery(StatisticalResultDTO.RESOURCE_NAME + ":" + resource); } if (status != null) { query.addFilterQuery(StatisticalResultDTO.STATUS + ":" + status); } QueryResponse response = statisticalResultCore.query(query); for (Count facet : response.getFacetField(StatisticalResultDTO.PHENOTYPING_CENTER).getValues()) { res.add(facet.getName()); } return res; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
/** * @author tudose//from w w w.ja v a 2 s .com * @since 2015/07/21 * @return List<ProcedureBean> */ public List<ImpressBaseDTO> getProcedures(String pipelineStableId, String observationType, String resource, Integer minParameterNumber, List<String> proceduresToSkip, String status, boolean includeWilcoxon) { List<ImpressBaseDTO> procedures = new ArrayList<>(); try { SolrQuery query = new SolrQuery().setQuery("*:*").addField(StatisticalResultDTO.PROCEDURE_ID) .addField(StatisticalResultDTO.PROCEDURE_NAME) .addField(StatisticalResultDTO.PROCEDURE_STABLE_ID); query.set("group", true); query.set("group.field", StatisticalResultDTO.PROCEDURE_NAME); query.setRows(10000); query.setSort(StatisticalResultDTO.DOCUMENT_ID, SolrQuery.ORDER.asc); query.set("group.limit", 1); if (!includeWilcoxon) { query.addFilterQuery("-" + StatisticalResultDTO.STATISTICAL_METHOD + ":Wilcoxon*"); } if (pipelineStableId != null) { query.addFilterQuery(StatisticalResultDTO.PIPELINE_STABLE_ID + ":" + pipelineStableId); } if (observationType != null) { query.addFilterQuery(StatisticalResultDTO.DATA_TYPE + ":" + observationType); } if (resource != null) { query.addFilterQuery(StatisticalResultDTO.RESOURCE_NAME + ":" + resource); } if (status != null) { query.addFilterQuery(StatisticalResultDTO.STATUS + ":" + status); } String pivotField = StatisticalResultDTO.PROCEDURE_NAME + "," + StatisticalResultDTO.PARAMETER_NAME; if (minParameterNumber != null && minParameterNumber > 0) { query.setFacet(true); query.setFacetMinCount(1); query.set("facet.pivot.mincount", minParameterNumber); query.set("facet.pivot", pivotField); } QueryResponse response = statisticalResultCore.query(query); for (Group group : response.getGroupResponse().getValues().get(0).getValues()) { ImpressBaseDTO procedure = new ImpressBaseDTO( Long.getLong(group.getResult().get(0).getFirstValue(StatisticalResultDTO.PROCEDURE_ID) .toString()), null, group.getResult().get(0).getFirstValue(StatisticalResultDTO.PROCEDURE_STABLE_ID).toString(), group.getResult().get(0).getFirstValue(StatisticalResultDTO.PROCEDURE_NAME).toString()); procedures.add(procedure); } if (minParameterNumber != null && minParameterNumber > 0) { // get procedureList with more than minParameterNumber // remove from procedures the ones not in procedureList List<Map<String, String>> res = getFacetPivotResults(response, false); HashSet<String> proceduresWithMinCount = new HashSet<>(); for (Map<String, String> pivot : res) { proceduresWithMinCount.addAll(pivot.values()); } List<ImpressBaseDTO> proceduresToReturn = new ArrayList<>(); for (ImpressBaseDTO proc : procedures) { if (proceduresWithMinCount.contains(proc.getName())) { if (proceduresToSkip != null && !proceduresToSkip.contains(proc.getStableId()) || proceduresToSkip == null) { proceduresToReturn.add(proc); } } } procedures = proceduresToReturn; } } catch (SolrServerException | IOException | IndexOutOfBoundsException e) { e.printStackTrace(); } return procedures; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public StackedBarsData getUnidimensionalData(Parameter p, List<String> genes, List<String> strains, String biologicalSample, String[] center, String[] sex) throws SolrServerException, IOException { String urlParams = ""; SolrQuery query = new SolrQuery() .addFilterQuery(StatisticalResultDTO.PARAMETER_STABLE_ID + ":" + p.getStableId()); String q = "*:*"; query.addFilterQuery((strains.size() > 1) ? "(" + StatisticalResultDTO.STRAIN_ACCESSION_ID + ":\"" + StringUtils.join(strains.toArray(), "\" OR " + StatisticalResultDTO.STRAIN_ACCESSION_ID + ":\"") + "\")" : StatisticalResultDTO.STRAIN_ACCESSION_ID + ":\"" + strains.get(0) + "\""); if (strains.size() > 0) { urlParams += "&strain=" + StringUtils.join(strains.toArray(), "&strain="); }/*from w ww . ja va2s . c o m*/ if (center != null && center.length > 0) { query.addFilterQuery( "(" + ((center.length > 1) ? StatisticalResultDTO.PHENOTYPING_CENTER + ":\"" + StringUtils.join(center, "\" OR " + StatisticalResultDTO.PHENOTYPING_CENTER + ":\"") + "\"" : StatisticalResultDTO.PHENOTYPING_CENTER + ":\"" + center[0] + "\"") + ")"); urlParams += "&phenotyping_center=" + StringUtils.join(center, "&phenotyping_center="); } if (sex != null && sex.length == 1) { if (sex[0].equalsIgnoreCase("male")) { query.addFilterQuery(StatisticalResultDTO.MALE_CONTROL_COUNT + ":[4 TO 100000]"); query.addFilterQuery(StatisticalResultDTO.MALE_MUTANT_COUNT + ":[4 TO 100000]"); } else { query.addFilterQuery(StatisticalResultDTO.FEMALE_CONTROL_COUNT + ":[4 TO 100000]"); query.addFilterQuery(StatisticalResultDTO.FEMALE_MUTANT_COUNT + ":[4 TO 100000]"); } } query.setQuery(q); query.addFilterQuery("(" + StatisticalResultDTO.FEMALE_CONTROL_COUNT + ":[4 TO 100000] OR " + StatisticalResultDTO.MALE_CONTROL_COUNT + ":[4 TO 100000])"); query.setRows(10000000); query.setSort(StatisticalResultDTO.DOCUMENT_ID, SolrQuery.ORDER.asc); query.setFields(StatisticalResultDTO.MARKER_ACCESSION_ID, StatisticalResultDTO.FEMALE_CONTROL_MEAN, StatisticalResultDTO.MARKER_SYMBOL, StatisticalResultDTO.FEMALE_MUTANT_MEAN, StatisticalResultDTO.MALE_CONTROL_MEAN, StatisticalResultDTO.MALE_MUTANT_MEAN, StatisticalResultDTO.FEMALE_CONTROL_COUNT, StatisticalResultDTO.FEMALE_MUTANT_COUNT, StatisticalResultDTO.MALE_CONTROL_COUNT, StatisticalResultDTO.MALE_MUTANT_COUNT); query.set("group", true); query.set("group.field", StatisticalResultDTO.COLONY_ID); query.set("group.limit", 1); List<Group> groups = statisticalResultCore.query(query).getGroupResponse().getValues().get(0).getValues(); double[] meansArray = new double[groups.size()]; String[] genesArray = new String[groups.size()]; String[] geneSymbolArray = new String[groups.size()]; int size = 0; for (Group gr : groups) { SolrDocumentList resDocs = gr.getResult(); String sexToDisplay = null; OverviewRatio overviewRatio = new OverviewRatio(); for (SolrDocument doc : resDocs) { sexToDisplay = getSexToDisplay(sex, sexToDisplay, doc); overviewRatio.add(doc); } if (sexToDisplay != null) { Double ratio = overviewRatio.getPlotRatio(sexToDisplay); if (ratio != null) { genesArray[size] = (String) resDocs.get(0).get(StatisticalResultDTO.MARKER_ACCESSION_ID); geneSymbolArray[size] = (String) resDocs.get(0).get(StatisticalResultDTO.MARKER_SYMBOL); meansArray[size] = ratio; size++; } } } // we do the binning for all the data but fill the bins after that to // keep tract of phenotype associations int binCount = Math.min((int) Math.floor((double) groups.size() / 2), 20); List<String> mutantGenes = new ArrayList<>(); List<String> controlGenes = new ArrayList<>(); List<String> mutantGeneAcc = new ArrayList<>(); List<String> controlGeneAcc = new ArrayList<>(); List<Double> upperBounds = new ArrayList<>(); EmpiricalDistribution distribution = new EmpiricalDistribution(binCount); if (size > 0) { distribution.load(ArrayUtils.subarray(meansArray, 0, size - 1)); for (double bound : distribution.getUpperBounds()) { upperBounds.add(bound); } // we we need to distribute the control mutants and the // phenotype-mutants in the bins List<Double> controlM = new ArrayList<>(); List<Double> phenMutants = new ArrayList<>(); for (int j = 0; j < upperBounds.size(); j++) { controlM.add((double) 0); phenMutants.add((double) 0); controlGenes.add(""); mutantGenes.add(""); controlGeneAcc.add(""); mutantGeneAcc.add(""); } for (int j = 0; j < size; j++) { // find out the proper bin int binIndex = getBin(upperBounds, meansArray[j]); if (genes.contains(genesArray[j])) { phenMutants.set(binIndex, 1 + phenMutants.get(binIndex)); String genesString = mutantGenes.get(binIndex); if (!genesString.contains(geneSymbolArray[j])) { if (genesString.equals("")) { mutantGenes.set(binIndex, geneSymbolArray[j]); mutantGeneAcc.set(binIndex, "accession=" + genesArray[j]); } else { mutantGenes.set(binIndex, genesString + ", " + geneSymbolArray[j]); mutantGeneAcc.set(binIndex, mutantGeneAcc.get(binIndex) + "&accession=" + genesArray[j]); } } } else { // treat as control because they don't have this phenotype association String genesString = controlGenes.get(binIndex); if (!genesString.contains(geneSymbolArray[j])) { if (genesString.equalsIgnoreCase("")) { controlGenes.set(binIndex, geneSymbolArray[j]); controlGeneAcc.set(binIndex, "accession=" + genesArray[j]); } else { controlGenes.set(binIndex, genesString + ", " + geneSymbolArray[j]); controlGeneAcc.set(binIndex, controlGeneAcc.get(binIndex) + "&accession=" + genesArray[j]); } } controlM.set(binIndex, 1 + controlM.get(binIndex)); } } // add the rest of parameters to the graph urls for (int t = 0; t < controlGeneAcc.size(); t++) { controlGeneAcc.set(t, controlGeneAcc.get(t) + urlParams); mutantGeneAcc.set(t, mutantGeneAcc.get(t) + urlParams); } StackedBarsData data = new StackedBarsData(); data.setUpperBounds(upperBounds); data.setControlGenes(controlGenes); data.setControlMutatns(controlM); data.setMutantGenes(mutantGenes); data.setPhenMutants(phenMutants); data.setControlGeneAccesionIds(controlGeneAcc); data.setMutantGeneAccesionIds(mutantGeneAcc); return data; } return null; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public Map<String, List<String>> getDistributionOfLinesByMPTopLevel(List<String> resourceName, Float pValueThreshold)//from w w w .ja v a 2 s .c o m throws SolrServerException, IOException, InterruptedException, ExecutionException { Map<String, List<String>> res = new ConcurrentHashMap<>(); //<parameter, <genes>> String pivotFacet = StatisticalResultDTO.TOP_LEVEL_MP_TERM_NAME + "," + StatisticalResultDTO.COLONY_ID; SolrQuery q = new SolrQuery(); if (resourceName != null) { q.setQuery(StatisticalResultDTO.RESOURCE_NAME + ":" + StringUtils.join(resourceName, " OR " + StatisticalResultDTO.RESOURCE_NAME + ":")); } else { q.setQuery("*:*"); } if (pValueThreshold != null) { q.setFilterQueries(StatisticalResultDTO.P_VALUE + ":[0 TO " + pValueThreshold + "]"); } q.set("facet.pivot", pivotFacet); q.setFacet(true); q.setFacetMinCount(1); q.setRows(1); q.set("facet.limit", -1); logger.info("Solr url for getDistributionOfLinesByMPTopLevel " + SolrUtils.getBaseURL(statisticalResultCore) + "/select?" + q); QueryResponse response = statisticalResultCore.query(q); for (PivotField pivot : response.getFacetPivot().get(pivotFacet)) { if (pivot.getPivot() != null) { List<String> colonies = new ArrayList<>(); for (PivotField colony : pivot.getPivot()) { colonies.add(colony.getValue().toString()); } res.put(pivot.getValue().toString(), new ArrayList<String>(colonies)); } } return res; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public Map<String, List<String>> getDistributionOfGenesByMPTopLevel(List<String> resourceName, Float pValueThreshold)/*from www. ja v a 2 s. co m*/ throws SolrServerException, IOException, InterruptedException, ExecutionException { Map<String, List<String>> res = new ConcurrentHashMap<>(); //<parameter, <genes>> String pivotFacet = StatisticalResultDTO.TOP_LEVEL_MP_TERM_NAME + "," + StatisticalResultDTO.MARKER_ACCESSION_ID; SolrQuery q = new SolrQuery(); if (resourceName != null) { q.setQuery(StatisticalResultDTO.RESOURCE_NAME + ":" + StringUtils.join(resourceName, " OR " + StatisticalResultDTO.RESOURCE_NAME + ":")); } else { q.setQuery("*:*"); } if (pValueThreshold != null) { q.setFilterQueries(StatisticalResultDTO.P_VALUE + ":[0 TO " + pValueThreshold + "]"); } q.set("facet.pivot", pivotFacet); q.setFacet(true); q.setRows(1); q.set("facet.limit", -1); logger.info("Solr url for getDistributionOfGenesByMPTopLevel " + SolrUtils.getBaseURL(statisticalResultCore) + "/select?" + q); QueryResponse response = statisticalResultCore.query(q); for (PivotField pivot : response.getFacetPivot().get(pivotFacet)) { if (pivot.getPivot() != null) { List<String> genes = new ArrayList<>(); for (PivotField gene : pivot.getPivot()) { genes.add(gene.getValue().toString()); } res.put(pivot.getValue().toString(), new ArrayList<String>(genes)); } } return res; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public PhenotypeFacetResult getPhenotypeFacetResultByPhenotypingCenterAndPipeline(String phenotypingCenter, String pipelineStableId) throws IOException, URISyntaxException, JSONException { SolrQuery query = new SolrQuery(); query.setQuery(StatisticalResultDTO.PHENOTYPING_CENTER + ":\"" + phenotypingCenter); query.addFilterQuery(StatisticalResultDTO.PIPELINE_STABLE_ID + ":" + pipelineStableId); query.setFacet(true);/*ww w . j a v a 2 s . c om*/ query.addFacetField(StatisticalResultDTO.RESOURCE_FULLNAME); query.addFacetField(StatisticalResultDTO.PROCEDURE_NAME); query.addFacetField(StatisticalResultDTO.MARKER_SYMBOL); query.addFacetField(StatisticalResultDTO.MP_TERM_NAME); query.setSort(StatisticalResultDTO.P_VALUE, SolrQuery.ORDER.asc); query.setRows(10000000); query.set("wt", "json"); query.set("version", "2.2"); String solrUrl = SolrUtils.getBaseURL(statisticalResultCore) + "/select?" + query; return createPhenotypeResultFromSolrResponse(solrUrl); }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public HashMap<String, GeneRowForHeatMap> getSecondaryProjectMapForGeneList(Set<String> geneAccessions, List<BasicBean> topLevelMps) throws IOException, SolrServerException { HashMap<String, GeneRowForHeatMap> geneRowMap = new HashMap<>(); // <geneAcc, row> SolrQuery q = new SolrQuery() .setQuery(geneAccessions.stream().collect( Collectors.joining("\" OR \"", StatisticalResultDTO.MARKER_ACCESSION_ID + ":(\"", "\")"))) .addField(StatisticalResultDTO.PROCEDURE_STABLE_ID) .addField(StatisticalResultDTO.MARKER_ACCESSION_ID) .addField(StatisticalResultDTO.TOP_LEVEL_MP_TERM_NAME).addField(StatisticalResultDTO.MP_TERM_NAME) .addField(StatisticalResultDTO.MARKER_SYMBOL).addField(StatisticalResultDTO.STATUS) .addField(StatisticalResultDTO.SIGNIFICANT).setRows(Integer.MAX_VALUE) .setSort(StatisticalResultDTO.DOCUMENT_ID, SolrQuery.ORDER.asc); q.addFilterQuery(StatisticalResultDTO.MP_TERM_ID + ":*"); // Ignore MPATH or other types of associations q.add("group", "true"); q.add("group.field", StatisticalResultDTO.MARKER_ACCESSION_ID); q.set("group.limit", Integer.MAX_VALUE); GroupCommand groups = statisticalResultCore.query(q, SolrRequest.METHOD.POST).getGroupResponse().getValues() .get(0);//from w w w . ja v a 2s.c o m for (Group group : groups.getValues()) { // Each group contains data for a different gene String geneAcc = group.getGroupValue(); SolrDocumentList docs = group.getResult(); GeneRowForHeatMap row = new GeneRowForHeatMap(geneAcc, docs.get(0).getFieldValue(StatisticalResultDTO.MARKER_SYMBOL).toString(), topLevelMps); // Fill row with default values for all mp top levels for (SolrDocument doc : docs) { List<String> currentTopLevelMps = (ArrayList<String>) doc .get(StatisticalResultDTO.TOP_LEVEL_MP_TERM_NAME); // The current top level might be null, because the actual term is already a top level, // check the associated mp term to see, and add it if it's already top-level if (currentTopLevelMps == null) { if (topLevelMps.stream().anyMatch(x -> x.getName() .equals(doc.getFieldValue(StatisticalResultDTO.MP_TERM_NAME).toString()))) { currentTopLevelMps = new ArrayList<>(); currentTopLevelMps.add(doc.getFieldValue(StatisticalResultDTO.MP_TERM_NAME).toString()); } } // The term might have been annotated to "mammalian phenotype" which doesn't have an icon in the grid. Skip it if (currentTopLevelMps != null) { for (String mp : currentTopLevelMps) { HeatMapCell cell = row.getXAxisToCellMap().containsKey(mp) ? row.getXAxisToCellMap().get(mp) : new HeatMapCell(mp, HeatMapCell.THREE_I_NO_DATA); if (doc.getFieldValue(StatisticalResultDTO.SIGNIFICANT) != null && doc.getFieldValue(StatisticalResultDTO.SIGNIFICANT).toString() .equalsIgnoreCase("true")) { cell.addStatus(HeatMapCell.THREE_I_DEVIANCE_SIGNIFICANT); } else if (doc.getFieldValue(StatisticalResultDTO.STATUS).toString().equals("Success")) { cell.addStatus(HeatMapCell.THREE_I_DATA_ANALYSED_NOT_SIGNIFICANT); } else { cell.addStatus(HeatMapCell.THREE_I_COULD_NOT_ANALYSE); } row.add(cell); } } } geneRowMap.put(geneAcc, row); } return geneRowMap; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
public Map<String, List<String>> getParametersToProcedureMap(String alleleAccession, String geneAccession, String resourceName, String phenotypingCenter, String pipelineSrableId, String procedure) throws SolrServerException, IOException { Map<String, List<String>> res = new ConcurrentHashMap<>(); //<parameter, <genes>> SolrQuery q = new SolrQuery().setQuery("*:*"); q.add("fl", StatisticalResultDTO.PARAMETER_NAME + "," + StatisticalResultDTO.PARAMETER_STABLE_ID); if (resourceName != null) { q.addFilterQuery(StatisticalResultDTO.RESOURCE_NAME + ":\"" + resourceName + "\""); }/*from w w w . ja v a2s . co m*/ if (phenotypingCenter != null) { q.addFilterQuery(StatisticalResultDTO.PHENOTYPING_CENTER + ":\"" + phenotypingCenter + "\""); } if (pipelineSrableId != null) { q.addFilterQuery(StatisticalResultDTO.PIPELINE_STABLE_ID + ":\"" + pipelineSrableId + "\""); } String pivotFacet = StatisticalResultDTO.PROCEDURE_NAME + "," + StatisticalResultDTO.PARAMETER_STABLE_ID; q.set("facet.pivot", pivotFacet); q.setFacet(true); q.setRows(1); q.set("facet.limit", -1); logger.info("Solr url for getParametersToProcedureMap " + SolrUtils.getBaseURL(statisticalResultCore) + "/select?" + q); QueryResponse response = statisticalResultCore.query(q); for (PivotField pivot : response.getFacetPivot().get(pivotFacet)) { if (pivot.getPivot() != null) { List<String> lst = new ArrayList<>(); for (PivotField gene : pivot.getPivot()) { lst.add(gene.getValue().toString()); } res.put(pivot.getValue().toString(), new ArrayList<String>(lst)); } } return res; }