SchemaUnions.scala 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. /*
  2. * Copyright (C) 2020 Prasoon Joshi
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. package graphql
  18. import graphql.SchemaDefinition._
  19. import sangria.schema._
  20. object SchemaUnions {
  21. lazy val MixedBasicElementsTypeList = List(FreeTextType, AbbrType, EmphType, ExpanType, ForeignType, LbType, PtrType, RefType)
  22. lazy val AccessTypesList = List(PersnameType, CorpnameType, FamnameType, GeognameType, NameType, OccupationType,
  23. SubjectType, GenreformType, FunctionTypeType, TitleType)
  24. lazy val InterNoquoteElementsTypeList = List(ChronlistType, ListTypeType, TableType)
  25. lazy val InterElementsTypeList = InterNoquoteElementsTypeList :+ BlockquoteType
  26. lazy val BlocksElementsTypeList = InterElementsTypeList :+ PType
  27. implicit lazy val MixedBasicPlusAccessibleOptionType: UnionType[Unit] =
  28. UnionType(
  29. "MixedBasicPlusAccessibleOptions",
  30. Some("A union of m.mixed.basic.elements, m.access, date, footnote, num ,quote"),
  31. types = MixedBasicElementsTypeList ++ AccessTypesList ++ List(DateType, FootnoteType, NumType, QuoteType)
  32. )
  33. implicit val MixedBasicElementsOptionType: UnionType[Unit] =
  34. UnionType(
  35. "MixedBasicElementsOption",
  36. Some("A union type for all MixedBasicElementsOption types"),
  37. types = MixedBasicElementsTypeList
  38. )
  39. implicit lazy val DatesetOptionType: UnionType[Unit] =
  40. UnionType(
  41. "DatesetOption",
  42. Some("A union of Daterange and Datesingle"),
  43. types = List(DatesingleType, DaterangeType)
  44. )
  45. implicit lazy val DatesetOption2Type: UnionType[Unit] =
  46. UnionType(
  47. "DatesetOption2",
  48. Some("A union of Datesingle and Daterange"),
  49. types = List(DatesingleType, DaterangeType)
  50. )
  51. implicit lazy val ParaContentableOptionType: UnionType[Unit] =
  52. UnionType(
  53. "ParaContentableOption",
  54. Some("A union of paragraph content options"),
  55. types = List(FreeTextType, AbbrType, CorpnameType, DateType, EmphType, ExpanType, FamnameType, FootnoteType, ForeignType,
  56. FunctionTypeType, GenreformType, GeognameType, LbType, ListTypeType, NameType, NumType, OccupationType,
  57. PersnameType, PtrType, QuoteType, RefType, SubjectType, TitleType)
  58. )
  59. implicit lazy val ArchDescOptionType: UnionType[Unit] =
  60. UnionType(
  61. "ArchDescOption",
  62. Some("A union of all types that make up Archive Description Options"),
  63. types = List(AccessrestrictType, AccrualsType, AcqinfoType, AltformavailType, AppraisalType, ArrangementType,
  64. BibliographyType, BioghistType, ControlaccessType, CustodhistType, FileplanType, IndexType, LegalstatusType,
  65. OddType, OriginalslocType, OtherfindaidType, PhystechType, PreferciteType, ProcessinfoType, RelatedmaterialType,
  66. RelationsType, ScopecontentType, SeparatedmaterialType, UserestrictType, DscType)
  67. )
  68. implicit lazy val AccessRestrictOptionType: UnionType[Unit] =
  69. UnionType(
  70. "AccessRestrictOptions",
  71. Some("A union of all types that make up AccessRestrictOptions"),
  72. types = List(AccessrestrictType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  73. )
  74. implicit lazy val BlockQuoteOptionType: UnionType[Unit] =
  75. UnionType(
  76. "BlockQuoteOptions",
  77. Some("A union of all types that make up BlockquoteOptions"),
  78. types = List(ChronlistType, ListTypeType, PType, TableType)
  79. )
  80. implicit lazy val MixedBasicElementsOption1Type: UnionType[Unit] =
  81. UnionType(
  82. "MixedBasicElementsOption1",
  83. Some("A union of mixedBasicElementsOption1 types."),
  84. types = List(FreeTextType, AbbrType, EmphType, ExpanType, ForeignType, LbType, PtrType, RefType)
  85. )
  86. implicit lazy val ChronItemOptionType: UnionType[Unit] =
  87. UnionType(
  88. "ChronItemOptions",
  89. Some("A union of chronitem options"),
  90. types = List(DaterangeType, DatesetType, DatesingleType)
  91. )
  92. implicit lazy val ChronItemOption2Type: UnionType[Unit] =
  93. UnionType(
  94. "ChronItemOption2",
  95. Some("A union of event or set of events"),
  96. types = List(ChronitemsetType, EventType, GeognameType)
  97. )
  98. implicit lazy val ListTypeOptionType: UnionType[Unit] =
  99. UnionType(
  100. "ListTypeOptions",
  101. Some("A union of Item, Listhead and Defitem"),
  102. types = List(ItemType, ListTypeSequence1Type)
  103. )
  104. implicit lazy val AccrualsOptionType: UnionType[Unit] =
  105. UnionType(
  106. "AccrualsOptions",
  107. Some("A union of accruals option types"),
  108. types = List(AccrualsType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  109. )
  110. implicit lazy val AcqInfoOptionType: UnionType[Unit] =
  111. UnionType(
  112. "AcqInfoOptions",
  113. Some("A union of acquisition info option types"),
  114. types = List(AcqinfoType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  115. )
  116. implicit lazy val AltFormAvailOptionType: UnionType[Unit] =
  117. UnionType(
  118. "AltFormAvailOptions",
  119. Some("A union of AltFormAvail Option types"),
  120. types = List(AltformavailType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  121. )
  122. implicit lazy val AppraisalOptionType: UnionType[Unit] =
  123. UnionType(
  124. "AppraisalOptions",
  125. Some("A union of all appraisal option types"),
  126. types = List(AppraisalType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  127. )
  128. implicit lazy val ArrangementOptionType: UnionType[Unit] =
  129. UnionType(
  130. "ArrangementOptions",
  131. Some("A union of all arrangement option types"),
  132. types = List(ArrangementType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  133. )
  134. implicit lazy val BibliographyOptionType: UnionType[Unit] =
  135. UnionType(
  136. "BibliographyOptions",
  137. Some("A union of all Bibliography option types"),
  138. types = List(ArchrefType, BibliographyType, BibrefType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  139. )
  140. implicit lazy val BiogHistOptionType: UnionType[Unit] =
  141. UnionType(
  142. "BiogHistOptions",
  143. Some("A union of all BiogHist option types"),
  144. types = List(BioghistType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  145. )
  146. implicit lazy val ControlAccessOptionType: UnionType[Unit] =
  147. UnionType(
  148. "ControlAccessOptions",
  149. Some("A union of all ControlAccess option types"),
  150. types = List(ControlaccessType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType,
  151. CorpnameType, FamnameType, FunctionTypeType, GenreformType, GeognameType, NameType, OccupationType, PersnameType,
  152. SubjectType, TitleType)
  153. )
  154. implicit lazy val CustodHistOptionType: UnionType[Unit] =
  155. UnionType(
  156. "CustodHistOptions",
  157. Some("A union of all CustodHist option types"),
  158. types = List(CustodhistType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  159. )
  160. implicit lazy val FilePlanOptionType: UnionType[Unit] =
  161. UnionType(
  162. "FilePlanOptions",
  163. Some("A union of all FilePlan option types"),
  164. types = List(FileplanType, BlockquoteType, ChronlistType, HeadType, ListTypeType, PType, TableType)
  165. )
  166. implicit lazy val IndexOptionType: UnionType[Unit] =
  167. UnionType(
  168. "IndexOptions",
  169. Some("A union of all Index option types"),
  170. types = List(IndexType, IndexentryType, ListheadType)
  171. )
  172. implicit lazy val IndexEntryOptionType: UnionType[Unit] =
  173. UnionType(
  174. "IndexEntryOption",
  175. Some("A union of all indexEntry option types"),
  176. types = List(NamegrpType, CorpnameType, FamnameType, FunctionTypeType, GenreformType, GeognameType, NameType,
  177. OccupationType, PersnameType, SubjectType, TitleType)
  178. )
  179. implicit lazy val AccessType: UnionType[Unit] =
  180. UnionType(
  181. "AccessTypes",
  182. Some("A union of all access types"),
  183. types = List(CorpnameType, FamnameType, FunctionTypeType, GenreformType, GeognameType, NameType, OccupationType,
  184. PersnameType, SubjectType, TitleType)
  185. )
  186. implicit lazy val IndexEntryOption2Type: UnionType[Unit] =
  187. UnionType(
  188. "IndexEntryOption2",
  189. Some("A union of PtrGrp and Refs"),
  190. types = List(PtrgrpType, PtrType, RefType)
  191. )
  192. implicit lazy val RefsOptionsType: UnionType[Unit] =
  193. UnionType(
  194. "RefOptions",
  195. Some("A union of refs options"),
  196. types = List(PtrType, RefType)
  197. )
  198. implicit lazy val LegalStatusOptionType: UnionType[Unit]=
  199. UnionType(
  200. "LegalStatusOption",
  201. Some("A union of LegalStatus and blocks"),
  202. types = BlocksElementsTypeList :+ LegalstatusType
  203. )
  204. implicit lazy val OddOptionType: UnionType[Unit] =
  205. UnionType(
  206. "OddOptions",
  207. Some("A union of blocks and Odd types"),
  208. types = BlocksElementsTypeList :+ OddType
  209. )
  210. implicit lazy val OriginalsLocOptionType: UnionType[Unit] =
  211. UnionType(
  212. "OriginalsLocOptions",
  213. Some("A union of m.blocks and OriginalsLoc types"),
  214. types = BlocksElementsTypeList :+ OriginalslocType
  215. )
  216. implicit lazy val OtherFindAidOptionType: UnionType[Unit] =
  217. UnionType(
  218. "OtherFindAidOptions",
  219. Some("A union of m.blocks, otherfindaid, archref and bibref types"),
  220. types = BlocksElementsTypeList ++ List(OtherfindaidType, ArchrefType, BibrefType)
  221. )
  222. implicit lazy val PhysTechOptionType: UnionType[Unit] =
  223. UnionType(
  224. "PhysTechOptions",
  225. Some("A union of m.blocks and phystech types"),
  226. types = BlocksElementsTypeList :+ PhystechType
  227. )
  228. implicit lazy val PrefereCiteOptionType: UnionType[Unit] =
  229. UnionType(
  230. "PreferCiteOptions",
  231. Some("A union of m.blocks and preferCite types"),
  232. types = BlocksElementsTypeList :+ PreferciteType
  233. )
  234. implicit lazy val ProcessInfoOptionType: UnionType[Unit] =
  235. UnionType(
  236. "ProcessInfoOption",
  237. Some("A union of m.blocks and processInfo types"),
  238. types = BlocksElementsTypeList :+ ProcessinfoType
  239. )
  240. implicit lazy val RelatedMaterialOptionType: UnionType[Unit] =
  241. UnionType(
  242. "RelatedMaterialOption",
  243. Some("A union of m.blocks, relatedMaterial, archref and bibref types"),
  244. types = BlocksElementsTypeList ++ List(RelatedmaterialType, ArchrefType, BibrefType)
  245. )
  246. implicit lazy val RelationOptionType: UnionType[Unit] =
  247. UnionType(
  248. "RelationOptions",
  249. Some("A Union of datesingle, daterange and dateset types"),
  250. types = List(DatesingleType, DaterangeType, DatesetType)
  251. )
  252. implicit lazy val ScopeContentOptionType: UnionType[Unit] =
  253. UnionType(
  254. "ScopeContentOptions",
  255. Some("A union of m.blocks and scopeContent types"),
  256. types = BlocksElementsTypeList :+ ScopecontentType
  257. )
  258. implicit lazy val SeparatedMaterialOptionType: UnionType[Unit] =
  259. UnionType(
  260. "SeparatedMaterialOption",
  261. Some("A union of m.blocks, separatedMaterial, archref and bibref types"),
  262. types = BlocksElementsTypeList ++ List(SeparatedmaterialType, ArchrefType, BibrefType)
  263. )
  264. implicit lazy val UseRestrictOptionType: UnionType[Unit] =
  265. UnionType(
  266. "UseRestrictOptions",
  267. Some("A union of m.blocks and useRestrict types"),
  268. types = BlocksElementsTypeList :+ UserestrictType
  269. )
  270. implicit lazy val DidOptionType: UnionType[Unit] =
  271. UnionType(
  272. "DidOptions",
  273. Some("A union of abstract, container, dao, daoset, didnote, head, langmaterial, materialspec, origination, " +
  274. "physdescset, physdesc, physdescstructured, physloc, repository, unitdate, unitdatestructured, unitid, " +
  275. "unittitle types"),
  276. types = List(AbstractType, ContainerType, DaoType, DaosetType, DidnoteType, LangmaterialType,
  277. MaterialspecType, OriginationType, PhysdescsetType, PhysdescType, PhysdescstructuredType, PhyslocType,
  278. RepositoryType, UnitdateType, UnitdatestructuredType, UnitidType, UnittitleType)
  279. )
  280. implicit lazy val LangMaterialOptionType: UnionType[Unit] =
  281. UnionType(
  282. "LangMaterialOption",
  283. Some("A union of language and languageset types"),
  284. types = List(LanguageType, LanguagesetType)
  285. )
  286. implicit lazy val OriginationOptionType: UnionType[Unit] =
  287. UnionType(
  288. "OriginationOptions",
  289. Some("A union of Corpname, Famname, Name, Persname types"),
  290. types = List(CorpnameType, FamnameType, NameType, PersnameType)
  291. )
  292. implicit lazy val PhysDescStructuredOptionType: UnionType[Unit] =
  293. UnionType(
  294. "physDescStructuredOptions",
  295. Some("Union of physfacet and dimensions"),
  296. types = List(PhysfacetType, DimensionsType)
  297. )
  298. implicit lazy val RepositoryOptionType: UnionType[Unit] =
  299. UnionType(
  300. "RepositoryOptions",
  301. Some("A union of CorpnameType, FamnameType, NameType and PersnameType"),
  302. types = List(CorpnameType, FamnameType, NameType, PersnameType)
  303. )
  304. implicit lazy val UnitDateStructuredOptionType: UnionType[Unit] =
  305. UnionType(
  306. "UnitDateStructuredOptions",
  307. Some("A Union of datesingle, daterange and dateset types"),
  308. types = List(DatesingleType, DaterangeType, DatesetType)
  309. )
  310. implicit lazy val DimensionsOptionType: UnionType[Unit] =
  311. UnionType(
  312. "DimensionsOptions",
  313. Some("A union of m.mixed.basic.elements and dimensions"),
  314. types = MixedBasicElementsTypeList :+ DimensionsType
  315. )
  316. implicit lazy val RefOptionType: UnionType[Unit] =
  317. UnionType(
  318. "RefOptions",
  319. Some("A union type for all RefOptions"),
  320. types = List(FreeTextType, AbbrType, CorpnameType, DateType, EmphType, ExpanType, FamnameType, FootnoteType,
  321. FunctionTypeType, GenreformType, GeognameType, LbType, NameType, NumType, OccupationType, PersnameType,
  322. PtrType, QuoteType, SubjectType, TitleType)
  323. )
  324. implicit val MixedBasicDateElementsOption1Type: UnionType[Unit] =
  325. UnionType(
  326. "MixedBasicDateElementsOption1",
  327. Some("A union of date element options"),
  328. types = List(FreeTextType, AbbrType, EmphType, ExpanType, ForeignType, LbType, PtrType, RefType)
  329. )
  330. implicit lazy val SeriesStmtOptionType: UnionType[Unit] =
  331. UnionType(
  332. "SeriesStmtOption",
  333. Some("A union of seriesStmt option types"),
  334. types = List(NumType, PType, TitleproperType)
  335. )
  336. implicit lazy val EditionStmtOptionType: UnionType[Unit] =
  337. UnionType(
  338. "EditionStmtOption",
  339. Some("A union of edition and p types"),
  340. types = List(EditionType, PType)
  341. )
  342. implicit lazy val PublicationStmtOptionType: UnionType[Unit] =
  343. UnionType(
  344. "PublicationStmtOptions",
  345. Some("A union of PublisherType, DateType, AddressType, NumType, PType"),
  346. types = List(PublisherType, DateType, AddressType, NumType, PType)
  347. )
  348. implicit lazy val LocalControlOptionType: UnionType[Unit] =
  349. UnionType(
  350. "LocalControlOptions",
  351. Some("A union type for LocalControl Options"),
  352. types = List(DatesingleType, DaterangeType)
  353. )
  354. implicit lazy val COrC01Type: UnionType[Unit] =
  355. UnionType(
  356. "cOrC01",
  357. Some("A union of c or c01."),
  358. types = List(CType, C01Type)
  359. )
  360. implicit lazy val BlocksOptionType: UnionType[Unit] =
  361. UnionType(
  362. "BlocksOptions",
  363. Some("A union of ChronlistType, ListTypeType, TableType, BlockquoteType, PType"),
  364. types = List(ChronlistType, ListTypeType, TableType, BlockquoteType, PType)
  365. )
  366. implicit lazy val DesBaseOptionType: UnionType[Unit] =
  367. UnionType(
  368. "DesBaseOption",
  369. Some("A union of AccessrestrictType, AccrualsType, AcqinfoType, AltformavailType, AppraisalType, ArrangementType, " +
  370. "BibliographyType, BioghistType, ControlaccessType, CustodhistType, FileplanType, IndexType, LegalstatusType," +
  371. "OddType, OriginalslocType, OtherfindaidType, PhystechType, PreferciteType, ProcessinfoType, " +
  372. "RelatedmaterialType, RelationsType, ScopecontentType, SeparatedmaterialType, UserestrictType"),
  373. types = List(AccessrestrictType, AccrualsType, AcqinfoType, AltformavailType, AppraisalType, ArrangementType,
  374. BibliographyType, BioghistType, ControlaccessType, CustodhistType, FileplanType, IndexType, LegalstatusType,
  375. OddType, OriginalslocType, OtherfindaidType, PhystechType, PreferciteType, ProcessinfoType,
  376. RelatedmaterialType, RelationsType, ScopecontentType, SeparatedmaterialType, UserestrictType)
  377. )
  378. }