annotate backend/src/main/java/org/dive4elements/river/importer/ImportWst.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 5358a5497b2b
children 392bbcd8a88b 0a5239a1e46e
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
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7194
diff changeset
68 public ImportWst(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7194
diff changeset
69 String description,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7194
diff changeset
70 ImportWstColumnFactory columnFactory
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7194
diff changeset
71 ) {
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
72 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
73 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
74 }
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 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
77 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
78 }
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
482
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
80 public Integer getKind() {
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
81 return kind;
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
82 }
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 public void setKind(Integer kind) {
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
85 this.kind = kind;
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
86 }
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
87
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
88 public boolean getKmUp() {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
89 return kmUp;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
90 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
91
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
92 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
93 this.kmUp = kmUp;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
94 }
482
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
95
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
96 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
97 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
98 }
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
99
5263
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
100 /** 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
101 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
102 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
103 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
104 }
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
105 }
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 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
108 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
109 }
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
110
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
111 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
112 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
113 }
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
114
5263
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
115 public List<ImportWstColumn> getColumns() {
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
116 return columns;
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
117 }
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
118
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
119 /** 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
120 public void addColumn(ImportWstColumn column) {
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
121 columns.add(column);
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
122 }
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
123
2347
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
124 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
125 return unit;
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
126 }
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
127
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
128 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
129 this.unit = unit;
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
130 }
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
131
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 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
133
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
134 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
135 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
136
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
137 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
138 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
139 }
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
140
503
bcc18293a547 Importer: Added unsharp lookup to avoid numerical problems.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 499
diff changeset
141 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
142 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
143 }
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
144
7183
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
145 public boolean guessWaterLevelIncreasing() {
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
146 int up = 0;
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
147 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
148 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
149 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
150 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
151 }
0fe00824bd96 flys/issue1500: The main wst file determines km_up now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6336
diff changeset
152
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2350
diff changeset
153 /** 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
154 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
155 if (peer == null) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7194
diff changeset
156 Session session = ImporterSession.getInstance()
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7194
diff changeset
157 .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
158 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
159 "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
160 "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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 }
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 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
170 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
171 }
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
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
173 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
174 return peer;
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 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org