annotate backend/src/main/java/org/dive4elements/river/importer/ImportLocationSystem.java @ 9709:b74f817435fe

comment removed
author dnt_bjoernsen <d.tironi@bjoernsen.de>
date Wed, 27 Jan 2021 11:47:38 +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
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
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.LocationSystem;
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;
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
17
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 ImportLocationSystem {
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
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
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(ImportLocationSystem.class);
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
23
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
24
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
25 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
26 protected String description;
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
27
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
28 protected LocationSystem peer;
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
29
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
30
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
31 public ImportLocationSystem(final String name, final String description) {
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 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
33 this.description = description;
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
34 }
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
35
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
36 public void storeDependencies() {
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
37 log.info("store LocationSystem '" + 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
38 final LocationSystem ls = getPeer();
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
39
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
40 final Session session = ImporterSession.getInstance().getDatabaseSession();
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
41 session.flush();
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 LocationSystem 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 LocationSystem 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 query.setParameter("description", this.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
51 final List<LocationSystem> lss = 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
52 if (lss.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
53 this.peer = new LocationSystem(this.name, this.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
54 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
55 } 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
56 this.peer = lss.get(0);
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
57 }
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
58 return this.peer;
2809
f283212966e8 Finished work on MINFO bed heights (single).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2808
diff changeset
59 }
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
60 }
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
61 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org