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

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

public class LayerDefinition
extends Object
implements Serializable

The LayerDefinition class is used to customize the query result. The LayerDefinition can be used to set field aliases, filter return fields, set symbols, etc. These customizations are used to represent the results of queries performed using the WebQuery object. The LayerDefinition set in the WebQuery object can be overriden for individual queries by setting a LayerDefinition on the IdentifyCriteria, PredefinedQueryCriteria and TextCriteria objects.

See Also:
WebQuery.setLayerDefinitions(List), IdentifyCriteria.setLayerDefinitions(List), PredefinedQueryCriteria.setLayerDefinitions(List), TextCriteria.setLayerDefinitions(List), Serialized Form

Field Summary
static String DEFAULT_TEMPLATE
           
 
Constructor Summary
LayerDefinition()
           
 
Method Summary
 String getCalloutTemplate()
          Returns the callout template.
 String getDisplayFieldName()
          Returns which field's value should be used to display the query's results.This value is used as the title in the map tip's callout window.
 Map<String,String> getFieldAliases()
          Returns the field aliases.
 WebRenderer getHighlightRenderer()
          Return the highlight renderer for callout.
 int getLayerId()
          Returns the layer id.
 double getMaximumAllowableOffset()
          This property specifies whether the geometry of features returned by the query should be generalized.
 int getMaxRecordCount()
          Returns the number of records that will be returned for the query operation.
 double getPointZoomToFactor()
          Returns the amount by which the map's full extent should be contracted to zoom into results returned by the query.
 WebRenderer getRenderer()
          Return the default renderer for callout.
 String getResourceId()
          Returns the resource id.
 String getResultTemplate()
          Returns the template used for formatting result attributes.
 List<String> getReturnFields()
          Specifies which fields should be included in the query results.
 List<String> getSearchFields()
          Returns which fields to perform the query on.
 boolean isFetchRelatedRecords()
          Returns true if the related records need to be fetched.
 boolean isFetchResultDetails()
          Specifies whether to retrieve detailed results for the query.
 boolean isReturnGeometry()
          Returns true if the Shape field should always be included in the query results.
 void setCalloutTemplate(String calloutTemplate)
          Sets the template used for displaying the callout.
 void setDisplayFieldName(String displayFieldName)
          Specifies which field's value should be used to display the query's results.
 void setFetchRelatedRecords(boolean fetchRelatedRecords)
          Specifies whether to retrieve the related records for the query.
 void setFetchResultDetails(boolean fetchResultDetails)
          Specifies whether to retrieve detailed results for the query.
 void setFieldAliases(Map<String,String> fields)
          Sets the field aliases name for the feature attributes.
 void setHighlightRenderer(WebRenderer highlightRenderer)
          Sets the highlight renderer for callout.
 void setLayerId(int layerId)
          Sets the layer id.
 void setMaximumAllowableOffset(double maximumAllowableOffset)
          This property specifies whether the geometry of features returned by the query should be generalized.
 void setMaxRecordCount(int count)
          Sets the number of records to be returned for the query operation.
 void setPointZoomToFactor(double factor)
          Specifies the amount by which the map's full extent should be contracted to zoom into results returned by the query.
 void setRenderer(WebRenderer renderer)
          Sets the default renderer for callout.
 void setResourceId(String resourceId)
          Sets the resource id of this layer definition.
 void setResultTemplate(String resultTemplate)
          Sets the template used for formatting result attributes.
 void setReturnFields(List<String> returnFields)
          Specifies which fields should be included in the query results.
 void setReturnGeometry(boolean returnGeometry)
          Specifies whether the Shape field should always be included in the query results.
 void setSearchFields(List<String> searchFields)
          Specifies which fields to perform the query on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TEMPLATE

public static final String DEFAULT_TEMPLATE
See Also:
Constant Field Values
Constructor Detail

LayerDefinition

public LayerDefinition()
Method Detail

setResourceId

public void setResourceId(String resourceId)
Sets the resource id of this layer definition. This is used to attach a layer definition to a resource. The argument resourceId is the key used to add the resource in the WebContext.

Parameters:
resourceId - the resource id of which this layer definition belongs
See Also:
WebContext.addResource(String, com.esri.adf.web.data.GISResource)

getResourceId

public String getResourceId()
Returns the resource id.

Returns:
the resource id

setLayerId

public void setLayerId(int layerId)
Sets the layer id.

Parameters:
layerId - the layer id

getLayerId

public int getLayerId()
Returns the layer id.

Returns:
the layer id

setDisplayFieldName

public void setDisplayFieldName(String displayFieldName)
Specifies which field's value should be used to display the query's results. This value is used as the title in the map tip's callout window.

Parameters:
displayFieldName - the name of the query result

getDisplayFieldName

public String getDisplayFieldName()
Returns which field's value should be used to display the query's results.This value is used as the title in the map tip's callout window.

Returns:
the name of the query result

setFetchResultDetails

public void setFetchResultDetails(boolean fetchResultDetails)
Specifies whether to retrieve detailed results for the query. The default value is true and all fields specified in getReturnFields() are retrieved. If the getReturnFields() does not include the Shape field, it may also be retrieved depending upon the value of isReturnGeometry(). When false, only the field specified in setDisplayFieldName(String) is retrieved. The Shape field may also be retrieved depending upon the value of isReturnGeometry().

Parameters:
fetchResultDetails - if true the feature attributes will be returned in query result

isFetchResultDetails

public boolean isFetchResultDetails()
Specifies whether to retrieve detailed results for the query. The default value is true and all fields specified in getReturnFields() are retrieved. If the getReturnFields() does not include the Shape field, it may also be retrieved depending upon the value of isReturnGeometry(). When false, only the field specified in setDisplayFieldName(String) is retrieved. The Shape field may also be retrieved depending upon the value of isReturnGeometry().

Returns:
if true, the feature attributes will be returned

setReturnGeometry

public void setReturnGeometry(boolean returnGeometry)
Specifies whether the Shape field should always be included in the query results. Please refer to setFetchResultDetails(boolean) for further information. Only applicable for queries based on AGSPredefinedQueryCriteriaHandler.

Parameters:
returnGeometry - if true the feature geometry will be returned in query result

isReturnGeometry

public boolean isReturnGeometry()
Returns true if the Shape field should always be included in the query results. Please refer to setFetchResultDetails(boolean) for further information. Only applicable for queries based on AGSPredefinedQueryCriteriaHandler.

Returns:
if true, the feature geometry will be returned

setFieldAliases

public void setFieldAliases(Map<String,String> fields)
Sets the field aliases name for the feature attributes.
  <managed-property>
   <property-name>fieldAliases</property-name>
   <map-entries>
     <map-entry>
       <key>CNTRY_NAME</key>
       <value>Name</value>
     </map-entry>
     <map-entry>
       <key>POP_CNTRY</key>
       <value>Population</value>
     </map-entry>
     <map-entry>
       <key>SQKM_CNTRY</key>
       <value>Area</value>
     </map-entry>
   </map-entries>
  </managed-property>
 

Parameters:
fields - the field aliases name for the feature attributes

getFieldAliases

public Map<String,String> getFieldAliases()
Returns the field aliases.

Returns:
the field aliases

setSearchFields

public void setSearchFields(List<String> searchFields)
Specifies which fields to perform the query on. The default value is null and all fields will be queried. Only applicable for queries based on TextCriteria.

Parameters:
searchFields - the list of search field names

getSearchFields

public List<String> getSearchFields()
Returns which fields to perform the query on. The default value is null and all fields will be queried. Only applicable for queries based on TextCriteria.

Returns:
the list of search field names

setReturnFields

public void setReturnFields(List<String> returnFields)
Specifies which fields should be included in the query results. By default, the value is null and all fields are included. Please refer to setFetchResultDetails(boolean) for further information.
  <managed-property>
   <property-name>returnFields</property-name>
   <list-entries>
     <value>CNTRY_NAME</value>
     <value>POP_CNTRY</value>
     <value>SQKM_CNTRY</value>
     <value>CURRENCY_TYPE</value>
   </list-entries>
  </managed-property>
 

Parameters:
returnFields - the list of return field names

getReturnFields

public List<String> getReturnFields()
Specifies which fields should be included in the query results. By default, the value is null and all fields are included. Please refer to setFetchResultDetails(boolean) for further information.

Returns:
the list of return field names

setMaxRecordCount

public void setMaxRecordCount(int count)
Sets the number of records to be returned for the query operation. PredefinedQueryCriteria.getMaxRecordCount() will take precedence over this value.

Parameters:
count - the record limit

getMaxRecordCount

public int getMaxRecordCount()
Returns the number of records that will be returned for the query operation. The default value is -1 which will return all records.

Returns:
the record limit

setRenderer

public void setRenderer(WebRenderer renderer)
Sets the default renderer for callout.

Parameters:
renderer - the default renderer for callout

getRenderer

public WebRenderer getRenderer()
Return the default renderer for callout.

Returns:
the default renderer for callout.

setHighlightRenderer

public void setHighlightRenderer(WebRenderer highlightRenderer)
Sets the highlight renderer for callout.

Parameters:
highlightRenderer - the highlight renderer for callout

getHighlightRenderer

public WebRenderer getHighlightRenderer()
Return the highlight renderer for callout.

Returns:
the highlight renderer for callout.

setCalloutTemplate

public void setCalloutTemplate(String calloutTemplate)
Sets the template used for displaying the callout. Setting null does not show the callout. Use DEFAULT_TEMPLATE for default formatting. In the template while specifying the field name within ${} use the alias field name if you would have already set using setFieldAliases(Map).
  A sample managed bean with custom callout formatting,
    <managed-property>
   <property-name>calloutTemplate</property-name>
   <value>
     <![CDATA[
       <header>
         <font style="background:#0404B4;color:#FFFFFF">Country Name : ${Name}</font>
       </header>
       <body>
         <table>
           <tr>
             <td><b>Name</b></td>
             <td>${Name}</td> <!-- if alias name is set then use the alias name -->
           </tr>
           <tr>
             <td>Population</td>
             <td>${Population}</td>
           </tr>
           <tr>
            <td>Area</td>
            <td>${Area}</td>
          </tr>
           <tr>
             <td>Currency</td>
             <td>${CURRENCY_TYPE}</td> <!-- alias name is not set using the actual field name -->
           </tr>
         </table>
       </body>
       <footer>
         <b>${Name}</b>
       </footer>
     ]]>
   </value>
 </managed-property>
 

Parameters:
calloutTemplate - the template used for displaying callout

getCalloutTemplate

public String getCalloutTemplate()
Returns the callout template.

Returns:
the callout template

setResultTemplate

public void setResultTemplate(String resultTemplate)
Sets the template used for formatting result attributes. Use DEFAULT_TEMPLATE for default formatting. In the template while specifying the field name within ${} use the alias field name if you would have already set using setFieldAliases(Map).
 A Sample managed bean with custom result formatting,
 
 <managed-property>
  <property-name>resultTemplate</property-name>
  <value>
    <![CDATA[
     <body>
       <table>
         <tr style="background:#0404B4;color:#FFFFFF">
          <th>Field Name</th>
          <th>Field Value</th>
         </tr>
         <tr>
          <td>Name</td>
          <td>${Name}</td>
         </tr>
         <tr>
          <td>Population</td>
          <td>${Population}</td>
         </tr>
         <tr>
          <td>Area</td>
          <td>${Area}</td>
         </tr>
         <tr>
          <td>Currency</td>
          <td>${CURRENCY_TYPE}</td>
         </tr>
       </table>          
     </body>
    ]]>
  </value>
 </managed-property>
 

Parameters:
resultTemplate - the template for formatting result attributes

getResultTemplate

public String getResultTemplate()
Returns the template used for formatting result attributes.

Returns:
the template for formatting result attributes

getMaximumAllowableOffset

public double getMaximumAllowableOffset()
This property specifies whether the geometry of features returned by the query should be generalized. Default value for MaximumAllowableOffset is "Double.NaN" which means the default setting will be honored. Values for MaximumAllowableOffset must be in the units of the WebContext's spatial reference. For example, if the spatial reference units of the resource being queried is in decimal degrees and the spatial reference units of the WebContext is in meters, the values specified for MaximumAllowableOffset must be in meters. This property only applies for queries based on AGSMapResource ArcGIS Server resources. It will be ignored for other resources.

Returns:
Returns the maximumAllowableOffset.

setMaximumAllowableOffset

public void setMaximumAllowableOffset(double maximumAllowableOffset)
This property specifies whether the geometry of features returned by the query should be generalized. Default value for MaximumAllowableOffset is "Double.NaN" which means the default setting will be honored. Values for MaximumAllowableOffset must be in the units of the WebContext's spatial reference. For example, if the spatial reference units of the resource being queried is in decimal degrees and the spatial reference units of the WebContext is in meters, the values specified for MaximumAllowableOffset must be in meters. This property only applies for queries based on AGSMapResource ArcGIS Server resources. It will be ignored for other resources.
Sample XML Snippet:
   <managed-property>
     <property-name>maximumAllowableOffset</property-name>
     <value>5</value>
   </managed-property>
 

Parameters:
maximumAllowableOffset - The maximumAllowableOffset to set.

getPointZoomToFactor

public double getPointZoomToFactor()
Returns the amount by which the map's full extent should be contracted to zoom into results returned by the query. This property only applies to point features because they don't have a well defined extent. The property is ignored if the layer definition is applied to polyline or polygon layers.

Returns:
the amount to zoom by for point features

setPointZoomToFactor

public void setPointZoomToFactor(double factor)
Specifies the amount by which the map's full extent should be contracted to zoom into results returned by the query. This property only applies to point features because they don't have a well defined extent. The property is ignored if the layer definition is applied to polyline or polygon layers. The default value is specified by QueryResult.ZOOMTO_POINT_FACTOR. So if the map's full extent is [-180,-90,180,90] and the result point feature is [0,0], a zoom factor of 20 would yield an extent [-9,-4.5,9,4.5] centered on the point.

Parameters:
factor - the amount to zoom by for point features

setFetchRelatedRecords

public void setFetchRelatedRecords(boolean fetchRelatedRecords)
Specifies whether to retrieve the related records for the query. The default value is true.

Parameters:
fetchRelatedRecords - if true the related records are fetched for the query

isFetchRelatedRecords

public boolean isFetchRelatedRecords()
Returns true if the related records need to be fetched.

Returns:
if true, the related records are fetched if the layer supports