annotate backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java @ 7193:7fabae60428b double-precision

Merged changes from default into double-precision branch.
author Tom Gottfried <tom@intevation.de>
date Fri, 27 Sep 2013 17:36:50 +0200
parents 3d83a4cf33ba 0fe00824bd96
children 2ce7bacc940f
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;
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
21 import java.util.Random;
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
23 import java.math.BigDecimal;
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
24
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
25 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
26
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2357
diff changeset
27
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2357
diff changeset
28 /** 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
29 public class ImportWstColumn
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 {
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
31 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
32
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
33 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
34 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
35 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
36 protected Integer position;
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
37 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
38
2357
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
39 protected ImportTimeInterval timeInterval;
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
40
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
41 protected List<ImportWstColumnQRange> columnQRanges;
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
42 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
43
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 protected WstColumn peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 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
47 columnQRanges = new ArrayList<ImportWstColumnQRange>();
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
48 columnValues = new ArrayList<ImportWstColumnValue>();
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
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
51 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
52 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
53 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
54 String description,
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
55 Integer position,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
56 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
57 ) {
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();
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.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
60 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
61 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
62 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
63 }
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
64
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
65 public ImportWstColumn(
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
66 ImportWst wst,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
67 String name,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
68 String description,
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
69 Integer position
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
70 ) {
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
71 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
72 }
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
73
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
74 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
75 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
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
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 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
79 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
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
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 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
83 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
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
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 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
87 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
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
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 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
91 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
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
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 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
95 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
96 }
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
97
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
98 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
99 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
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
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 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
103 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
104 }
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
105
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
106 public String getSource() {
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
107 return source;
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
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
110 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
111 this.source = source;
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
112 }
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
113
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
114 public void addColumnValue(BigDecimal position, BigDecimal w) {
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
115 columnValues.add(
497
67fd63e4ef66 Importer: centralized caching
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
116 new ImportWstColumnValue(this, position, w));
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
117 }
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
118
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
119 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
120 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
121 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
122 }
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
123
5237
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
124
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
125 /** 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
126 public List<ImportWstColumnValue> getColumnValues() {
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
127 return columnValues;
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
feb80b3afc40 ImportWstColumn: Expose columnValues with a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
130
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
131 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
132 log.info("store column '" + name + "'");
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
133 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
134
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
135 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
136 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
137 }
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
138
202
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
139 for (ImportWstColumnValue columnValue: columnValues) {
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
140 columnValue.getPeer(river);
29a408f80a89 Finished import of WSTs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
141 }
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
142 }
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
143
2357
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
144 public ImportTimeInterval getTimeInterval() {
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
145 return timeInterval;
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
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
148 public void setTimeInterval(ImportTimeInterval timeInterval) {
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
149 this.timeInterval = timeInterval;
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
150 }
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
151
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
152 public boolean guessWaterLevelIncreasing() {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
153
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
154 int N = columnValues.size();
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
155
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
156 if (N < 2) {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
157 return true;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
158 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
159
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
160 Random r = new Random();
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
161 int up = 0;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
162
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
163 int S = N < 50 ? N : (int)(0.1f * N)+1;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
164 for (int s = 0; s < S; ++s) {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
165 int i1, i2;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
166 do {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
167 i1 = r.nextInt(N-1);
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
168 i2 = r.nextInt(N-1);
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
169 } while (i1 == i2);
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
170 ImportWstColumnValue b = columnValues.get(i1);
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
171 ImportWstColumnValue a = columnValues.get(i2);
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
172 if (b.getPosition().compareTo(a.getPosition()) < 0) {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
173 ImportWstColumnValue t = a; a = b; b = t;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
174 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
175
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
176 if (a.getW().compareTo(b.getW()) < 0) ++up;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
177 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
178
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
179 return up > S - up;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
180 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
181
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2357
diff changeset
182 /** 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
183 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
184 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
185 Wst w = wst.getPeer(river);
497
67fd63e4ef66 Importer: centralized caching
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
186 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
187 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
188 "from WstColumn where" +
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
189 " 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
190 " 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
191 " and position=:position");
6504
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
192 query.setParameter("wst", w);
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
193 query.setParameter("name", name);
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
194 query.setParameter("position", position);
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
195 query.setParameter("source", source);
2357
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
196
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
197 TimeInterval ti = timeInterval != null
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
198 ? timeInterval.getPeer()
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
199 : null;
2e18e12fac11 Added date guesser for WST columns.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 501
diff changeset
200
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
201 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
202 if (columns.isEmpty()) {
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6506
diff changeset
203 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
204 peer = new WstColumn(
7664ab97b4c7 Backend: Store source of a wst column if available.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5992
diff changeset
205 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
206 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
207 }
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
208 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
209 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
210 }
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 return peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213 }
5542
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5237
diff changeset
214
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org