/** {@inheritDoc} */
  @Override
  public ActionForward execute(
      @SuppressWarnings("unused") ActionMapping mapping,
      @SuppressWarnings("unused") ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    ObjectStore os = im.getObjectStore();
    WebConfig webConfig = SessionMethods.getWebConfig(request);
    Integer objectId = new Integer(request.getParameter("object"));
    String fieldName = request.getParameter("field");
    String fileType = request.getParameter("type");
    InterMineObject object = os.getObjectById(objectId);

    FieldExporter fieldExporter = null;

    Set classes = DynamicUtil.decomposeClass(object.getClass());

    Iterator classIter = classes.iterator();

    while (classIter.hasNext()) {
      Class c = (Class) classIter.next();

      Type thisTypeConfig = webConfig.getTypes().get(c.getName());

      FieldConfig fc = thisTypeConfig.getFieldConfigMap().get(fieldName);

      if (fc != null) {
        String fieldExporterClassName = fc.getFieldExporter();
        if (fieldExporterClassName != null) {
          fieldExporter = (FieldExporter) Class.forName(fieldExporterClassName).newInstance();
          break;
        }
      }
    }

    if (fieldExporter == null) {
      Object fieldValue = object.getFieldValue(fieldName);
      if (fileType == null || fileType.length() == 0) {
        response.setContentType("text/plain; charset=UTF-8");
        response.setHeader("Content-Disposition ", "inline; filename=" + fieldName + ".txt");
      } else {
        response.setContentType("text/" + fileType);
        response.setHeader(
            "Content-Disposition ", "inline; filename=" + fieldName + "." + fileType);
      }
      PrintStream out = new PrintStream(response.getOutputStream());
      if (fieldValue instanceof ClobAccess) {
        ((ClobAccess) fieldValue).drainToPrintStream(out);
      } else {
        out.print(fieldValue);
      }
      out.flush();
    } else {
      fieldExporter.exportField(object, fieldName, os, response);
    }
    return null;
  }
示例#2
0
  /**
   * Save a single object to an existing bag.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @return an ActionForward object defining where control goes next
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    int id = Integer.parseInt(request.getParameter("object"));
    HttpSession session = request.getSession();

    final InterMineAPI im = SessionMethods.getInterMineAPI(request.getSession());

    Profile profile = SessionMethods.getProfile(session);
    String bagName = request.getParameter("bag");

    InterMineBag existingBag = profile.getSavedBags().get(bagName);
    if (existingBag != null) {
      // TODO add a warning when object already in bag ??
      try {
        InterMineObject o = im.getObjectStore().getObjectById(id);
        existingBag.addIdToBag(id, DynamicUtil.getFriendlyName(o.getClass()));
        recordMessage(new ActionMessage("bag.addedToBag", existingBag.getName()), request);
      } catch (IncompatibleTypesException e) {
        recordError(new ActionMessage("bag.typesDontMatch"), request);
      } catch (ObjectStoreException e) {
        recordError(new ActionMessage("bag.error"), request, e);
      }
    } else {
      recordError(new ActionMessage("bag.noSuchBag"), request);
    }
    return mapping.findForward("report");
  }
  @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);
  }
  /** {@inheritDoc} */
  @Override
  public ActionForward execute(
      @SuppressWarnings("unused") ComponentContext context,
      @SuppressWarnings("unused") ActionMapping mapping,
      @SuppressWarnings("unused") ActionForm form,
      HttpServletRequest request,
      @SuppressWarnings("unused") HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();

    Profile profile = SessionMethods.getProfile(session);
    PathQuery query = SessionMethods.getQuery(session);
    DisplayConstraintFactory factory = getFactory(session);

    if (session.getAttribute("newConstraintPath") != null) {
      // ADDING A NEW CONSTRAINT
      DisplayPath displayPath = (DisplayPath) session.getAttribute("newConstraintPath");
      DisplayConstraint displayConstraint = factory.get(displayPath.getPath(), profile, query);
      request.setAttribute("dec", displayConstraint);
      session.removeAttribute("newConstraintPath");
      saveToken(request);
    } else if (session.getAttribute("editingConstraint") != null) {
      // EDITING AN EXISTING CONSTRAINT
      PathConstraint con = (PathConstraint) session.getAttribute("editingConstraint");
      DisplayConstraint displayConstraint;
      if (query instanceof TemplateQuery) {
        TemplateQuery template = (TemplateQuery) query;
        displayConstraint = factory.get(con, profile, template);
      } else {
        displayConstraint = factory.get(con, profile, query);
      }

      request.setAttribute("dec", displayConstraint);
      session.removeAttribute("editingConstraint");
      if (session.getAttribute("editingTemplateConstraint") != null) {
        SessionMethods.moveToRequest("editingTemplateConstraint", request);
      }
      saveToken(request);
    } else if (session.getAttribute("joinStylePath") != null) {
      // ONLY EDITING JOIN STYLE
      String joinStylePathStr = (String) session.getAttribute("joinStylePath");
      Path joinStylePath = query.makePath(joinStylePathStr);
      DisplayConstraint displayConstraint = factory.get(joinStylePath, profile, query);
      session.removeAttribute("joinStylePath");

      if (query.getOuterMap().containsKey(joinStylePathStr)) {
        request.setAttribute("joinType", "outer");
      } else {
        request.setAttribute("joinType", "inner");
      }
      request.setAttribute("dec", displayConstraint);
      request.setAttribute("joinStyleOnly", "true");
      saveToken(request);
    }

    return null;
  }
示例#5
0
  /**
   * @param pt paged table
   * @param request request
   * @return all results of pathquery corresponding specified paged table.
   */
  public ExportResultsIterator getResultRows(PagedTable pt, HttpServletRequest request) {
    PathQuery pathQuery = pt.getWebTable().getPathQuery();
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    Profile profile = SessionMethods.getProfile(session);

    executor = im.getPathQueryExecutor(profile);
    executor.setBatchSize(BATCH_SIZE);
    return executor.execute(pathQuery);
  }
