Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightType.java @ 9651:eb3dfe900d8c
Importer (s/u-info) extensions: better exception handling
author | mschaefer |
---|---|
date | Mon, 23 Mar 2020 15:00:04 +0100 |
parents | a275ddf7a3a1 |
children |
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; |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
2809
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
11 import java.util.List; |
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
12 |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import org.apache.log4j.Logger; |
8974
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
14 import org.dive4elements.river.model.BedHeightType; |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
15 import org.hibernate.Query; |
2809
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
16 import org.hibernate.Session; |
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
17 |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 public class ImportBedHeightType { |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 private static final Logger log = |
8974
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
22 Logger.getLogger(ImportBedHeightType.class); |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 protected String name; |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
2809
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
26 protected BedHeightType peer; |
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
27 |
8974
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
28 public ImportBedHeightType(final BedHeightType peer) { |
5273
db196abd16ca
Use lookup table from bedd_height from database in importer.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2809
diff
changeset
|
29 this.peer = peer; |
8974
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
30 this.name = peer.getName(); |
5273
db196abd16ca
Use lookup table from bedd_height from database in importer.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2809
diff
changeset
|
31 } |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
5273
db196abd16ca
Use lookup table from bedd_height from database in importer.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2809
diff
changeset
|
33 |
8974
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
34 public ImportBedHeightType(final String name) { |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 this.name = name; |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 } |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
2809
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
39 public void storeDependencies() { |
5273
db196abd16ca
Use lookup table from bedd_height from database in importer.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2809
diff
changeset
|
40 getPeer(); |
2809
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
41 } |
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
42 |
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
43 |
f283212966e8
Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2808
diff
changeset
|
44 public BedHeightType getPeer() { |
8974
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
45 if (this.peer != null) |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
46 return this.peer; |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
47 final Session session = ImporterSession.getInstance().getDatabaseSession(); |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
48 final Query query = session.createQuery("FROM BedHeightType WHERE (trim(name)=:name) AND (trim(description)=:description)"); |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
49 query.setParameter("name", this.name); |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
50 final List<BedHeightType> types = query.list(); |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
51 if (types.isEmpty()) { |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
52 this.peer = new BedHeightType(this.name); |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
53 session.save(this.peer); |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
54 } else { |
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
55 this.peer = types.get(0); |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
8974
a275ddf7a3a1
Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
mschaefer
parents:
8856
diff
changeset
|
57 return this.peer; |
2808
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 } |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 } |
b57c95094b68
Finished work on parsing meta information and data specific to single bed heights files in MINFO.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |