Mercurial > dive4elements > river
comparison flys-backend/src/main/java/org/dive4elements/river/importer/ImportHYKFlowZoneType.java @ 5828:dfb26b03b179
Moved directories to org.dive4elements.river
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 11:53:11 +0200 |
parents | flys-backend/src/main/java/de/intevation/flys/importer/ImportHYKFlowZoneType.java@8aef353e54fb |
children | 18619c1e7c2a |
comparison
equal
deleted
inserted
replaced
5827:e308d4ecd35a | 5828:dfb26b03b179 |
---|---|
1 package de.intevation.flys.importer; | |
2 | |
3 import de.intevation.flys.model.HYKFlowZoneType; | |
4 | |
5 import org.hibernate.Session; | |
6 import org.hibernate.Query; | |
7 | |
8 import java.util.List; | |
9 | |
10 public class ImportHYKFlowZoneType | |
11 { | |
12 private String name; | |
13 private HYKFlowZoneType peer; | |
14 | |
15 public ImportHYKFlowZoneType() { | |
16 } | |
17 | |
18 public ImportHYKFlowZoneType(String name) { | |
19 this.name = name; | |
20 } | |
21 | |
22 public HYKFlowZoneType getPeer() { | |
23 if (peer == null) { | |
24 Session session = ImporterSession.getInstance() | |
25 .getDatabaseSession(); | |
26 Query query = session.createQuery( | |
27 "from HYKFlowZoneType where name=:name"); | |
28 query.setParameter("name", name); | |
29 List<HYKFlowZoneType> flowZoneTypes = query.list(); | |
30 if (flowZoneTypes.isEmpty()) { | |
31 peer = new HYKFlowZoneType(name); | |
32 session.save(peer); | |
33 } | |
34 else { | |
35 peer = flowZoneTypes.get(0); | |
36 } | |
37 } | |
38 return peer; | |
39 } | |
40 } | |
41 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |