Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/data/importer/LAFImporter.java @ 366:567ce7697fc7 0.5
Code documentation.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 10 Sep 2013 15:55:54 +0200 |
parents | e0bbb54f2f7c |
children | 183f8116d9a6 |
comparison
equal
deleted
inserted
replaced
365:fab80595ed55 | 366:567ce7697fc7 |
---|---|
1 package de.intevation.lada.data.importer; | 1 package de.intevation.lada.data.importer; |
2 | 2 |
3 import java.math.BigInteger; | |
4 import java.util.ArrayList; | 3 import java.util.ArrayList; |
5 import java.util.HashMap; | 4 import java.util.HashMap; |
6 import java.util.LinkedList; | |
7 import java.util.List; | 5 import java.util.List; |
8 import java.util.Map; | 6 import java.util.Map; |
9 | 7 |
10 import javax.ejb.Stateless; | 8 import javax.ejb.Stateless; |
11 import javax.ejb.TransactionAttribute; | |
12 import javax.ejb.TransactionAttributeType; | |
13 import javax.inject.Inject; | 9 import javax.inject.Inject; |
14 import javax.inject.Named; | 10 import javax.inject.Named; |
15 import javax.persistence.EntityManager; | 11 import javax.persistence.EntityManager; |
16 import javax.persistence.Query; | |
17 | 12 |
18 import de.intevation.lada.auth.AuthenticationResponse; | 13 import de.intevation.lada.auth.AuthenticationResponse; |
19 import de.intevation.lada.data.QueryBuilder; | |
20 import de.intevation.lada.data.Repository; | 14 import de.intevation.lada.data.Repository; |
21 import de.intevation.lada.model.LKommentarM; | |
22 import de.intevation.lada.model.LKommentarP; | |
23 import de.intevation.lada.model.LMessung; | |
24 import de.intevation.lada.model.LMesswert; | |
25 import de.intevation.lada.model.LOrt; | |
26 import de.intevation.lada.model.LProbe; | |
27 import de.intevation.lada.model.LProbeInfo; | |
28 import de.intevation.lada.rest.Response; | |
29 import de.intevation.lada.validation.ValidationException; | |
30 import de.intevation.lada.validation.Validator; | 15 import de.intevation.lada.validation.Validator; |
31 | 16 |
17 /** | |
18 * This importer uses the LAFParser to read data and create error/warning reports. | |
19 * | |
20 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> | |
21 */ | |
32 @Named("lafimporter") | 22 @Named("lafimporter") |
33 @Stateless | 23 @Stateless |
34 public class LAFImporter | 24 public class LAFImporter |
35 implements Importer | 25 implements Importer |
36 { | 26 { |
74 private Repository messwertRepository; | 64 private Repository messwertRepository; |
75 | 65 |
76 private Map<String, List<ReportData>> warnings; | 66 private Map<String, List<ReportData>> warnings; |
77 private Map<String, List<ReportData>> errors; | 67 private Map<String, List<ReportData>> errors; |
78 | 68 |
69 /** | |
70 * Default constructor. | |
71 */ | |
79 public LAFImporter() { | 72 public LAFImporter() { |
80 warnings = new HashMap<String, List<ReportData>>(); | 73 warnings = new HashMap<String, List<ReportData>>(); |
81 errors = new HashMap<String, List<ReportData>>(); | 74 errors = new HashMap<String, List<ReportData>>(); |
82 } | 75 } |
83 | 76 |
93 */ | 86 */ |
94 public Map<String, List<ReportData>> getErrors() { | 87 public Map<String, List<ReportData>> getErrors() { |
95 return errors; | 88 return errors; |
96 } | 89 } |
97 | 90 |
91 /** | |
92 * Import LAF formated data using authentication information. | |
93 * | |
94 * @param content The LAF file content. | |
95 * @param auth The authentication information. | |
96 * @return success. | |
97 */ | |
98 @Override | 98 @Override |
99 public boolean importData(String content, AuthenticationResponse auth) { | 99 public boolean importData(String content, AuthenticationResponse auth) { |
100 this.warnings.clear(); | 100 this.warnings.clear(); |
101 this.errors.clear(); | 101 this.errors.clear(); |
102 this.parser.reset(); | 102 this.parser.reset(); |
120 this.warnings.putAll(this.parser.getWarnings()); | 120 this.warnings.putAll(this.parser.getWarnings()); |
121 this.errors.putAll(this.parser.getErrors()); | 121 this.errors.putAll(this.parser.getErrors()); |
122 return true; | 122 return true; |
123 } | 123 } |
124 | 124 |
125 /** | |
126 * Reset the errors and warnings. Use this before calling importData() | |
127 * to have a clean error and warning report. | |
128 */ | |
125 public void reset() { | 129 public void reset() { |
126 parser.reset(); | 130 parser.reset(); |
127 this.warnings = new HashMap<String, List<ReportData>>(); | 131 this.warnings = new HashMap<String, List<ReportData>>(); |
128 this.errors = new HashMap<String, List<ReportData>>(); | 132 this.errors = new HashMap<String, List<ReportData>>(); |
129 } | 133 } |