Package com.esri.gpt.catalog.discovery

Examples of com.esri.gpt.catalog.discovery.DiscoveryException


   
    // determine the discoverable target, set the underlying storable
    Discoverable discoverable = propertyClause.getTarget();
    if (discoverable == null) {
      String sErr = "The PropertyClause.target is null.";
      throw new DiscoveryException(sErr);
    }
    if (discoverable.getStorable() == null) {
      String sErr = "The PropertyClause.target.storeable is null.";
      throw new DiscoveryException(sErr);
    } else {
      Storeable storeable = (Storeable)discoverable.getStorable();
      this.baseFieldName = storeable.getName();
      if (this.baseFieldName.endsWith(".intersects")) {
        this.inclusive = true;
        this.baseFieldName = this.baseFieldName.substring(0,this.baseFieldName.length()-11);
      } else if (this.baseFieldName.endsWith(".within")) {
        this.inclusive = false;
        this.baseFieldName = this.baseFieldName.substring(0,this.baseFieldName.length()-7);
      }
      this.intervalMetaFieldName = this.baseFieldName+".imeta";
      this.multiplicityFieldName = this.baseFieldName+".num";
      this.summaryMetaFieldName = this.baseFieldName+".meta";
    }
   
    // initialize values
    boolean bInclusive = this.inclusive;
    String sLiteral = Val.chkStr(propertyClause.getLiteral());
    String sLower = "";
    String sUpper = "";
    String sErr = null;
    String sErrSfx = " is not supported for timeperiod fields,"+
                     " use PropertyIsBetween.";
   
    if (propertyClause instanceof PropertyIsBetween) {
      PropertyIsBetween between = (PropertyIsBetween)propertyClause;
      sLower = Val.chkStr(between.getLowerBoundary());
      sUpper = Val.chkStr(between.getUpperBoundary());
      this.queryLower = this.parseDateTime(sLower,false);
      this.queryUpper = this.parseDateTime(sUpper,true);
     
    } else if ((propertyClause instanceof PropertyIsEqualTo||
               (propertyClause instanceof PropertyIsNotEqualTo)) {
      Query q = null;
      sLower = Val.chkStr(sLiteral);
      sUpper = Val.chkStr(sLiteral);
      this.queryLower = this.parseDateTime(sLower,false);
      if (this.queryLower == null) {
       sErr = "Timeperiod literal cannot be null for PropertyIsEqualTo/PropertyIsNotEqualTo";
      } else {
       this.queryUpper = this.parseDateTime(sUpper,true);
       if (propertyClause instanceof PropertyIsEqualTo) {
         q = this.makeEquals();
       } else {
         q = this.makeNotEquals();
       }
       appendQuery(activeBooleanQuery,activeLogicalClause,q);
       return;
      }
     
    } else if (propertyClause instanceof PropertyIsGreaterThan) {
      bInclusive = false; // use within logic
      sLower = sLiteral;
      this.queryLower = this.parseDateTime(sLower,false);
      if (this.queryLower != null) {
        this.queryLower = new Long(this.queryLower.longValue() + 1);
      }
     
    } else if (propertyClause instanceof PropertyIsGreaterThanOrEqualTo) {
      bInclusive = false; // use within logic
      sLower = sLiteral;
      this.queryLower = this.parseDateTime(sLower,false);
     
    } else if (propertyClause instanceof PropertyIsLessThan) {
      bInclusive = false; // use within logic
      sUpper = sLiteral;
      this.queryUpper = this.parseDateTime(sUpper,false);
      if (this.queryUpper != null) {
        this.queryUpper = new Long(this.queryUpper.longValue() - 1);
      }
     
    } else if (propertyClause instanceof PropertyIsLessThanOrEqualTo) {
      bInclusive = false; // use within logic
      sUpper = sLiteral;
      this.queryUpper = this.parseDateTime(sUpper,true);
     
    } else if (propertyClause instanceof PropertyIsNull) {
      appendQuery(activeBooleanQuery,activeLogicalClause,this.makeNull());
      return;
     
    } else if (propertyClause instanceof PropertyIsLike) { 
      sErr = "PropertyIsLike"+sErrSfx;
     
    } else {
      sErr = "Unrecognized property clause type: "+propertyClause.getClass().getName();
    }
    if (sErr != null) {
      throw new DiscoveryException(sErr);
    }
   
    // check for upper < lower
    if ((this.queryLower != null) && (this.queryUpper != null)) {
      if (this.queryUpper.longValue() < this.queryLower.longValue()) {
View Full Code Here


      }
      LOGGER.finest("MaxBndFieldIndex: "+nMax);
      this.maxIntervalFieldName = nMax;
    } catch (IOException e) {
      LOGGER.log(Level.SEVERE,"Index issue.",e);
      throw new DiscoveryException(e.toString(),e);
    } finally {
      this.getQueryAdapter().getIndexAdapter().closeSearcher(searcher);
    }
  }
