Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightType.java @ 2809:f283212966e8
Finished work on MINFO bed heights (single).
flys-backend/trunk@4221 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 12 Apr 2012 10:42:46 +0000 |
parents | b57c95094b68 |
children | db196abd16ca |
comparison
equal
deleted
inserted
replaced
2808:b57c95094b68 | 2809:f283212966e8 |
---|---|
1 package de.intevation.flys.importer; | 1 package de.intevation.flys.importer; |
2 | 2 |
3 import java.util.List; | |
4 | |
3 import org.apache.log4j.Logger; | 5 import org.apache.log4j.Logger; |
6 | |
7 import org.hibernate.Session; | |
8 import org.hibernate.Query; | |
9 | |
10 import de.intevation.flys.model.BedHeightType; | |
4 | 11 |
5 | 12 |
6 public class ImportBedHeightType { | 13 public class ImportBedHeightType { |
7 | 14 |
8 private static final Logger log = | 15 private static final Logger log = |
9 Logger.getLogger(ImportBedHeightType.class); | 16 Logger.getLogger(ImportBedHeightType.class); |
10 | 17 |
11 protected String name; | 18 protected String name; |
12 protected String description; | 19 protected String description; |
13 | 20 |
21 protected BedHeightType peer; | |
22 | |
14 | 23 |
15 public ImportBedHeightType(String name, String description) { | 24 public ImportBedHeightType(String name, String description) { |
16 this.name = name; | 25 this.name = name; |
17 this.description = description; | 26 this.description = description; |
18 } | 27 } |
19 | 28 |
20 | 29 |
21 public static String getBedHeightName(String description) { | 30 public void storeDependencies() { |
22 if (description.equals("Flächenpeilung")) { | 31 BedHeightType type = getPeer(); |
23 return "FP"; | 32 } |
33 | |
34 | |
35 public BedHeightType getPeer() { | |
36 if (peer == null) { | |
37 Session session = ImporterSession.getInstance().getDatabaseSession(); | |
38 | |
39 Query query = session.createQuery( | |
40 "from BedHeightType where " + | |
41 "name=:name and description=:description"); | |
42 | |
43 query.setParameter("name", name); | |
44 query.setParameter("description", description); | |
45 | |
46 List<BedHeightType> types = query.list(); | |
47 | |
48 if (types.isEmpty()) { | |
49 peer = new BedHeightType(name, description); | |
50 session.save(peer); | |
51 } | |
52 else { | |
53 peer = types.get(0); | |
54 } | |
24 } | 55 } |
25 else if ("Querprofile".equals(description)) { | 56 |
26 return "QP"; | 57 return peer; |
27 } | |
28 else { | |
29 log.warn("Unknown bed height type: " + description); | |
30 return null; | |
31 } | |
32 } | 58 } |
33 } | 59 } |
34 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 60 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |