annotate backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java @ 7162:4683bdf77ff9

Handle flow velocity measurements in the FlowVelocity processor
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 26 Sep 2013 10:38:21 +0200
parents 1c68d4b2a1c0
children 3d83a4cf33ba 0fe00824bd96
rev   line source
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5992
4c3ccf2b0304 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5889
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5992
4c3ccf2b0304 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5889
diff changeset
6 * documentation coming with Dive4Elements River for details.
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5829
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
9 package org.dive4elements.river.importer;
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
5829
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
11 import org.dive4elements.river.model.Wst;
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
12 import org.dive4elements.river.model.WstColumn;
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
13 import org.dive4elements.river.model.River;
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
14 import org.dive4elements.river.model.TimeInterval;
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
15
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
16 import org.hibernate.Session;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
17 import org.hibernate.Query;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
18
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
19 import java.util.List;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
20 import java.util.ArrayList;
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
22 import java.math.BigDecimal;
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
23
499
cce054f27dac Importer: Only accept main value types 'Q', 'W', 'D' and 'T' by default.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 497
diff changeset
24 import org.apache.log4j.Logger;
cce054f27dac Importer: Only accept main value types 'Q', 'W', 'D' and 'T' by default.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 497
diff changeset
25
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2357
diff changeset
26
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2357
diff changeset
27 /** Unmapped column of a WST. */
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public class ImportWstColumn
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 {
499
cce054f27dac Importer: Only accept main value types 'Q', 'W', 'D' and 'T' by default.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 497
diff changeset
30 private static Logger log = Logger.getLogger(ImportWstColumn.class);
cce054f27dac Importer: Only accept main value types 'Q', 'W', 'D' and 'T' by default.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 497
diff changeset
31
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
32 protected ImportWst wst;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
33 protected String name;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
34 protected String description;
471
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
35 protected Integer position;
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
36 protected String source;
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
37
2357
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
38 protected ImportTimeInterval timeInterval;
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
39
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
40 protected List<ImportWstColumnQRange> columnQRanges;
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
41 protected List<ImportWstColumnValue> columnValues;
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
42
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 protected WstColumn peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 public ImportWstColumn() {
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
46 columnQRanges = new ArrayList<ImportWstColumnQRange>();
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
47 columnValues = new ArrayList<ImportWstColumnValue>();
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
50 public ImportWstColumn(
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
51 ImportWst wst,
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
52 String name,
471
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
53 String description,
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
54 Integer position,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
55 String source
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
56 ) {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
57 this();
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
58 this.wst = wst;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
59 this.name = name;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
60 this.description = description;
471
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
61 this.position = position;
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
62 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
63
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
64 public ImportWstColumn(
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
65 ImportWst wst,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
66 String name,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
67 String description,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
68 Integer position
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
69 ) {
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
70 this(wst, name, description, position, null);
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
71 }
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
72
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
73 public ImportWst getWst() {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
74 return wst;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
75 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
76
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
77 public void setWst(ImportWst wst) {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
78 this.wst = wst;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
79 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
80
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
81 public String getName() {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
82 return name;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
83 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
84
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
85 public void setName(String name) {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
86 this.name = name;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
87 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
88
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
89 public String getDescription() {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
90 return description;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
91 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
92
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
93 public void setDescription(String description) {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
94 this.description = description;
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
95 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
96
471
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
97 public Integer getPosition() {
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
98 return position;
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
99 }
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
100
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
101 public void setPosition(Integer position) {
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
102 this.position = position;
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
103 }
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
104
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
105 public String getSource() {
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
106 return source;
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
107 }
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
108
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
109 public void setSource(String source) {
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
110 this.source = source;
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
111 }
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
112
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
113 public void addColumnValue(BigDecimal position, BigDecimal w) {
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
114 columnValues.add(
497
67fd63e4ef66 Importer: centralized caching
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
115 new ImportWstColumnValue(this, position, w));
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
116 }
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
117
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
118 public void addColumnQRange(ImportWstQRange columnQRange) {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
119 columnQRanges.add(
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
120 new ImportWstColumnQRange(this, columnQRange));
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
121 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
122
5237
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
123
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
124 /** Get the Column Values stored in this column. */
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
125 public List<ImportWstColumnValue> getColumnValues() {
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
126 return columnValues;
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
127 }
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
128
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
129
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
130 public void storeDependencies(River river) {
500
d50cd3a632e0 Importer: Use BigDecimals in hashing to prevent numerical problems. Cache ranges globally, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 499
diff changeset
131 log.info("store column '" + name + "'");
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
132 WstColumn column = getPeer(river);
501
04d449f7f0c9 Importer: Change caching strategy not to cause OOM any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 500
diff changeset
133
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
134 for (ImportWstColumnQRange columnQRange: columnQRanges) {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
135 columnQRange.getPeer(river);
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
136 }
499
cce054f27dac Importer: Only accept main value types 'Q', 'W', 'D' and 'T' by default.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 497
diff changeset
137
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
138 for (ImportWstColumnValue columnValue: columnValues) {
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
139 columnValue.getPeer(river);
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
140 }
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
141 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
142
2357
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
143 public ImportTimeInterval getTimeInterval() {
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
144 return timeInterval;
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
145 }
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
146
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
147 public void setTimeInterval(ImportTimeInterval timeInterval) {
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
148 this.timeInterval = timeInterval;
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
149 }
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
150
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2357
diff changeset
151 /** Get corresponding mapped wst-column (from database). */
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
152 public WstColumn getPeer(River river) {
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 if (peer == null) {
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
154 Wst w = wst.getPeer(river);
497
67fd63e4ef66 Importer: centralized caching
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
155 Session session = ImporterSession.getInstance().getDatabaseSession();
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
156 Query query = session.createQuery(
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
157 "from WstColumn where" +
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
158 " wst=:wst and name=:name" +
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
159 " and source=:source" +
471
3570e4af8cb2 Added 'position' column to wst_columns to allow order them by there column position in the original wst file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 202
diff changeset
160 " and position=:position");
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
161 query.setParameter("wst", w);
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
162 query.setParameter("name", name);
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
163 query.setParameter("position", position);
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
164 query.setParameter("source", source);
2357
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
165
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
166 TimeInterval ti = timeInterval != null
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
167 ? timeInterval.getPeer()
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
168 : null;
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
169
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
170 List<WstColumn> columns = query.list();
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
171 if (columns.isEmpty()) {
6506
1c68d4b2a1c0 Fix import of source from wst-files
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6504
diff changeset
172 log.debug("source: " + source);
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
173 peer = new WstColumn(
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
174 w, name, description, source, position, ti);
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
175 session.save(peer);
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
176 }
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
177 else {
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
178 peer = columns.get(0);
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
179 }
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 return peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 }
5542
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5237
diff changeset
183
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5237
diff changeset
184 public void fixRangesOrder() {
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5237
diff changeset
185 for (ImportWstColumnQRange wcqr: columnQRanges) {
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5237
diff changeset
186 wcqr.fixRangesOrder();
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5237
diff changeset
187 }
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5237
diff changeset
188 }
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
190 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org