⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filtertask.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.esri.solutions.jitk.web.tasks.filter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.esri.adf.web.ags.data.AGSLocalMapResource;
import com.esri.adf.web.ags.data.AGSMapFunctionality;
import com.esri.adf.web.ags.data.AGSMapResource;
import com.esri.adf.web.data.GISResource;
import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.WebContextInitialize;
import com.esri.adf.web.data.WebLayerInfo;
import com.esri.adf.web.data.query.QueryResult;
import com.esri.adf.web.data.query.WebQuery;
import com.esri.adf.web.data.tasks.TaskInfo;
import com.esri.adf.web.data.tasks.TaskInfoBean;
import com.esri.adf.web.faces.event.TaskEvent;
import com.esri.arcgisws.MapLayerInfo;
import com.esri.solutions.jitk.common.personalization.IPersonalizable;
import com.esri.solutions.jitk.common.personalization.IPersonalizationContext;
import com.esri.solutions.jitk.common.resources.TextResources;
import com.esri.solutions.jitk.web.data.FilterNotSupportedOnServiceTypeException;
import com.esri.solutions.jitk.web.data.WebFilter;
import com.esri.solutions.jitk.common.web.layer.WebLayerInfoUtil;
import com.esri.solutions.jitk.web.tasks.ErrorProducingTask;
import com.esri.solutions.jitk.web.tasks.query.querybuilder.ResourceProps;

/**
 * MVS-045: Filter Task. This task allows users to define filters using both spatial and non-spatial terms,
 * without requiring end user knowledge of SQL. 
 */
@SuppressWarnings( {"unchecked", "deprecation"} )
public class FilterTask extends ErrorProducingTask implements WebContextInitialize, TaskInfoBean, IPersonalizable {	
	private static final long serialVersionUID = 4204260836064484930L;
	private static final String FILTER_TASK = "filtertask.ui.label.filter";
	private static final String EQUAL_TO = "filtertask.ui.domain.equalTo";
	private static final String GREATER_THAN = "filtertask.ui.domain.greaterThan";
	private static final String LESS_THAN = "filtertask.ui.domain.lessThan";
	private static final String GREATER_THAN_OR_EQUAL_TO = "filtertask.ui.domain.greaterThanEqualTo";
	private static final String LESS_THAN_OR_EQUAL_TO = "filtertask.ui.domain.lessThanEqualTo";
	private static final String NOT_EQUAL_TO = "filtertask.ui.domain.notEqualTo";
	private static final String WITHIN = "filtertask.ui.domain.within";
	private static final String INTERSECT = "filtertask.ui.domain.intersects";
	private static final String NO_VALUES = "filtertask.ui.domain.noValues";
	private static final String QUERY_RESULT = "filtertask.ui.label.queryResult";
	private static final String ERROR_MESSAGE = "filtertask.msg.error";
	private static Logger logger = Logger.getLogger(FilterTask.class.getName());
	private FilterTaskInfo taskInfo = null;
	private String taskName = null;
	private LinkedHashMap<String, String> layerList = null;
	private LinkedHashMap<String, String> spatialLayerList = null;
	private LinkedHashMap<String, String> attributeList = null;
	private LinkedHashMap<String, String> operationList = null;
	private LinkedHashMap<String, String> spatialOperationList = null;
	private LinkedHashMap<String, String> domainValueList = null;
	private String inputLayer = null;
	private String attributeSelection = "domainValue";
	private String spatialFilterSelection = "graphics";
	private String layer = null;
	private String spatialLayer = "";
	private String attribute = "";
	private String operation = "";
	private String spatialOperation = "";
	private String sql = "";
	private String textValue = "";
	private String domainValue = "";
	private int maxRecords = 500;
	private String inputLayerLabel = null;
	private String attributeSelectionLabel = null;
	private String addToQueryExpressionLabel = null;
	private String queryExpressionLabel = null;
	private String filterButtonLabel = null;
	private String locationToQueryLabel = null;
	private String messageLabel = null;
	private String uiMessage1 = null;
	private String uiMessage2 = null;
	private String uiMessage3 = null;
	private String uiMessage4 = null;
	private String footerNote = null;
	private String selectedLayer = null;
	private QueryResult currentHighlighted = null;	
	private WebContext context = null;
	private WebFilter webFilter = null;
	private TaskFilterRenderer filterTaskRenderer = null;
	
	private IPersonalizationContext _personalCtx = null;
	private Map _layerMap = new HashMap();
	
	/**
	 * One and only constructor for FilterTask class
	 */
	public FilterTask(){
		this.taskInfo = new FilterTaskInfo();
		this.taskName = TextResources.getResourceString(FILTER_TASK);
	}
	
	/**
	 * Fulfills the {@link WebContextInitialize} contract 
	 * 
	 */
	public void destroy(){
		this.context = null;	
	}

	/**
	 * Fulfills the {@link WebContextInitialize} contract 
	 * 
	 */
	public void init(WebContext context){
		setContext(context);
	}

	/**
	 * Fulfills the {@link TaskInfoBean} contract 
	 * returns the TaskInfo object associated with FilterTask
	 * 
	 */
	public TaskInfo getTaskInfo(){		
		if(this.context == null){			
			taskInfo.getTaskDescriptor().setDisabled(true);
		}
		
		return this.taskInfo;
	}

	/*
	 * (non-Javadoc)
	 * @see com.esri.adf.web.data.tasks.TaskInfoBean#setTaskInfo(com.esri.adf.web.data.tasks.TaskInfo)
	 */
	public void setTaskInfo(TaskInfo taskInfo){
		this.taskInfo = (FilterTaskInfo)taskInfo;
	}

	/**
	 * Retrieves the WebContext object
	 * @return
	 * 		Webcontext object
	 */
	public WebContext getContext(){
		return context;
	}

	/**
	 * Sets the Webcontext 
	 * @param context
	 * 		{@link WebContext} object to be set
	 */
	public void setContext(WebContext context){
		if(context != null){
		    this.context = context;
		    this.layerList = FilterUtil.getLayerList(context);
			if (this.getLayer() == null){
				String flayer = null;
					
				for (Map.Entry<String, String> mapEntry : layerList.entrySet()){
					flayer = mapEntry.getKey();
					this.setLayer(flayer);
					getUpdateAttributeList(flayer);
				}
			}
		}
		else{
			taskInfo.getTaskDescriptor().setDisabled(true);
		}			
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.common.personalization.IPersonalizable#setPersonalizationContext(com.esri.solutions.jitk.common.personalization.IPersonalizationContext)
	 */
	public void setPersonalizationContext(IPersonalizationContext ctx) {
		_personalCtx = ctx;
	}
	
	/***
	 * Set the WebFilter via dependency injection
	 * @param wf
	 * 		{@link WebFilter} object to be set
	 */ 
	public void setWebFilter(WebFilter wf){
		this.webFilter = wf;
	}
	
	/**
	 * Set the FilterTaskRenderer via dependency injection
	 * @param renderer
	 * 		
	 */
	public void setFilterTaskRenderer(TaskFilterRenderer renderer){
		this.filterTaskRenderer = renderer;
	}
	
	/**
	 * Retrieve the {@link TaskFilterRenderer} object
	 * @return
	 */
	public TaskFilterRenderer getFilterTaskRenderer(){
		return this.filterTaskRenderer;
	}
	
	/**
	 * Set the first value in the attribute list
	 */
	public void setLayerAttribute(){
	    
	    // set the first attribute    
	    for( Map.Entry<String, String> attrList : attributeList.entrySet()){
	    	String attr = attrList.getKey();
			this.setAttribute(attr);
			break;
	    }
	}
	
	/**
	 * Gets the maximum number of records returned by a query
	 */
	public int getMaxRecords() {
		return maxRecords;
	}
	
	/**
	 * Sets the maximum number of records returned by a query
	 */	
	public void setMaxRecords(int maxNumberOfRecords) {
		maxRecords = maxNumberOfRecords;
	}

	/**
	 * Get task name
	 */
	public String getTaskName(){
		return taskName;
	}

	/**
	 * Set task name
	 */
	public void setTaskName(String taskName){
		this.taskName = taskName;
	}

	/**
	 * Get input layer label
	 */
	public String getInputLayerLabel(){
		return this.inputLayerLabel;
	}

	/**
	 * Set input layer label
	 */
	public void inputLayerLabelSet(String inputLayerLabel){
		this.inputLayerLabel = inputLayerLabel;
	}

	/**
	 * Get attribute selection label
	 */
	public String getAttributeSelectionLabel(){
		return this.attributeSelectionLabel;
	}

	/**
	 * Set attribute selection label
	 */
	public void setAttributeSelectionLabel(String attributeSelectionLabel){
		this.attributeSelectionLabel = attributeSelectionLabel;
	}
	
	/**
	 * Get filter button label
	 */
	public String getFilterButtonLabel(){
		return this.filterButtonLabel;
	}

	/**
	 * Set filter button label
	 */
	public void setFilterButtonLabel(String filterButtonLabel){
		this.filterButtonLabel = filterButtonLabel;
	}

	/**
	 * Get add to query expression label
	 */
	public String getAddToQueryExpressionLabel(){
		return this.addToQueryExpressionLabel;
	}

	/**
	 * Set add to query expression label
	 */
	public void setAddToQueryExpressionLabel(String addToQueryExpressionLabel){
		this.addToQueryExpressionLabel = addToQueryExpressionLabel;
	}

	/**
	 * Get query expression label
	 */
	public String getQueryExpressionLabel(){
		return this.queryExpressionLabel;
	}

	/**
	 * Set query expression label
	 */
	public void setQueryExpressionLabel(String queryExpressionLabel){
		this.queryExpressionLabel = queryExpressionLabel;
	}

	/**
	 * Get location to query label
	 */
	public String getLocationToQueryLabel(){
		return this.locationToQueryLabel;
	}

	/**
	 * Set location to query label
	 */
	public void setLocationToQueryLabel(String locationToQueryLabel){
		this.locationToQueryLabel = locationToQueryLabel;
	}

	/**
	 * Get message label
	 */
	public String getMessageLabel(){
		return this.messageLabel;
	}

	/**
	 * Set message label
	 */
	public void setMessageLabel(String messageLabel){
		this.messageLabel = messageLabel;
	}

	/**
	 * Get ui message 1
	 */
	public String getUiMessage1(){
		return this.uiMessage1;
	}

	/**
	 * Set ui message 1
	 */
	public void setUiMessage1(String uiMessage1){
		this.uiMessage1 = uiMessage1;
	}

	/**
	 * Get ui message 2
	 */
	public String getUiMessage2(){
		return this.uiMessage2;
	}

	/**
	 * Set ui message 2
	 */
	public void setUiMessage2(String uiMessage2){
		this.uiMessage2 = uiMessage2;
	}

	/**
	 * Get ui message 3
	 */
	public String getUiMessage3(){
		return this.uiMessage3;
	}

	/**
	 * Set ui message 3
	 */
	public void setUiMessage3(String uiMessage3){
		this.uiMessage3 = uiMessage3;
	}

	/**
	 * Get ui message 4
	 */
	public String getUiMessage4(){
		return this.uiMessage4;
	}

	/**
	 * Set ui message 4
	 */
	public void setUiMessage4(String uiMessage4){
		this.uiMessage4 = uiMessage4;
	}

	/**
	 * Get footer note
	 */
	public String getFooterNote(){
		return this.footerNote;
	}

	/**
	 * Set footer note
	 */
	public void setFooterNote(String footerNote){
		this.footerNote = footerNote;
	}
	
	/**
	 * Get selected layer
	 */
	public String getLayer(){
		return this.layer;
	}

	/**
	 * Set selected layer
	 */
	public void setLayer(String layer){
		this.layer = layer;
	}

	/**
	 * Get spatial layer
	 */
	public String getSpatialLayer(){
		return this.spatialLayer;
	}

	/**
	 * Set spatial layer
	 */
	public void setSpatialLayer(String spatialLayer){
		this.spatialLayer = spatialLayer;
	}

	/**
	 * Get text value
	 */
	public String getTextValue(){
		return this.textValue;
	}

	/**
	 * Set text value
	 */
	public void setTextValue(String textValue){
		this.textValue = textValue;
	}

	/**
	 * Get attribute
	 */
	public String getAttribute(){
		return this.attribute;
	}

	/**
	 * Set attribute
	 */
	public void setAttribute(String attribute){
		this.attribute = attribute;
	}

	/**
	 * Get operation
	 */
	public String getOperation(){
		return this.operation;
	}

	/**
	 * Set operation
	 */
	public void setOperation(String operation){
		this.operation = operation;
	}

	/**
	 * Get spatial operation
	 */
	public String getSpatialOperation(){
		return this.spatialOperation;
	}

	/**
	 * Set spatial operation
	 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -