changeset 9578:3dfcb6e1c4d6

Use of SessionHolder replaced by ImporterSession if query executed in the importer
author mschaefer
date Tue, 11 Dec 2018 14:40:36 +0100
parents ca19b7186294
children 67a42c9c46a7
files backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/CollisionParser.java backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionType.java
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/CollisionParser.java	Tue Nov 13 13:02:00 2018 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/CollisionParser.java	Tue Dec 11 14:40:36 2018 +0100
@@ -24,6 +24,7 @@
 import org.apache.log4j.Logger;
 import org.dive4elements.river.importer.Config;
 import org.dive4elements.river.importer.ImportRiver;
+import org.dive4elements.river.importer.ImporterSession;
 import org.dive4elements.river.importer.common.AbstractParser;
 import org.dive4elements.river.importer.common.ParsingState;
 import org.dive4elements.river.importer.sinfo.importitem.CollisionKmLineImport;
@@ -76,7 +77,7 @@
     public CollisionParser(final File importPath, final File rootRelativePath, final ImportRiver river) {
         super(importPath, rootRelativePath, river);
         this.types = new HashMap<>();
-        for (final CollisionType type : CollisionType.getTypes())
+        for (final CollisionType type : CollisionType.getTypes(ImporterSession.getInstance().getDatabaseSession()))
             this.types.put(type.getName().trim().toLowerCase(), new CollisionTypeImport(type.getName()));
     }
 
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionType.java	Tue Nov 13 13:02:00 2018 +0100
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionType.java	Tue Dec 11 14:40:36 2018 +0100
@@ -74,8 +74,10 @@
     /**
      * Queries all collision types from the database, orders by name
      */
-    public static List<CollisionType> getTypes() {
-        final Session session = SessionHolder.HOLDER.get();
+    public static List<CollisionType> getTypes(final Session session) {
+        Session session1 = session;
+        if (session1 == null)
+            session1 = SessionHolder.HOLDER.get();
         final Query query = session.createQuery("FROM CollisionType ORDER BY name");
         return new ArrayList<>(query.list());
     }

http://dive4elements.wald.intevation.org