annotate backend/src/main/java/org/dive4elements/river/importer/ImportWst.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 5358a5497b2b
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: 5844
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: 5844
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.River;
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
13
478
db430bd9e0e0 Implemented a WstColumnValue cache to speed up inserting WST files into database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 474
diff changeset
14 import org.apache.log4j.Logger;
db430bd9e0e0 Implemented a WstColumnValue cache to speed up inserting WST files into database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 474
diff changeset
15
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
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
478
db430bd9e0e0 Implemented a WstColumnValue cache to speed up inserting WST files into database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 474
diff changeset
19 import java.util.ArrayList;
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
20 import java.util.List;
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
6321
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5992
diff changeset
22 /** Not (yet) db-mapped WST object. */
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 public class ImportWst
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
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 private static Logger log = Logger.getLogger(ImportWst.class);
478
db430bd9e0e0 Implemented a WstColumnValue cache to speed up inserting WST files into database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 474
diff changeset
26
6336
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
27 public interface ImportWstColumnFactory {
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
28 ImportWstColumn create(ImportWst iw, int position);
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
29 }
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
30
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
31 public static final ImportWstColumnFactory COLUMN_FACTORY =
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
32 new ImportWstColumnFactory() {
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
33 @Override
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
34 public ImportWstColumn create(ImportWst importWst, int position) {
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
35 return new ImportWstColumn(importWst, null, null, position);
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
36 }
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
37 };
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
38
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
39 protected 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
40
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
41 protected Integer kind;
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
42
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
43 protected List<ImportWstColumn> columns;
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
44
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
45 protected ImportUnit unit;
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
46
6336
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
47 protected ImportWstColumnFactory columnFactory;
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
48
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
49 protected boolean kmUp;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
50
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2350
diff changeset
51 /** Wst as in db. */
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 protected Wst peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 public ImportWst() {
6336
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
55 this(COLUMN_FACTORY);
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
56 }
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
57
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
58 public ImportWst(ImportWstColumnFactory columnFactory) {
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
59 this.columnFactory = columnFactory;
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
60 kind = 0;
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
61 columns = new ArrayList<ImportWstColumn>();
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
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
64 public ImportWst(String description) {
6336
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
65 this(description, COLUMN_FACTORY);
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
66 }
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
67
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
68 public ImportWst(String description, ImportWstColumnFactory columnFactory) {
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
69 this(columnFactory);
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
70 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
71 }
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
72
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 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
74 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
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
482
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
77 public Integer getKind() {
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
78 return kind;
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
79 }
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
80
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
81 public void setKind(Integer kind) {
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
82 this.kind = kind;
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
83 }
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
84
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
85 public boolean getKmUp() {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
86 return kmUp;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
87 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
88
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
89 public void setKmUp(boolean kmUp) {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
90 this.kmUp = kmUp;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
91 }
482
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
92
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
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
5263
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
97 /** Create columns that can be accessed with getColumn. */
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
98 public void setNumberColumns(int numColumns) {
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
99 for (int i = 0; i < numColumns; ++i) {
6336
c4fbd85a33ee Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6321
diff changeset
100 columns.add(columnFactory.create(this, i));
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
101 }
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
102 }
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
103
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
104 public int getNumberColumns() {
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
105 return columns.size();
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
106 }
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
107
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
108 public ImportWstColumn getColumn(int index) {
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
109 return columns.get(index);
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
110 }
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
111
5263
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
112 public List<ImportWstColumn> getColumns() {
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
113 return columns;
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
114 }
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
115
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
116 /** Adds a column. Assumes that columns wst is this instance. */
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
117 public void addColumn(ImportWstColumn column) {
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
118 columns.add(column);
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
119 }
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
120
2347
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
121 public ImportUnit getUnit() {
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
122 return unit;
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
123 }
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
124
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
125 public void setUnit(ImportUnit unit) {
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
126 this.unit = unit;
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
127 }
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
128
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
129 public void storeDependencies(River river) {
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
130
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
131 log.info("store '" + description + "'");
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
132 getPeer(river);
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
133
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
134 for (ImportWstColumn column: columns) {
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 column.storeDependencies(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 }
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
137
503
bcc18293a547 Importer: Added unsharp lookup to avoid numerical problems.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 499
diff changeset
138 Session session = ImporterSession.getInstance().getDatabaseSession();
bcc18293a547 Importer: Added unsharp lookup to avoid numerical problems.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 499
diff changeset
139 session.flush();
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
140 }
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
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
142 public boolean guessWaterLevelIncreasing() {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
143 int up = 0;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
144 for (ImportWstColumn column: columns) {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
145 if (column.guessWaterLevelIncreasing()) ++up;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
146 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
147 return up > columns.size() - up;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
148 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
149
5542
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
150 public void fixRangesOrder() {
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
151 for (ImportWstColumn column: columns) {
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
152 column.fixRangesOrder();
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
153 }
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
154 }
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
155
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2350
diff changeset
156 /** Get corresponding mapped wst (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
157 public Wst getPeer(River river) {
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 if (peer == null) {
497
67fd63e4ef66 Importer: centralized caching
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
159 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
160 Query query = session.createQuery(
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
161 "from Wst where " +
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
162 "river=:river and description=:description and kind=:kind");
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
163 query.setParameter("river", 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
164 query.setParameter("description", description);
467
c8c09e31cdb8 Added new column 'kind' in discharge tables and wst to distinguish between different types.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 201
diff changeset
165 query.setParameter("kind", kind);
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
166 List<Wst> wsts = 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
167 if (wsts.isEmpty()) {
2347
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
168 peer = new Wst(river, description, kind);
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
169 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
170 }
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 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
172 peer = wsts.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
173 }
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
174
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
175 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
176 return peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org