Guest User

Obfuscated output of yesod-dsl

a guest
Jul 10th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 175.60 KB | None | 0 0
  1. {-# LANGUAGE RankNTypes #-}
  2. {-# LANGUAGE FlexibleInstances #-}
  3. {-# LANGUAGE OverloadedStrings #-}
  4. {-# LANGUAGE ExistentialQuantification #-}
  5. {-# LANGUAGE TemplateHaskell #-}
  6. {-# LANGUAGE QuasiQuotes #-}
  7. {-# LANGUAGE TypeFamilies #-}
  8. {-# LANGUAGE FlexibleContexts #-}
  9. {-# LANGUAGE DeriveDataTypeable #-}
  10. {-# LANGUAGE GADTs #-}
  11. {-# LANGUAGE ConstraintKinds #-}
  12. {-# OPTIONS_GHC -fno-warn-overlapping-patterns #-}
  13. {-# OPTIONS_GHC -fno-warn-orphans #-}
  14. {-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
  15. module Handler.Generated.Internal where
  16. import Handler.Generated.Enums
  17. import Prelude
  18. import Database.Esqueleto
  19. import Database.Esqueleto.Internal.Sql (unsafeSqlBinOp)
  20. import qualified Database.Persist as P
  21. import Database.Persist.TH
  22. import Yesod.Auth (requireAuthId, YesodAuth, AuthId, YesodAuthPersist)
  23. import Yesod.Core
  24. import Yesod.Persist (runDB, YesodPersist, YesodPersistBackend)
  25. import Data.Aeson ((.:), (.:?), (.!=), FromJSON, parseJSON, decode)
  26. import Data.Aeson.TH
  27. import Data.Int
  28. import Data.Word
  29. import Data.Time
  30. import Data.Text.Encoding (encodeUtf8)
  31. import Data.Typeable (Typeable)
  32. import qualified Data.Attoparsec as AP
  33. import qualified Data.Aeson as A
  34. import qualified Data.ByteString.Lazy as LBS
  35. import Data.Maybe
  36. import qualified Data.Text.Read
  37. import qualified Data.Text as T
  38. import Data.Text (Text)
  39. import qualified Data.List as DL
  40. import Control.Monad (mzero)
  41. import Control.Monad.Trans.Resource (runResourceT)
  42. import qualified Data.ByteString as B
  43. import qualified Data.ByteString.Lazy as L
  44. import qualified Network.HTTP.Conduit as C
  45. import qualified Network.Wai as W
  46. import Data.Conduit.Lazy (lazyConsume)
  47. import Network.HTTP.Types (status200, status400, status404)
  48. import Blaze.ByteString.Builder.ByteString (fromByteString)
  49. import Control.Applicative ((<$>), (<*>))  
  50. import qualified Data.HashMap.Lazy as HML
  51.  
  52. data FilterJsonMsg = FilterJsonMsg {
  53.     filterJsonMsg_type :: Text,
  54.     filterJsonMsg_value :: Text,
  55.     filterJsonMsg_field :: Text,
  56.     filterJsonMsg_property :: Text,
  57.     filterJsonMsg_comparison :: Text
  58. }
  59. instance FromJSON FilterJsonMsg where
  60.     parseJSON (A.Object v) = FilterJsonMsg <$>
  61.         v .:? "type" .!= "string" <*>
  62.         v .: "value" <*>
  63.         v .:? "field" .!= "" <*>
  64.         v .:? "property" .!= "" <*>
  65.         v .:? "comparison" .!= "eq"
  66.     parseJSON _ = mzero
  67.  
  68. data SortJsonMsg = SortJsonMsg {
  69.     sortJsonMsg_property :: Text,
  70.     sortJsonMsg_direction :: Text
  71. }
  72.  
  73. $(deriveJSON (drop 12) ''SortJsonMsg)
  74.  
  75. -- defaultFilterOp :: forall v typ. PersistField typ => Text -> EntityField v typ -> typ -> Filter v
  76. defaultFilterOp "eq" = (==.)
  77. defaultFilterOp "neq" = (!=.)
  78. defaultFilterOp "lt" = (<.)
  79. defaultFilterOp "gt" = (>.)
  80. defaultFilterOp "le" = (<=.)
  81. defaultFilterOp "ge" = (>=.)
  82. defaultFilterOp _ = (==.)
  83.  
  84. ilike = unsafeSqlBinOp " ILIKE "
  85. safeRead :: forall a. Read a => Text -> Maybe a
  86. safeRead s = case (reads $ T.unpack s) of
  87.    [(v,_)] -> Just v
  88.    _ -> Nothing
  89.  
  90. instance PathPiece Int32 where
  91.     fromPathPiece s =
  92.         case Data.Text.Read.decimal s of
  93.             Right (i, _) -> Just i
  94.             Left _ -> Nothing
  95.     toPathPiece = T.pack . show
  96.  
  97. instance PathPiece Word32 where
  98.     fromPathPiece s =
  99.         case Data.Text.Read.decimal s of
  100.             Right (i, _) -> Just i
  101.             Left _ -> Nothing
  102.  
  103.     toPathPiece = T.pack . show
  104.  
  105. instance PathPiece Word64 where
  106.     fromPathPiece s =
  107.         case Data.Text.Read.decimal s of
  108.             Right (i, _) -> Just i
  109.             Left _ -> Nothing
  110.  
  111.     toPathPiece = T.pack . show
  112.  
  113. instance PathPiece Double where
  114.     fromPathPiece s =
  115.         case Data.Text.Read.double s of
  116.             Right (i, _) -> Just i
  117.             Left _ -> Nothing
  118.     toPathPiece = T.pack . show
  119.  
  120. instance PathPiece Bool where
  121.     fromPathPiece "true" = Just True
  122.     fromPathPiece "false" = Just False
  123.     fromPathPiece "True" = Just True
  124.     fromPathPiece "False" = Just False
  125.     fromPathPiece  _ = Nothing
  126.     toPathPiece = T.pack . show
  127.  
  128. instance PathPiece TimeOfDay where
  129.     fromPathPiece = safeRead
  130.     toPathPiece = T.pack . show
  131.  
  132. instance PathPiece UTCTime where
  133.     fromPathPiece = safeRead
  134.     toPathPiece = T.pack . show
  135.  
  136. instance PathPiece ZonedTime where
  137.     fromPathPiece = safeRead
  138.     toPathPiece = T.pack . show
  139.  
  140. instance (PathPiece a, Show a) => PathPiece [a] where
  141.     fromPathPiece s = do
  142.         parts <- safeRead s
  143.         values <- mapM fromPathPiece parts
  144.         return values
  145.     toPathPiece = T.pack . show
  146.            
  147.  
  148. getDefaultFilter maybeGetParam defaultFilterJson p = do
  149.     f <- maybe maybeGetParam Just getFilter
  150.     fromPathPiece f
  151.     where
  152.         getFilter = do            
  153.             j <- defaultFilterJson
  154.             v <- DL.find (\fjm -> filterJsonMsg_property fjm == p) j
  155.             return (filterJsonMsg_value v)
  156. share [mkPersist sqlOnlySettings, mkMigrate "migrateGenerated" ] [persistLowerCase|
  157. E3 json
  158.     ownerId UserId  
  159.     e313 Text  
  160.     e314 UTCTime  
  161. E4 json
  162.     userId UserId  
  163.     e24Id E3Id Maybe  
  164.     message Text  
  165.     e314 UTCTime  
  166. E5 json
  167.     e314 UTCTime  
  168.     userId UserId  
  169. E6 json
  170.     f1 Text  
  171.     f2 Text  
  172.     f3 Text  
  173.     f4 E5Id  
  174.     userE7EId UserE7Id Maybe  
  175.     userE7E27EId UserE7E27Id Maybe  
  176.     userEId UserId Maybe  
  177.     e10EId E10Id Maybe  
  178.     e10E18EId E10E18Id Maybe  
  179.     e11PieceEId E11PieceId Maybe  
  180.     e11E18EId E11E18Id Maybe  
  181.     e25E18EId E25E18Id Maybe  
  182.     e21E18EId E21E18Id Maybe  
  183.     e16EId E16Id Maybe  
  184.     e16E8EId E16E8Id Maybe  
  185.     e13EId E13Id Maybe  
  186.     e13E18EId E13E18Id Maybe  
  187.     e14EId E14Id Maybe  
  188.     e26EId E26Id Maybe  
  189.     e26E7EId E26E7Id Maybe  
  190.     e28EId E28Id Maybe  
  191.     e19EId E19Id Maybe  
  192.     e20EId E20Id Maybe  
  193.     e20NumberEId E20NumberId Maybe  
  194. UserE7 json
  195.     name Text  
  196.     version E5Id Maybe  
  197.     e30d Bool  
  198.     UniqueE7 name !force
  199. UserE7E8 json
  200.     groupId UserE7Id  
  201.     userId UserId  
  202.     e30d Bool  
  203. UserE7E27 json
  204.     groupId UserE7Id  
  205.     e10EntityId E10Id Maybe  
  206.     e11PieceEntityId E11PieceId Maybe  
  207.     e11E18EntityId E11E18Id Maybe  
  208.     e25E18EntityId E25E18Id Maybe  
  209.     e21E18EntityId E21E18Id Maybe  
  210.     e16EntityId E16Id Maybe  
  211.     e13EntityId E13Id Maybe  
  212.     e14EntityId E14Id Maybe  
  213.     e28EntityId E28Id Maybe  
  214.     e19EntityId E19Id Maybe  
  215.     e20EntityId E20Id Maybe  
  216.     e30d Bool  
  217.     version E5Id Maybe  
  218. User json
  219.     firstName Text  
  220.     lastName Text  
  221.     email Text  
  222.     password Text  
  223.     salt Text  
  224.     admin Bool  default='false'
  225.     name Text  
  226.     version E5Id Maybe  
  227.     e30d Bool  
  228.     UniqueUser name !force
  229.     deriving Typeable
  230. E9 json
  231.     fs Word64  
  232.     l Word32  
  233. E10 json
  234.     e31 Text  
  235.     aaaId E9Id  
  236.     name Text  
  237.     version E5Id Maybe  
  238.     e30d Bool  
  239.     e311 Text Maybe  
  240.     e312 UTCTime  
  241.     e313 UserId Maybe  
  242.     UniqueE10E231 e311 !force
  243. E10E18 json
  244.     name Text  
  245.     version E5Id Maybe  
  246.     e30d Bool  
  247.     e311 Text Maybe  
  248.     UniqueE10E18E231 e311 !force
  249. E10E18E8 json
  250.     e10Id E10Id  
  251.     e10E18Id E10E18Id  
  252.     e30d Bool  
  253.     e311 Text Maybe  
  254.     UniqueE10E18E8E231 e311 !force
  255. E11Piece json
  256.     a Text  
  257.     c Text  
  258.     dc Text  
  259.     t Int32  
  260.     aaaId E9Id  
  261.     mS Bool  
  262.     fS Bool  
  263.     name Text  
  264.     version E5Id Maybe  
  265.     e30d Bool  
  266.     e311 Text Maybe  
  267.     e312 UTCTime  
  268.     e313 UserId Maybe  
  269.     UniqueE11PieceE231 e311 !force
  270. E11E18 json
  271.     e31 Text  
  272.     readOnly Bool  
  273.     lf Bool  
  274.     smallE18 Bool  
  275.     name Text  
  276.     version E5Id Maybe  
  277.     e30d Bool  
  278.     e311 Text Maybe  
  279.     UniqueE11E18E231 e311 !force
  280. E11E18E8 json
  281.     e11PieceId E11PieceId  
  282.     e11E18Id E11E18Id  
  283.     e30d Bool  
  284.     e311 Text Maybe  
  285.     UniqueE11E18E8E231 e311 !force
  286. E25E18 json
  287.     e31 Text  
  288.     op SO  
  289.     e11E18Id E11E18Id  
  290.     name Text  
  291.     version E5Id Maybe  
  292.     e30d Bool  
  293.     e311 Text Maybe  
  294.     UniqueE25E18E231 e311 !force
  295. E25E18E8 json
  296.     e11E18Id E11E18Id  
  297.     e30d Bool  
  298.     e311 Text Maybe  
  299.     UniqueE25E18E8E231 e311 !force
  300. E21E18 json
  301.     e31 Text  
  302.     e32 E21E18E23  
  303.     op SBO  
  304.     value Text  
  305.     valueType E21E18Value  
  306.     e11E18Id E11E18Id  
  307.     name Text  
  308.     version E5Id Maybe  
  309.     e30d Bool  
  310.     e311 Text Maybe  
  311.     UniqueE21E18E231 e311 !force
  312. E16 json
  313.     e31 Text  
  314.     name Text  
  315.     version E5Id Maybe  
  316.     e30d Bool  
  317.     e311 Text Maybe  
  318.     UniqueE16E231 e311 !force
  319. E16E8 json
  320.     e16Id E16Id  
  321.     e11E18Id E11E18Id  
  322.     amount Int32  
  323.     e30d Bool  
  324.     version E5Id Maybe  
  325.     e311 Text Maybe  
  326.     UniqueE16E8E231 e311 !force
  327. E13 json
  328.     aaaId E9Id  
  329.     name Text  
  330.     version E5Id Maybe  
  331.     e30d Bool  
  332.     e311 Text Maybe  
  333.     UniqueE13E231 e311 !force
  334. E13E18 json
  335.     e31 Text  
  336.     name Text  
  337.     version E5Id Maybe  
  338.     e30d Bool  
  339.     e311 Text Maybe  
  340.     UniqueE13E18E231 e311 !force
  341. E13E18E8 json
  342.     e13Id E13Id  
  343.     e13E18Id E13E18Id  
  344.     e30d Bool  
  345.     e311 Text Maybe  
  346.     UniqueE13E18E8E231 e311 !force
  347. E14 json
  348.     e31 Text  
  349.     author Text  
  350.     e29Date UTCTime  
  351.     name Text  
  352.     version E5Id Maybe  
  353.     e30d Bool  
  354.     e311 Text Maybe  
  355.     UniqueE14E231 e311 !force
  356. E14E8 json
  357.     e11PieceE14ContentId E11PieceId Maybe  
  358.     e11E18E14ContentId E11E18Id Maybe  
  359.     e13E14ContentId E13Id Maybe  
  360.     e13E18E14ContentId E13E18Id Maybe  
  361.     e14Id E14Id  
  362.     order Int32  
  363.     e30d Bool  
  364.     e311 Text Maybe  
  365.     UniqueE14E8E231 e311 !force
  366. E26 json
  367.     name Text  
  368.     version E5Id Maybe  
  369.     e30d Bool  
  370.     e311 Text Maybe  
  371.     UniqueE26E231 e311 !force
  372. E26E7 json
  373.     name Text  
  374.     version E5Id Maybe  
  375.     e30d Bool  
  376.     e311 Text Maybe  
  377.     UniqueE26E7E231 e311 !force
  378. E26E7E8 json
  379.     e26Id E26Id  
  380.     e26E7Id E26E7Id  
  381.     e30d Bool  
  382.     e311 Text Maybe  
  383.     UniqueE26E7E8E231 e311 !force
  384. E26BannedE9 json
  385.     e26Id E26Id  
  386.     aaaId E9Id  
  387. E28 json
  388.     place Text  
  389.     address Text  
  390.     technicalE27 Text  
  391.     lastConnectionE11 UTCTime  
  392.     lastTransferOKE11 UTCTime  
  393.     lastE11RecyclingE11 UTCTime  
  394.     diskSpace Int32  
  395.     diskUsage Int32  
  396.     rebootCount Int32  
  397.     lastReboot UTCTime  
  398.     lastE27Updated UTCTime  
  399.     active Bool  
  400.     gramexType E28Type  
  401.     restaurantIncome Int32  
  402.     name Text  
  403.     version E5Id Maybe  
  404.     e30d Bool  
  405.     e311 Text Maybe  
  406.     UniqueE28E231 e311 !force
  407. E26Contract json
  408.     startDate UTCTime  
  409.     endDate UTCTime  
  410.     ends Bool  
  411.     e31 Text  
  412.     e28Id E28Id  
  413. E12 json
  414.     e10Id E10Id  
  415.     e26Id E26Id  
  416.     day Day  
  417.     startE11 TimeOfDay  
  418.     e314Window Int32  
  419.     accurate Bool  
  420.     count Int32  
  421. E12E12 json
  422.     e10Id E10Id  
  423.     e26Id E26Id  
  424.     wday Enum1  
  425.     e314 TimeOfDay  
  426. E12E12E34 json
  427.     e26Id E26Id  
  428.     day Day  
  429.     UniqueE12E12E34 e26Id day !force
  430. E19 json
  431.     e31 Text  
  432.     name Text  
  433.     version E5Id Maybe  
  434.     e30d Bool  
  435.     e311 Text Maybe  
  436.     UniqueE19E231 e311 !force
  437. E19E8 json
  438.     e19Id E19Id  
  439.     aaaId E9Id Maybe  
  440.     order Int32  
  441.     e30d Bool  
  442.     e311 Text Maybe  
  443.     UniqueE19E8E231 e311 !force
  444. E20 json
  445.     title Text  
  446.     address Text  
  447.     email Text  
  448.     name Text  
  449.     version E5Id Maybe  
  450.     e30d Bool  
  451.     e311 Text Maybe  
  452.     UniqueE20E231 e311 !force
  453. E20Number json
  454.     e31Id E20Id  
  455.     number Text  
  456.     name Text  
  457.     version E5Id Maybe  
  458.     e30d Bool  
  459.     e311 Text Maybe  
  460.     UniqueE20NumberE231 e311 !force
  461. E16E12 json
  462.     e16Id E16Id  
  463.     e26Id E26Id  
  464.     day Day  
  465.     startE11 TimeOfDay  
  466.     e314Window Int32  
  467. E12E16E12 json
  468.     e16Id E16Id  
  469.     e26Id E26Id  
  470.     wday Enum1  
  471.     e314 TimeOfDay  
  472. E10E11 json
  473.     e26Id E26Id  
  474.     day Day  
  475.     startE11 TimeOfDay  
  476.     e314Window Int32  
  477.     active Bool  
  478. E12E10E11 json
  479.     e26Id E26Id  
  480.     wday Enum1  
  481.     startE11 TimeOfDay  
  482.     e314Window Int32  
  483. |]
  484. class Named a where
  485.     namedName :: a -> Text
  486. instance Named UserE7 where
  487.     namedName = userE7Name
  488. instance Named User where
  489.     namedName = userName
  490. instance Named E10 where
  491.     namedName = e10Name
  492. instance Named E10E18 where
  493.     namedName = e10E18Name
  494. instance Named E11Piece where
  495.     namedName = e11PieceName
  496. instance Named E11E18 where
  497.     namedName = e11E18Name
  498. instance Named E25E18 where
  499.     namedName = e25E18Name
  500. instance Named E21E18 where
  501.     namedName = e21E18Name
  502. instance Named E16 where
  503.     namedName = e16Name
  504. instance Named E13 where
  505.     namedName = e13Name
  506. instance Named E13E18 where
  507.     namedName = e13E18Name
  508. instance Named E14 where
  509.     namedName = e14Name
  510. instance Named E26 where
  511.     namedName = e26Name
  512. instance Named E26E7 where
  513.     namedName = e26E7Name
  514. instance Named E28 where
  515.     namedName = e28Name
  516. instance Named E19 where
  517.     namedName = e19Name
  518. instance Named E20 where
  519.     namedName = e20Name
  520. instance Named E20Number where
  521.     namedName = e20NumberName
  522. class C1 a where
  523.     c1E311 :: a -> Maybe Text
  524. instance C1 E10 where
  525.     c1E311 = e10E311
  526. instance C1 E10E18 where
  527.     c1E311 = e10E18E311
  528. instance C1 E10E18E8 where
  529.     c1E311 = e10E18E8E311
  530. instance C1 E11Piece where
  531.     c1E311 = e11PieceE311
  532. instance C1 E11E18 where
  533.     c1E311 = e11E18E311
  534. instance C1 E11E18E8 where
  535.     c1E311 = e11E18E8E311
  536. instance C1 E25E18 where
  537.     c1E311 = e25E18E311
  538. instance C1 E25E18E8 where
  539.     c1E311 = e25E18E8E311
  540. instance C1 E21E18 where
  541.     c1E311 = e21E18E311
  542. instance C1 E16 where
  543.     c1E311 = e16E311
  544. instance C1 E16E8 where
  545.     c1E311 = e16E8E311
  546. instance C1 E13 where
  547.     c1E311 = e13E311
  548. instance C1 E13E18 where
  549.     c1E311 = e13E18E311
  550. instance C1 E13E18E8 where
  551.     c1E311 = e13E18E8E311
  552. instance C1 E14 where
  553.     c1E311 = e14E311
  554. instance C1 E14E8 where
  555.     c1E311 = e14E8E311
  556. instance C1 E26 where
  557.     c1E311 = e26E311
  558. instance C1 E26E7 where
  559.     c1E311 = e26E7E311
  560. instance C1 E26E7E8 where
  561.     c1E311 = e26E7E8E311
  562. instance C1 E28 where
  563.     c1E311 = e28E311
  564. instance C1 E19 where
  565.     c1E311 = e19E311
  566. instance C1 E19E8 where
  567.     c1E311 = e19E8E311
  568. instance C1 E20 where
  569.     c1E311 = e20E311
  570. instance C1 E20Number where
  571.     c1E311 = e20NumberE311
  572. class C2 a where
  573.     c2E312 :: a -> UTCTime
  574.     c2E313 :: a -> Maybe UserId
  575. instance C2 E10 where
  576.     c2E312 = e10E312
  577.     c2E313 = e10E313
  578. instance C2 E11Piece where
  579.     c2E312 = e11PieceE312
  580.     c2E313 = e11PieceE313
  581. class C3 a where
  582.     c3Version :: a -> Maybe E5Id
  583. instance C3 UserE7 where
  584.     c3Version = userE7Version
  585. instance C3 UserE7E27 where
  586.     c3Version = userE7E27Version
  587. instance C3 User where
  588.     c3Version = userVersion
  589. instance C3 E10 where
  590.     c3Version = e10Version
  591. instance C3 E10E18 where
  592.     c3Version = e10E18Version
  593. instance C3 E11Piece where
  594.     c3Version = e11PieceVersion
  595. instance C3 E11E18 where
  596.     c3Version = e11E18Version
  597. instance C3 E25E18 where
  598.     c3Version = e25E18Version
  599. instance C3 E21E18 where
  600.     c3Version = e21E18Version
  601. instance C3 E16 where
  602.     c3Version = e16Version
  603. instance C3 E16E8 where
  604.     c3Version = e16E8Version
  605. instance C3 E13 where
  606.     c3Version = e13Version
  607. instance C3 E13E18 where
  608.     c3Version = e13E18Version
  609. instance C3 E14 where
  610.     c3Version = e14Version
  611. instance C3 E26 where
  612.     c3Version = e26Version
  613. instance C3 E26E7 where
  614.     c3Version = e26E7Version
  615. instance C3 E28 where
  616.     c3Version = e28Version
  617. instance C3 E19 where
  618.     c3Version = e19Version
  619. instance C3 E20 where
  620.     c3Version = e20Version
  621. instance C3 E20Number where
  622.     c3Version = e20NumberVersion
  623. class C4 a where
  624.     c4E30d :: a -> Bool
  625. instance C4 UserE7 where
  626.     c4E30d = userE7E30d
  627. instance C4 UserE7E8 where
  628.     c4E30d = userE7E8E30d
  629. instance C4 UserE7E27 where
  630.     c4E30d = userE7E27E30d
  631. instance C4 User where
  632.     c4E30d = userE30d
  633. instance C4 E10 where
  634.     c4E30d = e10E30d
  635. instance C4 E10E18 where
  636.     c4E30d = e10E18E30d
  637. instance C4 E10E18E8 where
  638.     c4E30d = e10E18E8E30d
  639. instance C4 E11Piece where
  640.     c4E30d = e11PieceE30d
  641. instance C4 E11E18 where
  642.     c4E30d = e11E18E30d
  643. instance C4 E11E18E8 where
  644.     c4E30d = e11E18E8E30d
  645. instance C4 E25E18 where
  646.     c4E30d = e25E18E30d
  647. instance C4 E25E18E8 where
  648.     c4E30d = e25E18E8E30d
  649. instance C4 E21E18 where
  650.     c4E30d = e21E18E30d
  651. instance C4 E16 where
  652.     c4E30d = e16E30d
  653. instance C4 E16E8 where
  654.     c4E30d = e16E8E30d
  655. instance C4 E13 where
  656.     c4E30d = e13E30d
  657. instance C4 E13E18 where
  658.     c4E30d = e13E18E30d
  659. instance C4 E13E18E8 where
  660.     c4E30d = e13E18E8E30d
  661. instance C4 E14 where
  662.     c4E30d = e14E30d
  663. instance C4 E14E8 where
  664.     c4E30d = e14E8E30d
  665. instance C4 E26 where
  666.     c4E30d = e26E30d
  667. instance C4 E26E7 where
  668.     c4E30d = e26E7E30d
  669. instance C4 E26E7E8 where
  670.     c4E30d = e26E7E8E30d
  671. instance C4 E28 where
  672.     c4E30d = e28E30d
  673. instance C4 E19 where
  674.     c4E30d = e19E30d
  675. instance C4 E19E8 where
  676.     c4E30d = e19E8E30d
  677. instance C4 E20 where
  678.     c4E30d = e20E30d
  679. instance C4 E20Number where
  680.     c4E30d = e20NumberE30d
  681. class C6 a where
  682. instance C6 E10 where
  683. instance C6 E11Piece where
  684. instance C6 E11E18 where
  685. instance C6 E25E18 where
  686. instance C6 E21E18 where
  687. instance C6 E16 where
  688. instance C6 E13 where
  689. instance C6 E14 where
  690. instance C6 E28 where
  691. instance C6 E19 where
  692. instance C6 E20 where
  693. class E14Content a where
  694. instance E14Content E11Piece where
  695. instance E14Content E11E18 where
  696. instance E14Content E13 where
  697. instance E14Content E13E18 where
  698. checkResult :: forall (m :: * -> *). (Monad m) => Text -> m Bool -> m (Maybe Text)
  699. checkResult msg f = do
  700.    result <- f
  701.    return $ if result then Nothing else (Just msg)
  702.  
  703. class Validatable a where
  704.     validate :: forall master b. (P.PersistMonadBackend (b (HandlerT master IO)) ~ P.PersistEntityBackend a,
  705.                  b ~ YesodPersistBackend master,
  706.                  P.PersistQuery (b (HandlerT master IO)),
  707.                  P.PersistUnique (b (HandlerT master IO)),
  708.                  YesodPersist master,
  709.                  GeneratedValidation master)
  710.              => a -> HandlerT master IO [Text]
  711.  
  712. class Yesod master => GeneratedValidation master where
  713.     nonEmpty :: (YesodPersist master) => Text -> HandlerT master IO Bool
  714. instance Validatable E3 where
  715.     validate v = do
  716.         results <- sequence [
  717.             ]
  718.         return $ catMaybes results
  719. instance Validatable E4 where
  720.     validate v = do
  721.         results <- sequence [
  722.             ]
  723.         return $ catMaybes results
  724. instance Validatable E5 where
  725.     validate v = do
  726.         results <- sequence [
  727.             ]
  728.         return $ catMaybes results
  729. instance Validatable E6 where
  730.     validate v = do
  731.         results <- sequence [
  732.             ]
  733.         return $ catMaybes results
  734. instance Validatable UserE7 where
  735.     validate v = do
  736.         results <- sequence [
  737.                 checkResult "UserE7.name nonEmpty" (nonEmpty $ userE7Name v)            ]
  738.         return $ catMaybes results
  739. instance Validatable UserE7E8 where
  740.     validate v = do
  741.         results <- sequence [
  742.             ]
  743.         return $ catMaybes results
  744. instance Validatable UserE7E27 where
  745.     validate v = do
  746.         results <- sequence [
  747.             ]
  748.         return $ catMaybes results
  749. instance Validatable User where
  750.     validate v = do
  751.         results <- sequence [
  752.                 checkResult "User.name nonEmpty" (nonEmpty $ userName v)            ]
  753.         return $ catMaybes results
  754. instance Validatable E9 where
  755.     validate v = do
  756.         results <- sequence [
  757.             ]
  758.         return $ catMaybes results
  759. instance Validatable E10 where
  760.     validate v = do
  761.         results <- sequence [
  762.                 checkResult "E10.name nonEmpty" (nonEmpty $ e10Name v)            ]
  763.         return $ catMaybes results
  764. instance Validatable E10E18 where
  765.     validate v = do
  766.         results <- sequence [
  767.                 checkResult "E10E18.name nonEmpty" (nonEmpty $ e10E18Name v)            ]
  768.         return $ catMaybes results
  769. instance Validatable E10E18E8 where
  770.     validate v = do
  771.         results <- sequence [
  772.             ]
  773.         return $ catMaybes results
  774. instance Validatable E11Piece where
  775.     validate v = do
  776.         results <- sequence [
  777.                 checkResult "E11Piece.name nonEmpty" (nonEmpty $ e11PieceName v)            ]
  778.         return $ catMaybes results
  779. instance Validatable E11E18 where
  780.     validate v = do
  781.         results <- sequence [
  782.                 checkResult "E11E18.name nonEmpty" (nonEmpty $ e11E18Name v)            ]
  783.         return $ catMaybes results
  784. instance Validatable E11E18E8 where
  785.     validate v = do
  786.         results <- sequence [
  787.             ]
  788.         return $ catMaybes results
  789. instance Validatable E25E18 where
  790.     validate v = do
  791.         results <- sequence [
  792.                 checkResult "E25E18.name nonEmpty" (nonEmpty $ e25E18Name v)            ]
  793.         return $ catMaybes results
  794. instance Validatable E25E18E8 where
  795.     validate v = do
  796.         results <- sequence [
  797.             ]
  798.         return $ catMaybes results
  799. instance Validatable E21E18 where
  800.     validate v = do
  801.         results <- sequence [
  802.                 checkResult "E21E18.name nonEmpty" (nonEmpty $ e21E18Name v)            ]
  803.         return $ catMaybes results
  804. instance Validatable E16 where
  805.     validate v = do
  806.         results <- sequence [
  807.                 checkResult "E16.name nonEmpty" (nonEmpty $ e16Name v)            ]
  808.         return $ catMaybes results
  809. instance Validatable E16E8 where
  810.     validate v = do
  811.         results <- sequence [
  812.             ]
  813.         return $ catMaybes results
  814. instance Validatable E13 where
  815.     validate v = do
  816.         results <- sequence [
  817.                 checkResult "E13.name nonEmpty" (nonEmpty $ e13Name v)            ]
  818.         return $ catMaybes results
  819. instance Validatable E13E18 where
  820.     validate v = do
  821.         results <- sequence [
  822.                 checkResult "E13E18.name nonEmpty" (nonEmpty $ e13E18Name v)            ]
  823.         return $ catMaybes results
  824. instance Validatable E13E18E8 where
  825.     validate v = do
  826.         results <- sequence [
  827.             ]
  828.         return $ catMaybes results
  829. instance Validatable E14 where
  830.     validate v = do
  831.         results <- sequence [
  832.                 checkResult "E14.name nonEmpty" (nonEmpty $ e14Name v)            ]
  833.         return $ catMaybes results
  834. instance Validatable E14E8 where
  835.     validate v = do
  836.         results <- sequence [
  837.             ]
  838.         return $ catMaybes results
  839. instance Validatable E26 where
  840.     validate v = do
  841.         results <- sequence [
  842.                 checkResult "E26.name nonEmpty" (nonEmpty $ e26Name v)            ]
  843.         return $ catMaybes results
  844. instance Validatable E26E7 where
  845.     validate v = do
  846.         results <- sequence [
  847.                 checkResult "E26E7.name nonEmpty" (nonEmpty $ e26E7Name v)            ]
  848.         return $ catMaybes results
  849. instance Validatable E26E7E8 where
  850.     validate v = do
  851.         results <- sequence [
  852.             ]
  853.         return $ catMaybes results
  854. instance Validatable E26BannedE9 where
  855.     validate v = do
  856.         results <- sequence [
  857.             ]
  858.         return $ catMaybes results
  859. instance Validatable E28 where
  860.     validate v = do
  861.         results <- sequence [
  862.                 checkResult "E28.name nonEmpty" (nonEmpty $ e28Name v)            ]
  863.         return $ catMaybes results
  864. instance Validatable E26Contract where
  865.     validate v = do
  866.         results <- sequence [
  867.             ]
  868.         return $ catMaybes results
  869. instance Validatable E12 where
  870.     validate v = do
  871.         results <- sequence [
  872.             ]
  873.         return $ catMaybes results
  874. instance Validatable E12E12 where
  875.     validate v = do
  876.         results <- sequence [
  877.             ]
  878.         return $ catMaybes results
  879. instance Validatable E12E12E34 where
  880.     validate v = do
  881.         results <- sequence [
  882.             ]
  883.         return $ catMaybes results
  884. instance Validatable E19 where
  885.     validate v = do
  886.         results <- sequence [
  887.                 checkResult "E19.name nonEmpty" (nonEmpty $ e19Name v)            ]
  888.         return $ catMaybes results
  889. instance Validatable E19E8 where
  890.     validate v = do
  891.         results <- sequence [
  892.             ]
  893.         return $ catMaybes results
  894. instance Validatable E20 where
  895.     validate v = do
  896.         results <- sequence [
  897.                 checkResult "E20.name nonEmpty" (nonEmpty $ e20Name v)            ]
  898.         return $ catMaybes results
  899. instance Validatable E20Number where
  900.     validate v = do
  901.         results <- sequence [
  902.                 checkResult "E20Number.name nonEmpty" (nonEmpty $ e20NumberName v)            ]
  903.         return $ catMaybes results
  904. instance Validatable E16E12 where
  905.     validate v = do
  906.         results <- sequence [
  907.             ]
  908.         return $ catMaybes results
  909. instance Validatable E12E16E12 where
  910.     validate v = do
  911.         results <- sequence [
  912.             ]
  913.         return $ catMaybes results
  914. instance Validatable E10E11 where
  915.     validate v = do
  916.         results <- sequence [
  917.             ]
  918.         return $ catMaybes results
  919. instance Validatable E12E10E11 where
  920.     validate v = do
  921.         results <- sequence [
  922.             ]
  923.         return $ catMaybes results
  924. instance ToJSON Day where
  925.     toJSON = toJSON . show
  926.  
  927. instance FromJSON Day where
  928.     parseJSON x = do
  929.         s <- parseJSON x
  930.         case reads s of
  931.             (d, _):_ -> return d
  932.             [] -> mzero
  933.  
  934. instance ToJSON TimeOfDay where
  935.     toJSON = toJSON . show
  936.  
  937. instance FromJSON TimeOfDay where
  938.     parseJSON x = do
  939.         s <- parseJSON x
  940.         case reads s of
  941.             (d, _):_ -> return d
  942.             [] -> mzero
  943. getE10sR :: forall master. (GeneratedValidation master,
  944.     YesodAuthPersist master,
  945.     YesodPersistBackend master ~ SqlPersistT)
  946.     => HandlerT Generated (HandlerT master IO) A.Value
  947. getE10sR  = do
  948.     authId <- lift $ requireAuthId
  949.     defaultFilterParam <- lookupGetParam "filter"
  950.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  951.     defaultSortParam <- lookupGetParam "sort"
  952.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  953.     defaultOffsetParam <- lookupGetParam "start"
  954.     defaultLimitParam <- lookupGetParam "limit"
  955.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  956.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  957.     filterParam_e10E18Id <- lookupGetParam "e10E18Id"
  958.     filterParam_query <- lookupGetParam "query"
  959.     let baseQuery limitOffsetOrder = from $ \(s ) -> do
  960.         let sId' = s ^. E10Id
  961.  
  962.        _ <- if limitOffsetOrder
  963.            then do
  964.                offset 0
  965.                limit 1000
  966.                case defaultSortJson of
  967.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  968.                            "e31" -> case (sortJsonMsg_direction sjm) of
  969.                                "ASC"  -> orderBy [ asc (s ^. E10E31) ]
  970.                                "DESC" -> orderBy [ desc (s ^. E10E31) ]
  971.                                _      -> return ()
  972.                            "aaaId" -> case (sortJsonMsg_direction sjm) of
  973.                                "ASC"  -> orderBy [ asc (s ^. E10AaaId) ]
  974.                                "DESC" -> orderBy [ desc (s ^. E10AaaId) ]
  975.                                _      -> return ()
  976.                            "name" -> case (sortJsonMsg_direction sjm) of
  977.                                "ASC"  -> orderBy [ asc (s ^. E10Name) ]
  978.                                "DESC" -> orderBy [ desc (s ^. E10Name) ]
  979.                                _      -> return ()
  980.                            "version" -> case (sortJsonMsg_direction sjm) of
  981.                                "ASC"  -> orderBy [ asc (s ^. E10Version) ]
  982.                                "DESC" -> orderBy [ desc (s ^. E10Version) ]
  983.                                _      -> return ()
  984.                            "e30d" -> case (sortJsonMsg_direction sjm) of
  985.                                "ASC"  -> orderBy [ asc (s ^. E10E30d) ]
  986.                                "DESC" -> orderBy [ desc (s ^. E10E30d) ]
  987.                                _      -> return ()
  988.                            "e311" -> case (sortJsonMsg_direction sjm) of
  989.                                "ASC"  -> orderBy [ asc (s ^. E10E311) ]
  990.                                "DESC" -> orderBy [ desc (s ^. E10E311) ]
  991.                                _      -> return ()
  992.                            "e312" -> case (sortJsonMsg_direction sjm) of
  993.                                "ASC"  -> orderBy [ asc (s ^. E10E312) ]
  994.                                "DESC" -> orderBy [ desc (s ^. E10E312) ]
  995.                                _      -> return ()
  996.                            "e313" -> case (sortJsonMsg_direction sjm) of
  997.                                "ASC"  -> orderBy [ asc (s ^. E10E313) ]
  998.                                "DESC" -> orderBy [ desc (s ^. E10E313) ]
  999.                                _      -> return ()
  1000.                
  1001.                            _ -> return ()
  1002.                        ) xs
  1003.                    Nothing -> orderBy [ asc (s ^. E10Name) ]
  1004.  
  1005.                case defaultOffset of
  1006.                    Just o -> offset o
  1007.                    Nothing -> return ()
  1008.                case defaultLimit of
  1009.                    Just l -> limit (min 10000 l)
  1010.                    Nothing -> return ()
  1011.                
  1012.            else return ()
  1013.        case defaultFilterJson of
  1014.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1015.                "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1016.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E31) (val v)
  1017.                    _        -> return ()
  1018.                "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1019.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10AaaId) (val v)
  1020.                    _        -> return ()
  1021.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1022.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Name) (val v)
  1023.                    _        -> return ()
  1024.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1025.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Version) (val (Just v))
  1026.                    _        -> return ()
  1027.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1028.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E30d) (val v)
  1029.                    _        -> return ()
  1030.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1031.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E311) (val (Just v))
  1032.                    _        -> return ()
  1033.                "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1034.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E312) (val v)
  1035.                    _        -> return ()
  1036.                "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1037.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E313) (val (Just v))
  1038.                    _        -> return ()
  1039.  
  1040.                _ -> return ()
  1041.                ) xs
  1042.            Nothing -> return ()  
  1043.        case getDefaultFilter filterParam_e10E18Id defaultFilterJson "e10E18Id" of
  1044.            Just localParam -> from $ \(sci) -> do
  1045.  
  1046.                where_ ((s ^. E10Id) ==. (sci ^. E10E18E8E10Id))
  1047.  
  1048.                where_ $ (sci ^. E10E18E8E10E18Id) ==. ((val localParam))
  1049.            Nothing -> return ()
  1050.        case getDefaultFilter filterParam_query defaultFilterJson "query" of
  1051.            Just localParam -> do
  1052.  
  1053.                where_ $ (s ^. E10Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  1054.            Nothing -> return ()
  1055.        return (s ^. E10Id, s ^. E10E31, s ^. E10AaaId, s ^. E10Name, s ^. E10Version, s ^. E10E30d, s ^. E10E311, s ^. E10E312, s ^. E10E313)
  1056.    count <- lift $ runDB $ select $ do
  1057.        baseQuery False
  1058.        let countRows' = countRows
  1059.         orderBy []
  1060.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1061.    results <- lift $ runDB $ select $ baseQuery True
  1062.    return $ A.object [
  1063.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1064.        "result" .= (toJSON $ map (\row -> case row of
  1065.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9)) -> A.object [
  1066.                    "id" .= toJSON f1,
  1067.                    "e31" .= toJSON f2,
  1068.                    "aaaId" .= toJSON f3,
  1069.                    "name" .= toJSON f4,
  1070.                    "version" .= toJSON f5,
  1071.                    "e30d" .= toJSON f6,
  1072.                    "e311" .= toJSON f7,
  1073.                    "e312" .= toJSON f8,
  1074.                    "e313" .= toJSON f9                                    
  1075.                    ]
  1076.                _ -> A.object []
  1077.            ) results)
  1078.       ]
  1079. postE10sR :: forall master. (GeneratedValidation master,
  1080.    YesodAuthPersist master,
  1081.    YesodPersistBackend master ~ SqlPersistT)
  1082.    => HandlerT Generated (HandlerT master IO) A.Value
  1083. postE10sR  = do
  1084.    authId <- lift $ requireAuthId
  1085.    yReq <- getRequest
  1086.    let wReq = reqWaiRequest yReq
  1087.    bss <- liftIO $ runResourceT $ lazyConsume $ W.requestBody wReq
  1088.    jsonBody <- case AP.eitherResult $ AP.parse A.json (B.concat bss) of
  1089.         Left err -> sendResponseStatus status400 $ A.object [ "message" .= ( "Could not decode JSON object from request body : " ++ err) ]
  1090.         Right o -> return o
  1091.    jsonBodyObj <- case jsonBody of
  1092.        A.Object o -> return o
  1093.        v -> sendResponseStatus status400 $ A.object [ "message" .= ("Expected JSON object in the request body, got: " ++ show v) ]
  1094.    e1 <- case A.fromJSON jsonBody of
  1095.        A.Success e -> return e
  1096.        A.Error err -> sendResponseStatus status400 ("Could not decode an entity of type E10 from JSON object in the request body : " ++ err )
  1097.    _ <- lift $ runDB $ do
  1098.        vErrors <- lift $ validate e1
  1099.        case vErrors of
  1100.            xs@(_:_) -> sendResponseStatus status400 (A.object [
  1101.                        "message" .= ("Entity validation failed" :: Text),
  1102.                        "errors" .= toJSON xs
  1103.                    ])
  1104.            _ -> P.insert (e1 :: E10)
  1105.    return $ A.Null
  1106. getE10sE10IdR :: forall master. (GeneratedValidation master,
  1107.    YesodAuthPersist master,
  1108.    YesodPersistBackend master ~ SqlPersistT)
  1109.    => E10Id -> HandlerT Generated (HandlerT master IO) A.Value
  1110. getE10sE10IdR p1 = do
  1111.    authId <- lift $ requireAuthId
  1112.    let baseQuery limitOffsetOrder = from $ \(s ) -> do
  1113.        let sId' = s ^. E10Id
  1114.         where_ ((s ^. E10Id) ==. ((val p1)))
  1115.  
  1116.         _ <- if limitOffsetOrder
  1117.             then do
  1118.                 offset 0
  1119.                 limit 10000
  1120.  
  1121.                  
  1122.             else return ()
  1123.         return (s ^. E10E31, s ^. E10AaaId, s ^. E10Name, s ^. E10Version, s ^. E10E30d, s ^. E10E311, s ^. E10E312, s ^. E10E313)
  1124.     count <- lift $ runDB $ select $ do
  1125.         baseQuery False
  1126.         let countRows' = countRows
  1127.        orderBy []
  1128.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1129.     results <- lift $ runDB $ select $ baseQuery True
  1130.     return $ A.object [
  1131.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1132.         "result" .= (toJSON $ map (\row -> case row of
  1133.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
  1134.                     "e31" .= toJSON f1,
  1135.                     "aaaId" .= toJSON f2,
  1136.                     "name" .= toJSON f3,
  1137.                     "version" .= toJSON f4,
  1138.                     "e30d" .= toJSON f5,
  1139.                     "e311" .= toJSON f6,
  1140.                     "e312" .= toJSON f7,
  1141.                     "e313" .= toJSON f8                                    
  1142.                     ]
  1143.                 _ -> A.object []
  1144.             ) results)
  1145.        ]
  1146. putE10sE10IdR :: forall master. (GeneratedValidation master,
  1147.     YesodAuthPersist master,
  1148.     YesodPersistBackend master ~ SqlPersistT)
  1149.     => E10Id -> HandlerT Generated (HandlerT master IO) A.Value
  1150. putE10sE10IdR p1 = do
  1151.     authId <- lift $ requireAuthId
  1152.     yReq <- getRequest
  1153.     let wReq = reqWaiRequest yReq
  1154.     bss <- liftIO $ runResourceT $ lazyConsume $ W.requestBody wReq
  1155.     jsonBody <- case AP.eitherResult $ AP.parse A.json (B.concat bss) of
  1156.          Left err -> sendResponseStatus status400 $ A.object [ "message" .= ( "Could not decode JSON object from request body : " ++ err) ]
  1157.          Right o -> return o
  1158.     jsonBodyObj <- case jsonBody of
  1159.         A.Object o -> return o
  1160.         v -> sendResponseStatus status400 $ A.object [ "message" .= ("Expected JSON object in the request body, got: " ++ show v) ]
  1161.     e1 <- case A.fromJSON jsonBody of
  1162.         A.Success e -> return e
  1163.         A.Error err -> sendResponseStatus status400 ("Could not decode an entity of type E10 from JSON object in the request body : " ++ err )
  1164.     _ <- lift $ runDB $ do
  1165.        vErrors <- lift $ validate e1
  1166.        case vErrors of
  1167.             xs@(_:_) -> sendResponseStatus status400 (A.object [
  1168.                         "message" .= ("Entity validation failed" :: Text),
  1169.                         "errors" .= toJSON xs
  1170.                     ])
  1171.             _ -> P.repsert p1 (e1 :: E10)
  1172.     return $ A.Null
  1173. deleteE10sE10IdR :: forall master. (GeneratedValidation master,
  1174.     YesodAuthPersist master,
  1175.     YesodPersistBackend master ~ SqlPersistT)
  1176.     => E10Id -> HandlerT Generated (HandlerT master IO) A.Value
  1177. deleteE10sE10IdR p1 = do
  1178.     authId <- lift $ requireAuthId
  1179.     _ <- lift $ runDB $ do
  1180.         delete $ from $ (\s -> where_ $ (s ^. E10Id) ==. ((val p1)))
  1181.     return $ A.Null
  1182. getE10e33R :: forall master. (GeneratedValidation master,
  1183.     YesodAuthPersist master,
  1184.     YesodPersistBackend master ~ SqlPersistT)
  1185.     => HandlerT Generated (HandlerT master IO) A.Value
  1186. getE10e33R  = do
  1187.     authId <- lift $ requireAuthId
  1188.     defaultFilterParam <- lookupGetParam "filter"
  1189.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  1190.     defaultSortParam <- lookupGetParam "sort"
  1191.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  1192.     defaultOffsetParam <- lookupGetParam "start"
  1193.     defaultLimitParam <- lookupGetParam "limit"
  1194.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  1195.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  1196.     filterParam_query <- lookupGetParam "query"
  1197.     let baseQuery limitOffsetOrder = from $ \(s ) -> do
  1198.         let sId' = s ^. E10E18Id
  1199.  
  1200.        _ <- if limitOffsetOrder
  1201.            then do
  1202.                offset 0
  1203.                limit 10000
  1204.                case defaultSortJson of
  1205.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  1206.                            "name" -> case (sortJsonMsg_direction sjm) of
  1207.                                "ASC"  -> orderBy [ asc (s ^. E10E18Name) ]
  1208.                                "DESC" -> orderBy [ desc (s ^. E10E18Name) ]
  1209.                                _      -> return ()
  1210.                            "version" -> case (sortJsonMsg_direction sjm) of
  1211.                                "ASC"  -> orderBy [ asc (s ^. E10E18Version) ]
  1212.                                "DESC" -> orderBy [ desc (s ^. E10E18Version) ]
  1213.                                _      -> return ()
  1214.                            "e30d" -> case (sortJsonMsg_direction sjm) of
  1215.                                "ASC"  -> orderBy [ asc (s ^. E10E18E30d) ]
  1216.                                "DESC" -> orderBy [ desc (s ^. E10E18E30d) ]
  1217.                                _      -> return ()
  1218.                            "e311" -> case (sortJsonMsg_direction sjm) of
  1219.                                "ASC"  -> orderBy [ asc (s ^. E10E18E311) ]
  1220.                                "DESC" -> orderBy [ desc (s ^. E10E18E311) ]
  1221.                                _      -> return ()
  1222.                
  1223.                            _ -> return ()
  1224.                        ) xs
  1225.                    Nothing -> orderBy [ asc (s ^. E10E18Name) ]
  1226.  
  1227.                case defaultOffset of
  1228.                    Just o -> offset o
  1229.                    Nothing -> return ()
  1230.                case defaultLimit of
  1231.                    Just l -> limit (min 10000 l)
  1232.                    Nothing -> return ()
  1233.                
  1234.            else return ()
  1235.        case defaultFilterJson of
  1236.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1237.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1238.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18Name) (val v)
  1239.                    _        -> return ()
  1240.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1241.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18Version) (val (Just v))
  1242.                    _        -> return ()
  1243.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1244.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18E30d) (val v)
  1245.                    _        -> return ()
  1246.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1247.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E18E311) (val (Just v))
  1248.                    _        -> return ()
  1249.  
  1250.                _ -> return ()
  1251.                ) xs
  1252.            Nothing -> return ()  
  1253.        case getDefaultFilter filterParam_query defaultFilterJson "query" of
  1254.            Just localParam -> do
  1255.  
  1256.                where_ $ (s ^. E10E18Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  1257.            Nothing -> return ()
  1258.        return (s ^. E10E18Id, s ^. E10E18Name, s ^. E10E18Version, s ^. E10E18E30d, s ^. E10E18E311)
  1259.    count <- lift $ runDB $ select $ do
  1260.        baseQuery False
  1261.        let countRows' = countRows
  1262.         orderBy []
  1263.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1264.    results <- lift $ runDB $ select $ baseQuery True
  1265.    return $ A.object [
  1266.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1267.        "result" .= (toJSON $ map (\row -> case row of
  1268.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
  1269.                    "id" .= toJSON f1,
  1270.                    "name" .= toJSON f2,
  1271.                    "version" .= toJSON f3,
  1272.                    "e30d" .= toJSON f4,
  1273.                    "e311" .= toJSON f5                                    
  1274.                    ]
  1275.                _ -> A.object []
  1276.            ) results)
  1277.       ]
  1278. getE11piecesR :: forall master. (GeneratedValidation master,
  1279.    YesodAuthPersist master,
  1280.    YesodPersistBackend master ~ SqlPersistT)
  1281.    => HandlerT Generated (HandlerT master IO) A.Value
  1282. getE11piecesR  = do
  1283.    authId <- lift $ requireAuthId
  1284.    defaultFilterParam <- lookupGetParam "filter"
  1285.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  1286.    defaultSortParam <- lookupGetParam "sort"
  1287.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  1288.    defaultOffsetParam <- lookupGetParam "start"
  1289.    defaultLimitParam <- lookupGetParam "limit"
  1290.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  1291.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  1292.    filterParam_e11E18Id <- lookupGetParam "e11E18Id"
  1293.    filterParam_query <- lookupGetParam "query"
  1294.    let baseQuery limitOffsetOrder = from $ \(m ) -> do
  1295.        let mId' = m ^. E11PieceId
  1296.  
  1297.         _ <- if limitOffsetOrder
  1298.             then do
  1299.                 offset 0
  1300.                 limit 10000
  1301.                 case defaultSortJson of
  1302.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  1303.                             "a" -> case (sortJsonMsg_direction sjm) of
  1304.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceA) ]
  1305.                                 "DESC" -> orderBy [ desc (m ^. E11PieceA) ]
  1306.                                 _      -> return ()
  1307.                             "c" -> case (sortJsonMsg_direction sjm) of
  1308.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceC) ]
  1309.                                 "DESC" -> orderBy [ desc (m ^. E11PieceC) ]
  1310.                                 _      -> return ()
  1311.                             "dc" -> case (sortJsonMsg_direction sjm) of
  1312.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceDc) ]
  1313.                                 "DESC" -> orderBy [ desc (m ^. E11PieceDc) ]
  1314.                                 _      -> return ()
  1315.                             "t" -> case (sortJsonMsg_direction sjm) of
  1316.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceT) ]
  1317.                                 "DESC" -> orderBy [ desc (m ^. E11PieceT) ]
  1318.                                 _      -> return ()
  1319.                             "aaaId" -> case (sortJsonMsg_direction sjm) of
  1320.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceAaaId) ]
  1321.                                 "DESC" -> orderBy [ desc (m ^. E11PieceAaaId) ]
  1322.                                 _      -> return ()
  1323.                             "mS" -> case (sortJsonMsg_direction sjm) of
  1324.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceMS) ]
  1325.                                 "DESC" -> orderBy [ desc (m ^. E11PieceMS) ]
  1326.                                 _      -> return ()
  1327.                             "fS" -> case (sortJsonMsg_direction sjm) of
  1328.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceFS) ]
  1329.                                 "DESC" -> orderBy [ desc (m ^. E11PieceFS) ]
  1330.                                 _      -> return ()
  1331.                             "name" -> case (sortJsonMsg_direction sjm) of
  1332.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceName) ]
  1333.                                 "DESC" -> orderBy [ desc (m ^. E11PieceName) ]
  1334.                                 _      -> return ()
  1335.                             "version" -> case (sortJsonMsg_direction sjm) of
  1336.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceVersion) ]
  1337.                                 "DESC" -> orderBy [ desc (m ^. E11PieceVersion) ]
  1338.                                 _      -> return ()
  1339.                             "e30d" -> case (sortJsonMsg_direction sjm) of
  1340.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceE30d) ]
  1341.                                 "DESC" -> orderBy [ desc (m ^. E11PieceE30d) ]
  1342.                                 _      -> return ()
  1343.                             "e311" -> case (sortJsonMsg_direction sjm) of
  1344.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceE311) ]
  1345.                                 "DESC" -> orderBy [ desc (m ^. E11PieceE311) ]
  1346.                                 _      -> return ()
  1347.                             "e312" -> case (sortJsonMsg_direction sjm) of
  1348.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceE312) ]
  1349.                                 "DESC" -> orderBy [ desc (m ^. E11PieceE312) ]
  1350.                                 _      -> return ()
  1351.                             "e313" -> case (sortJsonMsg_direction sjm) of
  1352.                                 "ASC"  -> orderBy [ asc (m ^. E11PieceE313) ]
  1353.                                 "DESC" -> orderBy [ desc (m ^. E11PieceE313) ]
  1354.                                 _      -> return ()
  1355.                
  1356.                             _ -> return ()
  1357.                         ) xs
  1358.                     Nothing -> orderBy [ asc (m ^. E11PieceName) ]
  1359.  
  1360.                 case defaultOffset of
  1361.                     Just o -> offset o
  1362.                     Nothing -> return ()
  1363.                 case defaultLimit of
  1364.                     Just l -> limit (min 10000 l)
  1365.                     Nothing -> return ()
  1366.                  
  1367.             else return ()
  1368.         case defaultFilterJson of
  1369.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1370.                 "a" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1371.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceA) (val v)
  1372.                     _        -> return ()
  1373.                 "c" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1374.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceC) (val v)
  1375.                     _        -> return ()
  1376.                 "dc" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1377.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceDc) (val v)
  1378.                     _        -> return ()
  1379.                 "t" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1380.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceT) (val v)
  1381.                     _        -> return ()
  1382.                 "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1383.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceAaaId) (val v)
  1384.                     _        -> return ()
  1385.                 "mS" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1386.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceMS) (val v)
  1387.                     _        -> return ()
  1388.                 "fS" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1389.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceFS) (val v)
  1390.                     _        -> return ()
  1391.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1392.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceName) (val v)
  1393.                     _        -> return ()
  1394.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1395.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceVersion) (val (Just v))
  1396.                     _        -> return ()
  1397.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1398.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE30d) (val v)
  1399.                     _        -> return ()
  1400.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1401.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE311) (val (Just v))
  1402.                     _        -> return ()
  1403.                 "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1404.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE312) (val v)
  1405.                     _        -> return ()
  1406.                 "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1407.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (m ^. E11PieceE313) (val (Just v))
  1408.                     _        -> return ()
  1409.  
  1410.                 _ -> return ()
  1411.                 ) xs
  1412.             Nothing -> return ()  
  1413.         case getDefaultFilter filterParam_e11E18Id defaultFilterJson "e11E18Id" of
  1414.             Just localParam -> from $ \(mci) -> do
  1415.  
  1416.                 where_ ((m ^. E11PieceId) ==. (mci ^. E11E18E8E11PieceId))
  1417.  
  1418.                 where_ $ (mci ^. E11E18E8E11E18Id) ==. ((val localParam))
  1419.             Nothing -> return ()
  1420.         case getDefaultFilter filterParam_query defaultFilterJson "query" of
  1421.             Just localParam -> do
  1422.  
  1423.                 where_ $ (m ^. E11PieceName) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  1424.             Nothing -> return ()
  1425.         return (m ^. E11PieceId, m ^. E11PieceA, m ^. E11PieceC, m ^. E11PieceDc, m ^. E11PieceT, m ^. E11PieceAaaId, m ^. E11PieceMS, m ^. E11PieceFS, m ^. E11PieceName, m ^. E11PieceVersion, m ^. E11PieceE30d, m ^. E11PieceE311, m ^. E11PieceE312, m ^. E11PieceE313)
  1426.     count <- lift $ runDB $ select $ do
  1427.         baseQuery False
  1428.         let countRows' = countRows
  1429.        orderBy []
  1430.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1431.     results <- lift $ runDB $ select $ baseQuery True
  1432.     return $ A.object [
  1433.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1434.         "result" .= (toJSON $ map (\row -> case row of
  1435.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9), (Database.Esqueleto.Value f10), (Database.Esqueleto.Value f11), (Database.Esqueleto.Value f12), (Database.Esqueleto.Value f13), (Database.Esqueleto.Value f14)) -> A.object [
  1436.                     "id" .= toJSON f1,
  1437.                     "a" .= toJSON f2,
  1438.                     "c" .= toJSON f3,
  1439.                     "dc" .= toJSON f4,
  1440.                     "t" .= toJSON f5,
  1441.                     "aaaId" .= toJSON f6,
  1442.                     "mS" .= toJSON f7,
  1443.                     "fS" .= toJSON f8,
  1444.                     "name" .= toJSON f9,
  1445.                     "version" .= toJSON f10,
  1446.                     "e30d" .= toJSON f11,
  1447.                     "e311" .= toJSON f12,
  1448.                     "e312" .= toJSON f13,
  1449.                     "e313" .= toJSON f14                                    
  1450.                     ]
  1451.                 _ -> A.object []
  1452.             ) results)
  1453.        ]
  1454. getE11e33R :: forall master. (GeneratedValidation master,
  1455.     YesodAuthPersist master,
  1456.     YesodPersistBackend master ~ SqlPersistT)
  1457.     => HandlerT Generated (HandlerT master IO) A.Value
  1458. getE11e33R  = do
  1459.     authId <- lift $ requireAuthId
  1460.     defaultFilterParam <- lookupGetParam "filter"
  1461.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  1462.     defaultSortParam <- lookupGetParam "sort"
  1463.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  1464.     defaultOffsetParam <- lookupGetParam "start"
  1465.     defaultLimitParam <- lookupGetParam "limit"
  1466.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  1467.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  1468.     filterParam_query <- lookupGetParam "query"
  1469.     let baseQuery limitOffsetOrder = from $ \(c ) -> do
  1470.         let cId' = c ^. E11E18Id
  1471.  
  1472.        _ <- if limitOffsetOrder
  1473.            then do
  1474.                offset 0
  1475.                limit 10000
  1476.                case defaultSortJson of
  1477.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  1478.                            "e31" -> case (sortJsonMsg_direction sjm) of
  1479.                                "ASC"  -> orderBy [ asc (c ^. E11E18E31) ]
  1480.                                "DESC" -> orderBy [ desc (c ^. E11E18E31) ]
  1481.                                _      -> return ()
  1482.                            "readOnly" -> case (sortJsonMsg_direction sjm) of
  1483.                                "ASC"  -> orderBy [ asc (c ^. E11E18ReadOnly) ]
  1484.                                "DESC" -> orderBy [ desc (c ^. E11E18ReadOnly) ]
  1485.                                _      -> return ()
  1486.                            "lf" -> case (sortJsonMsg_direction sjm) of
  1487.                                "ASC"  -> orderBy [ asc (c ^. E11E18Lf) ]
  1488.                                "DESC" -> orderBy [ desc (c ^. E11E18Lf) ]
  1489.                                _      -> return ()
  1490.                            "smallE18" -> case (sortJsonMsg_direction sjm) of
  1491.                                "ASC"  -> orderBy [ asc (c ^. E11E18SmallE18) ]
  1492.                                "DESC" -> orderBy [ desc (c ^. E11E18SmallE18) ]
  1493.                                _      -> return ()
  1494.                            "name" -> case (sortJsonMsg_direction sjm) of
  1495.                                "ASC"  -> orderBy [ asc (c ^. E11E18Name) ]
  1496.                                "DESC" -> orderBy [ desc (c ^. E11E18Name) ]
  1497.                                _      -> return ()
  1498.                            "version" -> case (sortJsonMsg_direction sjm) of
  1499.                                "ASC"  -> orderBy [ asc (c ^. E11E18Version) ]
  1500.                                "DESC" -> orderBy [ desc (c ^. E11E18Version) ]
  1501.                                _      -> return ()
  1502.                            "e30d" -> case (sortJsonMsg_direction sjm) of
  1503.                                "ASC"  -> orderBy [ asc (c ^. E11E18E30d) ]
  1504.                                "DESC" -> orderBy [ desc (c ^. E11E18E30d) ]
  1505.                                _      -> return ()
  1506.                            "e311" -> case (sortJsonMsg_direction sjm) of
  1507.                                "ASC"  -> orderBy [ asc (c ^. E11E18E311) ]
  1508.                                "DESC" -> orderBy [ desc (c ^. E11E18E311) ]
  1509.                                _      -> return ()
  1510.                
  1511.                            _ -> return ()
  1512.                        ) xs
  1513.                    Nothing -> orderBy [ asc (c ^. E11E18Name) ]
  1514.  
  1515.                case defaultOffset of
  1516.                    Just o -> offset o
  1517.                    Nothing -> return ()
  1518.                case defaultLimit of
  1519.                    Just l -> limit (min 10000 l)
  1520.                    Nothing -> return ()
  1521.                
  1522.            else return ()
  1523.        case defaultFilterJson of
  1524.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1525.                "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1526.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18E31) (val v)
  1527.                    _        -> return ()
  1528.                "readOnly" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1529.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18ReadOnly) (val v)
  1530.                    _        -> return ()
  1531.                "lf" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1532.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18Lf) (val v)
  1533.                    _        -> return ()
  1534.                "smallE18" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1535.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18SmallE18) (val v)
  1536.                    _        -> return ()
  1537.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1538.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18Name) (val v)
  1539.                    _        -> return ()
  1540.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1541.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18Version) (val (Just v))
  1542.                    _        -> return ()
  1543.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1544.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18E30d) (val v)
  1545.                    _        -> return ()
  1546.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1547.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E11E18E311) (val (Just v))
  1548.                    _        -> return ()
  1549.  
  1550.                _ -> return ()
  1551.                ) xs
  1552.            Nothing -> return ()  
  1553.        case getDefaultFilter filterParam_query defaultFilterJson "query" of
  1554.            Just localParam -> do
  1555.  
  1556.                where_ $ (c ^. E11E18Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  1557.            Nothing -> return ()
  1558.        return (c ^. E11E18Id, c ^. E11E18E31, c ^. E11E18ReadOnly, c ^. E11E18Lf, c ^. E11E18SmallE18, c ^. E11E18Name, c ^. E11E18Version, c ^. E11E18E30d, c ^. E11E18E311)
  1559.    count <- lift $ runDB $ select $ do
  1560.        baseQuery False
  1561.        let countRows' = countRows
  1562.         orderBy []
  1563.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1564.    results <- lift $ runDB $ select $ baseQuery True
  1565.    return $ A.object [
  1566.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1567.        "result" .= (toJSON $ map (\row -> case row of
  1568.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9)) -> A.object [
  1569.                    "id" .= toJSON f1,
  1570.                    "e31" .= toJSON f2,
  1571.                    "readOnly" .= toJSON f3,
  1572.                    "lf" .= toJSON f4,
  1573.                    "smallE18" .= toJSON f5,
  1574.                    "name" .= toJSON f6,
  1575.                    "version" .= toJSON f7,
  1576.                    "e30d" .= toJSON f8,
  1577.                    "e311" .= toJSON f9                                    
  1578.                    ]
  1579.                _ -> A.object []
  1580.            ) results)
  1581.       ]
  1582. getE16sR :: forall master. (GeneratedValidation master,
  1583.    YesodAuthPersist master,
  1584.    YesodPersistBackend master ~ SqlPersistT)
  1585.    => HandlerT Generated (HandlerT master IO) A.Value
  1586. getE16sR  = do
  1587.    authId <- lift $ requireAuthId
  1588.    defaultFilterParam <- lookupGetParam "filter"
  1589.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  1590.    defaultSortParam <- lookupGetParam "sort"
  1591.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  1592.    defaultOffsetParam <- lookupGetParam "start"
  1593.    defaultLimitParam <- lookupGetParam "limit"
  1594.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  1595.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  1596.    filterParam_query <- lookupGetParam "query"
  1597.    let baseQuery limitOffsetOrder = from $ \(mf ) -> do
  1598.        let mfId' = mf ^. E16Id
  1599.  
  1600.         _ <- if limitOffsetOrder
  1601.             then do
  1602.                 offset 0
  1603.                 limit 10000
  1604.                 case defaultSortJson of
  1605.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  1606.                             "e31" -> case (sortJsonMsg_direction sjm) of
  1607.                                 "ASC"  -> orderBy [ asc (mf ^. E16E31) ]
  1608.                                 "DESC" -> orderBy [ desc (mf ^. E16E31) ]
  1609.                                 _      -> return ()
  1610.                             "name" -> case (sortJsonMsg_direction sjm) of
  1611.                                 "ASC"  -> orderBy [ asc (mf ^. E16Name) ]
  1612.                                 "DESC" -> orderBy [ desc (mf ^. E16Name) ]
  1613.                                 _      -> return ()
  1614.                             "version" -> case (sortJsonMsg_direction sjm) of
  1615.                                 "ASC"  -> orderBy [ asc (mf ^. E16Version) ]
  1616.                                 "DESC" -> orderBy [ desc (mf ^. E16Version) ]
  1617.                                 _      -> return ()
  1618.                             "e30d" -> case (sortJsonMsg_direction sjm) of
  1619.                                 "ASC"  -> orderBy [ asc (mf ^. E16E30d) ]
  1620.                                 "DESC" -> orderBy [ desc (mf ^. E16E30d) ]
  1621.                                 _      -> return ()
  1622.                             "e311" -> case (sortJsonMsg_direction sjm) of
  1623.                                 "ASC"  -> orderBy [ asc (mf ^. E16E311) ]
  1624.                                 "DESC" -> orderBy [ desc (mf ^. E16E311) ]
  1625.                                 _      -> return ()
  1626.                
  1627.                             _ -> return ()
  1628.                         ) xs
  1629.                     Nothing -> orderBy [ asc (mf ^. E16Name) ]
  1630.  
  1631.                 case defaultOffset of
  1632.                     Just o -> offset o
  1633.                     Nothing -> return ()
  1634.                 case defaultLimit of
  1635.                     Just l -> limit (min 10000 l)
  1636.                     Nothing -> return ()
  1637.                  
  1638.             else return ()
  1639.         case defaultFilterJson of
  1640.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1641.                 "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1642.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16E31) (val v)
  1643.                     _        -> return ()
  1644.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1645.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16Name) (val v)
  1646.                     _        -> return ()
  1647.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1648.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16Version) (val (Just v))
  1649.                     _        -> return ()
  1650.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1651.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16E30d) (val v)
  1652.                     _        -> return ()
  1653.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1654.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (mf ^. E16E311) (val (Just v))
  1655.                     _        -> return ()
  1656.  
  1657.                 _ -> return ()
  1658.                 ) xs
  1659.             Nothing -> return ()  
  1660.         case getDefaultFilter filterParam_query defaultFilterJson "query" of
  1661.             Just localParam -> do
  1662.  
  1663.                 where_ $ (mf ^. E16Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  1664.             Nothing -> return ()
  1665.         return (mf ^. E16Id, mf ^. E16E31, mf ^. E16Name, mf ^. E16Version, mf ^. E16E30d, mf ^. E16E311)
  1666.     count <- lift $ runDB $ select $ do
  1667.         baseQuery False
  1668.         let countRows' = countRows
  1669.        orderBy []
  1670.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1671.     results <- lift $ runDB $ select $ baseQuery True
  1672.     return $ A.object [
  1673.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1674.         "result" .= (toJSON $ map (\row -> case row of
  1675.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
  1676.                     "id" .= toJSON f1,
  1677.                     "e31" .= toJSON f2,
  1678.                     "name" .= toJSON f3,
  1679.                     "version" .= toJSON f4,
  1680.                     "e30d" .= toJSON f5,
  1681.                     "e311" .= toJSON f6                                    
  1682.                     ]
  1683.                 _ -> A.object []
  1684.             ) results)
  1685.        ]
  1686. getE13sR :: forall master. (GeneratedValidation master,
  1687.     YesodAuthPersist master,
  1688.     YesodPersistBackend master ~ SqlPersistT)
  1689.     => HandlerT Generated (HandlerT master IO) A.Value
  1690. getE13sR  = do
  1691.     authId <- lift $ requireAuthId
  1692.     defaultFilterParam <- lookupGetParam "filter"
  1693.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  1694.     defaultSortParam <- lookupGetParam "sort"
  1695.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  1696.     defaultOffsetParam <- lookupGetParam "start"
  1697.     defaultLimitParam <- lookupGetParam "limit"
  1698.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  1699.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  1700.     filterParam_e13E18Id <- lookupGetParam "e13E18Id"
  1701.     filterParam_query <- lookupGetParam "query"
  1702.     let baseQuery limitOffsetOrder = from $ \(a ) -> do
  1703.         let aId' = a ^. E13Id
  1704.  
  1705.        _ <- if limitOffsetOrder
  1706.            then do
  1707.                offset 0
  1708.                limit 10000
  1709.                case defaultSortJson of
  1710.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  1711.                            "aaaId" -> case (sortJsonMsg_direction sjm) of
  1712.                                "ASC"  -> orderBy [ asc (a ^. E13AaaId) ]
  1713.                                "DESC" -> orderBy [ desc (a ^. E13AaaId) ]
  1714.                                _      -> return ()
  1715.                            "name" -> case (sortJsonMsg_direction sjm) of
  1716.                                "ASC"  -> orderBy [ asc (a ^. E13Name) ]
  1717.                                "DESC" -> orderBy [ desc (a ^. E13Name) ]
  1718.                                _      -> return ()
  1719.                            "version" -> case (sortJsonMsg_direction sjm) of
  1720.                                "ASC"  -> orderBy [ asc (a ^. E13Version) ]
  1721.                                "DESC" -> orderBy [ desc (a ^. E13Version) ]
  1722.                                _      -> return ()
  1723.                            "e30d" -> case (sortJsonMsg_direction sjm) of
  1724.                                "ASC"  -> orderBy [ asc (a ^. E13E30d) ]
  1725.                                "DESC" -> orderBy [ desc (a ^. E13E30d) ]
  1726.                                _      -> return ()
  1727.                            "e311" -> case (sortJsonMsg_direction sjm) of
  1728.                                "ASC"  -> orderBy [ asc (a ^. E13E311) ]
  1729.                                "DESC" -> orderBy [ desc (a ^. E13E311) ]
  1730.                                _      -> return ()
  1731.                
  1732.                            _ -> return ()
  1733.                        ) xs
  1734.                    Nothing -> orderBy [ asc (a ^. E13Name) ]
  1735.  
  1736.                case defaultOffset of
  1737.                    Just o -> offset o
  1738.                    Nothing -> return ()
  1739.                case defaultLimit of
  1740.                    Just l -> limit (min 10000 l)
  1741.                    Nothing -> return ()
  1742.                
  1743.            else return ()
  1744.        case defaultFilterJson of
  1745.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1746.                "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1747.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13AaaId) (val v)
  1748.                    _        -> return ()
  1749.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1750.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13Name) (val v)
  1751.                    _        -> return ()
  1752.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1753.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13Version) (val (Just v))
  1754.                    _        -> return ()
  1755.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1756.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13E30d) (val v)
  1757.                    _        -> return ()
  1758.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1759.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (a ^. E13E311) (val (Just v))
  1760.                    _        -> return ()
  1761.  
  1762.                _ -> return ()
  1763.                ) xs
  1764.            Nothing -> return ()  
  1765.        case getDefaultFilter filterParam_e13E18Id defaultFilterJson "e13E18Id" of
  1766.            Just localParam -> from $ \(apci) -> do
  1767.  
  1768.                where_ ((a ^. E13Id) ==. (apci ^. E13E18E8E13Id))
  1769.  
  1770.                where_ $ (apci ^. E13E18E8E13E18Id) ==. ((val localParam))
  1771.            Nothing -> return ()
  1772.        case getDefaultFilter filterParam_query defaultFilterJson "query" of
  1773.            Just localParam -> do
  1774.  
  1775.                where_ $ (a ^. E13Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  1776.            Nothing -> return ()
  1777.        return (a ^. E13Id, a ^. E13AaaId, a ^. E13Name, a ^. E13Version, a ^. E13E30d, a ^. E13E311)
  1778.    count <- lift $ runDB $ select $ do
  1779.        baseQuery False
  1780.        let countRows' = countRows
  1781.         orderBy []
  1782.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1783.    results <- lift $ runDB $ select $ baseQuery True
  1784.    return $ A.object [
  1785.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1786.        "result" .= (toJSON $ map (\row -> case row of
  1787.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
  1788.                    "id" .= toJSON f1,
  1789.                    "aaaId" .= toJSON f2,
  1790.                    "name" .= toJSON f3,
  1791.                    "version" .= toJSON f4,
  1792.                    "e30d" .= toJSON f5,
  1793.                    "e311" .= toJSON f6                                    
  1794.                    ]
  1795.                _ -> A.object []
  1796.            ) results)
  1797.       ]
  1798. getE13e33R :: forall master. (GeneratedValidation master,
  1799.    YesodAuthPersist master,
  1800.    YesodPersistBackend master ~ SqlPersistT)
  1801.    => HandlerT Generated (HandlerT master IO) A.Value
  1802. getE13e33R  = do
  1803.    authId <- lift $ requireAuthId
  1804.    defaultFilterParam <- lookupGetParam "filter"
  1805.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  1806.    defaultSortParam <- lookupGetParam "sort"
  1807.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  1808.    defaultOffsetParam <- lookupGetParam "start"
  1809.    defaultLimitParam <- lookupGetParam "limit"
  1810.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  1811.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  1812.    filterParam_query <- lookupGetParam "query"
  1813.    let baseQuery limitOffsetOrder = from $ \(c ) -> do
  1814.        let cId' = c ^. E13E18Id
  1815.  
  1816.         _ <- if limitOffsetOrder
  1817.             then do
  1818.                 offset 0
  1819.                 limit 10000
  1820.                 case defaultSortJson of
  1821.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  1822.                             "e31" -> case (sortJsonMsg_direction sjm) of
  1823.                                 "ASC"  -> orderBy [ asc (c ^. E13E18E31) ]
  1824.                                 "DESC" -> orderBy [ desc (c ^. E13E18E31) ]
  1825.                                 _      -> return ()
  1826.                             "name" -> case (sortJsonMsg_direction sjm) of
  1827.                                 "ASC"  -> orderBy [ asc (c ^. E13E18Name) ]
  1828.                                 "DESC" -> orderBy [ desc (c ^. E13E18Name) ]
  1829.                                 _      -> return ()
  1830.                             "version" -> case (sortJsonMsg_direction sjm) of
  1831.                                 "ASC"  -> orderBy [ asc (c ^. E13E18Version) ]
  1832.                                 "DESC" -> orderBy [ desc (c ^. E13E18Version) ]
  1833.                                 _      -> return ()
  1834.                             "e30d" -> case (sortJsonMsg_direction sjm) of
  1835.                                 "ASC"  -> orderBy [ asc (c ^. E13E18E30d) ]
  1836.                                 "DESC" -> orderBy [ desc (c ^. E13E18E30d) ]
  1837.                                 _      -> return ()
  1838.                             "e311" -> case (sortJsonMsg_direction sjm) of
  1839.                                 "ASC"  -> orderBy [ asc (c ^. E13E18E311) ]
  1840.                                 "DESC" -> orderBy [ desc (c ^. E13E18E311) ]
  1841.                                 _      -> return ()
  1842.                
  1843.                             _ -> return ()
  1844.                         ) xs
  1845.                     Nothing -> orderBy [ asc (c ^. E13E18Name) ]
  1846.  
  1847.                 case defaultOffset of
  1848.                     Just o -> offset o
  1849.                     Nothing -> return ()
  1850.                 case defaultLimit of
  1851.                     Just l -> limit (min 10000 l)
  1852.                     Nothing -> return ()
  1853.                  
  1854.             else return ()
  1855.         case defaultFilterJson of
  1856.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1857.                 "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1858.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18E31) (val v)
  1859.                     _        -> return ()
  1860.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1861.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18Name) (val v)
  1862.                     _        -> return ()
  1863.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1864.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18Version) (val (Just v))
  1865.                     _        -> return ()
  1866.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1867.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18E30d) (val v)
  1868.                     _        -> return ()
  1869.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1870.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E13E18E311) (val (Just v))
  1871.                     _        -> return ()
  1872.  
  1873.                 _ -> return ()
  1874.                 ) xs
  1875.             Nothing -> return ()  
  1876.         case getDefaultFilter filterParam_query defaultFilterJson "query" of
  1877.             Just localParam -> do
  1878.  
  1879.                 where_ $ (c ^. E13E18Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  1880.             Nothing -> return ()
  1881.         return (c ^. E13E18Id, c ^. E13E18E31, c ^. E13E18Name, c ^. E13E18Version, c ^. E13E18E30d, c ^. E13E18E311)
  1882.     count <- lift $ runDB $ select $ do
  1883.         baseQuery False
  1884.         let countRows' = countRows
  1885.        orderBy []
  1886.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1887.     results <- lift $ runDB $ select $ baseQuery True
  1888.     return $ A.object [
  1889.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  1890.         "result" .= (toJSON $ map (\row -> case row of
  1891.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
  1892.                     "id" .= toJSON f1,
  1893.                     "e31" .= toJSON f2,
  1894.                     "name" .= toJSON f3,
  1895.                     "version" .= toJSON f4,
  1896.                     "e30d" .= toJSON f5,
  1897.                     "e311" .= toJSON f6                                    
  1898.                     ]
  1899.                 _ -> A.object []
  1900.             ) results)
  1901.        ]
  1902. getE14sR :: forall master. (GeneratedValidation master,
  1903.     YesodAuthPersist master,
  1904.     YesodPersistBackend master ~ SqlPersistT)
  1905.     => HandlerT Generated (HandlerT master IO) A.Value
  1906. getE14sR  = do
  1907.     authId <- lift $ requireAuthId
  1908.     defaultFilterParam <- lookupGetParam "filter"
  1909.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  1910.     defaultSortParam <- lookupGetParam "sort"
  1911.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  1912.     defaultOffsetParam <- lookupGetParam "start"
  1913.     defaultLimitParam <- lookupGetParam "limit"
  1914.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  1915.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  1916.     let baseQuery limitOffsetOrder = from $ \(r ) -> do
  1917.         let rId' = r ^. E14Id
  1918.  
  1919.        _ <- if limitOffsetOrder
  1920.            then do
  1921.                offset 0
  1922.                limit 10000
  1923.                case defaultSortJson of
  1924.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  1925.                            "e31" -> case (sortJsonMsg_direction sjm) of
  1926.                                "ASC"  -> orderBy [ asc (r ^. E14E31) ]
  1927.                                "DESC" -> orderBy [ desc (r ^. E14E31) ]
  1928.                                _      -> return ()
  1929.                            "author" -> case (sortJsonMsg_direction sjm) of
  1930.                                "ASC"  -> orderBy [ asc (r ^. E14Author) ]
  1931.                                "DESC" -> orderBy [ desc (r ^. E14Author) ]
  1932.                                _      -> return ()
  1933.                            "e29Date" -> case (sortJsonMsg_direction sjm) of
  1934.                                "ASC"  -> orderBy [ asc (r ^. E14E29Date) ]
  1935.                                "DESC" -> orderBy [ desc (r ^. E14E29Date) ]
  1936.                                _      -> return ()
  1937.                            "name" -> case (sortJsonMsg_direction sjm) of
  1938.                                "ASC"  -> orderBy [ asc (r ^. E14Name) ]
  1939.                                "DESC" -> orderBy [ desc (r ^. E14Name) ]
  1940.                                _      -> return ()
  1941.                            "version" -> case (sortJsonMsg_direction sjm) of
  1942.                                "ASC"  -> orderBy [ asc (r ^. E14Version) ]
  1943.                                "DESC" -> orderBy [ desc (r ^. E14Version) ]
  1944.                                _      -> return ()
  1945.                            "e30d" -> case (sortJsonMsg_direction sjm) of
  1946.                                "ASC"  -> orderBy [ asc (r ^. E14E30d) ]
  1947.                                "DESC" -> orderBy [ desc (r ^. E14E30d) ]
  1948.                                _      -> return ()
  1949.                            "e311" -> case (sortJsonMsg_direction sjm) of
  1950.                                "ASC"  -> orderBy [ asc (r ^. E14E311) ]
  1951.                                "DESC" -> orderBy [ desc (r ^. E14E311) ]
  1952.                                _      -> return ()
  1953.                
  1954.                            _ -> return ()
  1955.                        ) xs
  1956.                    Nothing -> orderBy [ asc (r ^. E14Name) ]
  1957.  
  1958.                case defaultOffset of
  1959.                    Just o -> offset o
  1960.                    Nothing -> return ()
  1961.                case defaultLimit of
  1962.                    Just l -> limit (min 10000 l)
  1963.                    Nothing -> return ()
  1964.                
  1965.            else return ()
  1966.        case defaultFilterJson of
  1967.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  1968.                "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1969.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E31) (val v)
  1970.                    _        -> return ()
  1971.                "author" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1972.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14Author) (val v)
  1973.                    _        -> return ()
  1974.                "e29Date" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1975.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E29Date) (val v)
  1976.                    _        -> return ()
  1977.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1978.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14Name) (val v)
  1979.                    _        -> return ()
  1980.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1981.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14Version) (val (Just v))
  1982.                    _        -> return ()
  1983.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1984.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E30d) (val v)
  1985.                    _        -> return ()
  1986.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  1987.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (r ^. E14E311) (val (Just v))
  1988.                    _        -> return ()
  1989.  
  1990.                _ -> return ()
  1991.                ) xs
  1992.            Nothing -> return ()  
  1993.        return (r ^. E14Id, r ^. E14E31, r ^. E14Author, r ^. E14E29Date, r ^. E14Name, r ^. E14Version, r ^. E14E30d, r ^. E14E311)
  1994.    count <- lift $ runDB $ select $ do
  1995.        baseQuery False
  1996.        let countRows' = countRows
  1997.         orderBy []
  1998.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  1999.    results <- lift $ runDB $ select $ baseQuery True
  2000.    return $ A.object [
  2001.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2002.        "result" .= (toJSON $ map (\row -> case row of
  2003.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
  2004.                    "id" .= toJSON f1,
  2005.                    "e31" .= toJSON f2,
  2006.                    "author" .= toJSON f3,
  2007.                    "e29Date" .= toJSON f4,
  2008.                    "name" .= toJSON f5,
  2009.                    "version" .= toJSON f6,
  2010.                    "e30d" .= toJSON f7,
  2011.                    "e311" .= toJSON f8                                    
  2012.                    ]
  2013.                _ -> A.object []
  2014.            ) results)
  2015.       ]
  2016. getE14sE14IdContentR :: forall master. (GeneratedValidation master,
  2017.    YesodAuthPersist master,
  2018.    YesodPersistBackend master ~ SqlPersistT)
  2019.    => E14Id -> HandlerT Generated (HandlerT master IO) A.Value
  2020. getE14sE14IdContentR p1 = do
  2021.    authId <- lift $ requireAuthId
  2022.    let baseQuery limitOffsetOrder = from $ \(ri ) -> do
  2023.        let riId' = ri ^. E14E8Id
  2024.         where_ ((ri ^. E14E8E14Id) ==. ((val p1)))
  2025.  
  2026.         _ <- if limitOffsetOrder
  2027.             then do
  2028.                 offset 0
  2029.                 limit 10000
  2030.  
  2031.                  
  2032.             else return ()
  2033.         return (ri ^. E14E8Id, ri ^. E14E8E11PieceE14ContentId, ri ^. E14E8E11E18E14ContentId, ri ^. E14E8E13E14ContentId, ri ^. E14E8E13E18E14ContentId, ri ^. E14E8E14Id, ri ^. E14E8Order, ri ^. E14E8E30d, ri ^. E14E8E311)
  2034.     count <- lift $ runDB $ select $ do
  2035.         baseQuery False
  2036.         let countRows' = countRows
  2037.        orderBy []
  2038.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2039.     results <- lift $ runDB $ select $ baseQuery True
  2040.     return $ A.object [
  2041.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2042.         "result" .= (toJSON $ map (\row -> case row of
  2043.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8), (Database.Esqueleto.Value f9)) -> A.object [
  2044.                     "id" .= toJSON f1,
  2045.                     "e11PieceE14ContentId" .= toJSON f2,
  2046.                     "e11E18E14ContentId" .= toJSON f3,
  2047.                     "e13E14ContentId" .= toJSON f4,
  2048.                     "e13E18E14ContentId" .= toJSON f5,
  2049.                     "e14Id" .= toJSON f6,
  2050.                     "order" .= toJSON f7,
  2051.                     "e30d" .= toJSON f8,
  2052.                     "e311" .= toJSON f9                                    
  2053.                     ]
  2054.                 _ -> A.object []
  2055.             ) results)
  2056.        ]
  2057. getE26sR :: forall master. (GeneratedValidation master,
  2058.     YesodAuthPersist master,
  2059.     YesodPersistBackend master ~ SqlPersistT)
  2060.     => HandlerT Generated (HandlerT master IO) A.Value
  2061. getE26sR  = do
  2062.     authId <- lift $ requireAuthId
  2063.     defaultFilterParam <- lookupGetParam "filter"
  2064.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  2065.     defaultSortParam <- lookupGetParam "sort"
  2066.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  2067.     defaultOffsetParam <- lookupGetParam "start"
  2068.     defaultLimitParam <- lookupGetParam "limit"
  2069.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  2070.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  2071.     filterParam_e26E7Id <- lookupGetParam "e26E7Id"
  2072.     filterParam_query <- lookupGetParam "query"
  2073.     let baseQuery limitOffsetOrder = from $ \(c ) -> do
  2074.         let cId' = c ^. E26Id
  2075.  
  2076.        _ <- if limitOffsetOrder
  2077.            then do
  2078.                offset 0
  2079.                limit 10000
  2080.                case defaultSortJson of
  2081.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  2082.                            "name" -> case (sortJsonMsg_direction sjm) of
  2083.                                "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  2084.                                "DESC" -> orderBy [ desc (c ^. E26Name) ]
  2085.                                _      -> return ()
  2086.                            "version" -> case (sortJsonMsg_direction sjm) of
  2087.                                "ASC"  -> orderBy [ asc (c ^. E26Version) ]
  2088.                                "DESC" -> orderBy [ desc (c ^. E26Version) ]
  2089.                                _      -> return ()
  2090.                            "e30d" -> case (sortJsonMsg_direction sjm) of
  2091.                                "ASC"  -> orderBy [ asc (c ^. E26E30d) ]
  2092.                                "DESC" -> orderBy [ desc (c ^. E26E30d) ]
  2093.                                _      -> return ()
  2094.                            "e311" -> case (sortJsonMsg_direction sjm) of
  2095.                                "ASC"  -> orderBy [ asc (c ^. E26E311) ]
  2096.                                "DESC" -> orderBy [ desc (c ^. E26E311) ]
  2097.                                _      -> return ()
  2098.                
  2099.                            _ -> return ()
  2100.                        ) xs
  2101.                    Nothing -> orderBy [ asc (c ^. E26Name) ]
  2102.  
  2103.                case defaultOffset of
  2104.                    Just o -> offset o
  2105.                    Nothing -> return ()
  2106.                case defaultLimit of
  2107.                    Just l -> limit (min 10000 l)
  2108.                    Nothing -> return ()
  2109.                
  2110.            else return ()
  2111.        case defaultFilterJson of
  2112.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  2113.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2114.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  2115.                    _        -> return ()
  2116.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2117.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  2118.                    _        -> return ()
  2119.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2120.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  2121.                    _        -> return ()
  2122.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2123.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  2124.                    _        -> return ()
  2125.  
  2126.                _ -> return ()
  2127.                ) xs
  2128.            Nothing -> return ()  
  2129.        case getDefaultFilter filterParam_e26E7Id defaultFilterJson "e26E7Id" of
  2130.            Just localParam -> from $ \(cgi) -> do
  2131.  
  2132.                where_ ((c ^. E26Id) ==. (cgi ^. E26E7E8E26Id))
  2133.  
  2134.                where_ $ (cgi ^. E26E7E8E26E7Id) ==. ((val localParam))
  2135.            Nothing -> return ()
  2136.        case getDefaultFilter filterParam_query defaultFilterJson "query" of
  2137.            Just localParam -> do
  2138.  
  2139.                where_ $ (c ^. E26Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  2140.            Nothing -> return ()
  2141.        return (c ^. E26Id, c ^. E26Name, c ^. E26Version, c ^. E26E30d, c ^. E26E311)
  2142.    count <- lift $ runDB $ select $ do
  2143.        baseQuery False
  2144.        let countRows' = countRows
  2145.         orderBy []
  2146.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2147.    results <- lift $ runDB $ select $ baseQuery True
  2148.    return $ A.object [
  2149.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2150.        "result" .= (toJSON $ map (\row -> case row of
  2151.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
  2152.                    "id" .= toJSON f1,
  2153.                    "name" .= toJSON f2,
  2154.                    "version" .= toJSON f3,
  2155.                    "e30d" .= toJSON f4,
  2156.                    "e311" .= toJSON f5                                    
  2157.                    ]
  2158.                _ -> A.object []
  2159.            ) results)
  2160.       ]
  2161. getE26groupsR :: forall master. (GeneratedValidation master,
  2162.    YesodAuthPersist master,
  2163.    YesodPersistBackend master ~ SqlPersistT)
  2164.    => HandlerT Generated (HandlerT master IO) A.Value
  2165. getE26groupsR  = do
  2166.    authId <- lift $ requireAuthId
  2167.    defaultFilterParam <- lookupGetParam "filter"
  2168.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  2169.    defaultSortParam <- lookupGetParam "sort"
  2170.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  2171.    defaultOffsetParam <- lookupGetParam "start"
  2172.    defaultLimitParam <- lookupGetParam "limit"
  2173.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  2174.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  2175.    filterParam_query <- lookupGetParam "query"
  2176.    let baseQuery limitOffsetOrder = from $ \(cg ) -> do
  2177.        let cgId' = cg ^. E26E7Id
  2178.  
  2179.         _ <- if limitOffsetOrder
  2180.             then do
  2181.                 offset 0
  2182.                 limit 10000
  2183.                 case defaultSortJson of
  2184.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  2185.                             "name" -> case (sortJsonMsg_direction sjm) of
  2186.                                 "ASC"  -> orderBy [ asc (cg ^. E26E7Name) ]
  2187.                                 "DESC" -> orderBy [ desc (cg ^. E26E7Name) ]
  2188.                                 _      -> return ()
  2189.                             "version" -> case (sortJsonMsg_direction sjm) of
  2190.                                 "ASC"  -> orderBy [ asc (cg ^. E26E7Version) ]
  2191.                                 "DESC" -> orderBy [ desc (cg ^. E26E7Version) ]
  2192.                                 _      -> return ()
  2193.                             "e30d" -> case (sortJsonMsg_direction sjm) of
  2194.                                 "ASC"  -> orderBy [ asc (cg ^. E26E7E30d) ]
  2195.                                 "DESC" -> orderBy [ desc (cg ^. E26E7E30d) ]
  2196.                                 _      -> return ()
  2197.                             "e311" -> case (sortJsonMsg_direction sjm) of
  2198.                                 "ASC"  -> orderBy [ asc (cg ^. E26E7E311) ]
  2199.                                 "DESC" -> orderBy [ desc (cg ^. E26E7E311) ]
  2200.                                 _      -> return ()
  2201.                
  2202.                             _ -> return ()
  2203.                         ) xs
  2204.                     Nothing -> orderBy [ asc (cg ^. E26E7Name) ]
  2205.  
  2206.                 case defaultOffset of
  2207.                     Just o -> offset o
  2208.                     Nothing -> return ()
  2209.                 case defaultLimit of
  2210.                     Just l -> limit (min 10000 l)
  2211.                     Nothing -> return ()
  2212.                  
  2213.             else return ()
  2214.         case defaultFilterJson of
  2215.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  2216.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2217.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7Name) (val v)
  2218.                     _        -> return ()
  2219.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2220.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7Version) (val (Just v))
  2221.                     _        -> return ()
  2222.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2223.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7E30d) (val v)
  2224.                     _        -> return ()
  2225.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2226.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (cg ^. E26E7E311) (val (Just v))
  2227.                     _        -> return ()
  2228.  
  2229.                 _ -> return ()
  2230.                 ) xs
  2231.             Nothing -> return ()  
  2232.         case getDefaultFilter filterParam_query defaultFilterJson "query" of
  2233.             Just localParam -> do
  2234.  
  2235.                 where_ $ (cg ^. E26E7Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  2236.             Nothing -> return ()
  2237.         return (cg ^. E26E7Id, cg ^. E26E7Name, cg ^. E26E7Version, cg ^. E26E7E30d, cg ^. E26E7E311)
  2238.     count <- lift $ runDB $ select $ do
  2239.         baseQuery False
  2240.         let countRows' = countRows
  2241.        orderBy []
  2242.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2243.     results <- lift $ runDB $ select $ baseQuery True
  2244.     return $ A.object [
  2245.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2246.         "result" .= (toJSON $ map (\row -> case row of
  2247.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
  2248.                     "id" .= toJSON f1,
  2249.                     "name" .= toJSON f2,
  2250.                     "version" .= toJSON f3,
  2251.                     "e30d" .= toJSON f4,
  2252.                     "e311" .= toJSON f5                                    
  2253.                     ]
  2254.                 _ -> A.object []
  2255.             ) results)
  2256.        ]
  2257. getE12sR :: forall master. (GeneratedValidation master,
  2258.     YesodAuthPersist master,
  2259.     YesodPersistBackend master ~ SqlPersistT)
  2260.     => HandlerT Generated (HandlerT master IO) A.Value
  2261. getE12sR  = do
  2262.     authId <- lift $ requireAuthId
  2263.     defaultFilterParam <- lookupGetParam "filter"
  2264.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  2265.     defaultSortParam <- lookupGetParam "sort"
  2266.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  2267.     defaultOffsetParam <- lookupGetParam "start"
  2268.     defaultLimitParam <- lookupGetParam "limit"
  2269.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  2270.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  2271.     filterParam_e26IdList <- lookupGetParam "e26IdList"
  2272.     filterParam_e10IdList <- lookupGetParam "e10IdList"
  2273.     filterParam_dayList <- lookupGetParam "dayList"
  2274.     filterParam_startE11List <- lookupGetParam "startE11List"
  2275.     let baseQuery limitOffsetOrder = from $ \(t  `InnerJoin` c `InnerJoin` s) -> do
  2276.         on ((t ^. E12E10Id) ==. (s ^. E10Id))
  2277.         on ((t ^. E12E26Id) ==. (c ^. E26Id))
  2278.         let tId' = t ^. E12Id
  2279.  
  2280.        _ <- if limitOffsetOrder
  2281.            then do
  2282.                offset 0
  2283.                limit 100
  2284.                case defaultSortJson of
  2285.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  2286.                            "e26Name" -> case (sortJsonMsg_direction sjm) of
  2287.                                "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  2288.                                "DESC" -> orderBy [ desc (c ^. E26Name) ]
  2289.                                _      -> return ()
  2290.                            "e10Name" -> case (sortJsonMsg_direction sjm) of
  2291.                                "ASC"  -> orderBy [ asc (s ^. E10Name) ]
  2292.                                "DESC" -> orderBy [ desc (s ^. E10Name) ]
  2293.                                _      -> return ()
  2294.                            "day" -> case (sortJsonMsg_direction sjm) of
  2295.                                "ASC"  -> orderBy [ asc (t ^. E12Day) ]
  2296.                                "DESC" -> orderBy [ desc (t ^. E12Day) ]
  2297.                                _      -> return ()
  2298.                            "startE11" -> case (sortJsonMsg_direction sjm) of
  2299.                                "ASC"  -> orderBy [ asc (t ^. E12StartE11) ]
  2300.                                "DESC" -> orderBy [ desc (t ^. E12StartE11) ]
  2301.                                _      -> return ()
  2302.                            "e314Window" -> case (sortJsonMsg_direction sjm) of
  2303.                                "ASC"  -> orderBy [ asc (t ^. E12E314Window) ]
  2304.                                "DESC" -> orderBy [ desc (t ^. E12E314Window) ]
  2305.                                _      -> return ()
  2306.                            "accurate" -> case (sortJsonMsg_direction sjm) of
  2307.                                "ASC"  -> orderBy [ asc (t ^. E12Accurate) ]
  2308.                                "DESC" -> orderBy [ desc (t ^. E12Accurate) ]
  2309.                                _      -> return ()
  2310.                            "count" -> case (sortJsonMsg_direction sjm) of
  2311.                                "ASC"  -> orderBy [ asc (t ^. E12Count) ]
  2312.                                "DESC" -> orderBy [ desc (t ^. E12Count) ]
  2313.                                _      -> return ()
  2314.                
  2315.                            _ -> return ()
  2316.                        ) xs
  2317.                    Nothing -> orderBy [ asc (t ^. E12StartE11), asc (c ^. E26Name), asc (s ^. E10Name) ]
  2318.  
  2319.                case defaultOffset of
  2320.                    Just o -> offset o
  2321.                    Nothing -> return ()
  2322.                case defaultLimit of
  2323.                    Just l -> limit (min 10000 l)
  2324.                    Nothing -> return ()
  2325.                
  2326.            else return ()
  2327.        case defaultFilterJson of
  2328.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  2329.                "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2330.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E31) (val v)
  2331.                    _        -> return ()
  2332.                "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2333.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10AaaId) (val v)
  2334.                    _        -> return ()
  2335.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2336.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Name) (val v)
  2337.                    _        -> return ()
  2338.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2339.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Version) (val (Just v))
  2340.                    _        -> return ()
  2341.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2342.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E30d) (val v)
  2343.                    _        -> return ()
  2344.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2345.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E311) (val (Just v))
  2346.                    _        -> return ()
  2347.                "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2348.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E312) (val v)
  2349.                    _        -> return ()
  2350.                "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2351.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E313) (val (Just v))
  2352.                    _        -> return ()
  2353.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2354.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  2355.                    _        -> return ()
  2356.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2357.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  2358.                    _        -> return ()
  2359.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2360.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  2361.                    _        -> return ()
  2362.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2363.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  2364.                    _        -> return ()
  2365.                "e10Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2366.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10Id) (val v)
  2367.                    _        -> return ()
  2368.                "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2369.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E26Id) (val v)
  2370.                    _        -> return ()
  2371.                "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2372.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12Day) (val v)
  2373.                    _        -> return ()
  2374.                "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2375.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12StartE11) (val v)
  2376.                    _        -> return ()
  2377.                "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2378.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E314Window) (val v)
  2379.                    _        -> return ()
  2380.                "accurate" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2381.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12Accurate) (val v)
  2382.                    _        -> return ()
  2383.                "count" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2384.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12Count) (val v)
  2385.                    _        -> return ()
  2386.  
  2387.                _ -> return ()
  2388.                ) xs
  2389.            Nothing -> return ()  
  2390.        case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
  2391.            Just localParam -> do
  2392.  
  2393.                where_ $ (c ^. E26Id) `in_` ((valList localParam))
  2394.            Nothing -> return ()
  2395.        case getDefaultFilter filterParam_e10IdList defaultFilterJson "e10IdList" of
  2396.            Just localParam -> do
  2397.  
  2398.                where_ $ (s ^. E10Id) `in_` ((valList localParam))
  2399.            Nothing -> return ()
  2400.        case getDefaultFilter filterParam_dayList defaultFilterJson "dayList" of
  2401.            Just localParam -> do
  2402.  
  2403.                where_ $ (t ^. E12Day) `in_` ((valList localParam))
  2404.            Nothing -> return ()
  2405.        case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
  2406.            Just localParam -> do
  2407.  
  2408.                where_ $ (t ^. E12StartE11) `in_` ((valList localParam))
  2409.            Nothing -> return ()
  2410.        return (t ^. E12Id, c ^. E26Name, s ^. E10Name, t ^. E12Day, t ^. E12StartE11, t ^. E12E314Window, t ^. E12Accurate, t ^. E12Count)
  2411.    count <- lift $ runDB $ select $ do
  2412.        baseQuery False
  2413.        let countRows' = countRows
  2414.         orderBy []
  2415.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2416.    results <- lift $ runDB $ select $ baseQuery True
  2417.    return $ A.object [
  2418.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2419.        "result" .= (toJSON $ map (\row -> case row of
  2420.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
  2421.                    "id" .= toJSON f1,
  2422.                    "e26Name" .= toJSON f2,
  2423.                    "e10Name" .= toJSON f3,
  2424.                    "day" .= toJSON f4,
  2425.                    "startE11" .= toJSON f5,
  2426.                    "e314Window" .= toJSON f6,
  2427.                    "accurate" .= toJSON f7,
  2428.                    "count" .= toJSON f8                                    
  2429.                    ]
  2430.                _ -> A.object []
  2431.            ) results)
  2432.       ]
  2433. deleteE12sE12IdR :: forall master. (GeneratedValidation master,
  2434.    YesodAuthPersist master,
  2435.    YesodPersistBackend master ~ SqlPersistT)
  2436.    => E12Id -> HandlerT Generated (HandlerT master IO) A.Value
  2437. deleteE12sE12IdR p1 = do
  2438.    authId <- lift $ requireAuthId
  2439.    _ <- lift $ runDB $ do
  2440.        delete $ from $ (\t -> where_ $ (t ^. E12Id) ==. ((val p1)))
  2441.    return $ A.Null
  2442. getE17e12sR :: forall master. (GeneratedValidation master,
  2443.    YesodAuthPersist master,
  2444.    YesodPersistBackend master ~ SqlPersistT)
  2445.    => HandlerT Generated (HandlerT master IO) A.Value
  2446. getE17e12sR  = do
  2447.    authId <- lift $ requireAuthId
  2448.    defaultFilterParam <- lookupGetParam "filter"
  2449.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  2450.    defaultSortParam <- lookupGetParam "sort"
  2451.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  2452.    defaultOffsetParam <- lookupGetParam "start"
  2453.    defaultLimitParam <- lookupGetParam "limit"
  2454.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  2455.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  2456.    filterParam_e26IdList <- lookupGetParam "e26IdList"
  2457.    filterParam_e10IdList <- lookupGetParam "e10IdList"
  2458.    filterParam_wdayList <- lookupGetParam "wdayList"
  2459.    let baseQuery limitOffsetOrder = from $ \(t  `InnerJoin` c `InnerJoin` s) -> do
  2460.        on ((t ^. E12E12E10Id) ==. (s ^. E10Id))
  2461.        on ((t ^. E12E12E26Id) ==. (c ^. E26Id))
  2462.        let tId' = t ^. E12E12Id
  2463.  
  2464.         _ <- if limitOffsetOrder
  2465.             then do
  2466.                 offset 0
  2467.                 limit 100
  2468.                 case defaultSortJson of
  2469.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  2470.                             "e26Name" -> case (sortJsonMsg_direction sjm) of
  2471.                                 "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  2472.                                 "DESC" -> orderBy [ desc (c ^. E26Name) ]
  2473.                                 _      -> return ()
  2474.                             "e10Name" -> case (sortJsonMsg_direction sjm) of
  2475.                                 "ASC"  -> orderBy [ asc (s ^. E10Name) ]
  2476.                                 "DESC" -> orderBy [ desc (s ^. E10Name) ]
  2477.                                 _      -> return ()
  2478.                             "wday" -> case (sortJsonMsg_direction sjm) of
  2479.                                 "ASC"  -> orderBy [ asc (t ^. E12E12Wday) ]
  2480.                                 "DESC" -> orderBy [ desc (t ^. E12E12Wday) ]
  2481.                                 _      -> return ()
  2482.                             "e314" -> case (sortJsonMsg_direction sjm) of
  2483.                                 "ASC"  -> orderBy [ asc (t ^. E12E12E314) ]
  2484.                                 "DESC" -> orderBy [ desc (t ^. E12E12E314) ]
  2485.                                 _      -> return ()
  2486.                
  2487.                             _ -> return ()
  2488.                         ) xs
  2489.                     Nothing -> orderBy [ asc (t ^. E12E12E314), asc (c ^. E26Name), asc (s ^. E10Name) ]
  2490.  
  2491.                 case defaultOffset of
  2492.                     Just o -> offset o
  2493.                     Nothing -> return ()
  2494.                 case defaultLimit of
  2495.                     Just l -> limit (min 10000 l)
  2496.                     Nothing -> return ()
  2497.                  
  2498.             else return ()
  2499.         case defaultFilterJson of
  2500.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  2501.                 "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2502.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E31) (val v)
  2503.                     _        -> return ()
  2504.                 "aaaId" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2505.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10AaaId) (val v)
  2506.                     _        -> return ()
  2507.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2508.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Name) (val v)
  2509.                     _        -> return ()
  2510.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2511.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10Version) (val (Just v))
  2512.                     _        -> return ()
  2513.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2514.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E30d) (val v)
  2515.                     _        -> return ()
  2516.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2517.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E311) (val (Just v))
  2518.                     _        -> return ()
  2519.                 "e312" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2520.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E312) (val v)
  2521.                     _        -> return ()
  2522.                 "e313" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2523.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (s ^. E10E313) (val (Just v))
  2524.                     _        -> return ()
  2525.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2526.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  2527.                     _        -> return ()
  2528.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2529.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  2530.                     _        -> return ()
  2531.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2532.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  2533.                     _        -> return ()
  2534.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2535.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  2536.                     _        -> return ()
  2537.                 "e10Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2538.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12E10Id) (val v)
  2539.                     _        -> return ()
  2540.                 "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2541.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12E26Id) (val v)
  2542.                     _        -> return ()
  2543.                 "wday" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2544.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12Wday) (val v)
  2545.                     _        -> return ()
  2546.                 "e314" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2547.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E12E314) (val v)
  2548.                     _        -> return ()
  2549.  
  2550.                 _ -> return ()
  2551.                 ) xs
  2552.             Nothing -> return ()  
  2553.         case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
  2554.             Just localParam -> do
  2555.  
  2556.                 where_ $ (c ^. E26Id) `in_` ((valList localParam))
  2557.             Nothing -> return ()
  2558.         case getDefaultFilter filterParam_e10IdList defaultFilterJson "e10IdList" of
  2559.             Just localParam -> do
  2560.  
  2561.                 where_ $ (s ^. E10Id) `in_` ((valList localParam))
  2562.             Nothing -> return ()
  2563.         case getDefaultFilter filterParam_wdayList defaultFilterJson "wdayList" of
  2564.             Just localParam -> do
  2565.  
  2566.                 where_ $ (t ^. E12E12Wday) `in_` ((valList localParam))
  2567.             Nothing -> return ()
  2568.         return (t ^. E12E12Id, c ^. E26Name, s ^. E10Name, t ^. E12E12Wday, t ^. E12E12E314)
  2569.     count <- lift $ runDB $ select $ do
  2570.         baseQuery False
  2571.         let countRows' = countRows
  2572.        orderBy []
  2573.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2574.     results <- lift $ runDB $ select $ baseQuery True
  2575.     return $ A.object [
  2576.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2577.         "result" .= (toJSON $ map (\row -> case row of
  2578.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
  2579.                     "id" .= toJSON f1,
  2580.                     "e26Name" .= toJSON f2,
  2581.                     "e10Name" .= toJSON f3,
  2582.                     "wday" .= toJSON f4,
  2583.                     "e314" .= toJSON f5                                    
  2584.                     ]
  2585.                 _ -> A.object []
  2586.             ) results)
  2587.        ]
  2588. deleteE17e12sE12E12IdR :: forall master. (GeneratedValidation master,
  2589.     YesodAuthPersist master,
  2590.     YesodPersistBackend master ~ SqlPersistT)
  2591.     => E12E12Id -> HandlerT Generated (HandlerT master IO) A.Value
  2592. deleteE17e12sE12E12IdR p1 = do
  2593.     authId <- lift $ requireAuthId
  2594.     _ <- lift $ runDB $ do
  2595.         delete $ from $ (\t -> where_ $ (t ^. E12E12Id) ==. ((val p1)))
  2596.     return $ A.Null
  2597. postE17e12sE12E12IdR :: forall master. (GeneratedValidation master,
  2598.     YesodAuthPersist master,
  2599.     YesodPersistBackend master ~ SqlPersistT)
  2600.     => E12E12Id -> HandlerT Generated (HandlerT master IO) A.Value
  2601. postE17e12sE12E12IdR p1 = do
  2602.     authId <- lift $ requireAuthId
  2603.     yReq <- getRequest
  2604.     let wReq = reqWaiRequest yReq
  2605.     bss <- liftIO $ runResourceT $ lazyConsume $ W.requestBody wReq
  2606.     jsonBody <- case AP.eitherResult $ AP.parse A.json (B.concat bss) of
  2607.          Left err -> sendResponseStatus status400 $ A.object [ "message" .= ( "Could not decode JSON object from request body : " ++ err) ]
  2608.          Right o -> return o
  2609.     jsonBodyObj <- case jsonBody of
  2610.         A.Object o -> return o
  2611.         v -> sendResponseStatus status400 $ A.object [ "message" .= ("Expected JSON object in the request body, got: " ++ show v) ]
  2612.     e1 <- case A.fromJSON jsonBody of
  2613.         A.Success e -> return e
  2614.         A.Error err -> sendResponseStatus status400 ("Could not decode an entity of type E12E12 from JSON object in the request body : " ++ err )
  2615.     _ <- lift $ runDB $ do
  2616.         vErrors <- lift $ validate e1
  2617.         case vErrors of
  2618.             xs@(_:_) -> sendResponseStatus status400 (A.object [
  2619.                         "message" .= ("Entity validation failed" :: Text),
  2620.                         "errors" .= toJSON xs
  2621.                     ])
  2622.             _ -> P.insert (e1 :: E12E12)
  2623.     return $ A.Null
  2624. getE17e12e34sR :: forall master. (GeneratedValidation master,
  2625.     YesodAuthPersist master,
  2626.     YesodPersistBackend master ~ SqlPersistT)
  2627.     => HandlerT Generated (HandlerT master IO) A.Value
  2628. getE17e12e34sR  = do
  2629.     authId <- lift $ requireAuthId
  2630.     filterParam_e26IdList <- lookupGetParam "e26IdList"
  2631.     filterParam_firstDay <- lookupGetParam "firstDay"
  2632.     filterParam_lastDay <- lookupGetParam "lastDay"
  2633.     defaultFilterParam <- lookupGetParam "filter"
  2634.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  2635.     defaultSortParam <- lookupGetParam "sort"
  2636.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  2637.     defaultOffsetParam <- lookupGetParam "start"
  2638.     defaultLimitParam <- lookupGetParam "limit"
  2639.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  2640.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  2641.     let baseQuery limitOffsetOrder = from $ \(e  `InnerJoin` c) -> do
  2642.         on ((e ^. E12E12E34E26Id) ==. (c ^. E26Id))
  2643.         let eId' = e ^. E12E12E34Id
  2644.  
  2645.        _ <- if limitOffsetOrder
  2646.            then do
  2647.                offset 0
  2648.                limit 10000
  2649.                case defaultSortJson of
  2650.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  2651.                            "day" -> case (sortJsonMsg_direction sjm) of
  2652.                                "ASC"  -> orderBy [ asc (e ^. E12E12E34Day) ]
  2653.                                "DESC" -> orderBy [ desc (e ^. E12E12E34Day) ]
  2654.                                _      -> return ()
  2655.                            "e26Name" -> case (sortJsonMsg_direction sjm) of
  2656.                                "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  2657.                                "DESC" -> orderBy [ desc (c ^. E26Name) ]
  2658.                                _      -> return ()
  2659.                
  2660.                            _ -> return ()
  2661.                        ) xs
  2662.                    Nothing -> orderBy [ asc (e ^. E12E12E34Day), asc (e ^. E12E12E34E26Id) ]
  2663.  
  2664.                case defaultOffset of
  2665.                    Just o -> offset o
  2666.                    Nothing -> return ()
  2667.                case defaultLimit of
  2668.                    Just l -> limit (min 10000 l)
  2669.                    Nothing -> return ()
  2670.                
  2671.            else return ()
  2672.        case defaultFilterJson of
  2673.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  2674.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2675.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  2676.                    _        -> return ()
  2677.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2678.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  2679.                    _        -> return ()
  2680.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2681.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  2682.                    _        -> return ()
  2683.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2684.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  2685.                    _        -> return ()
  2686.                "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2687.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (e ^. E12E12E34E26Id) (val v)
  2688.                    _        -> return ()
  2689.                "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2690.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (e ^. E12E12E34Day) (val v)
  2691.                    _        -> return ()
  2692.  
  2693.                _ -> return ()
  2694.                ) xs
  2695.            Nothing -> return ()  
  2696.        case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
  2697.            Just localParam -> do
  2698.  
  2699.                where_ $ (e ^. E12E12E34E26Id) `in_` ((valList localParam))
  2700.            Nothing -> return ()
  2701.        case getDefaultFilter filterParam_firstDay defaultFilterJson "firstDay" of
  2702.            Just localParam -> do
  2703.  
  2704.                where_ $ (e ^. E12E12E34Day) >=. ((val localParam))
  2705.            Nothing -> return ()
  2706.        case getDefaultFilter filterParam_lastDay defaultFilterJson "lastDay" of
  2707.            Just localParam -> do
  2708.  
  2709.                where_ $ (e ^. E12E12E34Day) <=. ((val localParam))
  2710.            Nothing -> return ()
  2711.        return (e ^. E12E12E34Id, e ^. E12E12E34Day, c ^. E26Name)
  2712.    count <- lift $ runDB $ select $ do
  2713.        baseQuery False
  2714.        let countRows' = countRows
  2715.         orderBy []
  2716.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2717.    results <- lift $ runDB $ select $ baseQuery True
  2718.    return $ A.object [
  2719.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2720.        "result" .= (toJSON $ map (\row -> case row of
  2721.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3)) -> A.object [
  2722.                    "id" .= toJSON f1,
  2723.                    "day" .= toJSON f2,
  2724.                    "e26Name" .= toJSON f3                                    
  2725.                    ]
  2726.                _ -> A.object []
  2727.            ) results)
  2728.       ]
  2729. deleteE17e12e34sE12E12E34IdR :: forall master. (GeneratedValidation master,
  2730.    YesodAuthPersist master,
  2731.    YesodPersistBackend master ~ SqlPersistT)
  2732.    => E12E12E34Id -> HandlerT Generated (HandlerT master IO) A.Value
  2733. deleteE17e12e34sE12E12E34IdR p1 = do
  2734.    authId <- lift $ requireAuthId
  2735.    _ <- lift $ runDB $ do
  2736.        delete $ from $ (\e -> where_ $ (e ^. E12E12E34Id) ==. ((val p1)))
  2737.    return $ A.Null
  2738. getE19sR :: forall master. (GeneratedValidation master,
  2739.    YesodAuthPersist master,
  2740.    YesodPersistBackend master ~ SqlPersistT)
  2741.    => HandlerT Generated (HandlerT master IO) A.Value
  2742. getE19sR  = do
  2743.    authId <- lift $ requireAuthId
  2744.    defaultFilterParam <- lookupGetParam "filter"
  2745.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  2746.    defaultSortParam <- lookupGetParam "sort"
  2747.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  2748.    defaultOffsetParam <- lookupGetParam "start"
  2749.    defaultLimitParam <- lookupGetParam "limit"
  2750.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  2751.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  2752.    filterParam_query <- lookupGetParam "query"
  2753.    let baseQuery limitOffsetOrder = from $ \(p ) -> do
  2754.        let pId' = p ^. E19Id
  2755.  
  2756.         _ <- if limitOffsetOrder
  2757.             then do
  2758.                 offset 0
  2759.                 limit 10000
  2760.                 case defaultSortJson of
  2761.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  2762.                             "e31" -> case (sortJsonMsg_direction sjm) of
  2763.                                 "ASC"  -> orderBy [ asc (p ^. E19E31) ]
  2764.                                 "DESC" -> orderBy [ desc (p ^. E19E31) ]
  2765.                                 _      -> return ()
  2766.                             "name" -> case (sortJsonMsg_direction sjm) of
  2767.                                 "ASC"  -> orderBy [ asc (p ^. E19Name) ]
  2768.                                 "DESC" -> orderBy [ desc (p ^. E19Name) ]
  2769.                                 _      -> return ()
  2770.                             "version" -> case (sortJsonMsg_direction sjm) of
  2771.                                 "ASC"  -> orderBy [ asc (p ^. E19Version) ]
  2772.                                 "DESC" -> orderBy [ desc (p ^. E19Version) ]
  2773.                                 _      -> return ()
  2774.                             "e30d" -> case (sortJsonMsg_direction sjm) of
  2775.                                 "ASC"  -> orderBy [ asc (p ^. E19E30d) ]
  2776.                                 "DESC" -> orderBy [ desc (p ^. E19E30d) ]
  2777.                                 _      -> return ()
  2778.                             "e311" -> case (sortJsonMsg_direction sjm) of
  2779.                                 "ASC"  -> orderBy [ asc (p ^. E19E311) ]
  2780.                                 "DESC" -> orderBy [ desc (p ^. E19E311) ]
  2781.                                 _      -> return ()
  2782.                
  2783.                             _ -> return ()
  2784.                         ) xs
  2785.                     Nothing -> orderBy [ asc (p ^. E19Name) ]
  2786.  
  2787.                 case defaultOffset of
  2788.                     Just o -> offset o
  2789.                     Nothing -> return ()
  2790.                 case defaultLimit of
  2791.                     Just l -> limit (min 10000 l)
  2792.                     Nothing -> return ()
  2793.                  
  2794.             else return ()
  2795.         case defaultFilterJson of
  2796.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  2797.                 "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2798.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19E31) (val v)
  2799.                     _        -> return ()
  2800.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2801.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19Name) (val v)
  2802.                     _        -> return ()
  2803.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2804.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19Version) (val (Just v))
  2805.                     _        -> return ()
  2806.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2807.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19E30d) (val v)
  2808.                     _        -> return ()
  2809.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2810.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (p ^. E19E311) (val (Just v))
  2811.                     _        -> return ()
  2812.  
  2813.                 _ -> return ()
  2814.                 ) xs
  2815.             Nothing -> return ()  
  2816.         case getDefaultFilter filterParam_query defaultFilterJson "query" of
  2817.             Just localParam -> do
  2818.  
  2819.                 where_ $ (p ^. E19Name) `ilike` (((val "%")) ++. (((val (localParam :: Text))) ++. ((val "%"))))
  2820.             Nothing -> return ()
  2821.         return (p ^. E19Id, p ^. E19E31, p ^. E19Name, p ^. E19Version, p ^. E19E30d, p ^. E19E311)
  2822.     count <- lift $ runDB $ select $ do
  2823.         baseQuery False
  2824.         let countRows' = countRows
  2825.        orderBy []
  2826.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2827.     results <- lift $ runDB $ select $ baseQuery True
  2828.     return $ A.object [
  2829.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2830.         "result" .= (toJSON $ map (\row -> case row of
  2831.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
  2832.                     "id" .= toJSON f1,
  2833.                     "e31" .= toJSON f2,
  2834.                     "name" .= toJSON f3,
  2835.                     "version" .= toJSON f4,
  2836.                     "e30d" .= toJSON f5,
  2837.                     "e311" .= toJSON f6                                    
  2838.                     ]
  2839.                 _ -> A.object []
  2840.             ) results)
  2841.        ]
  2842. getE31sR :: forall master. (GeneratedValidation master,
  2843.     YesodAuthPersist master,
  2844.     YesodPersistBackend master ~ SqlPersistT)
  2845.     => HandlerT Generated (HandlerT master IO) A.Value
  2846. getE31sR  = do
  2847.     authId <- lift $ requireAuthId
  2848.     defaultFilterParam <- lookupGetParam "filter"
  2849.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  2850.     defaultSortParam <- lookupGetParam "sort"
  2851.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  2852.     defaultOffsetParam <- lookupGetParam "start"
  2853.     defaultLimitParam <- lookupGetParam "limit"
  2854.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  2855.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  2856.     let baseQuery limitOffsetOrder = from $ \(c ) -> do
  2857.         let cId' = c ^. E20Id
  2858.  
  2859.        _ <- if limitOffsetOrder
  2860.            then do
  2861.                offset 0
  2862.                limit 1000
  2863.                case defaultSortJson of
  2864.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  2865.                            "title" -> case (sortJsonMsg_direction sjm) of
  2866.                                "ASC"  -> orderBy [ asc (c ^. E20Title) ]
  2867.                                "DESC" -> orderBy [ desc (c ^. E20Title) ]
  2868.                                _      -> return ()
  2869.                            "address" -> case (sortJsonMsg_direction sjm) of
  2870.                                "ASC"  -> orderBy [ asc (c ^. E20Address) ]
  2871.                                "DESC" -> orderBy [ desc (c ^. E20Address) ]
  2872.                                _      -> return ()
  2873.                            "email" -> case (sortJsonMsg_direction sjm) of
  2874.                                "ASC"  -> orderBy [ asc (c ^. E20Email) ]
  2875.                                "DESC" -> orderBy [ desc (c ^. E20Email) ]
  2876.                                _      -> return ()
  2877.                            "name" -> case (sortJsonMsg_direction sjm) of
  2878.                                "ASC"  -> orderBy [ asc (c ^. E20Name) ]
  2879.                                "DESC" -> orderBy [ desc (c ^. E20Name) ]
  2880.                                _      -> return ()
  2881.                            "version" -> case (sortJsonMsg_direction sjm) of
  2882.                                "ASC"  -> orderBy [ asc (c ^. E20Version) ]
  2883.                                "DESC" -> orderBy [ desc (c ^. E20Version) ]
  2884.                                _      -> return ()
  2885.                            "e30d" -> case (sortJsonMsg_direction sjm) of
  2886.                                "ASC"  -> orderBy [ asc (c ^. E20E30d) ]
  2887.                                "DESC" -> orderBy [ desc (c ^. E20E30d) ]
  2888.                                _      -> return ()
  2889.                            "e311" -> case (sortJsonMsg_direction sjm) of
  2890.                                "ASC"  -> orderBy [ asc (c ^. E20E311) ]
  2891.                                "DESC" -> orderBy [ desc (c ^. E20E311) ]
  2892.                                _      -> return ()
  2893.                
  2894.                            _ -> return ()
  2895.                        ) xs
  2896.                    Nothing -> orderBy [ asc (c ^. E20Name) ]
  2897.  
  2898.                case defaultOffset of
  2899.                    Just o -> offset o
  2900.                    Nothing -> return ()
  2901.                case defaultLimit of
  2902.                    Just l -> limit (min 10000 l)
  2903.                    Nothing -> return ()
  2904.                
  2905.            else return ()
  2906.        case defaultFilterJson of
  2907.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  2908.                "title" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2909.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Title) (val v)
  2910.                    _        -> return ()
  2911.                "address" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2912.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Address) (val v)
  2913.                    _        -> return ()
  2914.                "email" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2915.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Email) (val v)
  2916.                    _        -> return ()
  2917.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2918.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Name) (val v)
  2919.                    _        -> return ()
  2920.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2921.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20Version) (val (Just v))
  2922.                    _        -> return ()
  2923.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2924.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20E30d) (val v)
  2925.                    _        -> return ()
  2926.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  2927.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E20E311) (val (Just v))
  2928.                    _        -> return ()
  2929.  
  2930.                _ -> return ()
  2931.                ) xs
  2932.            Nothing -> return ()  
  2933.        return (c ^. E20Id, c ^. E20Title, c ^. E20Address, c ^. E20Email, c ^. E20Name, c ^. E20Version, c ^. E20E30d, c ^. E20E311)
  2934.    count <- lift $ runDB $ select $ do
  2935.        baseQuery False
  2936.        let countRows' = countRows
  2937.         orderBy []
  2938.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2939.    results <- lift $ runDB $ select $ baseQuery True
  2940.    return $ A.object [
  2941.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2942.        "result" .= (toJSON $ map (\row -> case row of
  2943.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7), (Database.Esqueleto.Value f8)) -> A.object [
  2944.                    "id" .= toJSON f1,
  2945.                    "title" .= toJSON f2,
  2946.                    "address" .= toJSON f3,
  2947.                    "email" .= toJSON f4,
  2948.                    "name" .= toJSON f5,
  2949.                    "version" .= toJSON f6,
  2950.                    "e30d" .= toJSON f7,
  2951.                    "e311" .= toJSON f8                                    
  2952.                    ]
  2953.                _ -> A.object []
  2954.            ) results)
  2955.       ]
  2956. getE31E20IdNumbersR :: forall master. (GeneratedValidation master,
  2957.    YesodAuthPersist master,
  2958.    YesodPersistBackend master ~ SqlPersistT)
  2959.    => E20Id -> HandlerT Generated (HandlerT master IO) A.Value
  2960. getE31E20IdNumbersR p1 = do
  2961.    authId <- lift $ requireAuthId
  2962.    let baseQuery limitOffsetOrder = from $ \(c  `InnerJoin` cn) -> do
  2963.        on ((cn ^. E20NumberE31Id) ==. (c ^. E20Id))
  2964.        let cId' = c ^. E20Id
  2965.         where_ ((c ^. E20Id) ==. ((val p1)))
  2966.  
  2967.         _ <- if limitOffsetOrder
  2968.             then do
  2969.                 offset 0
  2970.                 limit 10000
  2971.  
  2972.                  
  2973.             else return ()
  2974.         return (cn ^. E20NumberId, cn ^. E20NumberE31Id, cn ^. E20NumberNumber, cn ^. E20NumberName, cn ^. E20NumberVersion, cn ^. E20NumberE30d, cn ^. E20NumberE311)
  2975.     count <- lift $ runDB $ select $ do
  2976.         baseQuery False
  2977.         let countRows' = countRows
  2978.        orderBy []
  2979.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  2980.     results <- lift $ runDB $ select $ baseQuery True
  2981.     return $ A.object [
  2982.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  2983.         "result" .= (toJSON $ map (\row -> case row of
  2984.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6), (Database.Esqueleto.Value f7)) -> A.object [
  2985.                     "id" .= toJSON f1,
  2986.                     "e31Id" .= toJSON f2,
  2987.                     "number" .= toJSON f3,
  2988.                     "name" .= toJSON f4,
  2989.                     "version" .= toJSON f5,
  2990.                     "e30d" .= toJSON f6,
  2991.                     "e311" .= toJSON f7                                    
  2992.                     ]
  2993.                 _ -> A.object []
  2994.             ) results)
  2995.        ]
  2996. getE16e12sR :: forall master. (GeneratedValidation master,
  2997.     YesodAuthPersist master,
  2998.     YesodPersistBackend master ~ SqlPersistT)
  2999.     => HandlerT Generated (HandlerT master IO) A.Value
  3000. getE16e12sR  = do
  3001.     authId <- lift $ requireAuthId
  3002.     defaultFilterParam <- lookupGetParam "filter"
  3003.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  3004.     defaultSortParam <- lookupGetParam "sort"
  3005.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  3006.     defaultOffsetParam <- lookupGetParam "start"
  3007.     defaultLimitParam <- lookupGetParam "limit"
  3008.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  3009.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  3010.     filterParam_e26IdList <- lookupGetParam "e26IdList"
  3011.     filterParam_E16IdList <- lookupGetParam "E16IdList"
  3012.     filterParam_dayList <- lookupGetParam "dayList"
  3013.     filterParam_startE11List <- lookupGetParam "startE11List"
  3014.     let baseQuery limitOffsetOrder = from $ \(t  `InnerJoin` c `InnerJoin` f) -> do
  3015.         on ((t ^. E16E12E16Id) ==. (f ^. E16Id))
  3016.         on ((t ^. E16E12E26Id) ==. (c ^. E26Id))
  3017.         let tId' = t ^. E16E12Id
  3018.  
  3019.        _ <- if limitOffsetOrder
  3020.            then do
  3021.                offset 0
  3022.                limit 100
  3023.                case defaultSortJson of
  3024.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  3025.                            "e26Name" -> case (sortJsonMsg_direction sjm) of
  3026.                                "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  3027.                                "DESC" -> orderBy [ desc (c ^. E26Name) ]
  3028.                                _      -> return ()
  3029.                            "e16Name" -> case (sortJsonMsg_direction sjm) of
  3030.                                "ASC"  -> orderBy [ asc (f ^. E16Name) ]
  3031.                                "DESC" -> orderBy [ desc (f ^. E16Name) ]
  3032.                                _      -> return ()
  3033.                            "day" -> case (sortJsonMsg_direction sjm) of
  3034.                                "ASC"  -> orderBy [ asc (t ^. E16E12Day) ]
  3035.                                "DESC" -> orderBy [ desc (t ^. E16E12Day) ]
  3036.                                _      -> return ()
  3037.                            "startE11" -> case (sortJsonMsg_direction sjm) of
  3038.                                "ASC"  -> orderBy [ asc (t ^. E16E12StartE11) ]
  3039.                                "DESC" -> orderBy [ desc (t ^. E16E12StartE11) ]
  3040.                                _      -> return ()
  3041.                            "e314Window" -> case (sortJsonMsg_direction sjm) of
  3042.                                "ASC"  -> orderBy [ asc (t ^. E16E12E314Window) ]
  3043.                                "DESC" -> orderBy [ desc (t ^. E16E12E314Window) ]
  3044.                                _      -> return ()
  3045.                
  3046.                            _ -> return ()
  3047.                        ) xs
  3048.                    Nothing -> orderBy [ asc (t ^. E16E12StartE11), asc (c ^. E26Name), asc (f ^. E16Name) ]
  3049.  
  3050.                case defaultOffset of
  3051.                    Just o -> offset o
  3052.                    Nothing -> return ()
  3053.                case defaultLimit of
  3054.                    Just l -> limit (min 10000 l)
  3055.                    Nothing -> return ()
  3056.                
  3057.            else return ()
  3058.        case defaultFilterJson of
  3059.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  3060.                "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3061.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E31) (val v)
  3062.                    _        -> return ()
  3063.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3064.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Name) (val v)
  3065.                    _        -> return ()
  3066.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3067.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Version) (val (Just v))
  3068.                    _        -> return ()
  3069.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3070.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E30d) (val v)
  3071.                    _        -> return ()
  3072.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3073.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E311) (val (Just v))
  3074.                    _        -> return ()
  3075.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3076.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  3077.                    _        -> return ()
  3078.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3079.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  3080.                    _        -> return ()
  3081.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3082.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  3083.                    _        -> return ()
  3084.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3085.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  3086.                    _        -> return ()
  3087.                "e16Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3088.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12E16Id) (val v)
  3089.                    _        -> return ()
  3090.                "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3091.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12E26Id) (val v)
  3092.                    _        -> return ()
  3093.                "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3094.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12Day) (val v)
  3095.                    _        -> return ()
  3096.                "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3097.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12StartE11) (val v)
  3098.                    _        -> return ()
  3099.                "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3100.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E16E12E314Window) (val v)
  3101.                    _        -> return ()
  3102.  
  3103.                _ -> return ()
  3104.                ) xs
  3105.            Nothing -> return ()  
  3106.        case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
  3107.            Just localParam -> do
  3108.  
  3109.                where_ $ (c ^. E26Id) `in_` ((valList localParam))
  3110.            Nothing -> return ()
  3111.        case getDefaultFilter filterParam_E16IdList defaultFilterJson "E16IdList" of
  3112.            Just localParam -> do
  3113.  
  3114.                where_ $ (f ^. E16Id) `in_` ((valList localParam))
  3115.            Nothing -> return ()
  3116.        case getDefaultFilter filterParam_dayList defaultFilterJson "dayList" of
  3117.            Just localParam -> do
  3118.  
  3119.                where_ $ (t ^. E16E12Day) `in_` ((valList localParam))
  3120.            Nothing -> return ()
  3121.        case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
  3122.            Just localParam -> do
  3123.  
  3124.                where_ $ (t ^. E16E12StartE11) `in_` ((valList localParam))
  3125.            Nothing -> return ()
  3126.        return (t ^. E16E12Id, c ^. E26Name, f ^. E16Name, t ^. E16E12Day, t ^. E16E12StartE11, t ^. E16E12E314Window)
  3127.    count <- lift $ runDB $ select $ do
  3128.        baseQuery False
  3129.        let countRows' = countRows
  3130.         orderBy []
  3131.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  3132.    results <- lift $ runDB $ select $ baseQuery True
  3133.    return $ A.object [
  3134.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  3135.        "result" .= (toJSON $ map (\row -> case row of
  3136.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
  3137.                    "id" .= toJSON f1,
  3138.                    "e26Name" .= toJSON f2,
  3139.                    "e16Name" .= toJSON f3,
  3140.                    "day" .= toJSON f4,
  3141.                    "startE11" .= toJSON f5,
  3142.                    "e314Window" .= toJSON f6                                    
  3143.                    ]
  3144.                _ -> A.object []
  3145.            ) results)
  3146.       ]
  3147. deleteE16e12sE16E12IdR :: forall master. (GeneratedValidation master,
  3148.    YesodAuthPersist master,
  3149.    YesodPersistBackend master ~ SqlPersistT)
  3150.    => E16E12Id -> HandlerT Generated (HandlerT master IO) A.Value
  3151. deleteE16e12sE16E12IdR p1 = do
  3152.    authId <- lift $ requireAuthId
  3153.    _ <- lift $ runDB $ do
  3154.        delete $ from $ (\t -> where_ $ (t ^. E16E12Id) ==. ((val p1)))
  3155.    return $ A.Null
  3156. getE17E16e12sR :: forall master. (GeneratedValidation master,
  3157.    YesodAuthPersist master,
  3158.    YesodPersistBackend master ~ SqlPersistT)
  3159.    => HandlerT Generated (HandlerT master IO) A.Value
  3160. getE17E16e12sR  = do
  3161.    authId <- lift $ requireAuthId
  3162.    defaultFilterParam <- lookupGetParam "filter"
  3163.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  3164.    defaultSortParam <- lookupGetParam "sort"
  3165.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  3166.    defaultOffsetParam <- lookupGetParam "start"
  3167.    defaultLimitParam <- lookupGetParam "limit"
  3168.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  3169.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  3170.    filterParam_e26IdList <- lookupGetParam "e26IdList"
  3171.    filterParam_e16IdList <- lookupGetParam "e16IdList"
  3172.    filterParam_wdayList <- lookupGetParam "wdayList"
  3173.    let baseQuery limitOffsetOrder = from $ \(t  `InnerJoin` c `InnerJoin` f) -> do
  3174.        on ((t ^. E12E16E12E16Id) ==. (f ^. E16Id))
  3175.        on ((t ^. E12E16E12E26Id) ==. (c ^. E26Id))
  3176.        let tId' = t ^. E12E16E12Id
  3177.  
  3178.         _ <- if limitOffsetOrder
  3179.             then do
  3180.                 offset 0
  3181.                 limit 100
  3182.                 case defaultSortJson of
  3183.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  3184.                             "e26Name" -> case (sortJsonMsg_direction sjm) of
  3185.                                 "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  3186.                                 "DESC" -> orderBy [ desc (c ^. E26Name) ]
  3187.                                 _      -> return ()
  3188.                             "e16Name" -> case (sortJsonMsg_direction sjm) of
  3189.                                 "ASC"  -> orderBy [ asc (f ^. E16Name) ]
  3190.                                 "DESC" -> orderBy [ desc (f ^. E16Name) ]
  3191.                                 _      -> return ()
  3192.                             "wday" -> case (sortJsonMsg_direction sjm) of
  3193.                                 "ASC"  -> orderBy [ asc (t ^. E12E16E12Wday) ]
  3194.                                 "DESC" -> orderBy [ desc (t ^. E12E16E12Wday) ]
  3195.                                 _      -> return ()
  3196.                             "e314" -> case (sortJsonMsg_direction sjm) of
  3197.                                 "ASC"  -> orderBy [ asc (t ^. E12E16E12E314) ]
  3198.                                 "DESC" -> orderBy [ desc (t ^. E12E16E12E314) ]
  3199.                                 _      -> return ()
  3200.                
  3201.                             _ -> return ()
  3202.                         ) xs
  3203.                     Nothing -> orderBy [ asc (t ^. E12E16E12E314), asc (c ^. E26Name), asc (f ^. E16Name) ]
  3204.  
  3205.                 case defaultOffset of
  3206.                     Just o -> offset o
  3207.                     Nothing -> return ()
  3208.                 case defaultLimit of
  3209.                     Just l -> limit (min 10000 l)
  3210.                     Nothing -> return ()
  3211.                  
  3212.             else return ()
  3213.         case defaultFilterJson of
  3214.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  3215.                 "e31" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3216.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E31) (val v)
  3217.                     _        -> return ()
  3218.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3219.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Name) (val v)
  3220.                     _        -> return ()
  3221.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3222.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16Version) (val (Just v))
  3223.                     _        -> return ()
  3224.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3225.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E30d) (val v)
  3226.                     _        -> return ()
  3227.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3228.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (f ^. E16E311) (val (Just v))
  3229.                     _        -> return ()
  3230.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3231.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  3232.                     _        -> return ()
  3233.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3234.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  3235.                     _        -> return ()
  3236.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3237.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  3238.                     _        -> return ()
  3239.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3240.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  3241.                     _        -> return ()
  3242.                 "e16Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3243.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12E16Id) (val v)
  3244.                     _        -> return ()
  3245.                 "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3246.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12E26Id) (val v)
  3247.                     _        -> return ()
  3248.                 "wday" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3249.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12Wday) (val v)
  3250.                     _        -> return ()
  3251.                 "e314" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3252.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E16E12E314) (val v)
  3253.                     _        -> return ()
  3254.  
  3255.                 _ -> return ()
  3256.                 ) xs
  3257.             Nothing -> return ()  
  3258.         case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
  3259.             Just localParam -> do
  3260.  
  3261.                 where_ $ (c ^. E26Id) `in_` ((valList localParam))
  3262.             Nothing -> return ()
  3263.         case getDefaultFilter filterParam_e16IdList defaultFilterJson "e16IdList" of
  3264.             Just localParam -> do
  3265.  
  3266.                 where_ $ (f ^. E16Id) `in_` ((valList localParam))
  3267.             Nothing -> return ()
  3268.         case getDefaultFilter filterParam_wdayList defaultFilterJson "wdayList" of
  3269.             Just localParam -> do
  3270.  
  3271.                 where_ $ (t ^. E12E16E12Wday) `in_` ((valList localParam))
  3272.             Nothing -> return ()
  3273.         return (t ^. E12E16E12Id, c ^. E26Name, f ^. E16Name, t ^. E12E16E12Wday, t ^. E12E16E12E314)
  3274.     count <- lift $ runDB $ select $ do
  3275.         baseQuery False
  3276.         let countRows' = countRows
  3277.        orderBy []
  3278.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  3279.     results <- lift $ runDB $ select $ baseQuery True
  3280.     return $ A.object [
  3281.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  3282.         "result" .= (toJSON $ map (\row -> case row of
  3283.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
  3284.                     "id" .= toJSON f1,
  3285.                     "e26Name" .= toJSON f2,
  3286.                     "e16Name" .= toJSON f3,
  3287.                     "wday" .= toJSON f4,
  3288.                     "e314" .= toJSON f5                                    
  3289.                     ]
  3290.                 _ -> A.object []
  3291.             ) results)
  3292.        ]
  3293. deleteE17E16e12sE12E16E12IdR :: forall master. (GeneratedValidation master,
  3294.     YesodAuthPersist master,
  3295.     YesodPersistBackend master ~ SqlPersistT)
  3296.     => E12E16E12Id -> HandlerT Generated (HandlerT master IO) A.Value
  3297. deleteE17E16e12sE12E16E12IdR p1 = do
  3298.     authId <- lift $ requireAuthId
  3299.     _ <- lift $ runDB $ do
  3300.         delete $ from $ (\t -> where_ $ (t ^. E12E16E12Id) ==. ((val p1)))
  3301.     return $ A.Null
  3302. getE10e314sR :: forall master. (GeneratedValidation master,
  3303.     YesodAuthPersist master,
  3304.     YesodPersistBackend master ~ SqlPersistT)
  3305.     => HandlerT Generated (HandlerT master IO) A.Value
  3306. getE10e314sR  = do
  3307.     authId <- lift $ requireAuthId
  3308.     defaultFilterParam <- lookupGetParam "filter"
  3309.     let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  3310.     defaultSortParam <- lookupGetParam "sort"
  3311.     let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  3312.     defaultOffsetParam <- lookupGetParam "start"
  3313.     defaultLimitParam <- lookupGetParam "limit"
  3314.     let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  3315.     let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  3316.     filterParam_e26IdList <- lookupGetParam "e26IdList"
  3317.     filterParam_dayList <- lookupGetParam "dayList"
  3318.     filterParam_startE11List <- lookupGetParam "startE11List"
  3319.     let baseQuery limitOffsetOrder = from $ \(t  `InnerJoin` c) -> do
  3320.         on ((t ^. E10E11E26Id) ==. (c ^. E26Id))
  3321.         let tId' = t ^. E10E11Id
  3322.  
  3323.        _ <- if limitOffsetOrder
  3324.            then do
  3325.                offset 0
  3326.                limit 100
  3327.                case defaultSortJson of
  3328.                    Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  3329.                            "e26Name" -> case (sortJsonMsg_direction sjm) of
  3330.                                "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  3331.                                "DESC" -> orderBy [ desc (c ^. E26Name) ]
  3332.                                _      -> return ()
  3333.                            "day" -> case (sortJsonMsg_direction sjm) of
  3334.                                "ASC"  -> orderBy [ asc (t ^. E10E11Day) ]
  3335.                                "DESC" -> orderBy [ desc (t ^. E10E11Day) ]
  3336.                                _      -> return ()
  3337.                            "startE11" -> case (sortJsonMsg_direction sjm) of
  3338.                                "ASC"  -> orderBy [ asc (t ^. E10E11StartE11) ]
  3339.                                "DESC" -> orderBy [ desc (t ^. E10E11StartE11) ]
  3340.                                _      -> return ()
  3341.                            "e314Window" -> case (sortJsonMsg_direction sjm) of
  3342.                                "ASC"  -> orderBy [ asc (t ^. E10E11E314Window) ]
  3343.                                "DESC" -> orderBy [ desc (t ^. E10E11E314Window) ]
  3344.                                _      -> return ()
  3345.                            "active" -> case (sortJsonMsg_direction sjm) of
  3346.                                "ASC"  -> orderBy [ asc (t ^. E10E11Active) ]
  3347.                                "DESC" -> orderBy [ desc (t ^. E10E11Active) ]
  3348.                                _      -> return ()
  3349.                
  3350.                            _ -> return ()
  3351.                        ) xs
  3352.                    Nothing -> orderBy [ asc (t ^. E10E11StartE11), asc (c ^. E26Name) ]
  3353.  
  3354.                case defaultOffset of
  3355.                    Just o -> offset o
  3356.                    Nothing -> return ()
  3357.                case defaultLimit of
  3358.                    Just l -> limit (min 10000 l)
  3359.                    Nothing -> return ()
  3360.                
  3361.            else return ()
  3362.        case defaultFilterJson of
  3363.            Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  3364.                "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3365.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  3366.                    _        -> return ()
  3367.                "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3368.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  3369.                    _        -> return ()
  3370.                "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3371.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  3372.                    _        -> return ()
  3373.                "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3374.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  3375.                    _        -> return ()
  3376.                "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3377.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11E26Id) (val v)
  3378.                    _        -> return ()
  3379.                "day" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3380.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11Day) (val v)
  3381.                    _        -> return ()
  3382.                "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3383.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11StartE11) (val v)
  3384.                    _        -> return ()
  3385.                "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3386.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11E314Window) (val v)
  3387.                    _        -> return ()
  3388.                "active" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3389.                    (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E10E11Active) (val v)
  3390.                    _        -> return ()
  3391.  
  3392.                _ -> return ()
  3393.                ) xs
  3394.            Nothing -> return ()  
  3395.        case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
  3396.            Just localParam -> do
  3397.  
  3398.                where_ $ (c ^. E26Id) `in_` ((valList localParam))
  3399.            Nothing -> return ()
  3400.        case getDefaultFilter filterParam_dayList defaultFilterJson "dayList" of
  3401.            Just localParam -> do
  3402.  
  3403.                where_ $ (t ^. E10E11Day) `in_` ((valList localParam))
  3404.            Nothing -> return ()
  3405.        case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
  3406.            Just localParam -> do
  3407.  
  3408.                where_ $ (t ^. E10E11StartE11) `in_` ((valList localParam))
  3409.            Nothing -> return ()
  3410.        return (t ^. E10E11Id, c ^. E26Name, t ^. E10E11Day, t ^. E10E11StartE11, t ^. E10E11E314Window, t ^. E10E11Active)
  3411.    count <- lift $ runDB $ select $ do
  3412.        baseQuery False
  3413.        let countRows' = countRows
  3414.         orderBy []
  3415.         return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  3416.    results <- lift $ runDB $ select $ baseQuery True
  3417.    return $ A.object [
  3418.        "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  3419.        "result" .= (toJSON $ map (\row -> case row of
  3420.                ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5), (Database.Esqueleto.Value f6)) -> A.object [
  3421.                    "id" .= toJSON f1,
  3422.                    "e26Name" .= toJSON f2,
  3423.                    "day" .= toJSON f3,
  3424.                    "startE11" .= toJSON f4,
  3425.                    "e314Window" .= toJSON f5,
  3426.                    "active" .= toJSON f6                                    
  3427.                    ]
  3428.                _ -> A.object []
  3429.            ) results)
  3430.       ]
  3431. deleteE10e314sE10E11IdR :: forall master. (GeneratedValidation master,
  3432.    YesodAuthPersist master,
  3433.    YesodPersistBackend master ~ SqlPersistT)
  3434.    => E10E11Id -> HandlerT Generated (HandlerT master IO) A.Value
  3435. deleteE10e314sE10E11IdR p1 = do
  3436.    authId <- lift $ requireAuthId
  3437.    _ <- lift $ runDB $ do
  3438.        delete $ from $ (\s -> where_ $ (s ^. E10E11Id) ==. ((val p1)))
  3439.    return $ A.Null
  3440. getE17e10e314sR :: forall master. (GeneratedValidation master,
  3441.    YesodAuthPersist master,
  3442.    YesodPersistBackend master ~ SqlPersistT)
  3443.    => HandlerT Generated (HandlerT master IO) A.Value
  3444. getE17e10e314sR  = do
  3445.    authId <- lift $ requireAuthId
  3446.    defaultFilterParam <- lookupGetParam "filter"
  3447.    let defaultFilterJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultFilterParam) :: Maybe [FilterJsonMsg]
  3448.    defaultSortParam <- lookupGetParam "sort"
  3449.    let defaultSortJson = (maybe Nothing (decode . LBS.fromChunks . (:[]) . encodeUtf8) defaultSortParam) :: Maybe [SortJsonMsg]
  3450.    defaultOffsetParam <- lookupGetParam "start"
  3451.    defaultLimitParam <- lookupGetParam "limit"
  3452.    let defaultOffset = (maybe Nothing fromPathPiece defaultOffsetParam) :: Maybe Int64
  3453.    let defaultLimit = (maybe Nothing fromPathPiece defaultLimitParam) :: Maybe Int64
  3454.    filterParam_e26IdList <- lookupGetParam "e26IdList"
  3455.    filterParam_wdayList <- lookupGetParam "wdayList"
  3456.    filterParam_startE11List <- lookupGetParam "startE11List"
  3457.    let baseQuery limitOffsetOrder = from $ \(t  `InnerJoin` c) -> do
  3458.        on ((t ^. E12E10E11E26Id) ==. (c ^. E26Id))
  3459.        let tId' = t ^. E12E10E11Id
  3460.  
  3461.         _ <- if limitOffsetOrder
  3462.             then do
  3463.                 offset 0
  3464.                 limit 100
  3465.                 case defaultSortJson of
  3466.                     Just xs -> mapM_ (\sjm -> case sortJsonMsg_property sjm of
  3467.                             "e26Name" -> case (sortJsonMsg_direction sjm) of
  3468.                                 "ASC"  -> orderBy [ asc (c ^. E26Name) ]
  3469.                                 "DESC" -> orderBy [ desc (c ^. E26Name) ]
  3470.                                 _      -> return ()
  3471.                             "wday" -> case (sortJsonMsg_direction sjm) of
  3472.                                 "ASC"  -> orderBy [ asc (t ^. E12E10E11Wday) ]
  3473.                                 "DESC" -> orderBy [ desc (t ^. E12E10E11Wday) ]
  3474.                                 _      -> return ()
  3475.                             "startE11" -> case (sortJsonMsg_direction sjm) of
  3476.                                 "ASC"  -> orderBy [ asc (t ^. E12E10E11StartE11) ]
  3477.                                 "DESC" -> orderBy [ desc (t ^. E12E10E11StartE11) ]
  3478.                                 _      -> return ()
  3479.                             "e314Window" -> case (sortJsonMsg_direction sjm) of
  3480.                                 "ASC"  -> orderBy [ asc (t ^. E12E10E11E314Window) ]
  3481.                                 "DESC" -> orderBy [ desc (t ^. E12E10E11E314Window) ]
  3482.                                 _      -> return ()
  3483.                
  3484.                             _ -> return ()
  3485.                         ) xs
  3486.                     Nothing -> orderBy [ asc (t ^. E12E10E11StartE11), asc (c ^. E26Name) ]
  3487.  
  3488.                 case defaultOffset of
  3489.                     Just o -> offset o
  3490.                     Nothing -> return ()
  3491.                 case defaultLimit of
  3492.                     Just l -> limit (min 10000 l)
  3493.                     Nothing -> return ()
  3494.                  
  3495.             else return ()
  3496.         case defaultFilterJson of
  3497.             Just xs -> mapM_ (\fjm -> case filterJsonMsg_field fjm of
  3498.                 "name" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3499.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Name) (val v)
  3500.                     _        -> return ()
  3501.                 "version" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3502.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26Version) (val (Just v))
  3503.                     _        -> return ()
  3504.                 "e30d" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3505.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E30d) (val v)
  3506.                     _        -> return ()
  3507.                 "e311" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3508.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (c ^. E26E311) (val (Just v))
  3509.                     _        -> return ()
  3510.                 "e26Id" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3511.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11E26Id) (val v)
  3512.                     _        -> return ()
  3513.                 "wday" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3514.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11Wday) (val v)
  3515.                     _        -> return ()
  3516.                 "startE11" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3517.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11StartE11) (val v)
  3518.                     _        -> return ()
  3519.                 "e314Window" -> case (fromPathPiece $ filterJsonMsg_value fjm) of
  3520.                     (Just v) -> where_ $ defaultFilterOp (filterJsonMsg_comparison fjm) (t ^. E12E10E11E314Window) (val v)
  3521.                     _        -> return ()
  3522.  
  3523.                 _ -> return ()
  3524.                 ) xs
  3525.             Nothing -> return ()  
  3526.         case getDefaultFilter filterParam_e26IdList defaultFilterJson "e26IdList" of
  3527.             Just localParam -> do
  3528.  
  3529.                 where_ $ (c ^. E26Id) `in_` ((valList localParam))
  3530.             Nothing -> return ()
  3531.         case getDefaultFilter filterParam_wdayList defaultFilterJson "wdayList" of
  3532.             Just localParam -> do
  3533.  
  3534.                 where_ $ (t ^. E12E10E11Wday) `in_` ((valList localParam))
  3535.             Nothing -> return ()
  3536.         case getDefaultFilter filterParam_startE11List defaultFilterJson "startE11List" of
  3537.             Just localParam -> do
  3538.  
  3539.                 where_ $ (t ^. E12E10E11StartE11) `in_` ((valList localParam))
  3540.             Nothing -> return ()
  3541.         return (t ^. E12E10E11Id, c ^. E26Name, t ^. E12E10E11Wday, t ^. E12E10E11StartE11, t ^. E12E10E11E314Window)
  3542.     count <- lift $ runDB $ select $ do
  3543.         baseQuery False
  3544.         let countRows' = countRows
  3545.        orderBy []
  3546.        return $ (countRows' :: SqlExpr (Database.Esqueleto.Value Int))
  3547.     results <- lift $ runDB $ select $ baseQuery True
  3548.     return $ A.object [
  3549.         "totalCount" .= (T.pack $ (\(Database.Esqueleto.Value v) -> show (v::Int)) (head count)),
  3550.         "result" .= (toJSON $ map (\row -> case row of
  3551.                 ((Database.Esqueleto.Value f1), (Database.Esqueleto.Value f2), (Database.Esqueleto.Value f3), (Database.Esqueleto.Value f4), (Database.Esqueleto.Value f5)) -> A.object [
  3552.                     "id" .= toJSON f1,
  3553.                     "e26Name" .= toJSON f2,
  3554.                     "wday" .= toJSON f3,
  3555.                     "startE11" .= toJSON f4,
  3556.                     "e314Window" .= toJSON f5                                    
  3557.                     ]
  3558.                 _ -> A.object []
  3559.             ) results)
  3560.        ]
  3561. deleteE17e10e314sE12E10E11IdR :: forall master. (GeneratedValidation master,
  3562.     YesodAuthPersist master,
  3563.     YesodPersistBackend master ~ SqlPersistT)
  3564.     => E12E10E11Id -> HandlerT Generated (HandlerT master IO) A.Value
  3565. deleteE17e10e314sE12E10E11IdR p1 = do
  3566.     authId <- lift $ requireAuthId
  3567.     _ <- lift $ runDB $ do
  3568.         delete $ from $ (\t -> where_ $ (t ^. E12E10E11Id) ==. ((val p1)))
  3569.     return $ A.Null
  3570.  
  3571. data Generated = Generated
  3572.  
  3573. getGenerated :: a -> Generated
  3574. getGenerated = const Generated
  3575.  
  3576. mkYesodSubData "Generated" [parseRoutes|
  3577. /e10s        E10sR      GET POST
  3578. /e10s/#E10Id        E10sE10IdR      GET PUT DELETE
  3579. /e10e33        E10e33R      GET
  3580. /e11pieces        E11piecesR      GET
  3581. /e11e33        E11e33R      GET
  3582. /e16s        E16sR      GET
  3583. /e13s        E13sR      GET
  3584. /e13e33        E13e33R      GET
  3585. /e14s        E14sR      GET
  3586. /e14s/#E14Id/content        E14sE14IdContentR      GET
  3587. /e26s        E26sR      GET
  3588. /e26groups        E26groupsR      GET
  3589. /e12s        E12sR      GET
  3590. /e12s/#E12Id        E12sE12IdR      DELETE
  3591. /e17e12s        E17e12sR      GET
  3592. /e17e12s/#E12E12Id        E17e12sE12E12IdR      DELETE POST
  3593. /e17e12e34s        E17e12e34sR      GET
  3594. /e17e12e34s/#E12E12E34Id        E17e12e34sE12E12E34IdR      DELETE
  3595. /e19s        E19sR      GET
  3596. /e31s        E31sR      GET
  3597. /e31/#E20Id/numbers        E31E20IdNumbersR      GET
  3598. /e16e12s        E16e12sR      GET
  3599. /e16e12s/#E16E12Id        E16e12sE16E12IdR      DELETE
  3600. /e17E16e12s        E17E16e12sR      GET
  3601. /e17E16e12s/#E12E16E12Id        E17E16e12sE12E16E12IdR      DELETE
  3602. /e10e314s        E10e314sR      GET
  3603. /e10e314s/#E10E11Id        E10e314sE10E11IdR      DELETE
  3604. /e17e10e314s        E17e10e314sR      GET
  3605. /e17e10e314s/#E12E10E11Id        E17e10e314sE12E10E11IdR      DELETE
  3606. |]
Advertisement
Add Comment
Please, Sign In to add comment