示例#6
0
  /** {@inheritDoc} */
  public ActionForward execute(
      @SuppressWarnings("unused") ActionMapping mapping,
      @SuppressWarnings("unused") ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String type = request.getParameter("type");
    if (type == null) {
      type = "webapp";
    }

    if ("webapp".equals(type)) {
      response.getOutputStream().print("OK");
    } else if ("query".equals(type)) {
      final InterMineAPI im = SessionMethods.getInterMineAPI(request.getSession());
      ObjectStore os = im.getObjectStore();
      Query q = new Query();
      QueryClass c = new QueryClass(InterMineObject.class);
      q.addFrom(c);
      q.addToSelect(c);
      // Add a unique value to the select to avoid caching the query
      QueryValue token = new QueryValue(System.currentTimeMillis());
      q.addToSelect(token);
      Results r = os.execute(q, 1, false, false, false);
      if (r.get(0) != null) {
        response.getOutputStream().print("OK");
      } else {
        response.getOutputStream().print("NO RESULTS");
      }
    }
    return null;
  }
示例#7
0
  public void setUp() throws Exception {
    super.setUp();

    userprofileOS.setModel(Model.getInstanceByName("userprofile"));
    Model testmodel = Model.getInstanceByName("testmodel");
    query = new PathQuery(testmodel);

    query.addView("Employee");
    query.addView("Employee.name");
    queryBag = new PathQuery(testmodel);

    queryBag.addView("Employee");
    queryBag.addView("Employee.name");
    queryBag.addConstraint(Constraints.in("Employee", "bag2"));
    sq = new SavedQuery("query1", date, query);
    sqBag = new SavedQuery("query3", date, queryBag);
    hist = new SavedQuery("query2", date, (PathQuery) query.clone());
    hist2 = new SavedQuery("query1", date, query.clone());
    template = new TemplateQuery("template", "ttitle", "tdesc", new PathQuery(testmodel));

    SessionMethods.initSession(this.getSession());
    Profile profile = (Profile) getSession().getAttribute(Constants.PROFILE);
    profile.saveQuery(sq.getName(), sq);
    profile.saveQuery(sqBag.getName(), sqBag);
    profile.saveHistory(hist);
    profile.saveHistory(hist2);
  }
示例#8
0
 // make sure new list name doesn't equal the default example list name
 private String getNewNameTextBox(HttpServletRequest request, String newBagName) {
   Properties properties =
       SessionMethods.getWebProperties(request.getSession().getServletContext());
   String exampleName = properties.getProperty("lists.input.example");
   if (StringUtils.isEmpty(newBagName) || newBagName.equalsIgnoreCase(exampleName)) {
     return null;
   }
   return newBagName;
 }
  /**
   * Either display the query builder or redirect to project.sitePrefix.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @return an ActionForward object defining where control goes next
   * @exception Exception if the application business logic throws an exception
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();
    PathQuery query = SessionMethods.getQuery(session);
    boolean showTemplate = (request.getParameter("showTemplate") != null);

    if (query == null) {
      return new ForwardParameters(
              getWebProperties(request).getProperty("project.sitePrefix"), true)
          .forward();
    }

    if (query instanceof TemplateQuery && showTemplate) {
      TemplateQuery template = (TemplateQuery) query;
      Profile profile = SessionMethods.getProfile(session);
      String temporaryName = null;
      for (SavedQuery sq : profile.getHistory().values()) {
        if (sq.getPathQuery() instanceof TemplateQuery
            && ((TemplateQuery) sq.getPathQuery()).getName().equals(template.getName())) {
          temporaryName = sq.getName();
        }
      }
      if (temporaryName != null) {
        return new ForwardParameters(mapping.findForward("template"))
            .addParameter("loadModifiedTemplate", "true")
            .addParameter("name", template.getName())
            .addParameter("savedQueryName", temporaryName)
            .forward();
      }
      return new ForwardParameters(mapping.findForward("template"))
          .addParameter("name", template.getName())
          .forward();
    }
    if (!(query instanceof TemplateQuery)) {
      session.removeAttribute(Constants.EDITING_TEMPLATE);
      session.removeAttribute(Constants.NEW_TEMPLATE);
    }
    return mapping.findForward("query");
  }
示例#10
0
  /** {@inheritDoc} */
  @Override
  public ActionForward execute(
      ComponentContext context,
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);

    InterMineBag imBag = (InterMineBag) request.getAttribute("bag");
    WebConfig webConfig = SessionMethods.getWebConfig(request);
    Model model = im.getModel();
    TemplateManager templateManager = im.getTemplateManager();

    Map<Class, ApiTemplate> conversionTypesMap =
        TypeConverter.getConversionTemplates(
            templateManager.getConversionTemplates(),
            TypeUtil.instantiate(model.getPackageName() + "." + imBag.getType()));
    ArrayList<String> conversionTypes = new ArrayList<String>();
    Map<Type, Boolean> fastaMap = new HashMap<Type, Boolean>();
    for (Class<?> clazz : conversionTypesMap.keySet()) {
      conversionTypes.add(TypeUtil.unqualifiedName(clazz.getName()));
      Type type = webConfig.getTypes().get(clazz.getName());
      FieldConfig fieldConfig = type.getFieldConfigMap().get("length");
      if (fieldConfig != null && fieldConfig.getDisplayer() != null) {
        fastaMap.put(type, Boolean.TRUE);
      } else {
        fastaMap.put(type, Boolean.FALSE);
      }
    }
    // Use custom converters
    BagQueryConfig bagQueryConfig = im.getBagQueryConfig();
    String bagType = imBag.getType();
    Set<AdditionalConverter> additionalConverters = bagQueryConfig.getAdditionalConverters(bagType);
    request.setAttribute("customConverters", additionalConverters);
    request.setAttribute("conversionTypes", conversionTypes);
    request.setAttribute("fastaMap", fastaMap);
    return null;
  }
  /** {@inheritDoc} */
  public ActionForward execute(
      ComponentContext context,
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String name = (String) context.getAttribute("name");
    String type = (String) context.getAttribute("type");
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);

    Profile profile = SessionMethods.getProfile(session);
    TagManager tagManager = im.getTagManager();

    Set<String> userTags = tagManager.getObjectTagNames(name, type, profile.getUsername());
    String isFavourite = Boolean.toString(userTags.contains(TagNames.IM_FAVOURITE));

    request.setAttribute("isFavourite", isFavourite);
    return null;
  }
