Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/MetaDataService.java @ 778:9a828e5a2390
Removed trailing whitespace
gnv-artifacts/trunk@851 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 07:58:51 +0000 |
parents | 9efc1c256dbb |
children | b1f5f2a8840f |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/MetaDataService.java Fri Mar 26 15:31:20 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/MetaDataService.java Mon Mar 29 07:58:51 2010 +0000 @@ -49,17 +49,17 @@ */ private static Logger log = Logger.getLogger(MetaDataService.class); - - private final static String FIS_REGION_QUERY_ID = + + private final static String FIS_REGION_QUERY_ID = "mapviewer_interface_fis_region"; - private final static String MAPSERVICES_HAS_FIS_QUERY_ID = + private final static String MAPSERVICES_HAS_FIS_QUERY_ID = "mapviewer_interface_mapservices_has_fis"; - private final static String MAPSERVICES_HAS_PARAMETER_QUERY_ID = + private final static String MAPSERVICES_HAS_PARAMETER_QUERY_ID = "mapviewer_interface_mapservices_has_parameter"; - - private final static String MAPSERVICES_HAS_PARAMETER_USING_LAYER_QUERY_ID = + + private final static String MAPSERVICES_HAS_PARAMETER_USING_LAYER_QUERY_ID = "mapviewer_interface_mapservices_has_parameter_using_layer"; - + private static String ATTRIBUTE_ID = "id"; private static String ATTRIBUTE_NAME = "name"; private static String ATTRIBUTE_TYPE = "type"; @@ -67,14 +67,14 @@ private static String ATTRIBUTE_GROUPLAYER = "isgrouplayer"; private static String ATTRIBUTE_PARENTID = "parentid"; private static String ATTRIBUTE_SRS = "srs"; - - + + private static String XPATH_LOACTION_NODE = "art:GetMetaData/art:location"; private static String XPATH_MAPSERVICES_NODESET = "art:GetMetaData/" + "art:mapservices/" + "art:mapservice"; private static String XPATH_LAYER_NODESET = "art:layer"; - + /** * The UID of this Class. */ @@ -98,7 +98,7 @@ try { Geometry g = this.parseGeometry(data); Collection<MapService> mapServices = this.parseMapServices(data); - Collection<FIS> resultFIS = this.unionFIS(this.getFIS(g), + Collection<FIS> resultFIS = this.unionFIS(this.getFIS(g), this.getFIS(mapServices)); document = XMLUtils.newDocument(); this.writeFIS2Document(document, resultFIS); @@ -110,11 +110,11 @@ } return document; } - - private Geometry parseGeometry(Document data) + + private Geometry parseGeometry(Document data) throws MetaDataServiceException{ log.debug("MetaDataService.parseGeometry"); - + Element locationNode = (Element) XMLUtils.xpath( data, XPATH_LOACTION_NODE, @@ -139,11 +139,11 @@ } return returnValue; } - + private Collection<MapService> parseMapServices(Document data){ log.debug("MetaDataService.parseMapServices"); - - NodeList mapServices = (NodeList) XMLUtils.xpath(data, + + NodeList mapServices = (NodeList) XMLUtils.xpath(data, XPATH_MAPSERVICES_NODESET, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE); @@ -156,8 +156,8 @@ String type = mapServiceNode.getAttribute(ATTRIBUTE_TYPE); String url = mapServiceNode.getAttribute(ATTRIBUTE_URL); Collection<Layer> layer = null; - - NodeList layerNodes = (NodeList) XMLUtils.xpath(mapServiceNode, + + NodeList layerNodes = (NodeList) XMLUtils.xpath(mapServiceNode, XPATH_LAYER_NODESET, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE); @@ -167,29 +167,29 @@ Element layerNode = (Element)layerNodes.item(j); String layerId = layerNode.getAttribute(ATTRIBUTE_ID); String layerName = layerNode.getAttribute(ATTRIBUTE_NAME); - boolean isGroupLayer = + boolean isGroupLayer = Boolean.parseBoolean(layerNode .getAttribute( ATTRIBUTE_GROUPLAYER)); String parentId = layerNode .getAttribute(ATTRIBUTE_PARENTID); - + layer.add(new DefaultLayer(layerId, layerName, isGroupLayer, parentId)); } } - MapService mapService = new DefaultMapService(id, layer, + MapService mapService = new DefaultMapService(id, layer, type, url); returnValue.add(mapService); - + } } return returnValue; } - - private Collection<FIS> unionFIS(Collection<FIS> fromGeometry, + + private Collection<FIS> unionFIS(Collection<FIS> fromGeometry, Collection<FIS> fromMapservices){ log.debug("MetaDataService.unionFIS"); Collection<FIS> returnValue = null; @@ -198,7 +198,7 @@ }else if (fromMapservices == null || fromMapservices.isEmpty()){ returnValue = fromGeometry; }else{ - + returnValue = new ArrayList<FIS>(); Iterator<FIS> it = fromMapservices.iterator(); while (it.hasNext()){ @@ -210,15 +210,15 @@ } return returnValue; } - + /** * Puts the retrieved FIS into the given XML-Document. * @param document the Document where the FIS should be put in. - * @param fis the retrieved FIS which should be written into + * @param fis the retrieved FIS which should be written into * the XML-Document. */ private void writeFIS2Document(Document document, Collection<FIS> fis){ - + if (fis != null){ Iterator<FIS> it = fis.iterator(); XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( @@ -228,16 +228,16 @@ ); Node rootNode = creator.create("result"); document.appendChild(rootNode); - + Node factoriesNode = creator.create("factories"); rootNode.appendChild(factoriesNode); while (it.hasNext()){ FIS tmpFIS = it.next(); Element fisNode = creator.create("factory"); fisNode.setAttribute("art:name",tmpFIS.getID()); - + Collection<Parameter> parameter = tmpFIS.getParameter(); - + if(parameter != null){ Iterator<Parameter> pit = parameter.iterator(); while (pit.hasNext()){ @@ -252,13 +252,13 @@ } } } - + /** * Returns all FIS which Areas is intersected by this given Geometry * @param g the Geometry which should be used to determine the FIS. * @return all FIS which Areas is intersected by this given Geometry */ - protected Collection<FIS> getFIS(Geometry g) + protected Collection<FIS> getFIS(Geometry g) throws MetaDataServiceException{ log.debug("MetaDataService.getFIS ==> Geometry"); Collection<FIS> resultValue = null; @@ -269,7 +269,7 @@ .getQueryExecutor(); Collection<Result> result = queryExecutor.executeQuery(FIS_REGION_QUERY_ID, new String[]{g.toString()}); - + if (result != null){ resultValue = new ArrayList<FIS>(result.size()); Iterator<Result> it = result.iterator(); @@ -286,7 +286,7 @@ } return resultValue; } - + /** * Returns all FIS which were represented by the given Mapservices * @param mapServices the Mapservices which should determine the FIS. @@ -298,16 +298,16 @@ Collection<FIS> resultValue = null; if (mapServices != null && !mapServices.isEmpty()){ try { - + String mapServiceNames = ""; - Iterator<MapService> mit = mapServices.iterator(); + Iterator<MapService> mit = mapServices.iterator(); while(mit.hasNext()){ if (mapServiceNames.length() > 0){ mapServiceNames += " , "; } mapServiceNames += "'"+mit.next().getID()+"'"; } - + QueryExecutor queryExecutor = QueryExecutorFactory .getInstance() .getQueryExecutor(); @@ -321,7 +321,7 @@ Result value = it.next(); String fisId = value.getString(0).trim(); String mapServiceID = value.getString(1).trim(); - + // FIRST LOOK IF ONE MAPSERVICE REPRESENTS ONLY ONE PARAM Collection<Result> result2 = queryExecutor.executeQuery( MAPSERVICES_HAS_PARAMETER_QUERY_ID, @@ -334,7 +334,7 @@ Result parameterValue = it2.next(); String parameterID = parameterValue.getString(0) .trim(); - parameter.add(new DefaultParameter(parameterID, + parameter.add(new DefaultParameter(parameterID, parameterID)); } }else{ @@ -344,14 +344,14 @@ mapServiceID); Collection<Layer> layer = service.getLayer(); if (layer != null && !layer.isEmpty()){ - String layerQueryString = + String layerQueryString = this.createLayerQueryString(layer); - Collection<Result> parameterResult = + Collection<Result> parameterResult = queryExecutor.executeQuery( MAPSERVICES_HAS_PARAMETER_USING_LAYER_QUERY_ID, new String[]{"'"+mapServiceID+"'", layerQueryString}); - if (parameterResult != null && + if (parameterResult != null && !parameterResult.isEmpty()){ Iterator<Result> it2 = parameterResult.iterator(); parameter = new ArrayList<Parameter>(parameterResult.size()); @@ -359,14 +359,14 @@ Result parameterValue = it2.next(); String parameterID = parameterValue.getString(0) .trim(); - parameter.add(new DefaultParameter(parameterID, + parameter.add(new DefaultParameter(parameterID, parameterID)); } } } - + } - + FIS fis = this.getFIS(resultValue, fisId); if (fis != null){ if (parameter != null){ @@ -381,14 +381,14 @@ log.error(e,e); throw new MetaDataServiceException("Cannot Query FIS from DB."); } - + } return resultValue; } - - + + private FIS getFIS (Collection<FIS> fis, String fisId){ - + Iterator<FIS> it = fis.iterator(); while(it.hasNext()){ FIS tmpFIS = it.next(); @@ -398,7 +398,7 @@ } return null; } - + private MapService getMapService(Collection<MapService> mapServices, String mapServiceID){ log.debug("MetaDataService.getMapService"); @@ -411,7 +411,7 @@ } return null; } - + private String createLayerQueryString(Collection<Layer> layer){ log.debug("MetaDataService.createLayerQueryString"); StringBuffer sb = new StringBuffer();; @@ -425,7 +425,7 @@ sb.append(" , "); } } - + } } String returnValue = sb.toString();