diff src/main/java/de/intevation/lada/importer/laf/LafProducer.java @ 1028:1c41c7b8f7c2 schema-update

Updated server application to new database model. THIS IS STILL WIP!!!
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 08 Jul 2016 15:32:36 +0200
parents 092e673cbb8d
children
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/importer/laf/LafProducer.java	Mon Jul 04 14:31:18 2016 +0200
+++ b/src/main/java/de/intevation/lada/importer/laf/LafProducer.java	Fri Jul 08 15:32:36 2016 +0200
@@ -15,16 +15,14 @@
 import javax.inject.Inject;
 
 import de.intevation.lada.importer.ReportItem;
-import de.intevation.lada.model.land.LKommentarM;
-import de.intevation.lada.model.land.LKommentarP;
-import de.intevation.lada.model.land.LMessung;
-import de.intevation.lada.model.land.LMesswert;
-import de.intevation.lada.model.land.LOrtszuordnung;
-import de.intevation.lada.model.land.LProbe;
-import de.intevation.lada.model.land.LZusatzWert;
-import de.intevation.lada.model.land.MessungTranslation;
-import de.intevation.lada.model.land.ProbeTranslation;
-import de.intevation.lada.model.stamm.Ort;
+import de.intevation.lada.model.land.KommentarM;
+import de.intevation.lada.model.land.KommentarP;
+import de.intevation.lada.model.land.Messung;
+import de.intevation.lada.model.land.Messwert;
+import de.intevation.lada.model.land.Ortszuordnung;
+import de.intevation.lada.model.land.Probe;
+import de.intevation.lada.model.land.ZusatzWert;
+import de.intevation.lada.model.stammdaten.Ort;
 
 /**
  * The LAFProducer creates entity objects form key-value pairs using the
@@ -37,22 +35,12 @@
     /**
      * The probe object created by this producer.
      */
-    private LProbe probe;
-
-    /**
-     * The probe translation object created by this producer.
-     */
-    private ProbeTranslation probeTranslation;
+    private Probe probe;
 
     /**
      * The messung object created by this producer.
      */
-    private LMessung messung;
-
-    /**
-     * The messung translation object created by this producer.
-     */
-    private MessungTranslation messungTranslation;
+    private Messung messung;
 
     /**
      * Creator used to build ort objects.
@@ -63,22 +51,22 @@
     /**
      * Probekommentare created by this producer.
      */
-    private List<LKommentarP> pKommentare;
+    private List<KommentarP> pKommentare;
 
     /**
      * Messungskommentare created by this producer.
      */
-    private Map<LMessung, List<LKommentarM>> mKommentare;
+    private Map<Messung, List<KommentarM>> mKommentare;
 
     /**
      * Messungen created by this producer.
      */
-    private Map<LMessung, MessungTranslation> messungen;
+    private List<Messung> messungen;
 
     /**
      * Orte created by this producer.
      */
-    private List<LOrtszuordnung> lorte;
+    private List<Ortszuordnung> ortszuordnungen;
 
     /**
      * SOrte created by this producer.
@@ -88,12 +76,12 @@
     /**
      * Messwerte created by this producer.
      */
-    private Map<LMessung, List<LMesswert>> messwerte;
+    private Map<Messung, List<Messwert>> messwerte;
 
     /**
      * Zusatzwerte created by this producer.
      */
-    private List<LZusatzWert> zusatzwerte;
+    private List<ZusatzWert> zusatzwerte;
 
     /**
      * Format mapping for probe objects.
@@ -133,13 +121,12 @@
     public LafProducer() {
         this.warnings = new HashMap<String, List<ReportItem>>();
         this.errors = new HashMap<String, List<ReportItem>>();
-        this.probe = new LProbe();
-        this.probeTranslation = new ProbeTranslation();
-        this.pKommentare = new ArrayList<LKommentarP>();
-        this.mKommentare = new HashMap<LMessung, List<LKommentarM>>();
-        this.messungen = new HashMap<LMessung, MessungTranslation>();
-        this.lorte = new ArrayList<LOrtszuordnung>();
-        this.messwerte = new HashMap<LMessung, List<LMesswert>>();
+        this.probe = new Probe();
+        this.pKommentare = new ArrayList<KommentarP>();
+        this.mKommentare = new HashMap<Messung, List<KommentarM>>();
+        this.messungen = new ArrayList<Messung>();
+        this.ortszuordnungen = new ArrayList<Ortszuordnung>();
+        this.messwerte = new HashMap<Messung, List<Messwert>>();
         String fileName = "/import.json";
         LafFormat format = new LafFormat();
         format.readConfigFile(fileName);
@@ -161,23 +148,23 @@
     throws LafParserException {
         String lKey = key.toLowerCase();
         if(lKey.equals("probenkommentar")) {
-            LKommentarP kommentar = new LKommentarP();
+            KommentarP kommentar = new KommentarP();
             kommentar.setProbeId(this.probe.getId());
             this.pKommentare.add(
                 mapper.addAttribute(lKey, values, kommentar));
         }
         else if (lKey.equals("kommentar")) {
-            LKommentarM kommentar = new LKommentarM();
+            KommentarM kommentar = new KommentarM();
             kommentar.setMessungsId(this.messung.getId());
             if (this.mKommentare.get(this.messung) == null) {
-                this.mKommentare.put(this.messung, new ArrayList<LKommentarM>());
+                this.mKommentare.put(this.messung, new ArrayList<KommentarM>());
             }
             this.mKommentare.get(this.messung).add(
                 mapper.addAttribute(lKey, values, kommentar));
         }
         else if (lKey.equals("probenzusatzbeschreibung")) {
-            LZusatzWert wert = new LZusatzWert();
-            LZusatzWert zusatzWert = mapper.addAttribute(lKey, values, wert);
+            ZusatzWert wert = new ZusatzWert();
+            ZusatzWert zusatzWert = mapper.addAttribute(lKey, values, wert);
             if (zusatzWert != null) {
                 zusatzWert.setProbeId(probe.getId());
                 this.zusatzwerte.add(zusatzWert);
@@ -195,8 +182,8 @@
             }
         }
         else if (lKey.equals("pzb_s")) {
-            LZusatzWert wert = new LZusatzWert();
-            LZusatzWert zusatzWert = mapper.addAttributeS(lKey, values, wert);
+            ZusatzWert wert = new ZusatzWert();
+            ZusatzWert zusatzWert = mapper.addAttributeS(lKey, values, wert);
             if (zusatzWert != null) {
                 zusatzWert.setProbeId(probe.getId());
                 this.zusatzwerte.add(zusatzWert);
@@ -214,12 +201,12 @@
             }
         }
         else if (lKey.equals("messwert")) {
-            LMesswert m = new LMesswert();
+            Messwert m = new Messwert();
             m.setMessungsId(this.messung.getId());
-            LMesswert wert = mapper.addAttribute(lKey, values, m);
+            Messwert wert = mapper.addAttribute(lKey, values, m);
             if (wert != null) {
                 if (this.messwerte.get(this.messung) == null) {
-                    this.messwerte.put(this.messung, new ArrayList<LMesswert>());
+                    this.messwerte.put(this.messung, new ArrayList<Messwert>());
                 }
                 this.messwerte.get(this.messung).add(
                     mapper.addAttribute(lKey, values, wert));
@@ -238,13 +225,10 @@
         }
         else if (isValidMessung(lKey, values.toString())) {
             this.messung = mapper.addAttribute(lKey, values, this.messung);
-            this.messungTranslation =
-                mapper.addAttribute(lKey, values, this.messungTranslation);
         }
         else if (isValidProbe(lKey, values.toString())) {
             this.probe = mapper.addAttribute(lKey, values, this.probe);
-            this.probeTranslation = mapper.addAttribute(lKey, values, this.probeTranslation);
-            if (this.probe == null || this.probeTranslation == null) {
+            if (this.probe == null) {
                 this.errors.put(values.toString(), mapper.getErrors());
                 throw new LafParserException(values.toString() + " exists");
             }
@@ -314,18 +298,14 @@
     /**
      * @return the {@link LProbe} entity.
      */
