changeset 606:9efc1c256dbb

Added the support of the usecase that one FIS can be identified by different MapServices. In that case the parameters will be merged into the existing FIS. gnv-artifacts/trunk@672 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 09 Feb 2010 15:23:07 +0000
parents e8ebdbc7f1e3
children 292fbcd5e9ac
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/MetaDataService.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/requestobjects/DefaultFIS.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/requestobjects/FIS.java
diffstat 4 files changed, 53 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Tue Feb 09 14:27:55 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Tue Feb 09 15:23:07 2010 +0000
@@ -1,3 +1,14 @@
+2010-02-09  Tim Englich  <tim.englich@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifacts/services/requestobjects/DefaultFIS.java (addParameter),
+	  src/main/java/de/intevation/gnv/artifacts/services/requestobjects/FIS.java (addParameter): 
+	  Added the possibility to add Parameters to an existing FIS.
+	  
+	* src/main/java/de/intevation/gnv/artifacts/services/MetaDataService.java (getFIS): 
+	  Added the support of the usecase that one FIS can be identified by different
+	  MapServices. In that case the parameters will be merged into the existing 
+	  FIS.
+
 2010-02-09  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/state/StateBase.java: Do not query the
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/MetaDataService.java	Tue Feb 09 14:27:55 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/MetaDataService.java	Tue Feb 09 15:23:07 2010 +0000
@@ -319,7 +319,7 @@
                     Iterator<Result> it = result.iterator();
                     while (it.hasNext()){
                         Result value = it.next();
-                        String fis_id = value.getString(0).trim();
+                        String fisId = value.getString(0).trim();
                         String mapServiceID = value.getString(1).trim();
                        
                         // FIRST LOOK IF ONE MAPSERVICE REPRESENTS ONLY ONE PARAM
@@ -366,7 +366,15 @@
                             }
                             
                         }
-                        resultValue.add(new DefaultFIS(fis_id, parameter));
+                        
+                        FIS fis = this.getFIS(resultValue, fisId);
+                        if (fis != null){
+                            if (parameter != null){
+                                fis.addParameter(parameter);
+                            }
+                        }else{
+                            resultValue.add(new DefaultFIS(fisId, parameter));
+                        }
                     }
                 }
             } catch (QueryException e) {
@@ -379,6 +387,18 @@
     }
     
     
+    private FIS getFIS (Collection<FIS> fis, String fisId){
+        
+        Iterator<FIS> it = fis.iterator();
+        while(it.hasNext()){
+            FIS tmpFIS = it.next();
+            if (tmpFIS.getID().equals(fisId)){
+                return tmpFIS;
+            }
+        }
+        return null;
+    }
+    
     private MapService getMapService(Collection<MapService> mapServices,
                                      String mapServiceID){
         log.debug("MetaDataService.getMapService");
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/requestobjects/DefaultFIS.java	Tue Feb 09 14:27:55 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/requestobjects/DefaultFIS.java	Tue Feb 09 15:23:07 2010 +0000
@@ -4,6 +4,7 @@
 package de.intevation.gnv.artifacts.services.requestobjects;
 
 import java.util.Collection;
+import java.util.Iterator;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -52,5 +53,23 @@
         }
         return returnValue;
     }
+    /**
+     * @see de.intevation.gnv.artifacts.services.requestobjects.FIS#addParameter(java.util.Collection)
+     */
+    public void addParameter(Collection<Parameter> parameter) {
+        if (this.parameter != null){
+            Iterator<Parameter> it = parameter.iterator();
+            while (it.hasNext()){
+                Parameter tmpParameter = it.next();
+                if (!this.parameter.contains(tmpParameter)){
+                    this.parameter.add(tmpParameter);
+                }
+            }
+        }else{
+            this.parameter = parameter;
+        }
+    }
+    
+    
 
 }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/requestobjects/FIS.java	Tue Feb 09 14:27:55 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/services/requestobjects/FIS.java	Tue Feb 09 15:23:07 2010 +0000
@@ -13,5 +13,6 @@
     
     String getID();
     Collection<Parameter> getParameter();
+    void addParameter(Collection<Parameter> parameter);
 
 }

http://dive4elements.wald.intevation.org