📄 aimstaskutil.java
字号:
package com.esri.adf.web.aims.tasks;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import javax.faces.model.SelectItem;
import com.esri.adf.web.aims.data.AIMSMapFunctionality;
import com.esri.adf.web.aims.data.AIMSMapResource;
import com.esri.adf.web.data.WebContext;
import com.esri.aims.mtier.model.map.Layers;
import com.esri.aims.mtier.model.map.Map;
import com.esri.aims.mtier.model.map.layer.Layer;
import com.esri.aims.mtier.model.service.Services;
public class AIMSTaskUtil
{
public AIMSTaskUtil()
{
}
public static LinkedHashMap getAimsServiceList(String host, int port, String userName, String password)
{
try
{
LinkedHashMap<Integer, String> newLayerList = new LinkedHashMap<Integer, String>();
Services aimsServices = new Services();
//aimsConnection.setUsername(this.aimsUsername);
//aimsConnection.setPassword(this.aimsPassword);
if(host!=null && host.toLowerCase().startsWith("http")== false)
{
aimsServices.getServices(host, port, userName, password);
}
else if(host!=null && host.toLowerCase().startsWith("http")== true)
{
URL url = new URL(host);
aimsServices.getServices(url, userName, password);
}
for(int i=0; i<aimsServices.getServicesCount(); i++)
{
if(aimsServices.getService(i)!= null)
{
SelectItem selectItem = new SelectItem(aimsServices.getService(i).getName(), aimsServices.getService(i).getName(), aimsServices.getService(i).getName());
newLayerList.put(new Integer(i), selectItem.getLabel());
}
}
return newLayerList;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
public static LinkedHashMap getAimsResourceList(WebContext context)
{
try
{
LinkedHashMap<Integer, String> newLayerList = new LinkedHashMap<Integer, String>();
if(context != null)
{
LinkedHashMap resources = (LinkedHashMap)context.getResources();
Object resource;
int i= 0;
for(Iterator iter = resources.keySet().iterator(); iter.hasNext();)
{
String id = (String)iter.next();
resource = resources.get(id);
if (resource instanceof AIMSMapResource)
{
AIMSMapResource tempAimsResource = (AIMSMapResource)resource;
SelectItem selectItem = new SelectItem(tempAimsResource.getServiceName(), tempAimsResource.getServiceName());
newLayerList.put(new Integer(i++), selectItem.getLabel());
}
}
}
return newLayerList;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
public static LinkedHashMap getLayerList(AIMSMapResource aimsMapResource)
{
try
{
LinkedHashMap<Integer, String> newLayerList = new LinkedHashMap<Integer, String>();
if(aimsMapResource != null)
{
AIMSMapFunctionality aimsMapFunc = (AIMSMapFunctionality)(aimsMapResource).getFunctionality("map");
Map aimsMap = aimsMapFunc.getMap();
Layers aimsLayers = aimsMap.getLayers();
for(int i=0; i<aimsLayers.getCount(); i++)
{
Layer aimsLayer = aimsLayers.item(i);
if(aimsLayer.getName().indexOf("Buffer") == -1)
{
SelectItem selectItem = new SelectItem(aimsLayer, aimsLayer.getName());
newLayerList.put(new Integer(i), selectItem.getLabel());
}
}
}
return newLayerList;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
public static AIMSMapResource getAimsResourceById(WebContext context, int id)
{
try
{
ArrayList<AIMSMapResource> resourceList = new ArrayList<AIMSMapResource>();
if(context != null)
{
LinkedHashMap resources = (LinkedHashMap)context.getResources();
Object resource;
for(Iterator iter = resources.keySet().iterator(); iter.hasNext();)
{
String i = (String)iter.next();
resource = resources.get(i);
if (resource instanceof AIMSMapResource)
{
AIMSMapResource tempAimsResource = (AIMSMapResource)resource;
resourceList.add(tempAimsResource);
}
}
}
return (AIMSMapResource)(resourceList.get(id));
}
catch(Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -