X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FNews.hs;h=a36ff7edec1abcbf4a2b862853071c5f2d6a205f;hb=d88388235ec3df702f80e70d50898850befef6ed;hp=50584be229e89389377e49bbbcb24e19b99a0e29;hpb=2bf6ea31afc5d87e2c953d44ff89ff7e4ec73c32;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/News.hs b/src/TSN/XML/News.hs index 50584be..a36ff7e 100644 --- a/src/TSN/XML/News.hs +++ b/src/TSN/XML/News.hs @@ -108,7 +108,7 @@ data Message = xml_sport :: String, xml_url :: Maybe String, xml_teams :: [NewsTeam], - xml_locations :: [NewsLocationXml], + xml_locations :: [Location], xml_sms :: String, xml_editor :: Maybe String, xml_text :: Maybe String, -- Text and continue seem to show up in pairs, @@ -190,38 +190,6 @@ data News_NewsTeam = News_NewsTeam (DefaultKey NewsTeam) --- * NewsLocationXml - --- | The XML type for locations as they show up in the news. The --- associated database type comes from "TSN.Location". --- -data NewsLocationXml = - NewsLocationXml { - xml_city :: Maybe String, - xml_state :: Maybe String, - xml_country :: String } - deriving (Eq, Show) - - -instance ToDb NewsLocationXml where - -- | The database analogue of a NewsLocationXml is a Location. - type Db NewsLocationXml = Location - - -instance FromXml NewsLocationXml where - -- | To convert from the XML representation to the database one, we - -- don't have to do anything. Just copy the fields. - -- - from_xml NewsLocationXml{..} = - Location xml_city xml_state xml_country - - --- | Allow us to import the XML representation directly into the --- database, without having to perform the conversion manually first. --- -instance XmlImport NewsLocationXml - - -- * News_Location -- | Mapping between 'News' records and 'Location' records in the @@ -267,7 +235,7 @@ instance DbImport Message where mapM_ insert_ news_news_teams -- Do all of that over again for the Locations. - loc_ids <- mapM insert_xml_or_select (xml_locations message) + loc_ids <- mapM insert_or_select (xml_locations message) let news_news_locations = map (News_Location news_id) loc_ids mapM_ insert_ news_news_locations @@ -374,9 +342,9 @@ pickle_msg_id = to_tuple m = (db_msg_id m, db_event_id m) --- | Convert a 'NewsLocationXml' to/from XML. +-- | Convert a 'Location' to/from XML. -- -pickle_location :: PU NewsLocationXml +pickle_location :: PU Location pickle_location = xpElem "location" $ xpWrap (from_tuple, to_tuple) $ @@ -385,8 +353,8 @@ pickle_location = (xpElem "country" xpText) where from_tuple = - uncurryN NewsLocationXml - to_tuple l = (xml_city l, xml_state l, xml_country l) + uncurryN Location + to_tuple l = (city l, state l, country l) -- | Convert a 'Message' to/from XML.