com.esri.adf.web.data.query
Class WebQuery

java.lang.Object
  extended by com.esri.adf.web.data.query.WebQuery
All Implemented Interfaces:
WebContextInitialize, Serializable

public class WebQuery
extends Object
implements WebContextInitialize, Serializable

WebQuery is a WebContextAttribute class used in a WebContext for querying attribute data and displaying related geometry objects spatially.

It is generally defined in the faces-config.xml of web applications. The following shows how it can be added as an attribute of the WebContext.

 <managed-bean>
   <managed-bean-name>mapContext</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.data.WebContext</managed-bean-class>
   <managed-bean-scope>request</managed-bean-scope>
   <managed-property>
     <property-name>attributes</property-name>
     <map-entries>
      <map-entry>
        <key>query</key>
        <value>#{webappQuery}</value>
      </map-entry>
      ...
 

Below is the declaration of a WebQuery managed bean. Note the LayerDefinition managed beans being referenced below.

 <managed-bean>
   <managed-bean-name>webappQuery</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.data.query.WebQuery</managed-bean-class>
   <managed-bean-scope>none</managed-bean-scope>
   <managed-property>
     <property-name>layerDefinitions</property-name>
     <list-entries>
       <value>#{arcgis_localmapgrid2_usa_2d_v_layer1}</value>
       ....
     </list-entries>
   </managed-property>
 </managed-bean>
 

The layer definitions are generally created through Java Manager or ArcGIS Server Java SDK IDE plug-ins. WebQuery itself does not contain any GIS query objects. The query calls are delegated to each QueryFunctionality existing in the GISResource objects of the WebContext. Following code snippet shows how to perform a query with a where clause.

 // Get WebQuery object from WebContext
 WebQuery wQuery = wContext.getWebQuery();
 resource = wContext.getResourceById(this.resourceId);
 
 // set query criteria
 if (resource != null && layerId != -1) {
   LayerDefinition lyrDef = this.getLayerDefinition() != null ? this.getLayerDefinition() : null;
   PredefinedQueryCriteria pqc = new PredefinedQueryCriteria();
 
   //set field for display
   pqc.setDisplayFieldName(displayFieldName);
   pqc.setWhereClause(whereClause);
   pqc.setMaxRecordCount(maxRecordCount);
   if (lyrDef != null) {
     List<LayerDefinition> lyrDefs = new ArrayList<LayerDefinition>(1);
     lyrDefs.add(lyrDef);
     pqc.setLayerDefinitions(lyrDefs);
   }
 
   //convert layer definition to WebLayerInfo
   WebLayerInfo layerInfo = QueryUtil.getWebLayerInfo(wQuery.getQueryLayers(), resource, layerId);
 
   ArrayList<WebLayerInfo> list = new ArrayList<WebLayerInfo>();
   list.add(layerInfo);
 
   //perform query
   results = wQuery.query(pqc, list);
 }
 

also see QueryFunctionality for detail query implementation.

See Also:
Serialized Form

Field Summary
static int ALL_LAYERS_OPTION_ID
          A constant layer ID used to instantiates allLayersOption which stands for "All Layers".
static WebLayerInfo allLayersOption
          The layer option stands for to all the layers.
protected  WebContext context
          The WebQuery associated WebContext.
protected  ArrayList<GISFunctionality> funcs
          A list stored the QueryFunctionality within the GIS resources.
protected  ArrayList<WebLayerInfo> layers
          A list stored the WebLayerInfo objects for query
protected  ArrayList<GraphicElement> multipointGraphics
          A list stored the multi-point graphics elements, which are created when process the query.
protected  GraphicElement pointGraphic
          A GraphicElement for rendering point and multi-points.
protected  ArrayList<GraphicElement> pointGraphics
          A list stored the point graphics elements, which are created when process the query.
protected  WebMultiPoint points
          Deprecated. As of ArcGIS Java Server 9.3, instead use multipointGraphics
protected  WebSimpleMarkerSymbol pointSymbol
          A Point symbol for drawing point and multi-points.
protected  GraphicElement polygonGraphic
          GraphicElement for rendering polygons.
protected  ArrayList<GraphicElement> polygonGraphics
          A list stored the polygon graphics, which are created when process the query.
protected  WebSimplePolygonSymbol polygonSymbol
          A Polygon symbol for drawing polygons.
protected  WebPolyline polyline
          Deprecated. As of ArcGIS Java Server 9.3, instead use polylineGraphics
protected  GraphicElement polylineGraphic
          A GraphicElement for rendering polyline.
protected  ArrayList<GraphicElement> polylineGraphics
          A list stored the polyline graphics, which are created when process the query.
protected  WebSimpleLineSymbol polylineSymbol
          A Polyline symbol for drawing lines.
 
Constructor Summary
WebQuery()
           
 
Method Summary
 WebGeometry addDisplayGeometry(WebGeometry geometry)
          The method will do a projection transformation for the given geometry object, add it to an appropriate geometry collection based on its type and displaying on the map with proper symbol.
 void clearGraphic(WebGeometry geometry)
          Removes the given geometry object from the WebGraphics as well as from geometry collections.
 void clearGraphics()
          Removes all graphic elements from the web graphic of WebContext for display,empties geometry list and refresh the map.
 boolean containsDisplayGeometry(WebGeometry geometry)
          Returns true if the specified geometry and the corresponding symbol available in the WebGraphics.
 void destroy()
           The cleaup chores (such as releasing held resources) of attributes of a WebContext should be performed in this method.
protected  void generateQueryLayers()
          Generates a list of queryable layers from the QueryFunctionality objects.
 List<? extends LayerDefinition> getLayerDefinitions()
          Returns the list of LayerDefinition.
 GraphicElement getLineGraphic()
          Returns the GraphicElement object used to render the line geometries.
 WebSimpleLineSymbol getLineGraphicSymbol()
          Returns the WebSimpleLineSymbol object used to symbolize the line geometry.
 GraphicElement getPointGraphic()
          Returns the GraphicElement object used to render the point geometries.
 WebSimpleMarkerSymbol getPointGraphicSymbol()
          Returns the WebSimpleMarkerSymbol object used to symbolize the point geometry.
 GraphicElement getPolgonGraphic()
          Deprecated. As of ArcGIS Java Server 9.3, instead use getPolygonGraphic()
 GraphicElement getPolygonGraphic()
          Returns the GraphicElement object used to render the polygon geometries.
 WebSimplePolygonSymbol getPolygonGraphicSymbol()
          Returns the WebSimplePolygonSymbol object used to symbolize the polygon geometry.
 List<WebLayerInfo> getQueryLayers()
          Returns a list of WebLayerInfo objects
 WebContext getWebContext()
          Returns the WebContext object associated with this query.
 void init(WebContext webContext)
           Initializes the WebQuery object.
 List<QueryResult> query(QueryCriteria criteria, List<? extends WebLayerInfo> queryLayers)
           Do a query based on the given list of queryLayers and criteria.
 void setLayerDefinitions(List<? extends LayerDefinition> layerDefinitions)
          Sets the list of LayerDefinition objects.
 void setLineGraphicSymbol(WebSimpleLineSymbol symbol)
          Sets the WebSimpleLineSymbol object used to symbolize the line geometry.
 void setPointGraphicSymbol(WebSimpleMarkerSymbol symbol)
          Sets the WebSimpleMarkerSymbol object used to symbolize the point geometry.
 void setPolygonGraphicSymbol(WebSimplePolygonSymbol symbol)
          Sets the WebSimplePolygonSymbol object used to symbolize the polygon geometry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_LAYERS_OPTION_ID

public static final int ALL_LAYERS_OPTION_ID
A constant layer ID used to instantiates allLayersOption which stands for "All Layers".

See Also:
Constant Field Values

allLayersOption

public static final WebLayerInfo allLayersOption
The layer option stands for to all the layers.


context

protected WebContext context
The WebQuery associated WebContext.


funcs

protected ArrayList<GISFunctionality> funcs
A list stored the QueryFunctionality within the GIS resources.


layers

protected ArrayList<WebLayerInfo> layers
A list stored the WebLayerInfo objects for query


pointGraphics

protected ArrayList<GraphicElement> pointGraphics
A list stored the point graphics elements, which are created when process the query.


pointGraphic

protected GraphicElement pointGraphic
A GraphicElement for rendering point and multi-points.


pointSymbol

protected WebSimpleMarkerSymbol pointSymbol
A Point symbol for drawing point and multi-points.


multipointGraphics

protected ArrayList<GraphicElement> multipointGraphics
A list stored the multi-point graphics elements, which are created when process the query.


points

@Deprecated
protected WebMultiPoint points
Deprecated. As of ArcGIS Java Server 9.3, instead use multipointGraphics

polylineGraphics

protected ArrayList<GraphicElement> polylineGraphics
A list stored the polyline graphics, which are created when process the query.


polylineGraphic

protected GraphicElement polylineGraphic
A GraphicElement for rendering polyline.


polylineSymbol

protected WebSimpleLineSymbol polylineSymbol
A Polyline symbol for drawing lines.


polyline

@Deprecated
protected WebPolyline polyline
Deprecated. As of ArcGIS Java Server 9.3, instead use polylineGraphics

polygonGraphics

protected ArrayList<GraphicElement> polygonGraphics
A list stored the polygon graphics, which are created when process the query.


polygonGraphic

protected GraphicElement polygonGraphic
GraphicElement for rendering polygons.


polygonSymbol

protected WebSimplePolygonSymbol polygonSymbol
A Polygon symbol for drawing polygons.

Constructor Detail

WebQuery

public WebQuery()
Method Detail

init

public void init(WebContext webContext)

Initializes the WebQuery object. The method will generate a list of QueryFunctionality objects internally by going through all GISResource in the given WebContext

Then it will use the QueryFunctionality list to collect all queryable layers from the QueryFunctionality, and instantiates the graphic elements used to display the returned geometries.

Specified by:
init in interface WebContextInitialize
Parameters:
webContext - - a WebContext object
See Also:
WebContext.init(WebContext), WebContext.addResource(String, GISResource, int), WebContext.removeResource(GISResource)

destroy

public void destroy()
Description copied from interface: WebContextInitialize

The cleaup chores (such as releasing held resources) of attributes of a WebContext should be performed in this method.

Typically this method is called by the WebContext when the context itself is destroyed.

The WebContext attribute is unusable after this method has been called.

Specified by:
destroy in interface WebContextInitialize
See Also:
WebContext.destroy()

generateQueryLayers

protected void generateQueryLayers()
Generates a list of queryable layers from the QueryFunctionality objects.

See Also:
getQueryLayers()

addDisplayGeometry

public WebGeometry addDisplayGeometry(WebGeometry geometry)
The method will do a projection transformation for the given geometry object, add it to an appropriate geometry collection based on its type and displaying on the map with proper symbol.

Parameters:
geometry - a WebGeometry object
Returns:
a projected WebGeometry object

containsDisplayGeometry

public boolean containsDisplayGeometry(WebGeometry geometry)
Returns true if the specified geometry and the corresponding symbol available in the WebGraphics.

Parameters:
geometry - - a WebGeometry object
Returns:
boolean - returns true if the specified geometry available in WebGraphics.
See Also:
getPointGraphicSymbol(), getLineGraphicSymbol(), getPolygonGraphicSymbol()

clearGraphic

public void clearGraphic(WebGeometry geometry)
Removes the given geometry object from the WebGraphics as well as from geometry collections. It will refresh the WebContext if the isFuseGraphics of the WebMap object returns true

Parameters:
geometry - - a WebGeometry object
See Also:
WebMap

clearGraphics

public void clearGraphics()
Removes all graphic elements from the web graphic of WebContext for display,empties geometry list and refresh the map.

See Also:
WebContext

query

public List<QueryResult> query(QueryCriteria criteria,
                               List<? extends WebLayerInfo> queryLayers)

Do a query based on the given list of queryLayers and criteria. The results will be returned in a List of QueryResult objects.

The method delegates the actual query to the appropriate query handler found in the QueryFunctionality based on the type of the given criteria.

Parameters:
criteria - the QueryCriteria based on which the query is performed
queryLayers - the List of WebLayerInfos to query.
Returns:
a List of QueryResult objects

getWebContext

public WebContext getWebContext()
Returns the WebContext object associated with this query.

Returns:
the WebContext object

getQueryLayers

public List<WebLayerInfo> getQueryLayers()
Returns a list of WebLayerInfo objects


getPointGraphic

public GraphicElement getPointGraphic()
Returns the GraphicElement object used to render the point geometries.


setPointGraphicSymbol

public void setPointGraphicSymbol(WebSimpleMarkerSymbol symbol)
Sets the WebSimpleMarkerSymbol object used to symbolize the point geometry.


getPointGraphicSymbol

public WebSimpleMarkerSymbol getPointGraphicSymbol()
Returns the WebSimpleMarkerSymbol object used to symbolize the point geometry.


getLineGraphic

public GraphicElement getLineGraphic()
Returns the GraphicElement object used to render the line geometries.


setLineGraphicSymbol

public void setLineGraphicSymbol(WebSimpleLineSymbol symbol)
Sets the WebSimpleLineSymbol object used to symbolize the line geometry.


getLineGraphicSymbol

public WebSimpleLineSymbol getLineGraphicSymbol()
Returns the WebSimpleLineSymbol object used to symbolize the line geometry.


getPolygonGraphic

public GraphicElement getPolygonGraphic()
Returns the GraphicElement object used to render the polygon geometries.


setPolygonGraphicSymbol

public void setPolygonGraphicSymbol(WebSimplePolygonSymbol symbol)
Sets the WebSimplePolygonSymbol object used to symbolize the polygon geometry.


getPolygonGraphicSymbol

public WebSimplePolygonSymbol getPolygonGraphicSymbol()
Returns the WebSimplePolygonSymbol object used to symbolize the polygon geometry.


setLayerDefinitions

public void setLayerDefinitions(List<? extends LayerDefinition> layerDefinitions)
Sets the list of LayerDefinition objects.

Parameters:
layerDefinitions - the list of layer definition objects

getLayerDefinitions

public List<? extends LayerDefinition> getLayerDefinitions()
Returns the list of LayerDefinition.

Returns:
the list of layer definition objects

getPolgonGraphic

@Deprecated
public GraphicElement getPolgonGraphic()
Deprecated. As of ArcGIS Java Server 9.3, instead use getPolygonGraphic()

Returns the GraphicElement object used to render the polygon geometries.