Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java @ 497:67fd63e4ef66
Importer: centralized caching
flys-backend/trunk@1851 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 08 May 2011 15:29:45 +0000 |
parents | db430bd9e0e0 |
children | cce054f27dac |
comparison
equal
deleted
inserted
replaced
496:4f2d8980415f | 497:67fd63e4ef66 |
---|---|
1 package de.intevation.flys.importer; | 1 package de.intevation.flys.importer; |
2 | 2 |
3 import de.intevation.flys.model.Wst; | 3 import de.intevation.flys.model.Wst; |
4 import de.intevation.flys.model.WstColumn; | 4 import de.intevation.flys.model.WstColumn; |
5 import de.intevation.flys.model.WstColumnValue; | |
6 import de.intevation.flys.model.River; | 5 import de.intevation.flys.model.River; |
7 | 6 |
8 import org.hibernate.Session; | 7 import org.hibernate.Session; |
9 import org.hibernate.Query; | 8 import org.hibernate.Query; |
10 | 9 |
11 import java.util.List; | 10 import java.util.List; |
12 import java.util.ArrayList; | 11 import java.util.ArrayList; |
13 import java.util.Map; | |
14 | 12 |
15 import java.math.BigDecimal; | 13 import java.math.BigDecimal; |
16 | 14 |
17 public class ImportWstColumn | 15 public class ImportWstColumn |
18 { | 16 { |
22 protected Integer position; | 20 protected Integer position; |
23 | 21 |
24 protected List<ImportWstColumnQRange> columnQRanges; | 22 protected List<ImportWstColumnQRange> columnQRanges; |
25 protected List<ImportWstColumnValue> columnValues; | 23 protected List<ImportWstColumnValue> columnValues; |
26 | 24 |
27 protected Map<WstColumnValueKey, WstColumnValue> wstCache; | |
28 | |
29 protected WstColumn peer; | 25 protected WstColumn peer; |
30 | 26 |
31 public ImportWstColumn() { | 27 public ImportWstColumn() { |
32 columnQRanges = new ArrayList<ImportWstColumnQRange>(); | 28 columnQRanges = new ArrayList<ImportWstColumnQRange>(); |
33 columnValues = new ArrayList<ImportWstColumnValue>(); | 29 columnValues = new ArrayList<ImportWstColumnValue>(); |
35 | 31 |
36 public ImportWstColumn( | 32 public ImportWstColumn( |
37 ImportWst wst, | 33 ImportWst wst, |
38 String name, | 34 String name, |
39 String description, | 35 String description, |
40 Integer position, | 36 Integer position |
41 Map<WstColumnValueKey, WstColumnValue> wstCache | |
42 ) { | 37 ) { |
43 this(); | 38 this(); |
44 this.wst = wst; | 39 this.wst = wst; |
45 this.name = name; | 40 this.name = name; |
46 this.description = description; | 41 this.description = description; |
47 this.position = position; | 42 this.position = position; |
48 this.wstCache = wstCache; | |
49 } | 43 } |
50 | 44 |
51 public ImportWst getWst() { | 45 public ImportWst getWst() { |
52 return wst; | 46 return wst; |
53 } | 47 } |
80 this.position = position; | 74 this.position = position; |
81 } | 75 } |
82 | 76 |
83 public void addColumnValue(BigDecimal position, BigDecimal w) { | 77 public void addColumnValue(BigDecimal position, BigDecimal w) { |
84 columnValues.add( | 78 columnValues.add( |
85 new ImportWstColumnValue(this, position, w, wstCache)); | 79 new ImportWstColumnValue(this, position, w)); |
86 } | 80 } |
87 | 81 |
88 public void addColumnQRange(ImportWstQRange columnQRange) { | 82 public void addColumnQRange(ImportWstQRange columnQRange) { |
89 columnQRanges.add( | 83 columnQRanges.add( |
90 new ImportWstColumnQRange(this, columnQRange)); | 84 new ImportWstColumnQRange(this, columnQRange)); |
101 } | 95 } |
102 | 96 |
103 public WstColumn getPeer(River river) { | 97 public WstColumn getPeer(River river) { |
104 if (peer == null) { | 98 if (peer == null) { |
105 Wst w = wst.getPeer(river); | 99 Wst w = wst.getPeer(river); |
106 Session session = Importer.sessionHolder.get(); | 100 Session session = ImporterSession.getInstance().getDatabaseSession(); |
107 Query query = session.createQuery( | 101 Query query = session.createQuery( |
108 "from WstColumn where " + | 102 "from WstColumn where " + |
109 "wst=:wst and name=:name and description=:description" + | 103 "wst=:wst and name=:name and description=:description" + |
110 " and position=:position"); | 104 " and position=:position"); |
111 query.setParameter("wst", w); | 105 query.setParameter("wst", w); |