コード例 #1
0
  /**
   * Grabs the appropriate stuff from a request and returns a list of case_ids
   *
   * @param request
   * @return
   * @throws ProtocolException
   * @throws DaoException
   */
  public static ArrayList<String> getSampleIds(HttpServletRequest request)
      throws ProtocolException, DaoException {
    String samples = request.getParameter(WebService.CASE_LIST);
    String sampleSetId = request.getParameter(WebService.CASE_SET_ID);
    String sampleIdsKey = request.getParameter(WebService.CASE_IDS_KEY);

    if (sampleIdsKey != null) {
      samples = SampleSetUtil.getSampleIds(sampleIdsKey);
    }

    ArrayList<String> sampleList = new ArrayList<String>();
    if (sampleSetId != null && !(sampleSetId.equals("-1"))) {
      DaoSampleList dao = new DaoSampleList();
      SampleList selectedSampleList = dao.getSampleListByStableId(sampleSetId);
      if (selectedSampleList == null) {
        throw new ProtocolException(
            "Invalid " + WebService.CASE_SET_ID + ":  " + sampleSetId + ".");
      }
      sampleList = selectedSampleList.getSampleList();
    } else if (samples != null) {
      for (String _sample : samples.split("[\\s,]+")) {
        _sample = _sample.trim();
        if (_sample.length() == 0) continue;
        sampleList.add(_sample);
      }
    } else if (samples != null) { // todo: this is a hack, samples is just another word for patients
      return new ArrayList(Arrays.asList(samples.split(" ")));
    } else {
      throw new ProtocolException(
          WebService.CASE_SET_ID + " or " + WebService.CASE_LIST + " must be specified.");
    }
    return sampleList;
  }
コード例 #2
0
  /**
   * Given an HttpServletRequest, determine all cancer_study_ids associated with it. cancer study
   * identifiers can be inferred from profile_ids, case_list_ids, or case_ids. this returns the set
   * of ALL POSSIBLE cancer study identifiers
   *
   * @param request
   * @return the cancer_study_ids associated with the request, which will be empty if none can be
   *     determined; or empty set if a problem arises.
   * @throws DaoException
   * @throws ProtocolException
   */
  public static HashSet<String> getCancerStudyIDs(HttpServletRequest request)
      throws DaoException, ProtocolException {

    HashSet<String> cancerStudies = new HashSet<String>();

    // a CANCER_STUDY_ID is explicitly provided, as in getGeneticProfiles, getCaseLists, etc.
    // make sure the cancer_study_id provided in the request points to a real study
    String studyIDstring = getCancerStudyId(request);
    if (studyIDstring != null) {
      if (DaoCancerStudy.doesCancerStudyExistByStableId(studyIDstring)) {
        cancerStudies.add(studyIDstring);
      }

      return cancerStudies;
    }

    // a genetic_profile_id is explicitly provided, as in getProfileData
    if (null != request.getParameter(WebService.GENETIC_PROFILE_ID)) {
      ArrayList<String> geneticProfileIds = getGeneticProfileId(request);
      for (String geneticProfileId : geneticProfileIds) {

        // that's the point of this code??
        //                if (geneticProfileId == null) {
        //                    return cancerStudies;
        //                }

        GeneticProfile aGeneticProfile =
            DaoGeneticProfile.getGeneticProfileByStableId(geneticProfileId);
        if (aGeneticProfile != null
            && DaoCancerStudy.doesCancerStudyExistByInternalId(
                aGeneticProfile.getCancerStudyId())) {
          cancerStudies.add(
              DaoCancerStudy.getCancerStudyByInternalId(aGeneticProfile.getCancerStudyId())
                  .getCancerStudyStableId());
        }
      }

      return cancerStudies;
    }

    // a patient_set_id is explicitly provided, as in getProfileData, getMutationData,
    // getClinicalData, etc.
    String sampleSetId = request.getParameter(WebService.CASE_SET_ID);
    if (sampleSetId != null) {
      DaoSampleList aDaoSampleList = new DaoSampleList();
      SampleList aSampleList = aDaoSampleList.getSampleListByStableId(sampleSetId);

      if (aSampleList != null
          && DaoCancerStudy.doesCancerStudyExistByInternalId(aSampleList.getCancerStudyId())) {
        cancerStudies.add(
            DaoCancerStudy.getCancerStudyByInternalId(aSampleList.getCancerStudyId())
                .getCancerStudyStableId());
      }

      return cancerStudies;
    }

    return cancerStudies;
  }