📄 defaultopenmapcomposition.java
字号:
WmsServiceType wms = (WmsServiceType) service.getWmsService();
resource = m_converter.createWMSMapResource(wms);
newResources.put(id, resource);
} else if (service.getWcsService() != null) {
WcsServiceType wcs = (WcsServiceType) service.getWcsService();
resource = m_converter.createWCSMapResource(wcs);
newResources.put(id, resource);
} else if (service.getWfsService() != null) {
WfsServiceType wfs = (WfsServiceType) service.getWfsService();
resource = m_converter.createWFSMapResource(wfs);
newResources.put(id, resource);
} else {
LOG.warn("Unrecognized service type encountered, ignoring");
}
}
m_persCtx.getWebContext().setResources(newResources);
applyFilters(mcData);
}
/**
* Applies the background color defined in the Map Composition to the
* Map Viewer. CURRENTLY NOT IMPLEMENTED.
*
* @param mcData Map Composition Data, cannot be <code>null</code>.
*/
protected void applyBackgroundColor(MapCompositionType mcData) {
}
/**
* Finds any ArcGIS Server layers within the Map Composition that
* contains a filter, and adds the Filter to a HashMap within the
* Personalization Context.
*
* @param mcData Map Composition Data
*/
@SuppressWarnings("unchecked")
protected void applyFilters(MapCompositionType mcData) {
if (mcData == null) {
throw new NullPointerException();
}
m_persCtx.setAttribute("FilterExpression", new HashMap());
ServiceListType serviceList = mcData.getServices();
List services = serviceList.getServiceItem();
for (Iterator i = services.iterator(); i.hasNext();) {
ServiceItemType item = (ServiceItemType) i.next();
if (item.getAgsInternetService() != null) {
AgsInternetServiceType ags = item.getAgsInternetService();
AGSMapResource res = findAGSMapResource(ags);
if (res != null) {
applyFilters((AGSMapFunctionality) res.getFunctionality(
MapFunctionality.FUNCTIONALITY_NAME), ags);
}
} else if (item.getAgsLocalService() != null) {
AgsLocalServiceType ags = item.getAgsLocalService();
AGSLocalMapResource res = findAGSLocalMapResource(ags);
if (res != null) {
applyFilters((AGSMapFunctionality) res.getFunctionality(
MapFunctionality.FUNCTIONALITY_NAME), ags);
}
}
}
}
/**
* Applies the filter information from to an AGSMapFunctionality from AGS
* Local Map Service data record stored in the Map Composition data.
*
* @param func AGS Map Functionality
* @param ags AGS Local Service information.
*/
@SuppressWarnings("unchecked")
private void applyFilters(AGSMapFunctionality func, AgsLocalServiceType ags) {
LayerListType layerList = ags.getLayers();
List layers = layerList.getLayerItem();
for (Iterator i = layers.iterator(); i.hasNext();) {
LayerType layer = (LayerType) i.next();
if ((layer.getFilterExpression() != null) &&
(layer.getFilterExpression().trim().length() != 0)) {
try {
LayerDescription ld = func.getLayerDescription(Integer.valueOf(
layer.getId()).intValue());
ld.setDefinitionExpression(layer.getFilterExpression());
MapLayerInfo li = func.getLayerInfo(Integer.valueOf(
layer.getId()).intValue());
Map map = (Map) m_persCtx.getAttribute("FilterExpression");
map.put(li, layer.getFilterExpression());
} catch (NumberFormatException e) {
}
}
}
}
/**
* Applies the filter information from to an AGSMapFunctionality from AGS
* Internet Map Service data record stored in the Map Composition data.
*
* @param func AGS Map Functionality
* @param ags AGS Internet Service information.
*/
@SuppressWarnings("unchecked")
private void applyFilters(AGSMapFunctionality func,
AgsInternetServiceType ags) {
LayerListType layerList = ags.getLayers();
List layers = layerList.getLayerItem();
for (Iterator i = layers.iterator(); i.hasNext();) {
LayerItemType item = (LayerItemType) i.next();
LayerType layer = null;
if (item.getLayer() != null) {
layer = item.getLayer();
} else if (item.getServiceLayer() != null) {
layer = item.getServiceLayer();
} else {
continue;
}
if ((layer.getFilterExpression() != null) &&
(layer.getFilterExpression().trim().length() != 0)) {
try {
LayerDescription ld = func.getLayerDescription(Integer.valueOf(
layer.getId()).intValue());
ld.setDefinitionExpression(layer.getFilterExpression());
MapLayerInfo li = func.getLayerInfo(Integer.valueOf(
layer.getId()).intValue());
Map map = (Map) m_persCtx.getAttribute("FilterExpression");
map.put(li, layer.getFilterExpression());
} catch (NumberFormatException e) {
LOG.warn(java.text.MessageFormat.format(
WARN_UNABLE_TO_FIND_LAYER_AGS, layer.getId(),
layer.getName(), ags.getEndPointUrl()));
}
}
}
}
/**
* Finds an {@link AGSMapResource} using information within a AGS Internet
* Service record within the Map Composition data.
*
* @param ags AGS Internet Service record, contains information for
* creating an {@link AGSMapResource}.
* @return Resource object that matches the data within the AGS Internet Service Record.
*/
private AGSMapResource findAGSMapResource(AgsInternetServiceType ags) {
AGSMapResource agsRes = null;
Map<String, GISResource> resources = m_persCtx.getWebContext()
.getResources();
for (GISResource res : resources.values()) {
if (res instanceof AGSMapResource &&
!(res instanceof AGSLocalMapResource)) {
agsRes = (AGSMapResource) res;
if (agsRes.getEndPointURL().equals(ags.getEndPointUrl()) &&
agsRes.getAlias().equals(ags.getDisplayName())) {
return agsRes;
}
}
}
return null;
}
/**
* Finds an {@link AGSLocalMapResource} using information within an AGS Local
* Service record within the Map Composition data.
*
* @param ags AGS Local Service record, contains information on
* creating an {@link AGSLocalMapResource}.
* @return Resource object that matches the data within the AGS Local Service Record.
*/
@SuppressWarnings("unchecked")
private AGSLocalMapResource findAGSLocalMapResource(AgsLocalServiceType ags) {
AGSLocalMapResource agsRes = null;
Map<String, GISResource> resources = m_persCtx.getWebContext()
.getResources();
List sortedHostList1 = new ArrayList();
sortedHostList1.addAll(ags.getHostList().getHost());
Collections.sort(sortedHostList1);
String hostList1 = "";
for (Object o : sortedHostList1) {
hostList1 += o.toString();
}
for (GISResource res : resources.values()) {
if (res instanceof AGSLocalMapResource) {
agsRes = (AGSLocalMapResource) res;
List sortedHostList2 = new ArrayList();
sortedHostList2.addAll(agsRes.getHosts());
Collections.sort(sortedHostList2);
String hostList2 = "";
for (Object o : sortedHostList2) {
hostList2 += o.toString();
}
if (hostList1.equalsIgnoreCase(hostList2) &&
ags.getDisplayName().equals(agsRes.getAlias())) {
return agsRes;
}
}
}
return null;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.web.tasks.mapcomp.IOpenMapComposition#getMessages()
*/
public List<String> getMessages() {
return new ArrayList<String>(m_messages);
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.web.tasks.mapcomp.IOpenMapComposition#clearMessages()
*/
public void clearMessages() {
m_messages.clear();
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.personalization.IPersonalizable#setPersonalizationContext(com.esri.solutions.jitk.common.personalization.IPersonalizationContext)
*/
public void setPersonalizationContext(IPersonalizationContext ctx) {
m_persCtx = ctx;
}
/**
* Sets the reference to the Bean to ADF converter object. The
* converter object converts Map Composition beans to ADF
* objects.
*
* @param converter Converts Map Composition beans to ADF objects.
*/
public void setConverter(IBeanToADFConverter converter) {
this.m_converter = converter;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -