]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/Main.hs
Get the Odds module to compile and pass tests under the new regime.
[dead/htsn-import.git] / src / Main.hs
index 6a0380091a65d60f342b86bdb65190e4d024bce5..27ddb66f84b2933b5600bd7fa5b58e2dcbf09429 100644 (file)
@@ -48,7 +48,7 @@ import qualified TSN.XML.Heartbeat as Heartbeat ( verify )
 import qualified TSN.XML.Injuries as Injuries ( Message )
 import qualified TSN.XML.InjuriesDetail as InjuriesDetail ( Message )
 import qualified TSN.XML.News as News ( Message )
---import qualified TSN.XML.Odds as Odds ( Odds )
+import qualified TSN.XML.Odds as Odds ( Message )
 import Xml ( DtdName(..), parse_opts )
 
 
@@ -135,11 +135,11 @@ import_file cfg path = do
         -- We special-case the heartbeat so it doesn't have to run in
         -- the database monad.
       | dtd == "Heartbeat.dtd" = Heartbeat.verify xml
-      | otherwise = do
+      | otherwise =
         -- We need NoMonomorphismRestriction here.
         if backend cfg == Postgres
-        then withPostgresqlConn cs $ runDbConn importer
-        else withSqliteConn cs $ runDbConn importer
+        then withPostgresqlConn cs $ runDbConn importer
+        else withSqliteConn cs $ runDbConn importer
         where
           -- | Pull the real connection String out  of the configuration.
           cs :: String
@@ -165,7 +165,10 @@ import_file cfg path = do
                 let errmsg = "Could not unpickle newsxml."
                 maybe (return $ ImportFailed errmsg) migrate_and_import m
 
-            -- | dtd == "Odds_XML.dtd" = undefined
+            | dtd == "Odds_XML.dtd" = do
+                let m = unpickleDoc xpickle xml :: Maybe Odds.Message
+                let errmsg = "Could not unpickle Odds_XML."
+                maybe (return $ ImportFailed errmsg) migrate_and_import m
 
             | otherwise = do
               let infomsg =