Package org.apache.oodt.cas.catalog.query

Examples of org.apache.oodt.cas.catalog.query.QueryExpression


    ingestedMetadata = metadatas.get(0).getMetadata();
    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");
View Full Code Here


      try {
        int totalResults = 0;
        LinkedHashMap<String, Integer> catalogToSizeOfMap = new LinkedHashMap<String, Integer>();
        for (String catalogId : catalogIds) {
          Catalog catalog = this.getCatalog(catalogId);
          QueryExpression qe = this.reduceToUnderstoodExpressions(catalog, queryExpression);
          if (qe != null) {
            int catalogResultSize = catalog.sizeOf(qe);
            totalResults += catalogResultSize;
            catalogToSizeOfMap.put(catalogId, catalogResultSize);
          }
        }
       
        LOG.log(Level.INFO, "Routing query to catalogs as non-cross catalog intersecting queries . . .");
        if (totalResults <= this.crossCatalogResultSortingThreshold) {
          List<CatalogReceipt> catalogReceipts = new Vector<CatalogReceipt>();
          for (String catalogId : catalogToSizeOfMap.keySet()) {
            Catalog catalog = this.getCatalog(catalogId);
            QueryExpression qe = this.reduceToUnderstoodExpressions(catalog, queryExpression);
            if (qe != null)
              catalogReceipts.addAll(catalog.query(qe));
          }
          List<TransactionReceipt> transactionReceipts = this.getPossiblyUnindexedTransactionReceipts(catalogReceipts);
          LOG.log(Level.INFO, "Sorting Query Results . . . ");
          Collections.sort(transactionReceipts, new Comparator<TransactionReceipt>() {
            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;
View Full Code Here

      if (queryResult.getCatalogReceipts() == null && queryResult.getInterestedCatalogs() != null) {
        for (Catalog catalog : this.getCurrentCatalogList()) {
          try {
            if (queryResult.getInterestedCatalogs().contains(catalog.getId())) {
              LOG.log(Level.INFO, "Restricting query to understood terms for Catalog '" + catalog + "'");
              QueryExpression reducedExpression = this.reduceToUnderstoodExpressions(catalog, queryExpression);
              LOG.log(Level.INFO, "Querying Catalog '" + catalog + "' with query '" + reducedExpression + "'");
              catalogReceipts.addAll(catalog.query(reducedExpression));
            }
          }catch (Exception e) {
            if (this.oneCatalogFailsAllFail)
View Full Code Here

      // check for catalogs interested in wrapper query expression
      restrictToCatalogIds.retainAll(getInterestedCatalogs(queryExpression, restrictToCatalogIds));
     
      // check for catalogs interested in wrapped query expression
      QueryResult wrapperExprQueryResult = null;
      QueryExpression wrapperQE = ((WrapperQueryExpression) queryExpression).getQueryExpression();
      if (wrapperQE instanceof QueryLogicalGroup) {
        wrapperExprQueryResult = this.queryRecur((QueryLogicalGroup) wrapperQE, restrictToCatalogIds);
      }else {
        wrapperExprQueryResult = new QueryResult(wrapperQE);
        wrapperExprQueryResult.interestedCatalogs = getInterestedCatalogs(wrapperQE, restrictToCatalogIds);
View Full Code Here

  protected QueryExpression reduceToUnderstoodExpressions(Catalog catalog, QueryExpression queryExpression) throws CatalogDictionaryException, CatalogException {
    if (queryExpression instanceof QueryLogicalGroup) {
          QueryLogicalGroup queryLogicalGroup = (QueryLogicalGroup) queryExpression;
          List<QueryExpression> restrictedExpressions = new Vector<QueryExpression>();
          for (QueryExpression qe : queryLogicalGroup.getExpressions()) {
            QueryExpression restrictedQE = this.reduceToUnderstoodExpressions(catalog, qe);
            if (restrictedQE == null && queryLogicalGroup.getOperator().equals(QueryLogicalGroup.Operator.AND) && this.disableIntersectingCrossCatalogQueries) {
              restrictedExpressions.clear();
              break;
            }
            if (restrictedQE != null)
              restrictedExpressions.add(restrictedQE);
          }
          if (restrictedExpressions.size() > 0) {
            if (restrictedExpressions.size() == 1) {
              return restrictedExpressions.get(0);
            }else {
              QueryLogicalGroup restrictedQueryLogicalGroup = queryLogicalGroup.clone();
              restrictedQueryLogicalGroup.setExpressions(restrictedExpressions);
              return restrictedQueryLogicalGroup;
            }
          }else {
            return null;
          }
    }else if (queryExpression instanceof WrapperQueryExpression) {
      WrapperQueryExpression wrapperQueryExpresssion = (WrapperQueryExpression) queryExpression;
          if (catalog.isInterested(queryExpression)) {
            QueryExpression qe = this.reduceToUnderstoodExpressions(catalog, wrapperQueryExpresssion.getQueryExpression());
        if (qe != null) {
          WrapperQueryExpression wqe = wrapperQueryExpresssion.clone();
          wqe.setQueryExpression(qe);
          return wqe;
        }else if (wrapperQueryExpresssion.isValidWithNoSubExpression()){
View Full Code Here

         throws CmdLineActionException {
      try {
         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 {
View Full Code Here

   public void execute(ActionMessagePrinter printer)
         throws CmdLineActionException {
      try {
         Validate.notNull(query, "Must specify query");

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

      try {
         Validate.isTrue(pageNum != -1, "Must specify pageNum");
         Validate.isTrue(pageSize != -1, "Must specify pageSize");
         Validate.notNull(query, "Must specify query");

         QueryExpression queryExpression = QueryParser
               .parseQueryExpression(query);
         Page page = null;
         if (catalogIds == null) {
            page = getClient().getPage(new PageInfo(pageSize, pageNum),
                  queryExpression);
View Full Code Here

         Validate.isTrue(pageNum != -1, "Must specify pageNum");
         Validate.isTrue(pageSize != -1, "Must specify pageSize");
         Validate.notNull(query, "Must specify query");
         Validate.notNull(termNames, "Must specify termNames");

         QueryExpression queryExpression = QueryParser
               .parseQueryExpression(query);
         Page page = null;
         if (catalogIds == null) {
            page = getClient().getPage(new PageInfo(pageSize, pageNum),
                  queryExpression);
View Full Code Here

    ingestedMetadata = metadatas.get(0).getMetadata();
    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();
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.catalog.query.QueryExpression

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.