Package org.apache.oodt.cas.catalog.page

Examples of org.apache.oodt.cas.catalog.page.QueryPager


    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    //test query using querypager
    QueryExpression qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
    QueryPager pager = cs.query(qe);
    metadatas = cs.getNextPage(pager);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);
View Full Code Here


      throw new CatalogServiceException("Failed to get catalog properties from catalog '" + catalogUrn + "' : " + e.getMessage(), e);
    }
  }
 
  public Page getNextPage(Page page) throws CatalogServiceException {
    QueryPager queryPager = new QueryPager(this._query(page.getQueryExpression(), page.getRestrictToCatalogIds()));
    queryPager.setPageInfo(new PageInfo(page.getPageSize(), page.getPageNum() + 1));
    return this.getPage(page.getQueryExpression(), page.getRestrictToCatalogIds(), queryPager);
  }
View Full Code Here

            public int compare(TransactionReceipt o1,
                TransactionReceipt o2) {
              return o2.getTransactionDate().compareTo(o1.getTransactionDate());
            }
          });
          QueryPager queryPager = new QueryPager(transactionReceipts);
          queryPager.setPageInfo(pageInfo);
          return this.getPage(queryExpression, catalogIds, queryPager);
        }else {
          int currentIndex = 0;
          int desiredStartingIndex = pageInfo.getPageNum() * pageInfo.getPageSize();
          List<CatalogReceipt> pageOfReceipts = new Vector<CatalogReceipt>();
          for (Entry<String, Integer> entry : catalogToSizeOfMap.entrySet()) {
            if (desiredStartingIndex - currentIndex <= entry.getValue()) {
              Catalog catalog = this.getCatalog(entry.getKey());
              QueryExpression qe = this.reduceToUnderstoodExpressions(catalog, queryExpression);
              if (qe != null) {
                List<CatalogReceipt> receipts = catalog.query(qe, desiredStartingIndex - currentIndex, Math.min((desiredStartingIndex - currentIndex) + pageInfo.getPageSize(), entry.getValue()));
                pageOfReceipts.addAll(receipts);
                if (pageOfReceipts.size() >= pageInfo.getPageSize())
                  break;
              }
            }else {
              currentIndex += entry.getValue();
            }
          }
          return new Page(new ProcessedPageInfo(pageInfo.getPageSize(), pageInfo.getPageNum(), totalResults), queryExpression, catalogIds, this.indexReceipts(this.getPossiblyUnindexedTransactionReceipts(pageOfReceipts)));
        }
      }catch (Exception e) {
        throw new CatalogServiceException(e.getMessage(), e);
      }
    }else {
      QueryPager queryPager = new QueryPager(this._query(queryExpression, catalogIds));
      queryPager.setPageInfo(pageInfo);
      return this.getPage(queryExpression, catalogIds, queryPager);
    }
  }
View Full Code Here

  protected Page getPage(QueryExpression queryExpression, Set<String> restrictToCatalogIds, QueryPager queryPager) throws CatalogServiceException {
    return new Page(new ProcessedPageInfo(queryPager.getPageSize(), queryPager.getPageNum(), queryPager.getNumOfHits()), queryExpression, restrictToCatalogIds, this.indexReceipts(queryPager.getCurrentPage()));
  }
 
  public QueryPager query(QueryExpression queryExpression, Set<String> catalogIds) throws CatalogServiceException {
    return new QueryPager(this.indexReceipts(this._query(queryExpression, catalogIds)));
  }
View Full Code Here

         Validate.notNull(query, "Must specify query");
         Validate.notNull(termNames, "Must specify termNames");

         QueryExpression queryExpression = QueryParser
               .parseQueryExpression(query);
         QueryPager queryPager = null;
         if (catalogIds == null) {
            queryPager = getClient().query(queryExpression);
         } else {
            queryPager = getClient().query(queryExpression, catalogIds);
         }
