Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2347:0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
flys-backend/trunk@2884 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 04 Oct 2011 15:28:19 +0000 |
parents | c5c48f52dc7b |
children | 33f40b23edd8 |
comparison
equal
deleted
inserted
replaced
2346:f834b411ca57 | 2347:0acf28a3d28a |
---|---|
17 | 17 |
18 import de.intevation.artifacts.common.utils.FileTools; | 18 import de.intevation.artifacts.common.utils.FileTools; |
19 import de.intevation.artifacts.common.utils.FileTools.HashedFile; | 19 import de.intevation.artifacts.common.utils.FileTools.HashedFile; |
20 | 20 |
21 import de.intevation.flys.model.River; | 21 import de.intevation.flys.model.River; |
22 import de.intevation.flys.model.Unit; | |
22 | 23 |
23 import de.intevation.flys.importer.parsers.PRFParser; | 24 import de.intevation.flys.importer.parsers.PRFParser; |
24 import de.intevation.flys.importer.parsers.HYKParser; | 25 import de.intevation.flys.importer.parsers.HYKParser; |
25 import de.intevation.flys.importer.parsers.AnnotationsParser; | 26 import de.intevation.flys.importer.parsers.AnnotationsParser; |
26 import de.intevation.flys.importer.parsers.AnnotationClassifier; | 27 import de.intevation.flys.importer.parsers.AnnotationClassifier; |
76 protected List<ImportWst> floodWater; | 77 protected List<ImportWst> floodWater; |
77 | 78 |
78 protected List<ImportWst> floodProtection; | 79 protected List<ImportWst> floodProtection; |
79 | 80 |
80 protected ImportWst wst; | 81 protected ImportWst wst; |
82 | |
83 protected ImportUnit wstUnit; | |
81 | 84 |
82 protected AnnotationClassifier annotationClassifier; | 85 protected AnnotationClassifier annotationClassifier; |
83 | 86 |
84 protected River peer; | 87 protected River peer; |
85 | 88 |
504 cal.setTimeInMillis(ms - ms%1000); | 507 cal.setTimeInMillis(ms - ms%1000); |
505 return cal.getTime(); | 508 return cal.getTime(); |
506 } | 509 } |
507 | 510 |
508 public void storeDependencies() { | 511 public void storeDependencies() { |
512 storeWstUnit(); | |
509 storeAnnotations(); | 513 storeAnnotations(); |
510 storeHYKs(); | 514 storeHYKs(); |
511 storeCrossSections(); | 515 storeCrossSections(); |
512 storeGauges(); | 516 storeGauges(); |
513 storeWst(); | 517 storeWst(); |
516 storeOfficialLines(); | 520 storeOfficialLines(); |
517 storeFloodWater(); | 521 storeFloodWater(); |
518 storeFloodProtection(); | 522 storeFloodProtection(); |
519 } | 523 } |
520 | 524 |
525 public void storeWstUnit() { | |
526 if (wst == null) { | |
527 wstUnit = new ImportUnit("NN + m"); | |
528 } | |
529 else { | |
530 wstUnit = wst.getUnit(); | |
531 } | |
532 } | |
533 | |
521 public void storeHYKs() { | 534 public void storeHYKs() { |
522 if (!Config.INSTANCE.skipHYKs()) { | 535 if (!Config.INSTANCE.skipHYKs()) { |
523 log.info("store HYKs"); | 536 log.info("store HYKs"); |
524 getPeer(); | 537 getPeer(); |
525 for (ImportHYK hyk: hyks) { | 538 for (ImportHYK hyk: hyks) { |
626 | 639 |
627 public River getPeer() { | 640 public River getPeer() { |
628 if (peer == null) { | 641 if (peer == null) { |
629 Session session = ImporterSession.getInstance().getDatabaseSession(); | 642 Session session = ImporterSession.getInstance().getDatabaseSession(); |
630 Query query = session.createQuery("from River where name=:name"); | 643 Query query = session.createQuery("from River where name=:name"); |
644 | |
645 Unit u = wstUnit.getPeer(); | |
646 | |
631 query.setString("name", name); | 647 query.setString("name", name); |
632 List<River> rivers = query.list(); | 648 List<River> rivers = query.list(); |
633 if (rivers.isEmpty()) { | 649 if (rivers.isEmpty()) { |
634 peer = new River(name); | 650 log.info("Store new river '" + name + "'"); |
651 peer = new River(name, u); | |
635 session.save(peer); | 652 session.save(peer); |
636 } | 653 } |
637 else { | 654 else { |
638 peer = rivers.get(0); | 655 peer = rivers.get(0); |
639 } | 656 } |