geonode-pycsw 3.0.0b2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. geonode_pycsw-3.0.0b2.dist-info/METADATA +73 -0
  2. geonode_pycsw-3.0.0b2.dist-info/RECORD +382 -0
  3. geonode_pycsw-3.0.0b2.dist-info/WHEEL +5 -0
  4. geonode_pycsw-3.0.0b2.dist-info/entry_points.txt +2 -0
  5. geonode_pycsw-3.0.0b2.dist-info/licenses/LICENSE.txt +26 -0
  6. geonode_pycsw-3.0.0b2.dist-info/top_level.txt +1 -0
  7. pycsw/__init__.py +33 -0
  8. pycsw/core/__init__.py +29 -0
  9. pycsw/core/admin.py +703 -0
  10. pycsw/core/config.py +621 -0
  11. pycsw/core/etree.py +43 -0
  12. pycsw/core/formats/__init__.py +29 -0
  13. pycsw/core/formats/fmt_json.py +69 -0
  14. pycsw/core/log.py +71 -0
  15. pycsw/core/metadata.py +1996 -0
  16. pycsw/core/pygeofilter_evaluate.py +83 -0
  17. pycsw/core/repository.py +941 -0
  18. pycsw/core/schemas/ogc/cat/csw/3.0/_wrapper.xsd +14 -0
  19. pycsw/core/schemas/ogc/cat/csw/3.0/cswAll.xsd +33 -0
  20. pycsw/core/schemas/ogc/cat/csw/3.0/cswCommon.xsd +71 -0
  21. pycsw/core/schemas/ogc/cat/csw/3.0/cswGetCapabilities.xsd +80 -0
  22. pycsw/core/schemas/ogc/cat/csw/3.0/cswGetDomain.xsd +146 -0
  23. pycsw/core/schemas/ogc/cat/csw/3.0/cswGetRecordById.xsd +58 -0
  24. pycsw/core/schemas/ogc/cat/csw/3.0/cswGetRecords.xsd +391 -0
  25. pycsw/core/schemas/ogc/cat/csw/3.0/cswHarvest.xsd +95 -0
  26. pycsw/core/schemas/ogc/cat/csw/3.0/cswTransaction.xsd +187 -0
  27. pycsw/core/schemas/ogc/cat/csw/3.0/cswUnHarvest.xsd +77 -0
  28. pycsw/core/schemas/ogc/cat/csw/3.0/rec-dcmes.xsd +245 -0
  29. pycsw/core/schemas/ogc/cat/csw/3.0/rec-dcterms.xsd +101 -0
  30. pycsw/core/schemas/ogc/cat/csw/3.0/record.xsd +170 -0
  31. pycsw/core/schemas/ogc/csw/2.0.2/CSW-discovery.xsd +494 -0
  32. pycsw/core/schemas/ogc/csw/2.0.2/CSW-publication.xsd +242 -0
  33. pycsw/core/schemas/ogc/csw/2.0.2/rec-dcmes.xsd +199 -0
  34. pycsw/core/schemas/ogc/csw/2.0.2/rec-dcterms.xsd +94 -0
  35. pycsw/core/schemas/ogc/csw/2.0.2/record.xsd +138 -0
  36. pycsw/core/schemas/ogc/filter/1.1.0/expr.xsd +67 -0
  37. pycsw/core/schemas/ogc/filter/1.1.0/filter.xsd +265 -0
  38. pycsw/core/schemas/ogc/filter/1.1.0/filterCapabilities.xsd +171 -0
  39. pycsw/core/schemas/ogc/filter/1.1.0/sort.xsd +46 -0
  40. pycsw/core/schemas/ogc/filter/2.0/_wrapper.xsd +5 -0
  41. pycsw/core/schemas/ogc/filter/2.0/expr.xsd +44 -0
  42. pycsw/core/schemas/ogc/filter/2.0/filter.xsd +396 -0
  43. pycsw/core/schemas/ogc/filter/2.0/filterAll.xsd +23 -0
  44. pycsw/core/schemas/ogc/filter/2.0/filterCapabilities.xsd +286 -0
  45. pycsw/core/schemas/ogc/filter/2.0/query.xsd +70 -0
  46. pycsw/core/schemas/ogc/filter/2.0/sort.xsd +49 -0
  47. pycsw/core/schemas/ogc/gml/3.1.1/base/basicTypes.xsd +278 -0
  48. pycsw/core/schemas/ogc/gml/3.1.1/base/coordinateOperations.xsd +789 -0
  49. pycsw/core/schemas/ogc/gml/3.1.1/base/coordinateReferenceSystems.xsd +429 -0
  50. pycsw/core/schemas/ogc/gml/3.1.1/base/coordinateSystems.xsd +408 -0
  51. pycsw/core/schemas/ogc/gml/3.1.1/base/coverage.xsd +451 -0
  52. pycsw/core/schemas/ogc/gml/3.1.1/base/dataQuality.xsd +129 -0
  53. pycsw/core/schemas/ogc/gml/3.1.1/base/datums.xsd +484 -0
  54. pycsw/core/schemas/ogc/gml/3.1.1/base/defaultStyle.xsd +454 -0
  55. pycsw/core/schemas/ogc/gml/3.1.1/base/dictionary.xsd +137 -0
  56. pycsw/core/schemas/ogc/gml/3.1.1/base/direction.xsd +72 -0
  57. pycsw/core/schemas/ogc/gml/3.1.1/base/dynamicFeature.xsd +115 -0
  58. pycsw/core/schemas/ogc/gml/3.1.1/base/feature.xsd +199 -0
  59. pycsw/core/schemas/ogc/gml/3.1.1/base/geometryAggregates.xsd +430 -0
  60. pycsw/core/schemas/ogc/gml/3.1.1/base/geometryBasic0d1d.xsd +602 -0
  61. pycsw/core/schemas/ogc/gml/3.1.1/base/geometryBasic2d.xsd +213 -0
  62. pycsw/core/schemas/ogc/gml/3.1.1/base/geometryComplexes.xsd +141 -0
  63. pycsw/core/schemas/ogc/gml/3.1.1/base/geometryPrimitives.xsd +1609 -0
  64. pycsw/core/schemas/ogc/gml/3.1.1/base/gml.xsd +22 -0
  65. pycsw/core/schemas/ogc/gml/3.1.1/base/gmlBase.xsd +294 -0
  66. pycsw/core/schemas/ogc/gml/3.1.1/base/grids.xsd +76 -0
  67. pycsw/core/schemas/ogc/gml/3.1.1/base/measures.xsd +200 -0
  68. pycsw/core/schemas/ogc/gml/3.1.1/base/observation.xsd +96 -0
  69. pycsw/core/schemas/ogc/gml/3.1.1/base/referenceSystems.xsd +211 -0
  70. pycsw/core/schemas/ogc/gml/3.1.1/base/temporal.xsd +332 -0
  71. pycsw/core/schemas/ogc/gml/3.1.1/base/temporalReferenceSystems.xsd +251 -0
  72. pycsw/core/schemas/ogc/gml/3.1.1/base/temporalTopology.xsd +186 -0
  73. pycsw/core/schemas/ogc/gml/3.1.1/base/topology.xsd +459 -0
  74. pycsw/core/schemas/ogc/gml/3.1.1/base/units.xsd +170 -0
  75. pycsw/core/schemas/ogc/gml/3.1.1/base/valueObjects.xsd +361 -0
  76. pycsw/core/schemas/ogc/gml/3.1.1/smil/smil20-language.xsd +117 -0
  77. pycsw/core/schemas/ogc/gml/3.1.1/smil/smil20.xsd +234 -0
  78. pycsw/core/schemas/ogc/gml/3.2.1/basicTypes.xsd +268 -0
  79. pycsw/core/schemas/ogc/gml/3.2.1/coordinateOperations.xsd +525 -0
  80. pycsw/core/schemas/ogc/gml/3.2.1/coordinateReferenceSystems.xsd +373 -0
  81. pycsw/core/schemas/ogc/gml/3.2.1/coordinateSystems.xsd +297 -0
  82. pycsw/core/schemas/ogc/gml/3.2.1/coverage.xsd +292 -0
  83. pycsw/core/schemas/ogc/gml/3.2.1/datums.xsd +287 -0
  84. pycsw/core/schemas/ogc/gml/3.2.1/defaultStyle.xsd +453 -0
  85. pycsw/core/schemas/ogc/gml/3.2.1/deprecatedTypes.xsd +1133 -0
  86. pycsw/core/schemas/ogc/gml/3.2.1/dictionary.xsd +90 -0
  87. pycsw/core/schemas/ogc/gml/3.2.1/direction.xsd +84 -0
  88. pycsw/core/schemas/ogc/gml/3.2.1/dynamicFeature.xsd +109 -0
  89. pycsw/core/schemas/ogc/gml/3.2.1/feature.xsd +94 -0
  90. pycsw/core/schemas/ogc/gml/3.2.1/geometryAggregates.xsd +197 -0
  91. pycsw/core/schemas/ogc/gml/3.2.1/geometryBasic0d1d.xsd +277 -0
  92. pycsw/core/schemas/ogc/gml/3.2.1/geometryBasic2d.xsd +124 -0
  93. pycsw/core/schemas/ogc/gml/3.2.1/geometryComplexes.xsd +95 -0
  94. pycsw/core/schemas/ogc/gml/3.2.1/geometryPrimitives.xsd +846 -0
  95. pycsw/core/schemas/ogc/gml/3.2.1/gml.xsd +20 -0
  96. pycsw/core/schemas/ogc/gml/3.2.1/gmlBase.xsd +185 -0
  97. pycsw/core/schemas/ogc/gml/3.2.1/grids.xsd +64 -0
  98. pycsw/core/schemas/ogc/gml/3.2.1/measures.xsd +68 -0
  99. pycsw/core/schemas/ogc/gml/3.2.1/observation.xsd +95 -0
  100. pycsw/core/schemas/ogc/gml/3.2.1/referenceSystems.xsd +70 -0
  101. pycsw/core/schemas/ogc/gml/3.2.1/temporal.xsd +269 -0
  102. pycsw/core/schemas/ogc/gml/3.2.1/temporalReferenceSystems.xsd +189 -0
  103. pycsw/core/schemas/ogc/gml/3.2.1/temporalTopology.xsd +119 -0
  104. pycsw/core/schemas/ogc/gml/3.2.1/topology.xsd +386 -0
  105. pycsw/core/schemas/ogc/gml/3.2.1/units.xsd +162 -0
  106. pycsw/core/schemas/ogc/gml/3.2.1/valueObjects.xsd +205 -0
  107. pycsw/core/schemas/ogc/ogcapi/records/part1/1.0/ogcapi-records-1.yaml +932 -0
  108. pycsw/core/schemas/ogc/ows/1.0.0/ows19115subset.xsd +222 -0
  109. pycsw/core/schemas/ogc/ows/1.0.0/owsAll.xsd +20 -0
  110. pycsw/core/schemas/ogc/ows/1.0.0/owsCommon.xsd +155 -0
  111. pycsw/core/schemas/ogc/ows/1.0.0/owsDataIdentification.xsd +112 -0
  112. pycsw/core/schemas/ogc/ows/1.0.0/owsExceptionReport.xsd +67 -0
  113. pycsw/core/schemas/ogc/ows/1.0.0/owsGetCapabilities.xsd +108 -0
  114. pycsw/core/schemas/ogc/ows/1.0.0/owsOperationsMetadata.xsd +161 -0
  115. pycsw/core/schemas/ogc/ows/1.0.0/owsServiceIdentification.xsd +55 -0
  116. pycsw/core/schemas/ogc/ows/1.0.0/owsServiceProvider.xsd +46 -0
  117. pycsw/core/schemas/ogc/ows/1.1.0/ows19115subset.xsd +236 -0
  118. pycsw/core/schemas/ogc/ows/1.1.0/owsAll.xsd +23 -0
  119. pycsw/core/schemas/ogc/ows/1.1.0/owsCommon.xsd +158 -0
  120. pycsw/core/schemas/ogc/ows/1.1.0/owsContents.xsd +87 -0
  121. pycsw/core/schemas/ogc/ows/1.1.0/owsDataIdentification.xsd +128 -0
  122. pycsw/core/schemas/ogc/ows/1.1.0/owsDomainType.xsd +280 -0
  123. pycsw/core/schemas/ogc/ows/1.1.0/owsExceptionReport.xsd +77 -0
  124. pycsw/core/schemas/ogc/ows/1.1.0/owsGetCapabilities.xsd +113 -0
  125. pycsw/core/schemas/ogc/ows/1.1.0/owsGetResourceByID.xsd +52 -0
  126. pycsw/core/schemas/ogc/ows/1.1.0/owsInputOutputData.xsd +60 -0
  127. pycsw/core/schemas/ogc/ows/1.1.0/owsManifest.xsd +125 -0
  128. pycsw/core/schemas/ogc/ows/1.1.0/owsOperationsMetadata.xsd +141 -0
  129. pycsw/core/schemas/ogc/ows/1.1.0/owsServiceIdentification.xsd +61 -0
  130. pycsw/core/schemas/ogc/ows/1.1.0/owsServiceProvider.xsd +48 -0
  131. pycsw/core/schemas/ogc/ows/2.0/ows19115subset.xsd +364 -0
  132. pycsw/core/schemas/ogc/ows/2.0/owsAdditionalParameters.xsd +114 -0
  133. pycsw/core/schemas/ogc/ows/2.0/owsAll.xsd +29 -0
  134. pycsw/core/schemas/ogc/ows/2.0/owsCommon.xsd +275 -0
  135. pycsw/core/schemas/ogc/ows/2.0/owsContents.xsd +163 -0
  136. pycsw/core/schemas/ogc/ows/2.0/owsDataIdentification.xsd +202 -0
  137. pycsw/core/schemas/ogc/ows/2.0/owsDomainType.xsd +388 -0
  138. pycsw/core/schemas/ogc/ows/2.0/owsExceptionReport.xsd +126 -0
  139. pycsw/core/schemas/ogc/ows/2.0/owsGetCapabilities.xsd +220 -0
  140. pycsw/core/schemas/ogc/ows/2.0/owsGetResourceByID.xsd +83 -0
  141. pycsw/core/schemas/ogc/ows/2.0/owsInputOutputData.xsd +98 -0
  142. pycsw/core/schemas/ogc/ows/2.0/owsManifest.xsd +181 -0
  143. pycsw/core/schemas/ogc/ows/2.0/owsOperationsMetadata.xsd +234 -0
  144. pycsw/core/schemas/ogc/ows/2.0/owsServiceIdentification.xsd +98 -0
  145. pycsw/core/schemas/ogc/ows/2.0/owsServiceProvider.xsd +64 -0
  146. pycsw/core/schemas/w3c/1999/xlink.xsd +271 -0
  147. pycsw/core/schemas/w3c/2001/xml.xsd +287 -0
  148. pycsw/core/util.py +552 -0
  149. pycsw/oaipmh.py +311 -0
  150. pycsw/ogc/__init__.py +29 -0
  151. pycsw/ogc/api/__init__.py +28 -0
  152. pycsw/ogc/api/oapi.py +558 -0
  153. pycsw/ogc/api/records.py +1414 -0
  154. pycsw/ogc/api/templates/_base.html +76 -0
  155. pycsw/ogc/api/templates/collection.html +44 -0
  156. pycsw/ogc/api/templates/collections.html +45 -0
  157. pycsw/ogc/api/templates/conformance.html +21 -0
  158. pycsw/ogc/api/templates/exception.html +8 -0
  159. pycsw/ogc/api/templates/item.html +228 -0
  160. pycsw/ogc/api/templates/items.html +337 -0
  161. pycsw/ogc/api/templates/landing_page.html +27 -0
  162. pycsw/ogc/api/templates/openapi.html +58 -0
  163. pycsw/ogc/api/templates/queryables.html +50 -0
  164. pycsw/ogc/api/templates/stac_items.html +173 -0
  165. pycsw/ogc/api/templates/static/favicon.ico +0 -0
  166. pycsw/ogc/api/templates/static/logo-horizontal.png +0 -0
  167. pycsw/ogc/api/templates/static/logo-vertical-darkbg.png +0 -0
  168. pycsw/ogc/api/util.py +252 -0
  169. pycsw/ogc/csw/__init__.py +29 -0
  170. pycsw/ogc/csw/cql.py +133 -0
  171. pycsw/ogc/csw/csw2.py +2042 -0
  172. pycsw/ogc/csw/csw3.py +2193 -0
  173. pycsw/ogc/fes/__init__.py +29 -0
  174. pycsw/ogc/fes/fes1.py +433 -0
  175. pycsw/ogc/fes/fes2.py +451 -0
  176. pycsw/ogc/gml/__init__.py +29 -0
  177. pycsw/ogc/gml/gml3.py +240 -0
  178. pycsw/ogc/gml/gml32.py +243 -0
  179. pycsw/opensearch.py +857 -0
  180. pycsw/plugins/__init__.py +29 -0
  181. pycsw/plugins/outputschemas/__init__.py +31 -0
  182. pycsw/plugins/outputschemas/atom.py +143 -0
  183. pycsw/plugins/outputschemas/datacite.py +375 -0
  184. pycsw/plugins/outputschemas/dif.py +213 -0
  185. pycsw/plugins/outputschemas/fgdc.py +180 -0
  186. pycsw/plugins/outputschemas/gm03.py +240 -0
  187. pycsw/plugins/profiles/__init__.py +29 -0
  188. pycsw/plugins/profiles/apiso/__init__.py +29 -0
  189. pycsw/plugins/profiles/apiso/apiso.py +757 -0
  190. pycsw/plugins/profiles/apiso/schemas/ogc/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd +13 -0
  191. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gco/basicTypes.xsd +429 -0
  192. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gco/gco.xsd +12 -0
  193. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gco/gcoBase.xsd +61 -0
  194. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/applicationSchema.xsd +42 -0
  195. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/citation.xsd +275 -0
  196. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/constraints.xsd +106 -0
  197. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/content.xsd +188 -0
  198. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/dataQuality.xsd +554 -0
  199. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/distribution.xsd +202 -0
  200. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/extent.xsd +205 -0
  201. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/freeText.xsd +122 -0
  202. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/gmd.xsd +12 -0
  203. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/identification.xsd +348 -0
  204. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/maintenance.xsd +86 -0
  205. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/metadataApplication.xsd +175 -0
  206. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/metadataEntity.xsd +70 -0
  207. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/metadataExtension.xsd +99 -0
  208. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/portrayalCatalogue.xsd +36 -0
  209. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/referenceSystem.xsd +100 -0
  210. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmd/spatialRepresentation.xsd +237 -0
  211. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/basicTypes.xsd +267 -0
  212. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/coordinateOperations.xsd +639 -0
  213. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/coordinateReferenceSystems.xsd +526 -0
  214. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/coordinateSystems.xsd +401 -0
  215. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/coverage.xsd +462 -0
  216. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/datums.xsd +342 -0
  217. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/dictionary.xsd +129 -0
  218. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/direction.xsd +80 -0
  219. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/dynamicFeature.xsd +142 -0
  220. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/feature.xsd +215 -0
  221. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/geometryAggregates.xsd +216 -0
  222. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/geometryBasic0d1d.xsd +304 -0
  223. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/geometryBasic2d.xsd +123 -0
  224. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/geometryComplexes.xsd +89 -0
  225. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/geometryPrimitives.xsd +892 -0
  226. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/gml.xsd +14 -0
  227. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/gmlBase.xsd +305 -0
  228. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/grids.xsd +58 -0
  229. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/measures.xsd +167 -0
  230. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/observation.xsd +90 -0
  231. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/referenceSystems.xsd +69 -0
  232. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/temporal.xsd +263 -0
  233. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/temporalReferenceSystems.xsd +183 -0
  234. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/temporalTopology.xsd +124 -0
  235. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/topology.xsd +372 -0
  236. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/units.xsd +156 -0
  237. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gml/valueObjects.xsd +212 -0
  238. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmx/catalogues.xsd +112 -0
  239. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmx/codelistItem.xsd +168 -0
  240. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmx/crsItem.xsd +1030 -0
  241. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmx/extendedTypes.xsd +75 -0
  242. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmx/gmx.xsd +2 -0
  243. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmx/gmxUsage.xsd +127 -0
  244. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gmx/uomItem.xsd +162 -0
  245. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gsr/gsr.xsd +12 -0
  246. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gsr/spatialReferencing.xsd +24 -0
  247. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gss/geometry.xsd +35 -0
  248. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gss/gss.xsd +12 -0
  249. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gts/gts.xsd +12 -0
  250. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/gts/temporalObjects.xsd +34 -0
  251. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/srv/serviceMetadata.xsd +197 -0
  252. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/srv/serviceModel.xsd +220 -0
  253. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20060504/srv/srv.xsd +13 -0
  254. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gco/basicTypes.xsd +431 -0
  255. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gco/gco.xsd +12 -0
  256. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gco/gcoBase.xsd +63 -0
  257. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/applicationSchema.xsd +43 -0
  258. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/citation.xsd +276 -0
  259. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/constraints.xsd +107 -0
  260. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/content.xsd +190 -0
  261. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/dataQuality.xsd +556 -0
  262. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/distribution.xsd +203 -0
  263. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/extent.xsd +206 -0
  264. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/freeText.xsd +123 -0
  265. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/gmd.xsd +12 -0
  266. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/identification.xsd +349 -0
  267. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/maintenance.xsd +87 -0
  268. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/metadataApplication.xsd +176 -0
  269. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/metadataEntity.xsd +71 -0
  270. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/metadataExtension.xsd +100 -0
  271. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/portrayalCatalogue.xsd +37 -0
  272. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/referenceSystem.xsd +101 -0
  273. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmd/spatialRepresentation.xsd +238 -0
  274. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmx/catalogues.xsd +113 -0
  275. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmx/codelistItem.xsd +169 -0
  276. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmx/crsItem.xsd +1031 -0
  277. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmx/extendedTypes.xsd +76 -0
  278. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmx/gmx.xsd +12 -0
  279. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmx/gmxUsage.xsd +128 -0
  280. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gmx/uomItem.xsd +163 -0
  281. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gsr/gsr.xsd +12 -0
  282. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gsr/spatialReferencing.xsd +25 -0
  283. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gss/geometry.xsd +36 -0
  284. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gss/gss.xsd +12 -0
  285. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gts/gts.xsd +12 -0
  286. pycsw/plugins/profiles/apiso/schemas/ogc/iso/19139/20070417/gts/temporalObjects.xsd +35 -0
  287. pycsw/plugins/profiles/ebrim/__init__.py +29 -0
  288. pycsw/plugins/profiles/ebrim/ebrim.py +174 -0
  289. pycsw/plugins/profiles/ebrim/schemas/ogc/csw/2.0.2/profiles/ebrim/1.0/csw-ebrim-iri.xsd +146 -0
  290. pycsw/plugins/profiles/ebrim/schemas/ogc/csw/2.0.2/profiles/ebrim/1.0/csw-ebrim.xsd +104 -0
  291. pycsw/plugins/profiles/iso19115p3/__init__.py +29 -0
  292. pycsw/plugins/profiles/iso19115p3/iso19115p3.py +854 -0
  293. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cat/1.0/cat.xsd +13 -0
  294. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cat/1.0/catalogues.xsd +53 -0
  295. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cat/1.0/codelistItem.xsd +54 -0
  296. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cat/1.0/crsItem.xsd +181 -0
  297. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cat/1.0/uomItem.xsd +38 -0
  298. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cit/1.0/cit.xsd +7 -0
  299. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cit/1.0/citation.xsd +514 -0
  300. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cit/2.0/cit.xsd +10 -0
  301. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/cit/2.0/citation.xsd +523 -0
  302. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gco/1.0/baseTypes2014.xsd +530 -0
  303. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gco/1.0/gco.xsd +16 -0
  304. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gcx/1.0/extendedTypes.xsd +92 -0
  305. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gcx/1.0/extendedTypes_autoFromShapeChange.xsd +60 -0
  306. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gcx/1.0/gcx.xsd +8 -0
  307. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gex/1.0/extent.xsd +241 -0
  308. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gex/1.0/gex.xsd +9 -0
  309. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gmw/1.0/gmlWrapperTypes2014.xsd +159 -0
  310. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/gmw/1.0/gmw.xsd +14 -0
  311. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/lan/1.0/lan.xsd +8 -0
  312. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/lan/1.0/language.xsd +140 -0
  313. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mac/1.0/acquisitionInformationImagery.xsd +622 -0
  314. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mac/1.0/mac.xsd +11 -0
  315. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mac/2.0/acquisitionInformationImagery.xsd +590 -0
  316. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mac/2.0/event.xsd +108 -0
  317. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mac/2.0/mac.xsd +10 -0
  318. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mas/1.0/applicationSchema.xsd +61 -0
  319. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mas/1.0/mas.xsd +9 -0
  320. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mcc/1.0/AbstractCommonClasses.xsd +358 -0
  321. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mcc/1.0/commonClasses.xsd +220 -0
  322. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mcc/1.0/mcc.xsd +8 -0
  323. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mco/1.0/constraints.xsd +188 -0
  324. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mco/1.0/mco.xsd +8 -0
  325. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/md1/1.0/md1.xsd +9 -0
  326. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/md1/1.0/metadataWExtendedType.xsd +4 -0
  327. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/md2/1.0/md2.xsd +15 -0
  328. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/md2/1.0/metadataWithExtensions.xsd +4 -0
  329. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mda/1.0/mda.xsd +8 -0
  330. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mda/1.0/metadataApplication.xsd +200 -0
  331. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mdb/1.0/mdb.xsd +14 -0
  332. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mdb/1.0/metadataBase.xsd +98 -0
  333. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mdb/2.0/mdb.xsd +20 -0
  334. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mdb/2.0/metadataBase.xsd +102 -0
  335. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mds/1.0/mds.xsd +22 -0
  336. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mds/1.0/metadataDataServices.xsd +4 -0
  337. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mdt/1.0/mdt.xsd +13 -0
  338. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mdt/1.0/metadataTransfer.xsd +111 -0
  339. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mex/1.0/metadataExtension.xsd +156 -0
  340. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mex/1.0/mex.xsd +8 -0
  341. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mmi/1.0/maintenance.xsd +76 -0
  342. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mmi/1.0/mmi.xsd +8 -0
  343. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mpc/1.0/mpc.xsd +8 -0
  344. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mpc/1.0/portrayalCatalogue.xsd +31 -0
  345. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrc/1.0/content.xsd +416 -0
  346. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrc/1.0/contentInformationImagery.xsd +185 -0
  347. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrc/1.0/mrc.xsd +11 -0
  348. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrc/2.0/content.xsd +419 -0
  349. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrc/2.0/contentInformationImagery.xsd +171 -0
  350. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrc/2.0/mrc.xsd +11 -0
  351. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrd/1.0/distribution.xsd +267 -0
  352. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrd/1.0/mrd.xsd +8 -0
  353. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mri/1.0/identification.xsd +517 -0
  354. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mri/1.0/mri.xsd +9 -0
  355. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrl/1.0/lineage.xsd +147 -0
  356. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrl/1.0/lineageImagery.xsd +236 -0
  357. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrl/1.0/mrl.xsd +9 -0
  358. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrl/2.0/lineage.xsd +147 -0
  359. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrl/2.0/lineageImagery.xsd +312 -0
  360. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrl/2.0/mrl.xsd +11 -0
  361. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrs/1.0/mrs.xsd +8 -0
  362. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/mrs/1.0/referenceSystem.xsd +47 -0
  363. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/msr/1.0/msr.xsd +10 -0
  364. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/msr/1.0/spatialRepresentation.xsd +375 -0
  365. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/msr/1.0/spatialRepresentationImagery.xsd +119 -0
  366. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/msr/2.0/msr.xsd +15 -0
  367. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/msr/2.0/spatialRepresentation.xsd +381 -0
  368. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/msr/2.0/spatialRepresentationImagery.xsd +120 -0
  369. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/srv/2.0/serviceInformation.xsd +272 -0
  370. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/srv/2.0/srv.xsd +6 -0
  371. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/srv/2.1/serviceInformation.xsd +278 -0
  372. pycsw/plugins/profiles/iso19115p3/schemas/ogc/iso/iso19115-3/srv/2.1/srv.xsd +6 -0
  373. pycsw/plugins/profiles/profile.py +141 -0
  374. pycsw/plugins/repository/__init__.py +29 -0
  375. pycsw/plugins/repository/odc/__init__.py +29 -0
  376. pycsw/plugins/repository/odc/odc.py +153 -0
  377. pycsw/server.py +938 -0
  378. pycsw/sru.py +217 -0
  379. pycsw/stac/__init__.py +29 -0
  380. pycsw/stac/api.py +571 -0
  381. pycsw/wsgi.py +233 -0
  382. pycsw/wsgi_flask.py +345 -0
@@ -0,0 +1,1414 @@
1
+ # =================================================================
2
+ #
3
+ # Authors: Tom Kralidis <tomkralidis@gmail.com>
4
+ # Angelos Tzotsos <tzotsos@gmail.com>
5
+ #
6
+ # Copyright (c) 2024 Tom Kralidis
7
+ # Copyright (c) 2021 Angelos Tzotsos
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person
10
+ # obtaining a copy of this software and associated documentation
11
+ # files (the "Software"), to deal in the Software without
12
+ # restriction, including without limitation the rights to use,
13
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ # copies of the Software, and to permit persons to whom the
15
+ # Software is furnished to do so, subject to the following
16
+ # conditions:
17
+ #
18
+ # The above copyright notice and this permission notice shall be
19
+ # included in all copies or substantial portions of the Software.
20
+ #
21
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28
+ # OTHER DEALINGS IN THE SOFTWARE.
29
+ #
30
+ # =================================================================
31
+
32
+ import json
33
+ import logging
34
+ import os
35
+ from urllib.parse import urlencode, quote
36
+
37
+ from owslib.ogcapi.records import Records
38
+ from pygeofilter.parsers.ecql import parse as parse_ecql
39
+ from pygeofilter.parsers.cql2_json import parse as parse_cql2_json
40
+
41
+ from pycsw import __version__
42
+ from pycsw.core import log
43
+ from pycsw.core.config import StaticContext
44
+ from pycsw.core.metadata import parse_record
45
+ from pycsw.core.pygeofilter_evaluate import to_filter
46
+ from pycsw.core.util import bind_url, get_today_and_now, jsonify_links, load_custom_repo_mappings, str2bool, wkt2geom
47
+ from pycsw.ogc.api.oapi import gen_oapi
48
+ from pycsw.ogc.api.util import match_env_var, render_j2_template, to_json, to_rfc3339
49
+
50
+ LOGGER = logging.getLogger(__name__)
51
+
52
+ #: Return headers for requests (e.g:X-Powered-By)
53
+ HEADERS = {
54
+ 'Content-Type': 'application/json',
55
+ 'X-Powered-By': f'pycsw {__version__}'
56
+ }
57
+
58
+ THISDIR = os.path.dirname(os.path.realpath(__file__))
59
+
60
+
61
+ CONFORMANCE_CLASSES = [
62
+ 'http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core',
63
+ 'http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections',
64
+ 'http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core',
65
+ 'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/queryables',
66
+ 'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/queryables-query-parameters', # noqa
67
+ 'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter',
68
+ 'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter',
69
+ 'http://www.opengis.net/spec/ogcapi-features-4/1.0/conf/create-replace-delete', # noqa
70
+ 'http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/core',
71
+ 'http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/sorting',
72
+ 'http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/json',
73
+ 'http://www.opengis.net/spec/ogcapi-records-1/1.0/conf/html',
74
+ 'http://www.opengis.net/spec/cql2/1.0/conf/cql2-json',
75
+ 'http://www.opengis.net/spec/cql2/1.0/conf/cql2-text'
76
+ ]
77
+
78
+
79
+ class API:
80
+ """API object"""
81
+
82
+ def __init__(self, config: dict):
83
+ """
84
+ constructor
85
+
86
+ :param config: pycsw configuration dict
87
+
88
+ :returns: `pycsw.ogc.api.API` instance
89
+ """
90
+
91
+ self.mode = 'ogcapi-records'
92
+ self.config = config
93
+
94
+ log.setup_logger(self.config.get('logging', {}))
95
+
96
+ if self.config['server']['url'].startswith('${'):
97
+ LOGGER.debug(f"Server URL is an environment variable: {self.config['server']['url']}")
98
+ url_ = match_env_var(self.config['server']['url'])
99
+ else:
100
+ url_ = self.config['server']['url']
101
+
102
+ LOGGER.debug(f'Server URL: {url_}')
103
+ self.config['server']['url'] = url_.rstrip('/')
104
+ self.facets = self.config['repository'].get('facets', ['type'])
105
+
106
+ self.context = StaticContext()
107
+
108
+ LOGGER.debug('Setting limit')
109
+ try:
110
+ self.limit = int(self.config['server']['maxrecords'])
111
+ except KeyError:
112
+ self.limit = 10
113
+ LOGGER.debug(f'limit: {self.limit}')
114
+
115
+ repo_filter = self.config['repository'].get('filter')
116
+
117
+ custom_mappings_path = self.config['repository'].get('mappings')
118
+ if custom_mappings_path is not None:
119
+ md_core_model = load_custom_repo_mappings(custom_mappings_path)
120
+ if md_core_model is not None:
121
+ self.context.md_core_model = md_core_model
122
+ else:
123
+ LOGGER.exception(
124
+ 'Could not load custom mappings: %s', custom_mappings_path)
125
+
126
+ self.orm = 'sqlalchemy'
127
+ from pycsw.core import repository
128
+ try:
129
+ LOGGER.info('Loading default repository')
130
+ self.repository = repository.Repository(
131
+ self.config['repository']['database'],
132
+ self.context,
133
+ table=self.config['repository']['table'],
134
+ repo_filter=repo_filter
135
+ )
136
+ LOGGER.debug(f'Repository loaded {self.repository.dbtype}')
137
+ except Exception as err:
138
+ msg = f'Could not load repository {err}'
139
+ LOGGER.exception(msg)
140
+ raise
141
+
142
+ def get_content_type(self, headers, args):
143
+ """
144
+ Decipher content type requested
145
+
146
+ :param headers: `dict` of HTTP request headers
147
+ :param args: `dict` of query arguments
148
+
149
+ :returns: `str` of response content type
150
+ """
151
+
152
+ content_type = 'application/json'
153
+
154
+ format_ = args.get('f')
155
+
156
+ if headers and 'Accept' in headers:
157
+ if 'text/html' in headers['Accept']:
158
+ content_type = 'text/html'
159
+ elif 'application/xml' in headers['Accept']:
160
+ content_type = 'application/xml'
161
+
162
+ if format_ is not None:
163
+ if format_ == 'json':
164
+ content_type = 'application/json'
165
+ elif format_ == 'xml':
166
+ content_type = 'application/xml'
167
+ elif format_ == 'html':
168
+ content_type = 'text/html'
169
+
170
+ return content_type
171
+
172
+ def get_response(self, status, headers, data, template=None):
173
+ """
174
+ Provide response
175
+
176
+ :param status: `int` of HTTP status
177
+ :param headers: `dict` of HTTP request headers
178
+ :param data: `dict` of response data
179
+ :param template: template filename (default is `None`)
180
+
181
+ :returns: tuple of headers, status code, content
182
+ """
183
+
184
+ if headers.get('Content-Type') == 'text/html' and template is not None:
185
+ content = render_j2_template(self.config, template, data)
186
+ else:
187
+ pretty_print = str2bool(self.config['server'].get('pretty_print', False))
188
+ content = to_json(data, pretty_print)
189
+
190
+ headers['Content-Length'] = len(content)
191
+
192
+ return headers, status, content
193
+
194
+ def landing_page(self, headers_, args):
195
+ """
196
+ Provide API landing page
197
+
198
+ :param headers_: copy of HEADERS object
199
+ :param args: request parameters
200
+
201
+ :returns: tuple of headers, status code, content
202
+ """
203
+
204
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
205
+
206
+ response = {
207
+ 'id': 'pycsw-catalogue',
208
+ 'links': [],
209
+ 'title': self.config['metadata']['identification']['title'],
210
+ 'description':
211
+ self.config['metadata']['identification']['description'],
212
+ 'keywords':
213
+ self.config['metadata']['identification']['keywords']
214
+ }
215
+
216
+ LOGGER.debug('Creating links')
217
+ response['links'] = [{
218
+ 'rel': 'self',
219
+ 'type': 'application/json',
220
+ 'title': 'This document as JSON',
221
+ 'href': f"{self.config['server']['url']}?f=json",
222
+ 'hreflang': self.config['server']['language']
223
+ }, {
224
+ 'rel': 'conformance',
225
+ 'type': 'application/json',
226
+ 'title': 'Conformance as JSON',
227
+ 'href': f"{self.config['server']['url']}/conformance?f=json"
228
+ }, {
229
+ 'rel': 'service-doc',
230
+ 'type': 'text/html',
231
+ 'title': 'The OpenAPI definition as HTML',
232
+ 'href': f"{self.config['server']['url']}/openapi?f=html"
233
+ }, {
234
+ 'rel': 'service-desc',
235
+ 'type': 'application/vnd.oai.openapi+json;version=3.0',
236
+ 'title': 'The OpenAPI definition as JSON',
237
+ 'href': f"{self.config['server']['url']}/openapi?f=json"
238
+ }, {
239
+ 'rel': 'data',
240
+ 'type': 'application/json',
241
+ 'title': 'Collections as JSON',
242
+ 'href': f"{self.config['server']['url']}/collections?f=json"
243
+ }, {
244
+ 'rel': 'search',
245
+ 'type': 'application/json',
246
+ 'title': 'Search collections',
247
+ 'href': f"{self.config['server']['url']}/search"
248
+ }, {
249
+ 'rel': 'child',
250
+ 'type': 'application/json',
251
+ 'title': 'Main metadata collection',
252
+ 'href': f"{self.config['server']['url']}/collections/metadata:main?f=json"
253
+ }, {
254
+ 'rel': 'service',
255
+ 'type': 'application/xml',
256
+ 'title': 'CSW 3.0.0 endpoint',
257
+ 'href': f"{self.config['server']['url']}/csw"
258
+ }, {
259
+ 'rel': 'service',
260
+ 'type': 'application/xml',
261
+ 'title': 'CSW 2.0.2 endpoint',
262
+ 'href': f"{self.config['server']['url']}/csw?service=CSW&version=2.0.2&request=GetCapabilities"
263
+ }, {
264
+ 'rel': 'service',
265
+ 'type': 'application/xml',
266
+ 'title': 'OpenSearch endpoint',
267
+ 'href': f"{self.config['server']['url']}/opensearch"
268
+ }, {
269
+ 'rel': 'service',
270
+ 'type': 'application/xml',
271
+ 'title': 'OAI-PMH endpoint',
272
+ 'href': f"{self.config['server']['url']}/oaipmh"
273
+ }, {
274
+ 'rel': 'service',
275
+ 'type': 'application/xml',
276
+ 'title': 'SRU endpoint',
277
+ 'href': f"{self.config['server']['url']}/sru"
278
+ }, {
279
+ 'rel': 'http://www.opengis.net/def/rel/ogc/1.0/queryables',
280
+ 'type': 'application/schema+json',
281
+ 'title': 'Queryables',
282
+ 'href': f"{self.config['server']['url']}/queryables"
283
+ }, {
284
+ 'rel': 'child',
285
+ 'type': 'application/json',
286
+ 'title': 'Main collection',
287
+ 'href': f"{self.config['server']['url']}/collections/metadata:main"
288
+ }
289
+ ]
290
+
291
+ return self.get_response(200, headers_, response, 'landing_page.html')
292
+
293
+ def openapi(self, headers_, args):
294
+ """
295
+ Provide OpenAPI document / Swagger
296
+
297
+ :param headers_: copy of HEADERS object
298
+ :param args: request parameters
299
+
300
+ :returns: tuple of headers, status code, content
301
+ """
302
+
303
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
304
+ if headers_['Content-Type'] == 'application/json':
305
+ headers_['Content-Type'] = 'application/vnd.oai.openapi+json;version=3.0'
306
+
307
+ filepath = f"{THISDIR}/../../core/schemas/ogc/ogcapi/records/part1/1.0/ogcapi-records-1.yaml"
308
+
309
+ response = gen_oapi(self.config, filepath)
310
+
311
+ return self.get_response(200, headers_, response, 'openapi.html')
312
+
313
+ def conformance(self, headers_, args):
314
+ """
315
+ Provide API conformance
316
+
317
+ :param headers_: copy of HEADERS object
318
+ :param args: request parameters
319
+
320
+ :returns: tuple of headers, status code, content
321
+ """
322
+
323
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
324
+
325
+ response = {
326
+ 'conformsTo': CONFORMANCE_CLASSES
327
+ }
328
+
329
+ return self.get_response(200, headers_, response, 'conformance.html')
330
+
331
+ def collections(self, headers_, args):
332
+ """
333
+ Provide API collections
334
+
335
+ :param headers_: copy of HEADERS object
336
+ :param args: request parameters
337
+
338
+ :returns: tuple of headers, status code, content
339
+ """
340
+
341
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
342
+
343
+ collections = []
344
+
345
+ LOGGER.debug('Generating default metadata:main collection')
346
+ collection_info = self.get_collection_info()
347
+
348
+ collections.append(collection_info)
349
+
350
+ LOGGER.debug('Generating virtual collections')
351
+ virtual_collections = self.repository.query_collections()
352
+
353
+ for virtual_collection in virtual_collections:
354
+ virtual_collection_info = self.get_collection_info(
355
+ virtual_collection.identifier,
356
+ dict(title=virtual_collection.title,
357
+ description=virtual_collection.abstract))
358
+
359
+ collections.append(virtual_collection_info)
360
+
361
+ response = {
362
+ 'collections': collections
363
+ }
364
+ url_base = f"{self.config['server']['url']}/collections"
365
+
366
+ is_html = headers_['Content-Type'] == 'text/html'
367
+
368
+ response['links'] = [{
369
+ 'rel': 'self' if not is_html else 'alternate',
370
+ 'type': 'application/json',
371
+ 'title': 'This document as JSON',
372
+ 'href': f"{url_base}?f=json",
373
+ 'hreflang': self.config['server']['language']
374
+ }, {
375
+ 'rel': 'self' if is_html else 'alternate',
376
+ 'type': 'text/html',
377
+ 'title': 'This document as HTML',
378
+ 'href': f"{url_base}?f=html",
379
+ 'hreflang': self.config['server']['language']
380
+ }]
381
+
382
+ return self.get_response(200, headers_, response, 'collections.html')
383
+
384
+ def collection(self, headers_, args, collection='metadata:main'):
385
+ """
386
+ Provide API collections
387
+
388
+ :param headers_: copy of HEADERS object
389
+ :param args: request parameters
390
+ :param collection: collection name
391
+
392
+ :returns: tuple of headers, status code, content
393
+ """
394
+
395
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
396
+
397
+ LOGGER.debug(f'Generating {collection} collection')
398
+
399
+ if collection == 'metadata:main':
400
+ collection_info = self.get_collection_info()
401
+ else:
402
+ virtual_collection = self.repository.query_ids([collection])[0]
403
+ collection_info = self.get_collection_info(
404
+ virtual_collection.identifier,
405
+ dict(title=virtual_collection.title,
406
+ description=virtual_collection.abstract))
407
+
408
+ response = collection_info
409
+ url_base = f"{self.config['server']['url']}/collections/{collection}"
410
+
411
+ is_html = headers_['Content-Type'] == 'text/html'
412
+
413
+ response['links'] = [{
414
+ 'rel': 'self' if not is_html else 'alternate',
415
+ 'type': 'application/json',
416
+ 'title': 'This document as JSON',
417
+ 'href': f"{url_base}?f=json",
418
+ 'hreflang': self.config['server']['language']
419
+ }, {
420
+ 'rel': 'self' if is_html else 'alternate',
421
+ 'type': 'text/html',
422
+ 'title': 'This document as HTML',
423
+ 'href': f"{url_base}?f=html",
424
+ 'hreflang': self.config['server']['language']
425
+ }, {
426
+ 'rel': 'items',
427
+ 'type': 'application/geo+json',
428
+ 'title': 'items as GeoJSON',
429
+ 'href': f"{url_base}/items?f=json",
430
+ 'hreflang': self.config['server']['language']
431
+ }, {
432
+ 'rel': 'items',
433
+ 'type': 'text/html',
434
+ 'title': 'items as HTML',
435
+ 'href': f"{url_base}/items?f=html",
436
+ 'hreflang': self.config['server']['language']
437
+ }, {
438
+ 'rel': 'http://www.opengis.net/def/rel/ogc/1.0/queryables',
439
+ 'type': 'application/schema+json',
440
+ 'title': 'Queryables as JSON',
441
+ 'href': f"{url_base}/queryables?f=json",
442
+ 'hreflang': self.config['server']['language']
443
+ }, {
444
+ 'rel': 'http://www.opengis.net/def/rel/ogc/1.0/queryables',
445
+ 'type': 'text/html',
446
+ 'title': 'Queryables as HTML',
447
+ 'href': f"{url_base}/queryables?f=html",
448
+ 'hreflang': self.config['server']['language']
449
+ }]
450
+
451
+ return self.get_response(200, headers_, response, 'collection.html')
452
+
453
+ def queryables(self, headers_, args, collection='metadata:main'):
454
+ """
455
+ Provide collection queryables
456
+
457
+ :param headers_: copy of HEADERS object
458
+ :param args: request parameters
459
+ :param collection: name of collection
460
+
461
+ :returns: tuple of headers, status code, content
462
+ """
463
+
464
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
465
+
466
+ if 'json' in headers_['Content-Type']:
467
+ headers_['Content-Type'] = 'application/schema+json'
468
+
469
+ if collection not in self.get_all_collections():
470
+ msg = 'Invalid collection'
471
+ LOGGER.exception(msg)
472
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
473
+
474
+ properties = self.repository.describe()
475
+ properties2 = {}
476
+
477
+ for key, value in properties.items():
478
+ if key in self.repository.query_mappings or key == 'geometry':
479
+ properties2[key] = value
480
+
481
+ if collection == 'metadata:main':
482
+ title = self.config['metadata']['identification']['title']
483
+ else:
484
+ title = self.config['metadata']['identification']['title']
485
+ virtual_collection = self.repository.query_ids([collection])[0]
486
+ title = virtual_collection.title
487
+
488
+ response = {
489
+ 'id': collection,
490
+ 'type': 'object',
491
+ 'title': title,
492
+ 'properties': properties2,
493
+ '$schema': 'http://json-schema.org/draft/2019-09/schema',
494
+ '$id': f"{self.config['server']['url']}/collections/{collection}/queryables"
495
+ }
496
+
497
+ return self.get_response(200, headers_, response, 'queryables.html')
498
+
499
+ def items(self, headers_, json_post_data, args, collection='metadata:main'):
500
+ """
501
+ Provide collection items
502
+
503
+ :param headers_: copy of HEADERS object
504
+ :param args: request parameters
505
+ :param collection: collection name
506
+
507
+ :returns: tuple of headers, status code, content
508
+ """
509
+
510
+ LOGGER.debug(f'Request args: {args.keys()}')
511
+ LOGGER.debug('converting request argument names to lower case')
512
+ args = {k.lower(): v for k, v in args.items()}
513
+ LOGGER.debug(f'Request args (lower case): {args.keys()}')
514
+
515
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
516
+
517
+ reserved_query_params = [
518
+ 'distributed',
519
+ 'f',
520
+ 'facets',
521
+ 'filter',
522
+ 'filter-lang',
523
+ 'limit',
524
+ 'sortby',
525
+ 'offset'
526
+ ]
527
+
528
+ filter_langs = [
529
+ 'cql2-json',
530
+ 'cql2-text'
531
+ ]
532
+
533
+ response = {
534
+ 'type': 'FeatureCollection',
535
+ 'facets': [],
536
+ 'features': [],
537
+ 'links': []
538
+ }
539
+
540
+ cql_query = None
541
+ query_parser = None
542
+ sortby = None
543
+ limit = None
544
+ bbox = []
545
+ facets_requested = False
546
+ collections = []
547
+
548
+ if collection not in self.get_all_collections():
549
+ msg = 'Invalid collection'
550
+ LOGGER.exception(msg)
551
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
552
+
553
+ if json_post_data is not None:
554
+ LOGGER.debug(f'JSON POST data: {json_post_data}')
555
+ LOGGER.debug('Transforming JSON POST data into request args')
556
+
557
+ for p in ['limit', 'bbox', 'datetime', 'collections']:
558
+ if p in json_post_data:
559
+ if p == 'bbox':
560
+ args[p] = ','.join(map(str, json_post_data.get(p)))
561
+ else:
562
+ args[p] = json_post_data.get(p)
563
+
564
+ if 'sortby' in json_post_data:
565
+ LOGGER.debug('Detected sortby')
566
+ args['sortby'] = json_post_data['sortby'][0]['field']
567
+ if json_post_data['sortby'][0].get('direction', 'asc') == 'desc':
568
+ args['sortby'] = f"-{args['sortby']}"
569
+
570
+ LOGGER.debug(f'Transformed args: {args}')
571
+
572
+ if 'filter' in args:
573
+ LOGGER.debug(f'CQL query specified {args["filter"]}')
574
+ cql_query = args['filter']
575
+ filter_lang = args.get('filter-lang')
576
+ if filter_lang is not None and filter_lang not in filter_langs:
577
+ msg = f'Invalid filter-lang, available: {", ".join(filter_langs)}'
578
+ LOGGER.exception(f'{msg} Used: {filter_lang}')
579
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
580
+
581
+ LOGGER.debug('Transforming property filters into CQL')
582
+ query_args = []
583
+ for k, v in args.items():
584
+ if k in reserved_query_params:
585
+ continue
586
+
587
+ if k not in reserved_query_params:
588
+ if k == 'ids':
589
+ ids = ','.join(f'"{x}"' for x in v.split(','))
590
+ query_args.append(f"identifier IN ({ids})")
591
+ elif k == 'collections':
592
+ if isinstance(collections, str):
593
+ collections = ','.join(f'"{x}"' for x in v.split(','))
594
+ else:
595
+ collections = ','.join(f'"{x}"' for x in v)
596
+ query_args.append(f"parentidentifier IN ({collections})")
597
+ elif k == 'anytext':
598
+ query_args.append(build_anytext(k, v))
599
+ elif k == 'bbox':
600
+ query_args.append(f'BBOX(geometry, {v})')
601
+ elif k == 'keywords':
602
+ query_args.append(f"keywords ILIKE '%{v}%'")
603
+ elif k == 'datetime':
604
+ if '/' not in v:
605
+ query_args.append(f'date = "{v}"')
606
+ else:
607
+ begin, end = v.split('/')
608
+ if begin != '..':
609
+ query_args.append(f'time_begin >= "{begin}"')
610
+ if end != '..':
611
+ query_args.append(f'time_end <= "{end}"')
612
+ elif k == 'q':
613
+ if v not in [None, '']:
614
+ query_args.append(build_anytext('anytext', v))
615
+ else:
616
+ query_args.append(f'{k} = "{v}"')
617
+
618
+ facets_requested = str2bool(args.get('facets', False))
619
+
620
+ if collection != 'metadata:main':
621
+ LOGGER.debug('Adding virtual collection filter')
622
+ query_args.append(f'parentidentifier = "{collection}"')
623
+
624
+ LOGGER.debug('Evaluating CQL and other specified filtering parameters')
625
+ if cql_query is not None and query_args:
626
+ LOGGER.debug('Combining CQL and other specified filtering parameters')
627
+ cql_query += ' AND ' + ' AND '.join(query_args)
628
+ elif cql_query is not None and not query_args:
629
+ LOGGER.debug('Just CQL detected')
630
+ elif cql_query is None and query_args:
631
+ LOGGER.debug('Just other specified filtering parameters detected')
632
+ cql_query = ' AND '.join(query_args)
633
+
634
+ LOGGER.debug(f'CQL query: {cql_query}')
635
+
636
+ if cql_query is not None:
637
+ LOGGER.debug('Detected CQL text')
638
+ query_parser = parse_ecql
639
+
640
+ elif json_post_data is not None:
641
+
642
+ if 'limit' in json_post_data:
643
+ limit = json_post_data.pop('limit')
644
+ if 'sortby' in json_post_data:
645
+ sortby = json_post_data.pop('sortby')
646
+ if 'collections' in json_post_data:
647
+ collections = json_post_data.pop('collections')
648
+ if 'bbox' in json_post_data:
649
+ bbox = json_post_data.pop('bbox')
650
+ if not json_post_data:
651
+ LOGGER.debug('No CQL specified, only query parameters')
652
+ json_post_data = {}
653
+ if not json_post_data and collections and collections != ['metadata:main']:
654
+ json_post_data = {'op': 'eq', 'args': [{'property': 'parentidentifier'}, collections[0]]}
655
+ if bbox:
656
+ json_post_data = {
657
+ 'op': 'and',
658
+ 'args': [{
659
+ 'op': 's_intersects',
660
+ 'args': [
661
+ {'property': 'geometry2'},
662
+ {'bbox': [bbox]}
663
+ ]},
664
+ json_post_data
665
+ ]
666
+ }
667
+
668
+ cql_query = json_post_data
669
+ LOGGER.debug('Detected CQL JSON; ignoring all other query predicates')
670
+ query_parser = parse_cql2_json
671
+
672
+ LOGGER.debug(f'query parser: {query_parser}')
673
+
674
+ if query_parser is not None and json_post_data != {}:
675
+ LOGGER.debug('Parsing CQL into AST')
676
+ LOGGER.debug(json_post_data)
677
+ LOGGER.debug(cql_query)
678
+ try:
679
+ ast = query_parser(cql_query)
680
+ LOGGER.debug(f'Abstract syntax tree: {ast}')
681
+ except Exception as err:
682
+ msg = f'CQL parsing error: {str(err)}'
683
+ LOGGER.exception(msg)
684
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
685
+
686
+ LOGGER.debug('Transforming AST into filters')
687
+ try:
688
+ filters = to_filter(ast, self.repository.dbtype, self.repository.query_mappings)
689
+ LOGGER.debug(f'Filter: {filters}')
690
+ except Exception as err:
691
+ msg = f'CQL evaluator error: {str(err)}'
692
+ LOGGER.exception(msg)
693
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
694
+
695
+ query = self.repository.session.query(self.repository.dataset).filter(filters)
696
+ if facets_requested:
697
+ LOGGER.debug('Running facet query')
698
+ facets_results = self.get_facets(filters)
699
+ else:
700
+ query = self.repository.session.query(self.repository.dataset)
701
+ facets_results = self.get_facets()
702
+
703
+ if facets_requested:
704
+ response['facets'] = facets_results
705
+ else:
706
+ response.pop('facets')
707
+
708
+ if 'sortby' in args:
709
+ LOGGER.debug('sortby specified')
710
+ sortby = args['sortby']
711
+
712
+ if sortby is not None:
713
+ LOGGER.debug('processing sortby')
714
+ if sortby.startswith('-'):
715
+ sortby = sortby.lstrip('-')
716
+
717
+ if sortby not in list(self.repository.query_mappings.keys()):
718
+ msg = 'Invalid sortby property'
719
+ LOGGER.exception(msg)
720
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
721
+
722
+ if args['sortby'].startswith('-'):
723
+ query = query.order_by(self.repository.query_mappings[sortby].desc())
724
+ else:
725
+ query = query.order_by(self.repository.query_mappings[sortby])
726
+
727
+ if limit is None and 'limit' in args:
728
+ limit = int(args['limit'])
729
+ LOGGER.debug('limit specified')
730
+ if limit < 1:
731
+ msg = 'Limit must be a positive integer'
732
+ LOGGER.exception(msg)
733
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
734
+ if limit > self.limit:
735
+ limit = self.limit
736
+ else:
737
+ limit = self.limit
738
+
739
+ offset = int(args.get('offset', 0))
740
+
741
+ LOGGER.debug(f'Query: {query}')
742
+ LOGGER.debug('Querying repository')
743
+ count = query.count()
744
+ records = query.limit(limit).offset(offset).all()
745
+
746
+ returned = len(records)
747
+
748
+ response['numberMatched'] = count
749
+ response['numberReturned'] = returned
750
+
751
+ for record in records:
752
+ response['features'].append(record2json(record, self.config['server']['url'], collection, self.mode))
753
+
754
+ response['distributedFeatures'] = []
755
+
756
+ distributed = str2bool(args.get('distributed', False))
757
+
758
+ if distributed:
759
+ for fc in self.config.get('federatedcatalogues', []):
760
+ LOGGER.debug(f'Running distributed search against {fc}')
761
+ fc_url, _, fc_collection = fc.rsplit('/', 2)
762
+ try:
763
+ w = Records(fc_url)
764
+ fc_results = w.collection_items(fc_collection, **args)
765
+ for feature in fc_results['features']:
766
+ response['distributedFeatures'].append(feature)
767
+ except Exception as err:
768
+ LOGGER.warning(err)
769
+
770
+ LOGGER.debug('Creating links')
771
+
772
+ link_args = {**args}
773
+
774
+ link_args.pop('f', None)
775
+
776
+ fragment = f'collections/{collection}/items'
777
+
778
+ if link_args:
779
+ url_base = f"{self.config['server']['url']}/{fragment}?{urlencode(link_args)}"
780
+ else:
781
+ url_base = f"{self.config['server']['url']}/{fragment}"
782
+
783
+ is_html = headers_['Content-Type'] == 'text/html'
784
+
785
+ response['links'].extend([{
786
+ 'rel': 'self' if not is_html else 'alternate',
787
+ 'type': 'application/geo+json',
788
+ 'title': 'This document as GeoJSON',
789
+ 'href': f"{bind_url(url_base)}f=json",
790
+ 'hreflang': self.config['server']['language']
791
+ }, {
792
+ 'rel': 'self' if is_html else 'alternate',
793
+ 'type': 'text/html',
794
+ 'title': 'This document as HTML',
795
+ 'href': f"{bind_url(url_base)}f=html",
796
+ 'hreflang': self.config['server']['language']
797
+ }, {
798
+ 'rel': 'collection',
799
+ 'type': 'application/json',
800
+ 'title': 'Collection URL',
801
+ 'href': f"{self.config['server']['url']}/collections/{collection}",
802
+ 'hreflang': self.config['server']['language']
803
+ }])
804
+
805
+ if offset > 0:
806
+ link_args.pop('offset', None)
807
+
808
+ prev = max(0, offset - limit)
809
+
810
+ url_ = f"{self.config['server']['url']}/{fragment}?{urlencode(link_args)}"
811
+
812
+ response['links'].append(
813
+ {
814
+ 'type': 'application/geo+json',
815
+ 'rel': 'prev',
816
+ 'title': 'items (prev)',
817
+ 'href': f"{bind_url(url_)}offset={prev}",
818
+ 'hreflang': self.config['server']['language']
819
+ })
820
+
821
+ if (offset + returned) < count:
822
+ link_args.pop('offset', None)
823
+
824
+ next_ = offset + returned
825
+
826
+ url_ = f"{self.config['server']['url']}/{fragment}?{urlencode(link_args)}"
827
+
828
+ response['links'].append({
829
+ 'rel': 'next',
830
+ 'type': 'application/geo+json',
831
+ 'title': 'items (next)',
832
+ 'href': f"{bind_url(url_)}offset={next_}",
833
+ 'hreflang': self.config['server']['language']
834
+ })
835
+
836
+ if headers_['Content-Type'] == 'text/html':
837
+ response['title'] = self.config['metadata']['identification']['title']
838
+ response['collection'] = collection
839
+
840
+ template = 'items.html'
841
+
842
+ return self.get_response(200, headers_, response, template)
843
+
844
+ def item(self, headers_, args, collection, item):
845
+ """
846
+ Provide collection item
847
+
848
+ :param headers_: copy of HEADERS object
849
+ :param args: request parameters
850
+ :param collection: name of collection
851
+ :param item: record identifier
852
+
853
+ :returns: tuple of headers, status code, content
854
+ """
855
+
856
+ record = None
857
+ headers_['Content-Type'] = self.get_content_type(headers_, args)
858
+
859
+ if collection not in self.get_all_collections():
860
+ msg = 'Invalid collection'
861
+ LOGGER.exception(msg)
862
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
863
+
864
+ LOGGER.debug(f'Querying repository for item {item}')
865
+ try:
866
+ record = self.repository.query_ids([item])[0]
867
+ response = record2json(record, self.config['server']['url'],
868
+ collection, self.mode)
869
+ except IndexError:
870
+ distributed = str2bool(args.get('distributed', False))
871
+
872
+ if distributed:
873
+ for fc in self.config.get('federatedcatalogues', []):
874
+ LOGGER.debug(f'Running distributed item search against {fc}')
875
+ fc_url, _, fc_collection = fc.rsplit('/', 2)
876
+ try:
877
+ w = Records(fc_url)
878
+ response = record = w.collection_item(fc_collection, item)
879
+ LOGGER.debug(f'Found item from {fc}')
880
+ break
881
+ except RuntimeError:
882
+ continue
883
+
884
+ if record is None:
885
+ return self.get_exception(
886
+ 404, headers_, 'InvalidParameterValue', 'item not found')
887
+
888
+ if headers_['Content-Type'] == 'application/xml':
889
+ return headers_, 200, record.xml
890
+
891
+ if headers_['Content-Type'] == 'text/html':
892
+ response['title'] = self.config['metadata']['identification']['title']
893
+ response['collection'] = collection
894
+
895
+ if 'json' in headers_['Content-Type']:
896
+ headers_['Content-Type'] = 'application/geo+json'
897
+
898
+ return self.get_response(200, headers_, response, 'item.html')
899
+
900
+ def manage_collection_item(self, headers_, action='create', item=None, data=None):
901
+ """
902
+ :param action: action (create, update, delete)
903
+ :param item: record identifier
904
+ :param data: raw data / payload
905
+
906
+ :returns: tuple of headers, status code, content
907
+ """
908
+
909
+ if not self.config['manager']['transactions']:
910
+ return self.get_exception(
911
+ 405, headers_, 'InvalidParameterValue',
912
+ 'transactions not allowed')
913
+
914
+ if action in ['create', 'update'] and data is None:
915
+ msg = 'No data found'
916
+ LOGGER.error(msg)
917
+ return self.get_exception(
918
+ 400, headers_, 'InvalidParameterValue', msg)
919
+
920
+ if action in ['create', 'update']:
921
+ try:
922
+ record = parse_record(self.context, data, self.repository)[0]
923
+ except Exception as err:
924
+ msg = f'Failed to parse data: {err}'
925
+ LOGGER.exception(msg)
926
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
927
+
928
+ if not hasattr(record, 'identifier'):
929
+ msg = 'Record requires an identifier'
930
+ LOGGER.exception(msg)
931
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
932
+
933
+ if action == 'create':
934
+ LOGGER.debug('Creating new record')
935
+ LOGGER.debug(f'Querying repository for item {item}')
936
+ try:
937
+ _ = self.repository.query_ids([record.identifier])[0]
938
+ return self.get_exception(
939
+ 400, headers_, 'InvalidParameterValue', 'item exists')
940
+ except Exception:
941
+ LOGGER.debug('Identifier does not exist')
942
+
943
+ # insert new record
944
+ try:
945
+ self.repository.insert(record, 'local', get_today_and_now())
946
+ except Exception as err:
947
+ msg = f'Record creation failed: {err}'
948
+ LOGGER.exception(msg)
949
+ return self.get_exception(400, headers_, 'InvalidParameterValue', msg)
950
+
951
+ code = 201
952
+ response = {}
953
+
954
+ elif action == 'update':
955
+ LOGGER.debug(f'Querying repository for item {item}')
956
+ try:
957
+ _ = self.repository.query_ids([record.identifier])[0]
958
+ except Exception:
959
+ msg = 'Identifier does not exist'
960
+ LOGGER.debug(msg)
961
+ return self.get_exception(404, headers_, 'InvalidParameterValue', msg)
962
+
963
+ _ = self.repository.update(record)
964
+
965
+ code = 204
966
+ response = {}
967
+
968
+ elif action == 'delete':
969
+ constraint = {
970
+ 'where': 'identifier = \'%s\'' % item,
971
+ 'values': [item]
972
+ }
973
+ _ = self.repository.delete(constraint)
974
+
975
+ code = 200
976
+ response = {}
977
+
978
+ return self.get_response(code, headers_, response)
979
+
980
+ def get_exception(self, status, headers, code, description):
981
+ """
982
+ Provide exception report
983
+
984
+ :param status: `int` of HTTP status code
985
+ :param headers_: copy of HEADERS object
986
+ :param code: exception code
987
+ :param description: exception description
988
+
989
+ :returns: tuple of headers, status code, content
990
+ """
991
+
992
+ exception = {
993
+ 'code': code,
994
+ 'description': description
995
+ }
996
+
997
+ return self.get_response(status, headers, exception, 'exception.html')
998
+
999
+ def get_collection_info(self, collection_name: str = 'metadata:main',
1000
+ collection_info: dict = {}) -> dict:
1001
+ """
1002
+ Generate collection metadata
1003
+
1004
+ :param collection_name: name of collection
1005
+ default is 'metadata:main' main collection
1006
+ :param collection_info: `dict` of collecton info
1007
+
1008
+ :returns: `dict` of collection
1009
+ """
1010
+
1011
+ if collection_name == 'metadata:main':
1012
+ id_ = collection_name
1013
+ title = self.config['metadata']['identification']['title']
1014
+ description = self.config['metadata']['identification']['description']
1015
+ else:
1016
+ id_ = collection_name
1017
+ title = collection_info.get('title')
1018
+ description = collection_info.get('description')
1019
+
1020
+ collection_info = {
1021
+ 'id': id_,
1022
+ 'type': 'catalog',
1023
+ 'title': title,
1024
+ 'description': description,
1025
+ 'itemType': 'record',
1026
+ 'crs': 'http://www.opengis.net/def/crs/OGC/1.3/CRS84',
1027
+ 'links': [{
1028
+ 'rel': 'collection',
1029
+ 'type': 'application/json',
1030
+ 'title': 'Collection URL',
1031
+ 'href': f"{self.config['server']['url']}/collections/{collection_name}",
1032
+ 'hreflang': self.config['server']['language']
1033
+ }, {
1034
+ 'rel': 'queryables',
1035
+ 'type': 'application/json',
1036
+ 'title': 'Collection queryables',
1037
+ 'href': f"{self.config['server']['url']}/collections/{collection_name}/queryables",
1038
+ 'hreflang': self.config['server']['language']
1039
+ }, {
1040
+ 'rel': 'items',
1041
+ 'type': 'application/geo+json',
1042
+ 'title': 'Collection items as GeoJSON',
1043
+ 'href': f"{self.config['server']['url']}/collections/{collection_name}/items",
1044
+ 'hreflang': self.config['server']['language']
1045
+ }]
1046
+ }
1047
+
1048
+ if collection_name == 'metadata:main':
1049
+ if 'federatedcatalogues' in self.config:
1050
+ LOGGER.debug('Adding federated catalogues')
1051
+ collection_info['federatedCatalogues'] = []
1052
+ if self.config.get('federatedcatalogues') not in [None, '']: # if empty in config
1053
+ for fc in self.config.get('federatedcatalogues'):
1054
+ collection_info['federatedCatalogues'].append({
1055
+ 'type': 'OGC API - Records',
1056
+ 'url': fc
1057
+ })
1058
+
1059
+ return collection_info
1060
+
1061
+ def get_all_collections(self) -> list:
1062
+ """
1063
+ Get all collections
1064
+
1065
+ :returns: `list` of collection identifiers
1066
+ """
1067
+
1068
+ default_collection = 'metadata:main'
1069
+ virtual_collections = self.repository.query_collections()
1070
+
1071
+ return [default_collection] + [vc.identifier for vc in virtual_collections]
1072
+
1073
+ def get_facets(self, filters=None) -> dict:
1074
+ """
1075
+ Gets all facets for a given query
1076
+
1077
+ :returns: `dict` of facets
1078
+ """
1079
+
1080
+ facets_results = {}
1081
+
1082
+ for facet in self.facets:
1083
+ LOGGER.debug(f'Running facet for {facet}')
1084
+ facetq = self.repository.session.query(self.repository.query_mappings[facet], self.repository.func.count(facet)).group_by(facet)
1085
+
1086
+ if filters is not None:
1087
+ facetq = facetq.filter(filters)
1088
+
1089
+ LOGGER.debug('Writing facet query results')
1090
+ facets_results[facet] = {
1091
+ 'type': 'terms',
1092
+ 'property': facet,
1093
+ 'buckets': []
1094
+ }
1095
+
1096
+ for fq in facetq.all():
1097
+ facets_results[facet]['buckets'].append({
1098
+ 'value': fq[0],
1099
+ 'count': fq[1]
1100
+ })
1101
+
1102
+ return facets_results
1103
+
1104
+
1105
+ def record2json(record, url, collection, mode='ogcapi-records'):
1106
+ """
1107
+ OGC API - Records record generator from core pycsw record model
1108
+
1109
+ :param record: pycsw record object
1110
+ :param url: server URL
1111
+ :param collection: collection id
1112
+ :param mode: `str` of API mode
1113
+
1114
+ :returns: `dict` of record GeoJSON
1115
+ """
1116
+
1117
+ if record.metadata_type == 'application/json':
1118
+ rec = json.loads(record.metadata)
1119
+ if rec.get('stac_version') is not None and rec['type'] == 'Feature' and mode == 'stac-api':
1120
+ LOGGER.debug('Returning native STAC representation')
1121
+ rec['links'].extend([{
1122
+ 'rel': 'self',
1123
+ 'type': 'application/geo+json',
1124
+ 'href': f"{url}/collections/{collection}/items/{rec['id']}"
1125
+ }, {
1126
+ 'rel': 'root',
1127
+ 'type': 'application/json',
1128
+ 'href': url
1129
+ }, {
1130
+ 'rel': 'parent',
1131
+ 'type': 'application/json',
1132
+ 'href': f"{url}/collections/{collection}"
1133
+ }, {
1134
+ 'rel': 'collection',
1135
+ 'type': 'application/json',
1136
+ 'href': f"{url}/collections/{collection}"
1137
+ }
1138
+ ])
1139
+
1140
+ return rec
1141
+
1142
+ LOGGER.debug('Removing STAC version')
1143
+ _ = rec.pop('stac_version', None)
1144
+ _ = rec.pop('stac_extensions', None)
1145
+ LOGGER.debug('Transforming assets to enclosure links')
1146
+ assets = rec.pop('assets', {})
1147
+ for key, value in assets.items():
1148
+ value['rel'] = 'enclosure'
1149
+ value['name'] = key
1150
+ rec['links'].append(value)
1151
+
1152
+ return rec
1153
+
1154
+ record_dict = {
1155
+ 'id': record.identifier,
1156
+ 'type': 'Feature',
1157
+ 'geometry': None,
1158
+ 'properties': {},
1159
+ 'links': []
1160
+ }
1161
+
1162
+ try:
1163
+ dt, dt_type = to_rfc3339(record.date)
1164
+ record_dict['time'] = {
1165
+ dt_type: dt
1166
+ }
1167
+ except Exception:
1168
+ record_dict['time'] = None
1169
+
1170
+ # todo; for keywords with a scheme use the theme property
1171
+ if record.topicategory:
1172
+ tctheme = {
1173
+ 'concepts': [],
1174
+ 'scheme': 'https://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_TopicCategoryCode'
1175
+ }
1176
+
1177
+ if isinstance(record.topicategory, list):
1178
+ for rtp in record.topicategory:
1179
+ tctheme['concepts'].append({'id': rtp})
1180
+ elif isinstance(record.topicategory, str):
1181
+ tctheme['concepts'].append({'id': record.topicategory})
1182
+
1183
+ record_dict['properties']['themes'] = [tctheme]
1184
+
1185
+ if record.otherconstraints:
1186
+ if isinstance(record.otherconstraints, str) and record.otherconstraints not in [None, 'None']:
1187
+ record.otherconstraints = [record.otherconstraints]
1188
+ record_dict['properties']['license'] = ", ".join(record.otherconstraints)
1189
+
1190
+ record_dict['properties']['updated'] = record.insert_date
1191
+
1192
+ if record.type:
1193
+ record_dict['properties']['type'] = record.type
1194
+
1195
+ if record.date_creation:
1196
+ record_dict['properties']['created'] = record.date_creation
1197
+
1198
+ if record.date_modified:
1199
+ record_dict['properties']['updated'] = record.date_modified
1200
+
1201
+ if record.language:
1202
+ record_dict['properties']['language'] = record.language
1203
+
1204
+ if record.source:
1205
+ record_dict['properties']['externalIds'] = [{'value': record.source}]
1206
+
1207
+ if record.title:
1208
+ record_dict['properties']['title'] = record.title
1209
+
1210
+ if record.abstract:
1211
+ record_dict['properties']['description'] = record.abstract
1212
+
1213
+ if record.format:
1214
+ record_dict['properties']['formats'] = [{'name': f} for f in record.format.split(',') if len(f) > 1]
1215
+
1216
+ if record.keywords:
1217
+ record_dict['properties']['keywords'] = [x for x in record.keywords.split(',')]
1218
+
1219
+ if record.contacts not in [None, '', 'null']:
1220
+ rcnt = []
1221
+ roles = []
1222
+ try:
1223
+ for cnt in json.loads(record.contacts):
1224
+ try:
1225
+ roles.append(cnt.get('role', '').lower())
1226
+ rcnt.append({
1227
+ 'name': cnt['name'],
1228
+ 'organization': cnt.get('organization', ''),
1229
+ 'position': cnt.get('position', ''),
1230
+ 'roles': [cnt.get('role', '')],
1231
+ 'phones': [{
1232
+ 'value': cnt.get('phone', '')
1233
+ }],
1234
+ 'emails': [{
1235
+ 'value': cnt.get('email', '')
1236
+ }],
1237
+ 'addresses': [{
1238
+ 'deliveryPoint': [cnt.get('address', '')],
1239
+ 'city': cnt.get('city', ''),
1240
+ 'administrativeArea': cnt.get('region', ''),
1241
+ 'postalCode': cnt.get('postcode', ''),
1242
+ 'country': cnt.get('country', '')
1243
+ }],
1244
+ 'links': [{
1245
+ 'href': cnt.get('onlineresource')
1246
+ }]
1247
+ })
1248
+ except Exception as err:
1249
+ LOGGER.exception(f"failed to parse contact of {record.identifier}: {err}")
1250
+ for r2 in "creator,publisher,contributor".split(","): # match role-fields with contacts
1251
+ if r2 not in roles and hasattr(record, r2) and record[r2] not in [None, '']:
1252
+ rcnt.append({
1253
+ 'organization': record[r2],
1254
+ 'roles': [r2]
1255
+ })
1256
+
1257
+ except Exception as err:
1258
+ LOGGER.warning(f"failed to parse contacts json of {record.identifier}: {err}")
1259
+
1260
+ record_dict['properties']['contacts'] = rcnt
1261
+
1262
+ if record.themes not in [None, '', 'null']:
1263
+ ogcapi_themes = record_dict['properties'].get('themes', [])
1264
+ # For a scheme, prefer uri over label
1265
+ # OWSlib currently uses .keywords_object for keywords with url, see https://github.com/geopython/OWSLib/pull/765
1266
+ try:
1267
+ for theme in json.loads(record.themes):
1268
+ try:
1269
+ ogcapi_themes.append({
1270
+ 'scheme': theme['thesaurus'].get('url') or theme['thesaurus'].get('title'),
1271
+ 'concepts': [{'id': c.get('name', '')} for c in theme.get('keywords', []) if 'name' in c and c['name'] not in [None, '']]
1272
+ })
1273
+ except Exception as err:
1274
+ LOGGER.exception(f"failed to parse theme of {record.identifier}: {err}")
1275
+ except Exception as err:
1276
+ LOGGER.exception(f"failed to parse themes json of {record.identifier}: {err}")
1277
+
1278
+ record_dict['properties']['themes'] = ogcapi_themes
1279
+
1280
+ if record.links:
1281
+ rdl = record_dict['links']
1282
+
1283
+ for link in jsonify_links(record.links):
1284
+ if link['url'] in [None, 'None']:
1285
+ LOGGER.debug(f'Skipping null link: {link}')
1286
+ continue
1287
+
1288
+ link2 = {
1289
+ 'href': link['url']
1290
+ }
1291
+ if link.get('name') not in [None, 'None']:
1292
+ link2['name'] = link['name']
1293
+ if link.get('description') not in [None, 'None']:
1294
+ link2['description'] = link['description']
1295
+ if link.get('protocol') not in [None, 'None']:
1296
+ link2['protocol'] = link['protocol']
1297
+ if 'rel' in link:
1298
+ link2['rel'] = link['rel']
1299
+ elif link['protocol'] == 'WWW:LINK-1.0-http--image-thumbnail':
1300
+ link2['rel'] = 'preview'
1301
+ elif 'function' in link:
1302
+ link2['rel'] = link['function']
1303
+
1304
+ rdl.append(link2)
1305
+
1306
+ for lnk in [record.parentidentifier, record.relation]:
1307
+ if lnk and len(lnk.strip()) > 0:
1308
+ if not lnk.startswith('http'):
1309
+ lnk = f"{url}/collections/{collection}/items/{quote(lnk)}"
1310
+ record_dict['links'].append({
1311
+ 'rel': 'related',
1312
+ 'href': lnk,
1313
+ 'name': 'related record',
1314
+ 'description': 'related record',
1315
+ 'type': 'application/json'
1316
+ })
1317
+
1318
+ record_dict['links'].append({
1319
+ 'rel': 'self',
1320
+ 'type': 'application/geo+json',
1321
+ 'title': record.identifier,
1322
+ 'name': 'item',
1323
+ 'description': record.identifier,
1324
+ 'href': f'{url}/collections/{collection}/items/{record.identifier}'
1325
+ })
1326
+
1327
+ record_dict['links'].append({
1328
+ 'rel': 'collection',
1329
+ 'type': 'application/json',
1330
+ 'title': 'Collection',
1331
+ 'name': 'collection',
1332
+ 'description': 'Collection',
1333
+ 'href': f'{url}/collections/{collection}'
1334
+ })
1335
+
1336
+ if record.wkt_geometry:
1337
+ minx, miny, maxx, maxy = wkt2geom(record.wkt_geometry)
1338
+ geometry = {
1339
+ 'type': 'Polygon',
1340
+ 'coordinates': [[
1341
+ [minx, miny],
1342
+ [minx, maxy],
1343
+ [maxx, maxy],
1344
+ [maxx, miny],
1345
+ [minx, miny]
1346
+ ]]
1347
+ }
1348
+ record_dict['geometry'] = geometry
1349
+
1350
+ if record.time_begin or record.time_end:
1351
+ if record.time_end not in [None, '']:
1352
+ if record.time_begin not in [None, '']:
1353
+ begin, _ = to_rfc3339(record.time_begin)
1354
+ end, _ = to_rfc3339(record.time_end)
1355
+ record_dict['time'] = {
1356
+ 'interval': [begin, end]
1357
+ }
1358
+ else:
1359
+ end, end_type = to_rfc3339(record.time_end)
1360
+ record_dict['time'] = {
1361
+ end_type: end
1362
+ }
1363
+ else:
1364
+ begin, begin_type = to_rfc3339(record.time_begin)
1365
+ record_dict['time'] = {
1366
+ begin_type: begin
1367
+ }
1368
+
1369
+ if mode == 'stac-api':
1370
+ date_, date_type = to_rfc3339(record.date)
1371
+ record_dict['properties']['datetime'] = date_
1372
+
1373
+ if None not in [record.time_begin, record.time_end]:
1374
+ start_date, start_date_type = to_rfc3339(record.time_begin)
1375
+ end_date, end_date_type = to_rfc3339(record.time_end)
1376
+
1377
+ record_dict['properties']['start_datetime'] = start_date
1378
+ record_dict['properties']['end_datetime'] = end_date
1379
+
1380
+ return record_dict
1381
+
1382
+
1383
+ def build_anytext(name, value):
1384
+ """
1385
+ deconstructs free-text search into CQL predicate(s)
1386
+
1387
+ :param name: property name
1388
+ :param name: property value
1389
+
1390
+ :returns: string of CQL predicate(s)
1391
+ """
1392
+
1393
+ LOGGER.debug(f'Name: {name}')
1394
+ LOGGER.debug(f'Value: {value}')
1395
+
1396
+ predicates = []
1397
+ tokens = value.split(',')
1398
+
1399
+ if len(tokens) == 1 and ' ' not in value: # single term
1400
+ LOGGER.debug('Single term with no spaces')
1401
+ return f"{name} ILIKE '%{value}%'"
1402
+
1403
+ for token in tokens:
1404
+ if ' ' in token:
1405
+ tokens2 = token.split()
1406
+ predicates2 = []
1407
+ for token2 in tokens2:
1408
+ predicates2.append(f"{name} ILIKE '%{token2}%'")
1409
+
1410
+ predicates.append('(' + ' AND '.join(predicates2) + ')')
1411
+ else:
1412
+ predicates.append(f"{name} ILIKE '%{token}%'")
1413
+
1414
+ return f"({' OR '.join(predicates)})"