postcard.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. --[[
  2. Sample submission layout config file for a postcard model.
  3. This configuration is read according to the content model set in the sidecar
  4. metadata for the top-level submission object. Content models, relationships,
  5. and other metadata for individual child objects can be inferred from the
  6. submission file and folder layout.
  7. ]]
  8. --[[
  9. Attribute enrichment rules.
  10. These rules add one or more attributes to each resource that individually
  11. matches a set of conditions.
  12. ]]
  13. attributes = {
  14. -- Rule #1: assign "StillImage" to all folders containing "recto", "verso",
  15. -- etc., in their name.
  16. -- Matching directives.
  17. {
  18. match = {
  19. -- "path" matches a regular expression against each resource path.
  20. -- NOTE: match is always case-insensitive at the moment.
  21. path = {"(?:back|front|recto|verso)$"},
  22. -- "fs_type" matches the resource type in the file system: file or
  23. -- folder, or both if unspecified.
  24. fs_type = "folder",
  25. },
  26. -- TODO match existing metadata attributes.
  27. -- "add" adds one or more types to the matching objects.
  28. -- Add directives are written as key-value pairs:
  29. -- `<attribute name>: [<value>, ...]`
  30. add = { contentType = {"pas:StillImage"} },
  31. },
  32. -- Rule #2: assign the "recto" tag to folders with specific names.
  33. {
  34. match = {
  35. path = {
  36. ".*/.*front",
  37. ".*/.*recto",
  38. },
  39. fs_type = "folder",
  40. },
  41. add = {
  42. role = { "Recto" },
  43. },
  44. },
  45. -- Rule #3: assign the "verso" tag to folders with specific names.
  46. {
  47. match = {
  48. path = {
  49. ".*/.*back",
  50. ".*/.*verso",
  51. },
  52. fs_type = "folder"
  53. },
  54. add = {
  55. role = { "pas:Verso" }
  56. },
  57. },
  58. -- Rule #4: assign "ArchivalMaster" role to a TIFF file found under the
  59. -- StillImage folder.
  60. {
  61. match = {
  62. path = { "(?:back|front|recto|verso)/.*?\\.tiff?$" },
  63. fs_type = "file",
  64. },
  65. add = {
  66. contentType = { "StillImageFile" },
  67. role = { "ArchivalMaster" },
  68. },
  69. },
  70. -- Rule #5: assign "DeliveryFile" role to a JPG or JPH file found under the
  71. -- StillImage folder.
  72. {
  73. match = {
  74. path = { "(?:back|front|recto|verso)/.*?\\.jp[gh]$" },
  75. fs_type = "file",
  76. },
  77. add = {
  78. contentType = { "StillImageFile" },
  79. role = { "DeliveryFile" },
  80. }
  81. },
  82. --[[
  83. Relationship enrichment rules.
  84. These rules establish relationships between pairs of resources that match
  85. certain conditions individually and/or in relationship to one another.
  86. Directives for matching are similar to attribute enrichment ones and they
  87. come in two sets: one for the source (the resource that would be added the
  88. relationship), and one for the target (the resource pointed to by the
  89. relationship). The relationship is established to all objects that match both
  90. sets of conditions.
  91. ]]
  92. relationships = {
  93. {
  94. source = {
  95. match = {
  96. --[[
  97. Attribute matching: this matches resources with specific
  98. attributes. It is a multi-valued key-value map, in which
  99. values of each key are joined by OR, and multiple keys are
  100. joined by AND.
  101. For example, the directive below matches resources with an
  102. attribute named "role" with a value of "Recto" OR "Verso",
  103. AND an attribute named "contentType" with a value of
  104. "StillImage" (this example is quite contrived as the rules
  105. are redundant together).
  106. Attributes added in the attribute enrichment step above are
  107. available at this point.
  108. ]]
  109. attributes = {
  110. role = {"pas:Recto", "pas:Verso"},
  111. contentType = {"pas:StillImage"},
  112. },
  113. },
  114. -- "add" adds each of the listed relationships to each of the
  115. -- resources matching "source" conditions, pointing to all the
  116. -- resources matching "target" conditions for each source.
  117. add = { "hasFile" },
  118. },
  119. target = {
  120. match = {
  121. -- Path matching is done via regex here too, with the
  122. -- addition of the `{{src_path}}` variable that gets
  123. -- expanded to the source path before parsing the regex.
  124. path = {"{{src_path}}/[^/]+$"},
  125. fs_type = "file",
  126. },
  127. },
  128. },
  129. }