Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 483:f1fd9cab6a07
Importer: parse and store fixation wst files as well
flys-backend/trunk@1805 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 May 2011 13:50:37 +0000 |
parents | 3a99d0295006 |
children | a9e9a8a44d19 |
comparison
equal
deleted
inserted
replaced
482:3a99d0295006 | 483:f1fd9cab6a07 |
---|---|
19 { | 19 { |
20 private static Logger log = Logger.getLogger(ImportRiver.class); | 20 private static Logger log = Logger.getLogger(ImportRiver.class); |
21 | 21 |
22 public static final String PEGEL_GLT = "PEGEL.GLT"; | 22 public static final String PEGEL_GLT = "PEGEL.GLT"; |
23 | 23 |
24 public static final String FIXATIONS = "Fixierungen"; | |
25 | |
24 public static final String EXTRA_LONGITUDINALS = | 26 public static final String EXTRA_LONGITUDINALS = |
25 "Zus.L\u00e4ngsschnitte"; | 27 "Zus.L\u00e4ngsschnitte"; |
26 | 28 |
27 protected String name; | 29 protected String name; |
28 | 30 |
34 | 36 |
35 protected List<ImportAnnotation> annotations; | 37 protected List<ImportAnnotation> annotations; |
36 | 38 |
37 protected List<ImportWst> extraWsts; | 39 protected List<ImportWst> extraWsts; |
38 | 40 |
41 protected List<ImportWst> fixations; | |
42 | |
39 protected ImportWst wst; | 43 protected ImportWst wst; |
40 | 44 |
41 protected River peer; | 45 protected River peer; |
42 | 46 |
43 public ImportRiver() { | 47 public ImportRiver() { |
44 extraWsts = new ArrayList<ImportWst>(); | 48 extraWsts = new ArrayList<ImportWst>(); |
49 fixations = new ArrayList<ImportWst>(); | |
45 } | 50 } |
46 | 51 |
47 public ImportRiver(String name, File wstFile, File bbInfoFile) { | 52 public ImportRiver(String name, File wstFile, File bbInfoFile) { |
48 this(); | 53 this(); |
49 this.name = name; | 54 this.name = name; |
86 public void parseDependencies() throws IOException { | 91 public void parseDependencies() throws IOException { |
87 parseGauges(); | 92 parseGauges(); |
88 parseAnnotations(); | 93 parseAnnotations(); |
89 parseWst(); | 94 parseWst(); |
90 parseExtraWsts(); | 95 parseExtraWsts(); |
96 parseFixations(); | |
97 } | |
98 | |
99 public void parseFixations() throws IOException { | |
100 log.info("Parse fixation wst files"); | |
101 | |
102 File riverDir = wstFile.getParentFile().getParentFile(); | |
103 | |
104 File fixDir = FileTools.repair( | |
105 new File(riverDir, FIXATIONS)); | |
106 | |
107 if (!fixDir.isDirectory() || !fixDir.canRead()) { | |
108 log.info("no fixation wst file directory found"); | |
109 return; | |
110 } | |
111 | |
112 File [] files = fixDir.listFiles(); | |
113 | |
114 if (files == null) { | |
115 log.warn("cannot read fixations wst file directory"); | |
116 return; | |
117 } | |
118 | |
119 for (File file: files) { | |
120 if (!file.isFile() || !file.canRead()) { | |
121 continue; | |
122 } | |
123 String name = file.getName().toLowerCase(); | |
124 if (!name.endsWith(".wst")) { | |
125 continue; | |
126 } | |
127 log.debug("Found WST file: " + file); | |
128 | |
129 WstParser wstParser = new WstParser(); | |
130 wstParser.parse(file); | |
131 ImportWst iw = wstParser.getWst(); | |
132 iw.setKind(2); | |
133 iw.setDescription("Fix: " + iw.getDescription()); | |
134 fixations.add(iw); | |
135 } | |
91 } | 136 } |
92 | 137 |
93 public void parseExtraWsts() throws IOException { | 138 public void parseExtraWsts() throws IOException { |
94 log.info("Parse extra longitudinal wst files"); | 139 log.info("Parse extra longitudinal wst files"); |
95 | 140 |
165 public void storeDependencies() { | 210 public void storeDependencies() { |
166 storeAnnotations(); | 211 storeAnnotations(); |
167 storeGauges(); | 212 storeGauges(); |
168 storeWst(); | 213 storeWst(); |
169 storeExtraWsts(); | 214 storeExtraWsts(); |
215 storeFixations(); | |
170 } | 216 } |
171 | 217 |
172 public void storeWst() { | 218 public void storeWst() { |
173 River river = getPeer(); | 219 River river = getPeer(); |
174 wst.storeDependencies(river); | 220 wst.storeDependencies(river); |
221 } | |
222 | |
223 public void storeFixations() { | |
224 log.info("store fixation wsts"); | |
225 River river = getPeer(); | |
226 for (ImportWst wst: fixations) { | |
227 log.debug("name: " + wst.getDescription()); | |
228 wst.storeDependencies(river); | |
229 } | |
175 } | 230 } |
176 | 231 |
177 public void storeExtraWsts() { | 232 public void storeExtraWsts() { |
178 log.info("store extra wsts"); | 233 log.info("store extra wsts"); |
179 River river = getPeer(); | 234 River river = getPeer(); |