org.opencb.commons.datastore.core.Query.containsKey()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.opencb.commons.datastore.core.Query.containsKey方法的一些代码示例,展示了Query.containsKey的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.containsKey方法的具体详情如下:
包路径:org.opencb.commons.datastore.core.Query
类名称:Query
方法名:containsKey

Query.containsKey介绍

暂无

代码示例

代码示例来源:origin: opencb/opencga

/**
 * Checks if the query contains any annotation query.
 *
 * @param query Query object.
 * @return whether query contains an annotation query or not.
 */
public boolean containsAnnotationQuery(Query query) {
  if (query == null || query.isEmpty()) {
    return false;
  }
  return query.containsKey(Constants.ANNOTATION);
}

代码示例来源:origin: opencb/opencga

private boolean isCaseProvided(Query query) {
    if (query != null) {
      return query.containsKey(ClinicalVariantEngine.QueryParams.CLINICAL_ANALYSIS_ID.key())
          || query.containsKey(ClinicalVariantEngine.QueryParams.FAMILY.key())
          || query.containsKey(ClinicalVariantEngine.QueryParams.SUBJECT.key())
          || query.containsKey(ClinicalVariantEngine.QueryParams.SAMPLE.key());
    }
    return false;
  }
}

代码示例来源:origin: opencb/cellbase

private void getGwasFilters(Query query, Set<String> sourceContent, List<Bson> sourceBson) {
  // If only clinvar-specific filters are provided it must be avoided to include the source=gwas condition since
  // sourceBson is going to be an OR list
  if (!(query.containsKey(QueryParams.CLINVARRCV.key()) || query.containsKey(QueryParams.CLINVARCLINSIG.key())
      || query.containsKey(QueryParams.CLINVARREVIEW.key())
      || query.containsKey(QueryParams.CLINVARTYPE.key())
      || query.containsKey(QueryParams.CLINVARRS.key()))) {
    if (sourceContent != null && sourceContent.contains("gwas")) {
      sourceBson.add(Filters.eq("source", "gwas"));
    }
  }
}

代码示例来源:origin: org.opencb.cellbase/cellbase-lib

private void getGwasFilters(Query query, Set<String> sourceContent, List<Bson> sourceBson) {
  // If only clinvar-specific filters are provided it must be avoided to include the source=gwas condition since
  // sourceBson is going to be an OR list
  if (!(query.containsKey(QueryParams.CLINVARRCV.key()) || query.containsKey(QueryParams.CLINVARCLINSIG.key())
      || query.containsKey(QueryParams.CLINVARREVIEW.key())
      || query.containsKey(QueryParams.CLINVARTYPE.key())
      || query.containsKey(QueryParams.CLINVARRS.key()))) {
    if (sourceContent != null && sourceContent.contains("gwas")) {
      sourceBson.add(Filters.eq("source", "gwas"));
    }
  }
}

代码示例来源:origin: opencb/opencga

private List<String> getStudyIds(String userId, Query query) throws CatalogException {
  List<String> studyIds = new ArrayList<>();
  if (query != null && query.containsKey(ClinicalVariantEngine.QueryParams.STUDY.key())) {
    String study = query.getString(ClinicalVariantEngine.QueryParams.STUDY.key());
    List<String> studies = Arrays.asList(study.split(","));
    studyIds = catalogManager.getStudyManager().resolveIds(studies, userId)
        .stream()
        .map(Study::getFqn)
        .collect(Collectors.toList());
  }
  return studyIds;
}

代码示例来源:origin: org.opencb.commons/commons-datastore-mongodb

public static Bson createAutoFilter(String mongoDbField, String queryParam, Query query, QueryParam.Type type)
    throws NumberFormatException {
  Bson filter = null;
  if (query != null && query.containsKey(queryParam)) {
    List<String> values = query.getAsStringList(queryParam);
    LogicalOperator operator = LogicalOperator.OR;
    if (values.size() == 1) {
      operator = checkOperator(values.get(0));
    }
    filter = createAutoFilter(mongoDbField, queryParam, query, type, operator);
  }
  return filter;
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key()) && !query.containsKey(QueryParams.UID.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + File.FileStatus.TRASHED + ";!=" + Status.DELETED + ";!="
        + File.FileStatus.REMOVED + ";!=" + File.FileStatus.PENDING_DELETE + ";!=" + File.FileStatus.DELETING);
  }
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
  }
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
  }
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
  }
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
  }
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
  }
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
  }
}

代码示例来源:origin: opencb/opencga

private void filterOutDeleted(Query query) {
  if (!query.containsKey(QueryParams.STATUS_NAME.key())) {
    query.append(QueryParams.STATUS_NAME.key(), "!=" + Status.DELETED);
  }
}

代码示例来源:origin: opencb/opencga

private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException {
  if (query.containsKey("inputFiles")) {
    MyResources<File> resource = catalogManager.getFileManager().getUids(query.getAsStringList("inputFiles"), study.getFqn(),
        sessionId);
    query.put(JobDBAdaptor.QueryParams.INPUT_UID.key(), resource.getResourceList().stream().map(File::getUid)
        .collect(Collectors.toList()));
    query.remove("inputFiles");
  }
  if (query.containsKey("outputFiles")) {
    MyResources<File> resource = catalogManager.getFileManager().getUids(query.getAsStringList("outputFiles"), study.getFqn(),
        sessionId);
    query.put(JobDBAdaptor.QueryParams.OUTPUT_UID.key(), resource.getResourceList().stream().map(File::getUid)
        .collect(Collectors.toList()));
    query.remove("outputFiles");
  }
}

代码示例来源:origin: opencb/opencga

private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException {
  if (query.containsKey(CohortDBAdaptor.QueryParams.SAMPLES.key())) {
    // First look for the sample ids.
    MyResources<Sample> samples = catalogManager.getSampleManager()
        .getUids(query.getAsStringList(CohortDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId);
    query.remove(CohortDBAdaptor.QueryParams.SAMPLES.key());
    query.append(CohortDBAdaptor.QueryParams.SAMPLE_UIDS.key(), samples.getResourceList().stream().map(Sample::getUid)
        .collect(Collectors.toList()));
  }
}

代码示例来源:origin: org.opencb.cellbase/cellbase-lib

@Override
public QueryResult nativeGet(Query query, QueryOptions options) {
  Bson bson = parseQuery(query);
  Bson match = Aggregates.match(bson);
  Bson project = Aggregates.project(Projections.include("transcripts.xrefs"));
  Bson unwind = Aggregates.unwind("$transcripts");
  Bson unwind2 = Aggregates.unwind("$transcripts.xrefs");
  // This project the three fields of Xref to the top of the object
  Document document = new Document("id", "$transcripts.xrefs.id");
  document.put("dbName", "$transcripts.xrefs.dbName");
  document.put("dbDisplayName", "$transcripts.xrefs.dbDisplayName");
  Bson project1 = Aggregates.project(document);
  if (query.containsKey(QueryParams.DBNAME.key())) {
    Bson bson2 = parseQuery(new Query(QueryParams.DBNAME.key(), query.get(QueryParams.DBNAME.key())));
    Bson match2 = Aggregates.match(bson2);
    return mongoDBCollection.aggregate(Arrays.asList(match, project, unwind, unwind2, match2, project1), options);
  }
  return mongoDBCollection.aggregate(Arrays.asList(match, project, unwind, unwind2, project1), options);
}

代码示例来源:origin: opencb/opencga

@Test
public void parseSampleAnnotationQuery() throws Exception {
  Query query = CatalogUtils.parseSampleAnnotationQuery("age>20;" + SampleDBAdaptor.QueryParams.PHENOTYPES.key() + "=hpo:123,hpo:456;" + SampleDBAdaptor.QueryParams.ID.key() + "=smith", SampleDBAdaptor.QueryParams::getParam);
  assertEquals(3, query.size());
  assertTrue(query.containsKey(SampleDBAdaptor.QueryParams.ID.key()));
  assertEquals("=smith", query.getString(SampleDBAdaptor.QueryParams.ID.key()));
  assertTrue(query.containsKey(SampleDBAdaptor.QueryParams.ANNOTATION.key()));
  assertEquals("annotation.age>20", query.getString(SampleDBAdaptor.QueryParams.ANNOTATION.key()));
  assertTrue(query.containsKey(SampleDBAdaptor.QueryParams.PHENOTYPES.key()));
  assertEquals("=hpo:123,hpo:456", query.getString(SampleDBAdaptor.QueryParams.PHENOTYPES.key()));
}

代码示例来源:origin: opencb/opencga

public QueryResult<VariableSet> searchVariableSets(String studyStr, Query query, QueryOptions options, String sessionId)
      throws CatalogException {
    String userId = catalogManager.getUserManager().getUserId(sessionId);
    Study study = resolveId(studyStr, userId);
//        authorizationManager.checkStudyPermission(studyId, userId, StudyAclEntry.StudyPermissions.VIEW_VARIABLE_SET);
    options = ParamUtils.defaultObject(options, QueryOptions::new);
    query = ParamUtils.defaultObject(query, Query::new);
    if (query.containsKey(StudyDBAdaptor.VariableSetParams.UID.key())) {
      // Id could be either the id or the name
      MyResourceId resource = getVariableSetId(query.getString(StudyDBAdaptor.VariableSetParams.UID.key()), studyStr, sessionId);
      query.put(StudyDBAdaptor.VariableSetParams.UID.key(), resource.getResourceId());
    }
    query.put(StudyDBAdaptor.VariableSetParams.STUDY_ID.key(), study.getUid());
    return studyDBAdaptor.getVariableSets(query, options, userId);
  }

代码示例来源:origin: opencb/opencga

@Override
public QueryResult<ClinicalAnalysis> get(String studyStr, Query query, QueryOptions options, String sessionId) throws CatalogException {
  query = ParamUtils.defaultObject(query, Query::new);
  options = ParamUtils.defaultObject(options, QueryOptions::new);
  String userId = catalogManager.getUserManager().getUserId(sessionId);
  Study study = catalogManager.getStudyManager().resolveId(studyStr, userId);
  query.append(ClinicalAnalysisDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid());
  QueryResult<ClinicalAnalysis> queryResult = clinicalDBAdaptor.get(query, options, userId);
  if (queryResult.getNumResults() == 0 && query.containsKey(ClinicalAnalysisDBAdaptor.QueryParams.UID.key())) {
    List<Long> analysisList = query.getAsLongList(ClinicalAnalysisDBAdaptor.QueryParams.UID.key());
    for (Long analysisId : analysisList) {
      authorizationManager.checkClinicalAnalysisPermission(study.getUid(), analysisId, userId,
          ClinicalAnalysisAclEntry.ClinicalAnalysisPermissions.VIEW);
    }
  }
  return queryResult;
}

相关文章