-- that league contains a bunch of listings.
--
module TSN.XML.Weather (
+ dtd,
pickle_message,
-- * Tests
weather_tests,
import Data.Tuple.Curry ( uncurryN )
import Database.Groundhog (
countAll,
- executeRaw,
+ deleteAll,
migrate,
runMigration,
silentMigrationLogger )
import TSN.Picklers ( xp_gamedate, xp_time_stamp )
import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
import Xml (
+ Child(..),
FromXml(..),
FromXmlFk(..),
ToDb(..),
unsafe_unpickle )
+
+-- | The DTD to which this module corresponds. Used to invoke dbimport.
+--
+dtd :: String
+dtd = "weatherxml.dtd"
+
+
--
-- DB/XML Data types
--
instance ToDb WeatherForecastListingXml where
type Db WeatherForecastListingXml = WeatherForecastListing
--- | This is needed to define the 'XmlImportFk' instance for
--- 'WeatherForecastListing'.
---
-instance FromXmlFk WeatherForecastListingXml where
+
+instance Child WeatherForecastListingXml where
-- | Each 'WeatherForecastListingXml' is contained in a
-- 'WeatherForecast'.
--
type Parent WeatherForecastListingXml = WeatherForecast
+
+-- | This is needed to define the 'XmlImportFk' instance for
+-- 'WeatherForecastListing'.
+--
+instance FromXmlFk WeatherForecastListingXml where
from_xml_fk fk WeatherForecastListingXml{..} =
WeatherForecastListing {
db_weather_forecasts_id = fk,
--
type Db WeatherForecastXml = WeatherForecast
-instance FromXmlFk WeatherForecastXml where
+
+instance Child WeatherForecastXml where
+ -- | The database type containing a 'WeatherForecastXml' is
+ -- 'Weather'.
type Parent WeatherForecastXml = Weather
+
+instance FromXmlFk WeatherForecastXml where
+
-- | To convert a 'WeatherForecastXml' into a 'WeatherForecast', we
-- replace the 'WeatherLeague' with its name.
--
migrate b
migrate c
_ <- dbimport weather
- -- No idea how 'delete' works, so do this instead.
- executeRaw False "DELETE FROM weather;" []
+ deleteAll a
count_a <- countAll a
count_b <- countAll b
count_c <- countAll c