annotate backend/src/main/java/org/dive4elements/river/importer/ImportWst.java @ 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.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 14 Jun 2013 13:25:23 +0200
parents 6c41a4ca2876
children 3d83a4cf33ba 0fe00824bd96
rev   line source
5844
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4dd33b86dc61 Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5992
4c3ccf2b0304 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 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
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2350
diff changeset
49 /** Wst as in db. */
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 protected Wst peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 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
53 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
54 }
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
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 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
57 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
58 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
59 columns = new ArrayList<ImportWstColumn>();
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61
201
3169b559ca3c Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 196
diff changeset
62 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
63 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
64 }
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
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 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
67 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
68 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
69 }
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
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 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
72 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
73 }
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
482
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
75 public Integer getKind() {
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
76 return kind;
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
77 }
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
78
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
79 public void setKind(Integer kind) {
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
80 this.kind = kind;
3a99d0295006 Importer: Support parsing "zusaetzliche Laengsschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 478
diff changeset
81 }
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
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
84 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
85 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
86 }
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
5263
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
88 /** 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
89 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
90 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
91 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
92 }
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
93 }
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
94
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
95 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
96 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
97 }
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
98
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
99 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
100 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
101 }
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
102
5263
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
103 public List<ImportWstColumn> getColumns() {
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
104 return columns;
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
105 }
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
106
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
107 /** 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
108 public void addColumn(ImportWstColumn column) {
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
109 columns.add(column);
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
110 }
db341e37d194 ImportWst: Doc and getters.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5000
diff changeset
111
2347
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
112 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
113 return unit;
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
114 }
0acf28a3d28a Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2346
diff changeset
115
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
116 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
117 this.unit = unit;
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
118 }
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
119
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
120 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
121
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
122 log.info("store '" + description + "'");
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
123 Wst wst = 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
124
474
5d920695a7f0 Import of q ranges of wst files was totally broken.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 471
diff changeset
125 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
126 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
127 }
2346
f834b411ca57 Added db table, model class and importer stuff for units.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 503
diff changeset
128
503
bcc18293a547 Importer: Added unsharp lookup to avoid numerical problems.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 499
diff changeset
129 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
130 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
131 }
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
5542
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
133 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
134 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
135 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
136 }
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
137 }
f3b270e5462e Wst Parser: Another attempt to fix the order of the Q ranges.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5263
diff changeset
138
5000
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2350
diff changeset
139 /** 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
140 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
141 if (peer == null) {
497
67fd63e4ef66 Importer: centralized caching
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 482
diff changeset
142 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
143 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
144 "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
145 "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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 }
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 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
155 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
156 }
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
196
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 return peer;
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 }
a33c065b95eb Added importer helper model stubs for WST imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org