-    public LProbe getProbe() {
+    public Probe getProbe() {
         return this.probe;
     }
 
-    public ProbeTranslation getProbeTranslation() {
-        return this.probeTranslation;
-    }
-
     /**
      * @return List of {@link LMessung} entities.
      */
-    public Map<LMessung, MessungTranslation> getMessungen() {
+    public List<Messung> getMessungen() {
         return this.messungen;
     }
 
@@ -339,35 +319,35 @@
     /**
      * @return List of {@link LOrt} entities.
      */
-    public List<LOrtszuordnung> getLOrte() {
-        return this.lorte;
+    public List<Ortszuordnung> getOrtszuordnungen() {
+        return this.ortszuordnungen;
     }
 
     /**
      * @return List of {@link LKommentarP} entities.
      */
-    public List<LKommentarP> getProbenKommentare() {
+    public List<KommentarP> getProbenKommentare() {
         return this.pKommentare;
     }
 
     /**
      * @return List of {@link LKommentarM} entities.
      */
-    public Map<LMessung, List<LKommentarM>> getMessungsKommentare() {
+    public Map<Messung, List<KommentarM>> getMessungsKommentare() {
         return this.mKommentare;
     }
 
     /**
      * @return List of {@link LMesswert} entities.
      */
-    public Map<LMessung, List<LMesswert>> getMesswerte() {
+    public Map<Messung, List<Messwert>> getMesswerte() {
         return this.messwerte;
     }
 
     /**
      * @return List of {@link LZusatzWert} entities.
      */
-    public List<LZusatzWert> getZusatzwerte() {
+    public List<ZusatzWert> getZusatzwerte() {
         return this.zusatzwerte;
     }
 
@@ -377,15 +357,15 @@
     public void reset() {
         this.errors = new HashMap<String, List<ReportItem>>();
         this.warnings = new HashMap<String, List<ReportItem>>();
-        this.probe = new LProbe();
-        this.messungen = new HashMap<LMessung, MessungTranslation>();
+        this.probe = new Probe();
+        this.messungen = new ArrayList<Messung>();
         this.messung = null;
-        this.lorte = new ArrayList<LOrtszuordnung>();
+        this.ortszuordnungen = new ArrayList<Ortszuordnung>();
         this.orte = new ArrayList<Ort>();
         this.ort.reset();
-        this.messwerte = new HashMap<LMessung, List<LMesswert>>();
-        this.mKommentare = new HashMap<LMessung, List<LKommentarM>>();
-        this.pKommentare = new ArrayList<LKommentarP>();
+        this.messwerte = new HashMap<Messung, List<Messwert>>();
+        this.mKommentare = new HashMap<Messung, List<KommentarM>>();
+        this.pKommentare = new ArrayList<KommentarP>();
         mapper.reset();
     }
 
@@ -393,17 +373,16 @@
      * Add the current {@link LMessung} entity to the List and create a new one.
      */
     public void newMessung() {
-        if (this.messung != null && this.messungTranslation != null) {
+        if (this.messung != null) {
             if (this.messung.getFertig() == null) {
                 this.messung.setFertig(false);
             }
             if (this.messung.getGeplant() == null) {
                 this.messung.setGeplant(false);
             }
-            this.messungen.put(this.messung, this.messungTranslation);
+            this.messungen.add(this.messung);
         }
-        this.messung = new LMessung();
-        this.messungTranslation = new MessungTranslation();
+        this.messung = new Messung();
     }
 
     /**
@@ -416,9 +395,9 @@
             if (o != null) {
                 this.orte.add(o);
             }
-            LOrtszuordnung lo = this.ort.toLOrt();
+            Ortszuordnung lo = this.ort.toOrtszuordnung();
             if (lo != null) {
-                this.lorte.add(lo);
+                this.ortszuordnungen.add(lo);
             }
         }
         OrtCreator creator = this.ort;
@@ -451,14 +430,14 @@
      * @return the errors
      */
     public Map<String, List<ReportItem>> getErrors() {
-        if (this.probe == null || this.probeTranslation == null) {
+        if (this.probe == null) {
             return this.errors;
         }
         if (mapper.getErrors() == null || mapper.getErrors().size() == 0) {
             return this.errors;
         }
-        String key = probeTranslation.getProbeIdAlt() == null ?
-            "probeId" : probeTranslation.getProbeIdAlt();
+        String key = probe.getIdAlt() == null ?
+            "probeId" : probe.getIdAlt();
         List<ReportItem> err = this.errors.get(key);
         if (err == null) {
             this.errors.put(key, mapper.getErrors());
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)