View Full Code Here

      activeBooleanQuery.add(queryToAppend,BooleanClause.Occur.SHOULD);
    } else if (activeLogicalClause instanceof LogicalClause.LogicalNot) {
      activeBooleanQuery.add(queryToAppend,BooleanClause.Occur.MUST_NOT);
    } else {
      String sErr = "Unrecognized logical clause type: ";
      throw new DiscoveryException(sErr+activeLogicalClause.getClass().getName());
    }
  }
View Full Code Here

    // determine the discoverable target, set names
    String sErr;
    Discoverable discoverable = spatialClause.getTarget();
    if (discoverable == null) {
      sErr = "The SpatialClause.target is null.";
      throw new DiscoveryException(sErr);
    }
    if (discoverable.getStorable() == null) {
      sErr = "The SpatialClause.target.storeable is null.";
      throw new DiscoveryException(sErr);
    } else {
      Storeable storeable = (Storeable)discoverable.getStorable();
      if (!(storeable instanceof GeometryProperty)) {
        sErr = "The SpatialClause.target.storeable is not a GeometryProperty.";
        throw new DiscoveryException(sErr);
      }
    }
       
    // check the envelope
    envelope = spatialClause.getBoundingEnvelope();
    if ((envelope == null) || envelope.isEmpty()) {
      sErr = "The SpatialClause.boundingEnvelope is empty.";
      throw new DiscoveryException(sErr);
    }
   
    // initialize the values of the input query envelope
    qryMinX = envelope.getMinX();
    qryMinY = envelope.getMinY();
    qryMaxX = envelope.getMaxX();
    qryMaxY = envelope.getMaxY();
    if (qryMinX > qryMaxX) {
      qryCrossedDateline = true;
    }
   
    // determine spatialRelevance parameters
    // (original defaults were queryPower=2.0, targetPower=0.5)
    RequestContext rc = this.getQueryAdapter().getIndexAdapter().getRequestContext();
    StringAttributeMap params = rc.getCatalogConfiguration().getParameters();
    double queryPower = Val.chkDbl(params.getValue("spatialRelevance.queryPower"),1.0);
    double targetPower = Val.chkDbl(params.getValue("spatialRelevance.targetPower"),1.0);
    String rankingOption = Val.chkStr(params.getValue("spatialRelevance.ranking.enabled"));
    int rankingMaxDoc = Val.chkInt(params.getValue("spatialRelevance.ranking.maxDoc"),50000);
    boolean bUseSpatialRanking = false;
    if (rankingOption.equalsIgnoreCase("true")) {
      bUseSpatialRanking = true;
    } else if (rankingOption.equalsIgnoreCase("false")) {
      bUseSpatialRanking = false;
    } else {
  
      // default spatialRelevance.ranking.enabled option is "auto"
      if (this.getQueryAdapter() != null) {
        int maxDoc = this.getQueryAdapter().getMaxDoc();
        if ((maxDoc > 0) && (maxDoc <= rankingMaxDoc)) {
          bUseSpatialRanking = true;
        }
      }
    }
   
    // Handle each operation - Beyond, Crosses, DWithin and Touches are not implemented
   
    if (bUseSpatialRanking) {
      Query spatialQuery = null;
      if (spatialClause instanceof SpatialClause.GeometryBBOXIntersects) {
        spatialQuery = this.makeIntersects();
      } else if (spatialClause instanceof SpatialClause.GeometryContains) {
        spatialQuery = this.makeContains();
      } else if (spatialClause instanceof SpatialClause.GeometryIntersects) {
        spatialQuery = this.makeIntersects();
      } else if (spatialClause instanceof SpatialClause.GeometryIsDisjointTo) {
        bUseSpatialRanking = false;
      } else if (spatialClause instanceof SpatialClause.GeometryIsEqualTo) {
        bUseSpatialRanking = false;
      } else if (spatialClause instanceof SpatialClause.GeometryIsWithin) {
        spatialQuery = this.makeWithin();
      } else if (spatialClause instanceof SpatialClause.GeometryOverlaps) {
        spatialQuery = this.makeIntersects();
      } else {
        sErr = "Unrecognized spatial clause type: ";
        throw new DiscoveryException(sErr+spatialClause.getClass().getName());
      }
     
      if (bUseSpatialRanking) {
        SpatialRankingValueSource srvs = new SpatialRankingValueSource(envelope,queryPower,targetPower);
        Query spatialRankingQuery = new ValueSourceQuery(srvs);
        BooleanQuery bq = new BooleanQuery();
        bq.add(spatialQuery,BooleanClause.Occur.MUST);
        bq.add(spatialRankingQuery,BooleanClause.Occur.MUST);
        appendQuery(activeBooleanQuery,activeLogicalClause,bq);
        this.getQueryAdapter().setHasScoredExpression(true);
      }
    }

    if (!bUseSpatialRanking) {
      if (spatialClause instanceof SpatialClause.GeometryBBOXIntersects) {
        appendQuery(activeBooleanQuery,activeLogicalClause,makeIntersects());
      } else if (spatialClause instanceof SpatialClause.GeometryContains) {
        appendQuery(activeBooleanQuery,activeLogicalClause,makeContains());
      } else if (spatialClause instanceof SpatialClause.GeometryIntersects) {
        appendQuery(activeBooleanQuery,activeLogicalClause,makeIntersects());
      } else if (spatialClause instanceof SpatialClause.GeometryIsDisjointTo) {
        appendQuery(activeBooleanQuery,activeLogicalClause,makeDisjoint());
      } else if (spatialClause instanceof SpatialClause.GeometryIsEqualTo) {
        appendQuery(activeBooleanQuery,activeLogicalClause,makeEquals());
      } else if (spatialClause instanceof SpatialClause.GeometryIsWithin) {
        appendQuery(activeBooleanQuery,activeLogicalClause,makeWithin())
      } else if (spatialClause instanceof SpatialClause.GeometryOverlaps) {
        appendQuery(activeBooleanQuery,activeLogicalClause,makeIntersects());
      } else {
        sErr = "Unrecognized spatial clause type: ";
        throw new DiscoveryException(sErr+spatialClause.getClass().getName());
      }
    }
       
  }
View Full Code Here

    if (literalLowerValue.length() > 0) {
      try {
        Timestamp ts = (Timestamp)valueType.evaluate(literalLowerValue,true,false);
        if (ts != null) lLower = ts.getTime();
      } catch (NumberFormatException e) {
        throw new DiscoveryException("Invalid Timestamp: "+literalLowerValue);
      }
    }
    if (literalUpperValue.length() > 0) {
      try {
        Timestamp ts = (Timestamp)valueType.evaluate(literalUpperValue,false,true);
        if (ts != null) lUpper = ts.getTime();
      } catch (NumberFormatException e) {
        throw new DiscoveryException("Invalid Timestamp: "+literalUpperValue);
      }
    }
    if ((lLower == null) && (lUpper == null)) {
      throw new DiscoveryException("No range values were supplied.");
    }
    return NumericRangeQuery.newLongRange(
        this.getName(),lLower,lUpper,lowerBoundaryIsInclusive,upperBoundaryIsInclusive);
  }
View Full Code Here

        LOGGER.finer("Timestamp to query: "+tsValue);
      }
     
      return NumericUtils.longToPrefixCoded(tsValue.getTime());
    } catch (IllegalArgumentException e) {
      throw new DiscoveryException("Invalid date: "+value);
    }
  }
View Full Code Here

    throws DiscoveryException, ParseException  {
   
    // loop the the sub clauses, recurse any logical clauses
    for (DiscoveryClause clause: logicalClause.getClauses()) {
      if (clause == null) {
        throw new DiscoveryException("A null clause was encountered.");

      } else if (clause instanceof LogicalClause) {
        BooleanQuery subQuery = new BooleanQuery();
        appendQuery(activeBooleanQuery,logicalClause,subQuery);
        adaptLogicalClause(subQuery,(LogicalClause)clause);
       
      } else if (clause instanceof PropertyClause) {
        PropertyClauseAdapter adapter = new PropertyClauseAdapter(getQueryAdapter());
        PropertyClause subClause = (PropertyClause)clause;
        if ((subClause.getTarget() != null) && (subClause.getTarget().getMeaning() != null)) {
          PropertyValueType pvt = subClause.getTarget().getMeaning().getValueType();
          if ((pvt != null) && pvt.equals(PropertyValueType.TIMEPERIOD)) {
            adapter = new TimeperiodClauseAdapter(getQueryAdapter());
          }
        }
        adapter.adaptPropertyClause(activeBooleanQuery,logicalClause,subClause);
       
      } else if (clause instanceof SpatialClause) {
        SpatialClauseAdapter adapter = new SpatialClauseAdapter(getQueryAdapter());
        SpatialClause subClause = (SpatialClause)clause;
        adapter.adaptSpatialClause(activeBooleanQuery,logicalClause,subClause);
       
      } else {
        String sErr = "Unrecognized clause type:"+clause.getClass().getName();
        throw new DiscoveryException(sErr);
      }
    }
   
    // MUST_NOT causes a problem when there is only one MUST_NOT clause within
    // a BooleanQuery, to get round it we add all documents as a SHOULD
View Full Code Here

    try {
      executeQuery(discoveryQuery);
    } catch (ParseException e) {
      String sMsg = "Error querying documents:\n "+Val.chkStr(e.getMessage());
      throw new DiscoveryException(sMsg,e);
    } catch (CorruptIndexException e) {
      String sMsg = "Error querying documents:\n "+Val.chkStr(e.getMessage());
      throw new DiscoveryException(sMsg,e);
    } catch (IOException e) {
      String sMsg = "Error querying documents:\n "+Val.chkStr(e.getMessage());
      throw new DiscoveryException(sMsg,e);
    }
  }
View Full Code Here

   
    // determine the discoverable target, set the underlying storable
    discoverable = propertyClause.getTarget();
    if (discoverable == null) {
      String sErr = "The PropertyClause.target is null.";
      throw new DiscoveryException(sErr);
    }
    if (discoverable.getStorable() == null) {
      String sErr = "The PropertyClause.target.storeable is null.";
      throw new DiscoveryException(sErr);
    } else {
      storeable = (Storeable)discoverable.getStorable();
    }
   
    // execute the appropriate operation,
View Full Code Here

    } else if (propertyClause instanceof PropertyIsNull) {
      appendNullCheck(activeBooleanQuery,fieldName);
     
    } else {
      String sErr = "Unrecognized property clause type: ";
      throw new DiscoveryException(sErr+propertyClause.getClass().getName());
    }

  }
View Full Code Here

TOP

Related Classes of com.esri.gpt.catalog.discovery.DiscoveryException

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.