View Full Code Here

      try {
         Validate.notNull(query, "Must specify query");

         QueryExpression queryExpression = QueryParser
               .parseQueryExpression(query);
         QueryPager queryPager = null;
         if (catalogIds == null) {
            queryPager = getClient().query(queryExpression);
         } else {
            queryPager = getClient().query(queryExpression, catalogIds);
         }
View Full Code Here

    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);

    // test query using querypager
    QueryExpression qe = QueryParser
        .parseQueryExpression("testkey1 == 'testval1'");
    QueryPager pager = cs.query(qe);
    metadatas = cs.getNextPage(pager);
    assertEquals(metadatas.size(), 1);
    ingestedMetadata = metadatas.get(0).getMetadata();
    assertEquals(ingestedMetadata.getMetadata("testkey1"), "testval1");
    assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);
View Full Code Here

  protected String query;
  protected Set<String> catalogIds;
 
  public void performAction(CatalogServiceClient csClient) throws Exception {
    QueryExpression queryExpression = QueryParser.parseQueryExpression(query);
    QueryPager queryPager = null;
    if (catalogIds == null)
      queryPager = csClient.query(queryExpression);
    else
      queryPager = csClient.query(queryExpression, catalogIds);
    List<TransactionalMetadata> transactionMetadatas = csClient.getAllPages(queryPager);
View Full Code Here

      throw new CatalogServiceException("Failed to get catalog properties from catalog '" + catalogUrn + "' : " + e.getMessage(), e);
    }
  }
 
  public Page getNextPage(Page page) throws CatalogServiceException {
    QueryPager queryPager = new QueryPager(this._query(page.getQueryExpression(), page.getRestrictToCatalogIds()));
    queryPager.setPageInfo(new PageInfo(page.getPageSize(), page.getPageNum() + 1));
    return this.getPage(page.getQueryExpression(), page.getRestrictToCatalogIds(), queryPager);
  }
View Full Code Here

            public int compare(TransactionReceipt o1,
                TransactionReceipt o2) {
              return o2.getTransactionDate().compareTo(o1.getTransactionDate());
            }
          });
          QueryPager queryPager = new QueryPager(transactionReceipts);
          queryPager.setPageInfo(pageInfo);
          return this.getPage(queryExpression, catalogIds, queryPager);
        }else {
          int currentIndex = 0;
          int desiredStartingIndex = pageInfo.getPageNum() * pageInfo.getPageSize();
          List<CatalogReceipt> pageOfReceipts = new Vector<CatalogReceipt>();
          for (Entry<String, Integer> entry : catalogToSizeOfMap.entrySet()) {
            if (desiredStartingIndex - currentIndex <= entry.getValue()) {
              Catalog catalog = this.getCatalog(entry.getKey());
              QueryExpression qe = this.reduceToUnderstoodExpressions(catalog, queryExpression);
              if (qe != null) {
                List<CatalogReceipt> receipts = catalog.query(qe, desiredStartingIndex - currentIndex, Math.min((desiredStartingIndex - currentIndex) + pageInfo.getPageSize(), entry.getValue()));
                pageOfReceipts.addAll(receipts);
                if (pageOfReceipts.size() >= pageInfo.getPageSize())
                  break;
              }
            }else {
              currentIndex += entry.getValue();
            }
          }
          return new Page(new ProcessedPageInfo(pageInfo.getPageSize(), pageInfo.getPageNum(), totalResults), queryExpression, catalogIds, this.indexReceipts(this.getPossiblyUnindexedTransactionReceipts(pageOfReceipts)));
        }
      }catch (Exception e) {
        throw new CatalogServiceException(e.getMessage(), e);
      }
    }else {
      QueryPager queryPager = new QueryPager(this._query(queryExpression, catalogIds));
      queryPager.setPageInfo(pageInfo);
      return this.getPage(queryExpression, catalogIds, queryPager);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.catalog.page.QueryPager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.