Пример #1
0
  @SuppressWarnings("unchecked")
  @Override
  public void display(HttpServletRequest request, ReportObject reportObject) {

    // get the gene/protein in question from the request
    InterMineObject object = reportObject.getObject();
    // wrapper for the result so we can say what type it is
    HashMap<String, Object> result = new HashMap();

    // API connection
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    Model model = im.getModel();
    PathQuery query = new PathQuery(model);

    // dealing with genes...
    if (object instanceof Gene) {
      // cast me Gene
      Gene gene = (Gene) object;
      String geneID = String.valueOf(gene.getId());
      query = geneCommentsQuery(geneID, query);

      Profile profile = SessionMethods.getProfile(session);
      PathQueryExecutor executor = im.getPathQueryExecutor(profile);
      ExportResultsIterator values;
      try {
        values = executor.execute(query);
      } catch (ObjectStoreException e) {
        throw new RuntimeException(e);
      }

      result.put("gene", geneComments2(values));

      // result.put("gene", geneComments(gene));
    } else if (object instanceof Protein) {
      // cast me Protein
      Protein protein = (Protein) object;
      String proteinID = String.valueOf(protein.getId());
      query = proteinCommentsQuery(proteinID, query);

      Profile profile = SessionMethods.getProfile(session);
      PathQueryExecutor executor = im.getPathQueryExecutor(profile);
      ExportResultsIterator values;
      try {
        values = executor.execute(query);
      } catch (ObjectStoreException e) {
        throw new RuntimeException(e);
      }

      result.put("protein", proteinComments2(values));

      // result.put("protein", proteinComments(protein));
    } else {
      // big fat fail
    }

    request.setAttribute("response", result);
  }