示例#12
0
  /**
   * Method called when user has finished updating a constraint.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @return an ActionForward object defining where control goes next
   * @exception Exception if the application business logic throws an exception
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    ProfileManager pm = im.getProfileManager();
    String username = ((CreateAccountForm) form).getUsername();
    String password = ((CreateAccountForm) form).getPassword();
    pm.createNewProfile(username, password);
    Properties webProperties = SessionMethods.getWebProperties(session.getServletContext());
    try {
      MailUtils.email(username, webProperties);
      if (((CreateAccountForm) form).getMailinglist()
          && webProperties.getProperty("mail.mailing-list") != null
          && webProperties.getProperty("mail.mailing-list").length() > 0) {
        MailUtils.subscribe(username, webProperties);
      }
      SessionMethods.recordMessage(
          "You have successfully created an account, and logged in.", session);
    } catch (Exception e) {
      SessionMethods.recordError("Failed to send confirmation email", session);
    }

    /*
     * This code generates an MD5 key for the given username which is then
     * encoded in Hexadecimal. This could later be used for account
     * activation.
     *
     * try { MessageDigest md5 = MessageDigest.getInstance("MD5"); byte[]
     * buffer = username.getBytes(); md5.update(buffer); byte[] array =
     * md5.digest(); String encoded = HexBin.encode(array); } catch
     * (NoSuchAlgorithmException e) { }
     */
    doLogin(request, username, password);
    return new ActionForward("/begin.do");
  }
示例#13
0
  public void setUp() throws Exception {
    super.setUp();
    MockServletContext context = new MockServletContext();
    final Properties p = new Properties();
    p.setProperty("web.config.classname.mappings", "CLASS_NAME_MAPPINGS");
    p.setProperty("web.config.fieldname.mappings", "FIELD_NAME_MAPPINGS");
    SessionMethods.setWebProperties(context, p);

    final InputStream is = getClass().getClassLoader().getResourceAsStream("WebConfigTest.xml");
    final InputStream classesIS =
        getClass().getClassLoader().getResourceAsStream("testClassMappings.properties");
    final InputStream fieldsIS =
        getClass().getClassLoader().getResourceAsStream("testFieldMappings.properties");
    context.addInputStream("/WEB-INF/webconfig-model.xml", is);
    context.addInputStream("/WEB-INF/CLASS_NAME_MAPPINGS", classesIS);
    context.addInputStream("/WEB-INF/FIELD_NAME_MAPPINGS", fieldsIS);
    webConfig = WebConfig.parse(context, os.getModel());
  }
示例#14
0
 private void delete(ActionForm form, HttpServletRequest request) throws Exception {
   HttpSession session = request.getSession();
   Profile profile = SessionMethods.getProfile(session);
   ModifyBagForm mbf = (ModifyBagForm) form;
   for (int i = 0; i < mbf.getSelectedBags().length; i++) {
     String bagName = mbf.getSelectedBags()[i];
     InterMineBag bag = profile.getSavedBags().get(bagName);
     if (bag != null) {
       deleteQueriesThatMentionBag(profile, bag.getName());
       deleteBag(session, profile, bag);
     } else {
       bag = profile.getSharedBags().get(bagName);
       if (bag == null) {
         LOG.error("Asked to delete a bag this user does not have access to.");
       } else {
         unshareBag(session, profile, bag);
       }
     }
   }
 }
  /** {@inheritDoc} */
  @Override
  public ActionForward execute(
      ComponentContext context,
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    boolean canExportAsBED = false;

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

    // org and dbkey for galaxy use
    Set<String> orgSet = new HashSet<String>();
    Set<String> genomeBuildSet = new HashSet<String>();

    // Build GenomicRegion pathquery, the request is from GenomicRegionSearch "export to Galaxy"
    if (request.getParameter("featureIds") != null) {
      String featureIds = request.getParameter("featureIds").trim();
      String orgName = request.getParameter("orgName");

      if (orgName != null && !"".equals(orgName)) {
        orgSet.add(orgName);
      }

      // Refer to GenomicRegionSearchService.getExportFeaturesQuery method
      String path = "SequenceFeature";
      query.addView(path + ".primaryIdentifier");
      query.addView(path + ".chromosomeLocation.locatedOn.primaryIdentifier");
      query.addView(path + ".chromosomeLocation.start");
      query.addView(path + ".chromosomeLocation.end");
      query.addView(path + ".organism.name");

      // use ids or pids
      String[] idsInStr = featureIds.split(",");
      Set<Integer> ids = new HashSet<Integer>();
      boolean isIds = true;
      for (String id : idsInStr) {
        id = id.trim();
        if (!Pattern.matches("^\\d+$", id)) {
          isIds = false;
          break;
        }
        ids.add(Integer.valueOf(id));
      }

      if (isIds) {
        query.addConstraint(Constraints.inIds(path, ids));
      } else {
        if (featureIds.contains("'")) {
          featureIds = featureIds.replaceAll("'", "\\\\'");
        }
        query.addConstraint(Constraints.lookup(path, featureIds, null));
      }

      canExportAsBED = true;

    } else { // request from normal result table
      String tableName = request.getParameter("table");
      request.setAttribute("table", tableName);
      PagedTable pt = SessionMethods.getResultsTable(session, tableName);

      // Null check to page table, maybe session timeout?
      if (pt == null) {
        LOG.error("Page table is NULL...");
        return null;
      }

      // Check if can export as BED
      TableHttpExporter tableExporter = new BEDHttpExporter();

      try {
        canExportAsBED = tableExporter.canExport(pt);
      } catch (Exception e) {
        canExportAsBED = false;

        LOG.error("Caught an error running canExport() for: BEDHttpExporter. " + e);
        e.printStackTrace();
      }

      LinkedHashMap<Path, Integer> exportClassPathsMap = getExportClassPaths(pt);
      List<Path> exportClassPaths = new ArrayList<Path>(exportClassPathsMap.keySet());

      Map<String, String> pathMap = new LinkedHashMap<String, String>();
      for (Path path : exportClassPaths) {
        String pathString = path.toStringNoConstraints();
        String displayPath = pathString.replace(".", " &gt; ");
        pathMap.put(pathString, displayPath);
      }

      Map<String, Integer> pathIndexMap = new LinkedHashMap<String, Integer>();
      for (int index = 0; index < exportClassPaths.size(); index++) {
        String pathString = exportClassPaths.get(index).toStringNoConstraints();
        Integer idx = exportClassPathsMap.get(exportClassPaths.get(index));
        pathIndexMap.put(pathString, idx);
      }

      request.setAttribute("exportClassPaths", pathMap);
      request.setAttribute("pathIndexMap", pathIndexMap);

      // Support export public and private lists to Galaxy
      query = pt.getWebTable().getPathQuery();
      ObjectStore os = im.getObjectStore();

      Map<PathConstraint, String> constrains = query.getConstraints();
      for (PathConstraint constraint : constrains.keySet()) {
        if (constraint instanceof PathConstraintBag) {
          String bagName = ((PathConstraintBag) constraint).getBag();
          InterMineBag imBag =
              im.getBagManager().getBag(SessionMethods.getProfile(session), bagName);

          // find the classKeys
          Set<String> classKeySet = new LinkedHashSet<String>();
          for (Integer id : imBag.getContentsAsIds()) {
            String classKey = pt.findClassKeyValue(im.getClassKeys(), os.getObjectById(id));
            classKeySet.add(classKey);
          }

          String path = ((PathConstraintBag) constraint).getPath();
          // replace constraint in the pathquery
          PathConstraintLookup newConstraint =
              new PathConstraintLookup(
                  path,
                  classKeySet.toString().substring(1, classKeySet.toString().length() - 1),
                  null);
          query.replaceConstraint(constraint, newConstraint);
        }
      }

      orgSet = SequenceFeatureExportUtil.getOrganisms(query, session);
    }

    if (query instanceof TemplateQuery) {
      TemplateQuery templateQuery = (TemplateQuery) query;
      Map<PathConstraint, SwitchOffAbility> constraintSwitchOffAbilityMap =
          templateQuery.getConstraintSwitchOffAbility();
      for (Map.Entry<PathConstraint, SwitchOffAbility> entry :
          constraintSwitchOffAbilityMap.entrySet()) {
        if (entry.getValue().compareTo(SwitchOffAbility.OFF) == 0) {
          templateQuery.removeConstraint(entry.getKey());
        }
      }
    }

    String queryXML =
        PathQueryBinding.marshal(query, "", model.getName(), PathQuery.USERPROFILE_VERSION);

    //        String encodedQueryXML = URLEncoder.encode(queryXML, "UTF-8");

    String tableViewURL =
        new URLGenerator(request).getPermanentBaseURL() + "/service/query/results";

    request.setAttribute("tableURL", tableViewURL);
    request.setAttribute("queryXML", queryXML);
    request.setAttribute("size", 1000000);

    // If can export as BED
    request.setAttribute("canExportAsBED", canExportAsBED);
    if (canExportAsBED) {
      String bedURL =
          new URLGenerator(request).getPermanentBaseURL() + "/service/query/results/bed";

      request.setAttribute("bedURL", bedURL);

      genomeBuildSet =
          (Set<String>) OrganismGenomeBuildLookup.getGenomeBuildByOrgansimCollection(orgSet);

      String org =
          (orgSet.size() < 1) ? "Organism information not available" : StringUtil.join(orgSet, ",");

      // possible scenario: [null, ce3, null], should remove all null element and then join
      genomeBuildSet.removeAll(Collections.singleton(null));
      String dbkey =
          (genomeBuildSet.size() < 1)
              ? "Genome Build information not available"
              : StringUtil.join(genomeBuildSet, ",");

      request.setAttribute("org", org);
      request.setAttribute("dbkey", dbkey);
    }

    // PathMap
    Map<String, String> pathsMap = new LinkedHashMap<String, String>();
    List<String> views = query.getView();
    for (String view : views) {
      String title = query.getGeneratedPathDescription(view);
      title = WebUtil.formatColumnName(title);
      pathsMap.put(view, title);
    }

    request.setAttribute("pathsMap", pathsMap);

    return null;
  }
示例#16
0
 public TrackAjaxServices() {
   HttpSession session = WebContextFactory.get().getSession();
   final InterMineAPI im = SessionMethods.getInterMineAPI(session);
   uos = im.getProfileManager().getProfileObjectStoreWriter().getObjectStore();
 }
