changeset 374:958b7ffbbfcc

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 24 Sep 2013 14:01:06 +0200
parents bc6d0785986f (diff) 9c3b3d34b260 (current diff)
children 0ddfa534173e 4f42d1b2570a
files
diffstat 4 files changed, 124 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pom.xml	Mon Sep 23 14:47:59 2013 +0200
+++ b/pom.xml	Tue Sep 24 14:01:06 2013 +0200
@@ -278,6 +278,33 @@
         </profile>
 
         <profile>
+            <id>remote</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.jboss.as.plugins</groupId>
+                        <artifactId>jboss-as-maven-plugin</artifactId>
+                        <version>7.1.1.Final</version>
+                        <configuration>
+                            <hostname>ike.polyhedra.intevation.de</hostname>
+                            <port>9999</port>
+                            <username>admin</username>
+                            <password>secret</password>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>deploy-jar</id>
+                                <phase>install</phase>
+                                <goals>
+                                    <goal>deploy</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
             <!-- An optional Arquillian testing profile that executes tests 
                 in your JBoss AS instance -->
             <!-- This profile will start a new JBoss AS instance, and execute 
--- a/src/main/java/de/intevation/lada/data/importer/LAFProducer.java	Mon Sep 23 14:47:59 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/importer/LAFProducer.java	Tue Sep 24 14:01:06 2013 +0200
@@ -39,6 +39,7 @@
 
     private LProbe probe;
     private LMessung messung;
+    @Inject
     private OrtCreator ort;
 
     private List<LKommentarP> pKommentare;
@@ -183,7 +184,7 @@
             }
         }
         else if (isValidOrt(lKey, values.toString())) {
-            this.ort = mapper.addAttribute(lKey, values, this.ort);
+            this.ort.addAttribute(lKey, values);
         }
     }
 
@@ -320,7 +321,7 @@
         this.messung = null;
         this.lorte = new ArrayList<LOrt>();
         this.orte = new ArrayList<Ort>();
-        this.ort = null;
+        this.ort.reset();
         this.messwerte = new ArrayList<LMesswert>();
         this.mKommentare = new ArrayList<LKommentarM>();
         this.pKommentare = new ArrayList<LKommentarP>();
@@ -356,7 +357,7 @@
                 this.lorte.add(lo);
             }
         }
-        this.ort = new OrtCreator();
+        this.ort.reset();
         this.ort.setProbeId(this.probe.getProbeId());
     }
 
--- a/src/main/java/de/intevation/lada/data/importer/LAFWriter.java	Mon Sep 23 14:47:59 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/importer/LAFWriter.java	Tue Sep 24 14:01:06 2013 +0200
@@ -10,8 +10,12 @@
 import javax.inject.Inject;
 import javax.inject.Named;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
 import javax.persistence.Query;
 
+import org.hibernate.HibernateException;
+import org.postgresql.util.PSQLException;
+
 import de.intevation.lada.auth.AuthenticationResponse;
 import de.intevation.lada.data.Repository;
 import de.intevation.lada.model.LKommentarM;
@@ -125,7 +129,13 @@
             errors.add(new ReportData("probeId", "missing", 673));
             return false;
         }
-        persist(probe);
+        try {
+            persist(probe);
+        }
+        catch (PersistenceException e) {
+            errors.add(new ReportData("probe", "writing", 670));
+            return false;
+        }
         return true;
     }
 
@@ -319,7 +329,8 @@
      * @param probe The {@link LProbe} object.
      */
     @TransactionAttribute(TransactionAttributeType.REQUIRED)
-    private void persist(LProbe probe) {
+    private void persist(LProbe probe)
+    throws PersistenceException {
         String queryColumns = "insert into l_probe (probe_id, ba_id, test," +
             " datenbasis_id, netzbetreiber_id, mst_id, probenart_id, umw_id";
         String queryParameter = " values (:probe_id, :ba_id, :test," +
--- a/src/main/java/de/intevation/lada/data/importer/OrtCreator.java	Mon Sep 23 14:47:59 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/importer/OrtCreator.java	Tue Sep 24 14:01:06 2013 +0200
@@ -2,6 +2,7 @@
 
 import java.util.List;
 
+import javax.ejb.Stateless;
 import javax.inject.Inject;
 import javax.inject.Named;
 
@@ -18,6 +19,7 @@
  *
  * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
  */
+@Stateless
 public class OrtCreator
 {
     @Inject
@@ -305,6 +307,61 @@
     }
 
     /**
+     * Add an attribute to the OrtCreator. The creator is used to build the
+     * two objects Ort and LOrt.
+     *
+     * @param key       The key mapping to a object member.
+     * @param value     The value to set.
+     * @param ort       The creator object.
+     * @return The updated creator object.
+     */
+    public void addAttribute(
+        String key,
+        Object value
+    ) {
+        if ("ort_code".equals(key)) {
+            this.setOrtCode(value.toString());
+        }
+        if ("ort_typ".equals(key)) {
+            this.setOrtTyp(value.toString());
+        }
+        if ("ort_zusatz".equals(key)) {
+            this.setZusatztext(value.toString());
+        }
+        if ("ort_land_lang".equals(key)) {
+            this.setLandLang(value.toString());
+        }
+        if ("ort_land_kurz".equals(key)) {
+            this.setLandKurz(value.toString());
+        }
+        if ("ort_land_s".equals(key)) {
+            this.setLandS(value.toString());
+        }
+        if ("ort_gemeindeschlüssel".equals(key)) {
+            this.setGemSchluessel(value.toString());
+        }
+        if ("ort_bezeichnung".equals(key)) {
+            this.setBezeichnung(value.toString());
+        }
+        if ("ort_beschreibung".equals(key)) {
+            this.setBeschreibung(value.toString());
+        }
+        if ("ort_nuts_code".equals(key)) {
+            this.setNuts(value.toString());
+        }
+        if ("ort_hoehe_land".equals(key)) {
+            this.setHoehe(value.toString());
+        }
+        if ("ort_koordinaten".equals(key)) {
+            this.setKoordinaten(value.toString());
+        }
+        if ("ort_koordinaten_s".equals(key)) {
+            this.setKoordinatenS(value.toString());
+        }
+    }
+
+
+    /**
      * Create the Ort object.
      *
      * @return The new Ort.
@@ -610,7 +667,8 @@
      */
     public LOrt toLOrt() {
         if (this.ortId == null &&
-            (this.ortCode == null || this.ortCode.length() == 0)) {
+            (this.ortCode == null || this.ortCode.length() == 0) ||
+            this.probeId == null) {
             return null;
         }
         if(this.ortCode != null && this.ortCode.length() > 0) {
@@ -631,4 +689,25 @@
         return ort;
     }
 
+    public void reset() {
+        this.beschreibung = null;
+        this.bezeichnung = null;
+        this.gemName = null;
+        this.gemSchluessel = null;
+        this.hoehe = null;
+        this.koord = null;
+        this.koordArt = null;
+        this.koordinaten = null;
+        this.koordinatenS = null;
+        this.koordS = null;
+        this.landKurz = null;
+        this.landLang = null;
+        this.landS = null;
+        this.nuts = null;
+        this.ortCode = null;
+        this.ortId = null;
+        this.ortTyp = null;
+        this.probeId = null;
+        this.zusatztext = null;
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)