📄 resourcefinder.java
字号:
package com.esri.solutions.jitk.web.tasks.query.querybuilder;
import java.util.Iterator;
import java.util.LinkedHashMap;
import com.esri.adf.web.ags.data.AGSMapResource;
import com.esri.adf.web.aims.data.AIMSMapResource;
import com.esri.adf.web.data.GISResource;
import com.esri.adf.web.data.WebContext;
import com.esri.solutions.jitk.web.wfs.data.WFSMapResource;
public class ResourceFinder {
public ResourceFinder() {
}
/**
* Get the map resource associated with the currently selected layer
*/
@SuppressWarnings("unused")
public AGSMapResource getAGSMapResource(WebContext webContext, LinkedHashMap<String, GISResource> resources, String layerName) {
Object resource;
for(Iterator<String> it = resources.keySet().iterator(); it.hasNext();) {
String id = (String)it.next();
resource = resources.get(id);
if (resource instanceof AGSMapResource){
AGSMapResource agsMapResource = (AGSMapResource)resource;
LinkedHashMap<String, String> layerList = getAGSLayerList(agsMapResource, id, webContext);
Iterator<String> iter = layerList.keySet().iterator();
while (iter.hasNext()){
String layer = (String)iter.next();
if (layerName.equals(layer)){
return agsMapResource;
}
}
}
}
return null;
}
public WFSMapResource getWFSMapResource(WebContext webContext, LinkedHashMap<String, GISResource> resources, String layerName)
throws Exception {
Object resource;
for(Iterator<String> it = resources.keySet().iterator(); it.hasNext();) {
String id = (String)it.next();
resource = resources.get(id);
if (resource instanceof WFSMapResource) {
WFSMapResource wfsMapResource = (WFSMapResource)resource;
LinkedHashMap<String, String> layerList =
QueryBuilderTaskWfsUtil.getServiceLayerList(wfsMapResource, id, webContext.getWebQuery().getQueryLayers());
Iterator<String> iter = layerList.keySet().iterator();
while (iter.hasNext()) {
String layer = (String)iter.next();
if (layerName.equals(layer)){
return wfsMapResource;
}
}
}
}
return null;
}
/**
* Get the map resource associated with the layername passed in. This
* is used for loading queries because the layer id changes everytime
* a new query is loaded. Have to search for the resource by name
* rather than by layerid.
*/
@SuppressWarnings("unused")
public AGSMapResource getAGSMapResourceByLayerName(WebContext webContext, LinkedHashMap<String, GISResource> resources, String layerName) {
Object resource;
for(Iterator<String> it = resources.keySet().iterator(); it.hasNext();) {
String id = (String)it.next();
resource = resources.get(id);
if (resource instanceof AGSMapResource){
AGSMapResource agsMapResource = (AGSMapResource)resource;
LinkedHashMap<String, String> layerList = getAGSLayerList(agsMapResource, id, webContext);
if (layerList.containsValue(layerName)){
return agsMapResource;
}
}
}
return null;
}
/**
* Get the AIMS map resource associated with the currently selected layer
*/
@SuppressWarnings("unused")
public AIMSMapResource getAIMSMapResource(WebContext webContext, LinkedHashMap<String, GISResource> resources, String layerName) {
Object resource;
for(Iterator<String> it = resources.keySet().iterator(); it.hasNext();) {
String id = (String)it.next();
resource = resources.get(id);
if (resource instanceof AIMSMapResource){
AIMSMapResource aimsMapResource = (AIMSMapResource)resource;
LinkedHashMap<String, String>layerList = getAIMSLayerList(aimsMapResource, id);
Iterator<String> iter = layerList.keySet().iterator();
while (iter.hasNext()){
String layer = (String)iter.next();
if (layerName.equals(layer)){
return aimsMapResource;
}
}
}
}
return null;
}
/**
* Get the map resource associated with the layername passed in. This
* is used for loading queries because the layer id changes every time
* a new query is loaded. Have to search for the layer by name
* rather than by id.
*/
@SuppressWarnings("unused")
public AIMSMapResource getAIMSMapResourceByLayerName(WebContext webContext, LinkedHashMap<String, GISResource> resources, String layerName) {
Object resource;
for(Iterator<String> it = resources.keySet().iterator(); it.hasNext();) {
String id = (String)it.next();
resource = resources.get(id);
if (resource instanceof AIMSMapResource){
AIMSMapResource aimsMapResource = (AIMSMapResource)resource;
LinkedHashMap<String, String> layerList = getAIMSLayerList(aimsMapResource, id);
Iterator<String> iter = layerList.keySet().iterator();
if (layerList.containsValue(layerName)){
return aimsMapResource;
}
}
}
return null;
}
private LinkedHashMap<String, String> getAIMSLayerList( AIMSMapResource resource, String id){
return QueryBuilderTaskAimsUtil.getServiceLayerList(resource, id);
}
private LinkedHashMap<String, String> getAGSLayerList( AGSMapResource resource, String id, WebContext context){
return QueryBuilderTaskAgsUtil.getServiceLayerList(resource, id, context.getWebQuery().getQueryLayers());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -