Example #1
0
 /**
  * Create a new WebResults object.
  *
  * @param pathQuery used to get the paths of the columns
  * @param results the underlying Results object
  * @param im intermine API
  * @param pathToQueryNode the mapping between Paths (in the columnPaths argument) and the
  *     QueryNodes in the results object
  * @param pathToBagQueryResult a Map containing results from LOOKUP operations
  */
 public WebResults(
     InterMineAPI im,
     PathQuery pathQuery,
     Results results,
     Map<String, QuerySelectable> pathToQueryNode,
     Map<String, BagQueryResult> pathToBagQueryResult) {
   this.im = im;
   this.osResults = results;
   this.flatResults = new ResultsFlatOuterJoinsImpl(((List) osResults), osResults.getQuery());
   model = im.getModel();
   this.columnPaths = new ArrayList<Path>();
   try {
     for (String pathString : pathQuery.getView()) {
       this.columnPaths.add(pathQuery.makePath(pathString));
     }
   } catch (PathException e) {
     throw new RuntimeException("Error creating WebResults because PathQuery is invalid", e);
   }
   classKeys = im.getClassKeys();
   this.pathToQueryNode = new HashMap<String, QuerySelectable>();
   if (pathToQueryNode != null) {
     this.pathToQueryNode.putAll(pathToQueryNode);
   }
   this.pathToBagQueryResult = new HashMap<String, BagQueryResult>();
   if (pathToBagQueryResult != null) {
     this.pathToBagQueryResult.putAll(pathToBagQueryResult);
   }
   this.pathQuery = pathQuery;
   pathToIndex = getPathToIndex();
   redirector = im.getLinkRedirector();
   addColumnsInternal(columnPaths);
 }
Example #2
0
 /**
  * Calls ObjectStore.releaseGoFaster() if this object wraps a Results object from an
  * ObjectStoreInterMineImpl.
  *
  * @throws ObjectStoreException if ObjectStoreInterMineImpl.releaseGoFaster() throws the exception
  */
 public synchronized void releaseGoFaster() throws ObjectStoreException {
   goingFaster--;
   if (goingFaster == 0) {
     ObjectStore os = osResults.getObjectStore();
     if (os instanceof ObjectStoreInterMineImpl) {
       ((ObjectStoreInterMineImpl) os).releaseGoFaster(osResults.getQuery());
     }
   }
 }
Example #3
0
 /**
  * Calls ObjectStore.goFaster() if this object wraps a Results object from an
  * ObjectStoreInterMineImpl.
  *
  * @throws ObjectStoreException if ObjectStoreInterMineImpl.goFaster() throws the exception
  */
 public synchronized void goFaster() throws ObjectStoreException {
   goingFaster++;
   if (goingFaster == 1) {
     osResults = changeResultBatchSize(osResults, BIG_BATCH_SIZE);
     ObjectStore os = osResults.getObjectStore();
     if (os instanceof ObjectStoreInterMineImpl) {
       ((ObjectStoreInterMineImpl) os).goFaster(osResults.getQuery());
     }
   }
 }
Example #4
0
  /**
   * Create and ObjectStore query from a PathQuery and execute it, returning results in a format
   * appropriate for displaying a web table.
   *
   * @param pathQuery the query to execute
   * @param pathToBagQueryResult will be populated with results from bag queries used in any LOOKUP
   *     constraints
   * @return results in a format appropriate for display in a web page table
   * @throws ObjectStoreException if problem running query
   */
  public WebResults execute(PathQuery pathQuery, Map<String, BagQueryResult> pathToBagQueryResult)
      throws ObjectStoreException {
    Map<String, QuerySelectable> pathToQueryNode = new HashMap<String, QuerySelectable>();

    Query q = makeQuery(pathQuery, pathToBagQueryResult, pathToQueryNode);

    Results results = os.execute(q, Constants.BATCH_SIZE, true, true, false);

    Query realQ = results.getQuery();
    if (realQ == q) {
      queryToPathToQueryNode.put(q, pathToQueryNode);
    } else {
      pathToQueryNode = queryToPathToQueryNode.get(realQ);
    }

    WebResults webResults =
        new WebResults(im, pathQuery, results, pathToQueryNode, pathToBagQueryResult);

    return webResults;
  }
Example #5
0
 /**
  * Make a copy of a Results object, but with a different batch size.
  *
  * @param oldResults the original Results objects
  * @param newBatchSize the new batch size
  * @return a new Results object with a new batch size
  */
 private Results changeResultBatchSize(Results oldResults, int newBatchSize) {
   Results newResults =
       oldResults.getObjectStore().execute(oldResults.getQuery(), newBatchSize, true, true, true);
   return newResults;
 }