示例#17
0
 // Remove a bag from userprofile database and session cache
 private void deleteBag(HttpSession session, Profile profile, InterMineBag bag)
     throws ObjectStoreException {
   // removed a cached bag table from the session
   SessionMethods.invalidateBagTable(session, bag.getName());
   profile.deleteBag(bag.getName());
 }
示例#18
0
 private void unshareBag(HttpSession session, Profile profile, InterMineBag bag) {
   InterMineAPI api = SessionMethods.getInterMineAPI(session);
   BagManager bm = api.getBagManager();
   bm.unshareBagWithUser(bag, profile);
 }
示例#19
0
  private void combine(ActionForm form, HttpServletRequest request, String opText) {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    Profile profile = SessionMethods.getProfile(session);
    ModifyBagForm mbf = (ModifyBagForm) form;

    BagManager bagManager = im.getBagManager();
    Map<String, InterMineBag> allBags = bagManager.getBags(profile);

    String[] selectedBagNames = mbf.getSelectedBags();

    Collection<InterMineBag> selectedBags = getSelectedBags(allBags, selectedBagNames);

    String newBagName = NameUtil.validateName(allBags.keySet(), mbf.getNewBagName());

    int newBagSize = 0;
    try {
      if (opText.equals(BagOperations.UNION)) {
        newBagSize = BagOperations.union(selectedBags, newBagName, profile, im.getClassKeys());
      } else if (opText.equals(BagOperations.INTERSECT)) {
        newBagSize = BagOperations.intersect(selectedBags, newBagName, profile, im.getClassKeys());
      } else if (opText.equals(BagOperations.SUBTRACT)) {
        newBagSize = BagOperations.subtract(selectedBags, newBagName, profile, im.getClassKeys());
      }
    } catch (IncompatibleTypesException e) {
      SessionMethods.recordError(
          "You can only perform operations on lists of the same type."
              + " Lists "
              + StringUtil.prettyList(Arrays.asList(selectedBagNames))
              + " do not match.",
          session);
      return;
    } catch (ObjectStoreException e) {
      LOG.error(e);
      ActionMessage actionMessage = new ActionMessage("An error occurred while saving the list");
      recordError(actionMessage, request);
      return;
    }

    if (newBagSize > 0) {
      SessionMethods.recordMessage(
          "Created list \""
              + newBagName
              + "\" as "
              + opText
              + " of  "
              + StringUtil.prettyList(Arrays.asList(selectedBagNames))
              + ".",
          session);
      // track the list creation
      im.getTrackerDelegate()
          .trackListCreation(
              BagOperations.getCommonBagType(selectedBags),
              newBagSize,
              ListBuildMode.OPERATION,
              profile,
              session.getId());
    } else {
      SessionMethods.recordError(
          opText
              + " operation on lists "
              + StringUtil.prettyList(Arrays.asList(selectedBagNames))
              + " produced no results.",
          session);
    }
  }
  /**
   * Method called to export a saved Query.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @return an ActionForward object defining where control goes next
   * @exception Exception if the application business logic throws an exception
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    Profile profile = SessionMethods.getProfile(session);

    String type = request.getParameter("type");
    String name = request.getParameter("name");

    PathQuery query = null;

    if (StringUtils.isEmpty(type) || StringUtils.isEmpty(name)) {
      query = SessionMethods.getQuery(session);
    } else if ("history".equals(type)) {
      SavedQuery sq = profile.getHistory().get(name);

      if (sq == null) {
        recordError(new ActionMessage("errors.query.missing", name), request);
        return mapping.findForward("mymine");
      }

      query = sq.getPathQuery();
    } else if ("saved".equals(type)) {
      SavedQuery sq = profile.getSavedQueries().get(name);

      if (sq == null) {
        recordError(new ActionMessage("errors.query.missing", name), request);
        return mapping.findForward("mymine");
      }

      query = sq.getPathQuery();
    } else {
      LOG.error("Bad type parameter: " + type);
      return null;
    }

    if (query == null) {
      LOG.error("Failed to find query " + name + " of type " + type);
      return null;
    }

    if (query.getView().size() == 0) {
      response.getWriter().write("Invalid query. No fields selected for output.");
      return null;
    }

    response.setContentType("text/plain; charset=utf-8");
    WebResultsExecutor webResultsExecutor = im.getWebResultsExecutor(profile);

    String format;
    if (!StringUtils.isEmpty(request.getParameter("as"))) {
      format = request.getParameter("as").toLowerCase();
    } else {
      format = "xml";
    }
    if ("xml".equals(format)) {
      String xml = getQueryXML(name, query);
      xml = XmlUtil.indentXmlSimple(xml);
      response.getWriter().write(xml);
    } else if ("iql".equals(format)) {
      Query osQuery = webResultsExecutor.makeQuery(query);
      response.getWriter().println(osQuery.toString());
    } else if ("sql".equals(format)) {
      response.getWriter().println(webResultsExecutor.makeSql(query));
    } else if ("link".equals(format)) {
      String serviceFormat;
      if (request.getParameter("serviceFormat") != null) {
        serviceFormat = request.getParameter("serviceFormat");
      } else {
        serviceFormat = "tab";
      }
      String xml = getQueryXML(name, query);
      String link =
          new QueryResultLinkGenerator()
              .getLink(new URLGenerator(request).getPermanentBaseURL(), xml, serviceFormat);
      response.getWriter().write(link);
    } else {
      response.getWriter().println("Unknown export type: " + request.getParameter("as"));
    }

    return null;
  }
示例#21
0
  private void copy(ActionForm form, HttpServletRequest request) throws ObjectStoreException {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    Profile profile = SessionMethods.getProfile(session);
    ModifyBagForm frm = (ModifyBagForm) form;
    String[] selectedBagNames = frm.getSelectedBags();

    BagManager bagManager = im.getBagManager();
    Map<String, InterMineBag> allBags = bagManager.getBags(profile);

    String newNameTextBox = getNewNameTextBox(request, frm.getNewBagName());

    if (selectedBagNames.length == 1) {
      String selectedBagName = selectedBagNames[0];
      InterMineBag origBag = allBags.get(selectedBagName);

      if (origBag == null) {
        recordError(new ActionMessage("errors.bag.notfound"), request);
        return;
      }

      String newBagName = "";
      if (newNameTextBox != null) {
        newBagName = NameUtil.validateName(allBags.keySet(), newNameTextBox);
        if (newBagName.isEmpty()) {
          recordError(new ActionMessage("bag.createdlists.notvalidname", newNameTextBox), request);
          return;
        }
      }
      if (newNameTextBox == null) {
        newBagName = NameUtil.generateNewName(allBags.keySet(), selectedBagName);
      }

      if (createBag(origBag, newBagName, profile)) {
        recordMessage(new ActionMessage("bag.createdlists", newBagName), request);
        // track the list creation
        im.getTrackerDelegate()
            .trackListCreation(
                origBag.getType(),
                origBag.getSize(),
                ListBuildMode.OPERATION,
                profile,
                session.getId());
      }
    } else {
      if (newNameTextBox != null) {
        recordError(new ActionMessage("errors.bag.namecannotbespecified"), request);
        return;
      }
      String msg = "";
      for (int i = 0; i < selectedBagNames.length; i++) {

        String selectedBagName = selectedBagNames[i];
        InterMineBag origBag = allBags.get(selectedBagName);

        if (origBag == null) {
          recordError(new ActionMessage("errors.bag.notfound"), request);
          return;
        }

        String newBagName = NameUtil.generateNewName(allBags.keySet(), selectedBagName);
        if (createBag(origBag, newBagName, profile)) {
          msg += newBagName + ", ";
        }
      }
      if (msg.length() > 2) {
        msg = msg.substring(0, msg.length() - 2);
      }
      if (msg.length() > 0) {
        recordMessage(new ActionMessage("bag.createdlists", msg), request);
      }
    }
  }
示例#22
0
  /** {@inheritDoc} */
  @SuppressWarnings("unused")
  @Override
  public ActionForward execute(
      @SuppressWarnings("unused") ActionMapping mapping,
      @SuppressWarnings("unused") ActionForm form,
      HttpServletRequest request,
      @SuppressWarnings("unused") HttpServletResponse response)
      throws Exception {

    long startTime = System.currentTimeMillis();

    HttpSession session = request.getSession();
    InterMineAPI im = SessionMethods.getInterMineAPI(session);

    if (im.getBagManager().isAnyBagToUpgrade(SessionMethods.getProfile(session))) {
      recordError(new ActionMessage("login.upgradeListManually"), request);
    }
    // fetch & set requested object
    InterMineObject requestedObject = getRequestedObject(im, request);

    if (requestedObject != null) {
      ReportObjectFactory reportObjectFactory = SessionMethods.getReportObjects(session);
      ReportObject reportObject = reportObjectFactory.get(requestedObject);

      request.setAttribute("object", reportObject);
      request.setAttribute("reportObject", reportObject);

      request.setAttribute("requestedObject", requestedObject);

      // hell starts here
      TagManager tagManager = im.getTagManager();
      ServletContext servletContext = session.getServletContext();
      ObjectStore os = im.getObjectStore();
      String superuser = im.getProfileManager().getSuperuser();
      if (superuser.equals(SessionMethods.getProfile(session).getUsername())) {
        request.setAttribute("SHOW_TAGS", true);
      }
      // place InlineLists based on TagManager, reportObject is cached while Controller is not
      Map<String, List<InlineList>> placedInlineLists = new TreeMap<String, List<InlineList>>();
      // traverse all unplaced (non-header) InlineLists
      for (InlineList list : reportObject.getNormalInlineLists()) {
        FieldDescriptor fd = list.getDescriptor();
        String taggedType = getTaggedType(fd);

        // assign lists to any aspects they are tagged to or put in unplaced lists
        String fieldPath = fd.getClassDescriptor().getUnqualifiedName() + "." + fd.getName();
        List<Tag> tags = tagManager.getTags(null, fieldPath, taggedType, superuser);
        for (Tag tag : tags) {
          String tagName = tag.getTagName();
          if (AspectTagUtil.isAspectTag(tagName)) {
            List<InlineList> listsForAspect = placedInlineLists.get(tagName);
            if (listsForAspect == null) {
              listsForAspect = new ArrayList<InlineList>();
              placedInlineLists.put(tagName, listsForAspect);
            }
            listsForAspect.add(list);
          } else if (tagName.equals(TagNames.IM_SUMMARY)) {
            List<InlineList> summaryLists = placedInlineLists.get(tagName);
            if (summaryLists == null) {
              summaryLists = new ArrayList<InlineList>();
              placedInlineLists.put(tagName, summaryLists);
            }
            summaryLists.add(list);
          }
        }
      }

      // any lists that aren't tagged will be 'unplaced'
      List<InlineList> unplacedInlineLists =
          new ArrayList<InlineList>(reportObject.getNormalInlineLists());
      unplacedInlineLists.removeAll(placedInlineLists.values());

      long now = System.currentTimeMillis();
      LOG.info("TIME placed inline lists: " + (now - startTime) + "ms");
      long stepTime = now;

      request.setAttribute("mapOfInlineLists", placedInlineLists);
      request.setAttribute("listOfUnplacedInlineLists", unplacedInlineLists);

      Map<String, Map<String, DisplayField>> placementRefsAndCollections =
          new TreeMap<String, Map<String, DisplayField>>();
      Set<String> aspects = new LinkedHashSet<String>(SessionMethods.getCategories(servletContext));

      Set<ClassDescriptor> cds =
          os.getModel().getClassDescriptorsForClass(requestedObject.getClass());

      for (String aspect : aspects) {
        placementRefsAndCollections.put(
            TagNames.IM_ASPECT_PREFIX + aspect,
            new TreeMap<String, DisplayField>(String.CASE_INSENSITIVE_ORDER));
      }

      Map<String, DisplayField> miscRefs =
          new TreeMap<String, DisplayField>(reportObject.getRefsAndCollections());
      placementRefsAndCollections.put(TagNames.IM_ASPECT_MISC, miscRefs);

      // summary refs and colls
      Map<String, DisplayField> summaryRefsCols = new TreeMap<String, DisplayField>();
      placementRefsAndCollections.put(TagNames.IM_SUMMARY, summaryRefsCols);

      for (Iterator<Entry<String, DisplayField>> iter =
              reportObject.getRefsAndCollections().entrySet().iterator();
          iter.hasNext(); ) {
        Map.Entry<String, DisplayField> entry = iter.next();
        DisplayField df = entry.getValue();
        if (df instanceof DisplayReference) {
          categoriseBasedOnTags(
              ((DisplayReference) df).getDescriptor(),
              "reference",
              df,
              miscRefs,
              tagManager,
              superuser,
              placementRefsAndCollections,
              SessionMethods.isSuperUser(session));
        } else if (df instanceof DisplayCollection) {
          categoriseBasedOnTags(
              ((DisplayCollection) df).getDescriptor(),
              "collection",
              df,
              miscRefs,
              tagManager,
              superuser,
              placementRefsAndCollections,
              SessionMethods.isSuperUser(session));
        }
      }

      // remove any fields overridden by displayers
      removeFieldsReplacedByReportDisplayers(reportObject, placementRefsAndCollections);
      request.setAttribute("placementRefsAndCollections", placementRefsAndCollections);

      String type = reportObject.getType();
      request.setAttribute("objectType", type);

      String stableLink = PortalHelper.generatePortalLink(reportObject.getObject(), im, request);
      if (stableLink != null) {
        request.setAttribute("stableLink", stableLink);
      }

      stepTime = System.currentTimeMillis();
      startTime = stepTime;

      // attach only non empty categories
      Set<String> allClasses = new HashSet<String>();
      for (ClassDescriptor cld : cds) {
        allClasses.add(cld.getUnqualifiedName());
      }
      TemplateManager templateManager = im.getTemplateManager();
      Map<String, List<ReportDisplayer>> displayerMap = reportObject.getReportDisplayers();

      stepTime = System.currentTimeMillis();
      startTime = stepTime;

      List<String> categories = new LinkedList<String>();
      for (String aspect : aspects) {
        // 1) Displayers
        // 2) Inline Lists
        if ((displayerMap != null && displayerMap.containsKey(aspect))
            || placedInlineLists.containsKey(aspect)) {
          categories.add(aspect);
        } else {
          // 3) Templates
          if (!templateManager.getReportPageTemplatesForAspect(aspect, allClasses).isEmpty()) {
            categories.add(aspect);
          } else {
            // 4) References & Collections
            if (placementRefsAndCollections.containsKey("im:aspect:" + aspect)
                && placementRefsAndCollections.get("im:aspect:" + aspect) != null) {
              for (DisplayField df :
                  placementRefsAndCollections.get("im:aspect:" + aspect).values()) {
                categories.add(aspect);
                break;
              }
            }
          }
        }
      }
      if (!categories.isEmpty()) {
        request.setAttribute("categories", categories);
      }
      now = System.currentTimeMillis();
      LOG.info("TIME made list of categories: " + (now - stepTime) + "ms");
    }

    return null;
  }
 private DisplayConstraintFactory getFactory(HttpSession session) {
   InterMineAPI im = SessionMethods.getInterMineAPI(session);
   AutoCompleter ac = SessionMethods.getAutoCompleter(session.getServletContext());
   DisplayConstraintFactory factory = new DisplayConstraintFactory(im, ac);
   return factory;
 }
  @Override
  public void display(HttpServletRequest request, ReportObject reportObject) {

    // get the gene/protein in question from the request
    InterMineObject object = reportObject.getObject();

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

    // cast me Gene
    Gene gene = (Gene) object;
    Object genePrimaryIDObj = gene.getPrimaryIdentifier();
    if (genePrimaryIDObj != null) {
      // fetch the expression
      String genePrimaryID = String.valueOf(genePrimaryIDObj);
      query = geneExpressionAtlasQuery(genePrimaryID, query);

      // execute the query
      Profile profile = SessionMethods.getProfile(session);
      PathQueryExecutor executor = im.getPathQueryExecutor(profile);
      ExportResultsIterator values = executor.execute(query);

      // convert to a map
      GeneExpressionAtlasDiseasesExpressions geae =
          new GeneExpressionAtlasDiseasesExpressions(values);

      // attach to results
      request.setAttribute("expressions", geae);
      request.setAttribute("url", "http://www.ebi.ac.uk/gxa/experiment/E-MTAB-62/" + genePrimaryID);
      request.setAttribute("defaultPValue", "1e-4");
      request.setAttribute("defaultTValue", "4");

      // get the corresponding collection
      for (FieldDescriptor fd : reportObject.getClassDescriptor().getAllFieldDescriptors()) {
        if ("atlasExpression".equals(fd.getName()) && fd.isCollection()) {
          // fetch the collection
          Collection<?> collection = null;
          try {
            collection = (Collection<?>) reportObject.getObject().getFieldValue("atlasExpression");
          } catch (IllegalAccessException e) {
            e.printStackTrace();
          }

          List<Class<?>> lc =
              PathQueryResultHelper.queryForTypesInCollection(
                  reportObject.getObject(), "atlasExpression", im.getObjectStore());

          // create an InlineResultsTable
          InlineResultsTable t =
              new InlineResultsTable(
                  collection,
                  fd.getClassDescriptor().getModel(),
                  SessionMethods.getWebConfig(request),
                  im.getClassKeys(),
                  collection.size(),
                  false,
                  lc);

          request.setAttribute("collection", t);
          break;
        }
      }
    }
  }
