annotate flys-backend/src/main/java/org/dive4elements/river/importer/ImportPosition.java @ 5829:18619c1e7c2a

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 11:54:36 +0200
parents dfb26b03b179
children
rev   line source
5829
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
1 package org.dive4elements.river.importer;
185
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
5829
18619c1e7c2a Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5828
diff changeset
3 import org.dive4elements.river.model.Position;
187
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
4
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
5 import org.hibernate.Session;
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
6 import org.hibernate.Query;
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
7
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
8 import java.util.List;
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
9
185
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 public class ImportPosition
186
cf8cbcb6a10d Added parser to read *.KM files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 185
diff changeset
11 implements Comparable<ImportPosition>
185
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 {
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 protected String value;
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
187
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
15 protected Position peer;
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
16
185
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 public ImportPosition() {
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 }
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public ImportPosition(String value) {
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 this.value = value;
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 }
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
186
cf8cbcb6a10d Added parser to read *.KM files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 185
diff changeset
24 public int compareTo(ImportPosition other) {
cf8cbcb6a10d Added parser to read *.KM files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 185
diff changeset
25 return value.compareTo(other.value);
cf8cbcb6a10d Added parser to read *.KM files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 185
diff changeset
26 }
cf8cbcb6a10d Added parser to read *.KM files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 185
diff changeset
27
185
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public String getValue() {
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 return value;
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 public void setValue(String value) {
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 this.value = value;
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 }
187
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
35
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
36 public Position getPeer() {
188
003ac16812dd Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 187
diff changeset
37 if (peer == null) {
497
67fd63e4ef66 Importer: centralized caching
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 188
diff changeset
38 Session session = ImporterSession.getInstance().getDatabaseSession();
187
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
39 Query query = session.createQuery("from Position where value=:value");
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
40 query.setString("value", value);
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
41 List<Position> positions = query.list();
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
42 if (positions.isEmpty()) {
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
43 peer = new Position(value);
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
44 session.save(peer);
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
45 }
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
46 else {
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
47 peer = positions.get(0);
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
48 }
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
49 }
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
50 return peer;
ecf90018563b Importer: Bound Attributes and Positions to there backend peers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 186
diff changeset
51 }
185
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 }
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
a60edcfe5f53 Added new helper models for import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54

http://dive4elements.wald.intevation.org