示例#25
0
 /**
  * Get the web proprties.
  *
  * @param request current request (from which we fetch the servlet context).
  * @return Properties
  */
 public static Properties getWebProperties(HttpServletRequest request) {
   return SessionMethods.getWebProperties(request.getSession().getServletContext());
 }
  /**
   * Forward to the correct method based on the button pressed
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @return an ActionForward object defining where control goes next
   * @exception Exception if the application business logic throws an exception
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    Profile profile = SessionMethods.getProfile(session);

    Model model = im.getModel();
    ModifyBagDetailsForm mbdf = (ModifyBagDetailsForm) form;
    BagManager bagManager = im.getBagManager();

    InterMineBag imBag = bagManager.getBag(profile, mbdf.getBagName());
    String bagIdentifier = "bag." + imBag.getName();

    if (request.getParameter("removeFromBag") != null) {
      PagedTable pc = SessionMethods.getResultsTable(session, bagIdentifier);
      String msg = "";

      if (pc.isAllRowsSelected()) {
        // TODO these messages need to be moved to properties file
        msg = "You can't remove all items from your list.  Try deleting your list instead.";
      } else {
        int removed = pc.removeSelectedFromBag(imBag, session);
        msg = "You have removed " + removed + " items from your list.";
      }
      SessionMethods.recordMessage(msg, session);
      // return new ForwardParameters(mapping.findForward("bagDetails"))
      // .addParameter("bagName", mbdf.getBagName()).forward();

      // pass an extra parameter telling the JSP to open up the results table
      return new ForwardParameters(mapping.findForward("bagDetails"))
          .addParameter("bagName", mbdf.getBagName())
          .addParameter("table", "open")
          .forward();

    } else if (request.getParameter("addToBag") != null) {
      InterMineBag newBag = bagManager.getBag(profile, mbdf.getExistingBagName());
      String msg = "";
      if (newBag.getType().equals(imBag.getType())) {
        PagedTable pc = SessionMethods.getResultsTable(session, bagIdentifier);
        int oldSize = newBag.size();
        pc.addSelectedToBag(newBag);
        int newSize = newBag.size();
        int added = newSize - oldSize;
        msg =
            "You have added "
                + added
                + " items from list <strong>"
                + imBag.getName()
                + "</strong> to list <strong>"
                + newBag.getName()
                + "</strong>";
      } else {
        msg = "You can only add objects to other lists of the same type";
      }
      SessionMethods.recordMessage(msg, session);
      // orthologues form
    } else if (request.getParameter("convertToThing") != null) {
      BagQueryConfig bagQueryConfig = im.getBagQueryConfig();
      Set<AdditionalConverter> additionalConverters =
          bagQueryConfig.getAdditionalConverters(imBag.getType());
      if (additionalConverters != null && !additionalConverters.isEmpty()) {
        for (AdditionalConverter additionalConverter : additionalConverters) {
          BagConverter bagConverter =
              PortalHelper.getBagConverter(
                  im, SessionMethods.getWebConfig(request), additionalConverter.getClassName());
          List<Integer> converted =
              bagConverter.getConvertedObjectIds(
                  profile, imBag.getType(), imBag.getContentsAsIds(), mbdf.getExtraFieldValue());

          if (converted.size() == 1) {
            return goToReport(mapping, converted.get(0).toString());
          }

          String bagName =
              NameUtil.generateNewName(
                  profile.getSavedBags().keySet(),
                  mbdf.getExtraFieldValue() + " orthologues of " + imBag.getName());

          InterMineBag newBag = profile.createBag(bagName, imBag.getType(), "", im.getClassKeys());
          return createBagAndGoToBagDetails(mapping, newBag, converted);
        }
      }

      // "use in bag" link
    } else if (request.getParameter("useBag") != null) {
      PagedTable pc = SessionMethods.getResultsTable(session, bagIdentifier);
      PathQuery pathQuery = pc.getWebTable().getPathQuery().clone();
      SessionMethods.setQuery(session, pathQuery);
      session.setAttribute("path", imBag.getType());
      session.setAttribute("prefix", imBag.getType());
      String msg = "You can now create a query using your list " + imBag.getName();
      SessionMethods.recordMessage(msg, session);
      return mapping.findForward("query");

      // convert links
    } else if (request.getParameter("convert") != null && request.getParameter("bagName") != null) {
      String type2 = request.getParameter("convert");
      TemplateManager templateManager = im.getTemplateManager();
      PathQuery q =
          BagConversionHelper.getConvertedObjects(
              session,
              templateManager.getConversionTemplates(),
              TypeUtil.instantiate(model.getPackageName() + "." + imBag.getType()),
              TypeUtil.instantiate(model.getPackageName() + "." + type2),
              imBag);
      q.setTitle(type2 + "s from list '" + imBag.getName() + "'");
      SessionMethods.loadQuery(q, session, response);
      String qid = SessionMethods.startQueryWithTimeout(request, false, q);
      Thread.sleep(200); // slight pause in the hope of avoiding holding page
      final String trail = "|bag." + imBag.getName();
      return new ForwardParameters(mapping.findForward("waiting"))
          .addParameter("trail", trail)
          .addParameter("qid", qid)
          .forward();
    }
    return new ForwardParameters(mapping.findForward("bagDetails"))
        .addParameter("bagName", mbdf.getBagName())
        .forward();
  }