Browse Source

Initial submission config (not implemented).

scossu 2 days ago
parent
commit
1cfd49ea52
1 changed files with 147 additions and 0 deletions
  1. 147 0
      config/model/submission/postcard.lua

+ 147 - 0
config/model/submission/postcard.lua

@@ -0,0 +1,147 @@
+--[[
+Sample submission layout config file for a postcard model.
+
+This configuration is read according to the content model set in the sidecar
+metadata for the top-level submission object. Content models, relationships,
+and other metadata for individual child objects can be inferred from the
+submission file and folder layout.
+]]
+
+--[[
+Attribute enrichment rules.
+
+These rules add one or more attributes to each resource that individually
+matches a set of conditions.
+]]
+attributes = {
+    -- Rule #1: assign "StillImage" to all folders containing "recto", "verso",
+    -- etc., in their name.
+    -- Matching directives.
+    {
+        match = {
+            -- "path" matches a regular expression against each resource path.
+            -- NOTE: match is always case-insensitive at the moment.
+            path = {"(?:back|front|recto|verso)$"},
+
+            -- "fs_type" matches the resource type in the file system: file or
+            -- folder, or both if unspecified.
+            fs_type = "folder",
+        },
+
+        -- TODO match existing metadata attributes.
+
+        -- "add" adds one or more types to the matching objects.
+        -- Add directives are written as key-value pairs:
+        -- `<attribute name>: [<value>, ...]`
+        add = { contentType = {"pas:StillImage"} },
+    },
+
+    -- Rule #2: assign the "recto" tag to folders with specific names.
+    {
+        match = {
+            path = {
+                ".*/.*front",
+                ".*/.*recto",
+            },
+            fs_type = "folder",
+        },
+        add = {
+            role =  { "Recto" },
+        },
+    },
+
+    -- Rule #3: assign the "verso" tag to folders with specific names.
+    {
+        match = {
+            path = {
+                ".*/.*back",
+                ".*/.*verso",
+            },
+            fs_type = "folder"
+        },
+        add = {
+            role = { "pas:Verso" }
+        },
+    },
+    -- Rule #4: assign "ArchivalMaster" role to a TIFF file found under the
+    -- StillImage folder.
+    {
+        match = {
+            path = { "(?:back|front|recto|verso)/.*?\\.tiff?$" },
+            fs_type = "file",
+        },
+        add = {
+            contentType = { "StillImageFile" },
+            role = { "ArchivalMaster" },
+        },
+    },
+    -- Rule #5: assign "DeliveryFile" role to a JPG or JPH file found under the
+    -- StillImage folder.
+    {
+        match = {
+            path = { "(?:back|front|recto|verso)/.*?\\.jp[gh]$" },
+            fs_type = "file",
+        },
+        add = {
+            contentType = { "StillImageFile" },
+            role = { "DeliveryFile" },
+        }
+    },
+
+
+
+    --[[
+    Relationship enrichment rules.
+
+    These rules establish relationships between pairs of resources that match
+    certain conditions individually and/or in relationship to one another.
+
+    Directives for matching are similar to attribute enrichment ones and they
+    come in two sets: one for the source (the resource that would be added the
+    relationship), and one for the target (the resource pointed to by the
+    relationship). The relationship is established to all objects that match both
+    sets of conditions.
+    ]]
+    relationships = {
+        {
+            source = {
+                match = {
+                    --[[
+                    Attribute matching: this matches resources with specific
+                    attributes.  It is a multi-valued key-value map, in which
+                    values of each key are joined by OR, and multiple keys are
+                    joined by AND.
+
+                    For example, the directive below matches resources with an
+                    attribute named "role" with a value of "Recto" OR "Verso",
+                    AND an attribute named "contentType" with a value of
+                    "StillImage" (this example is quite contrived as the rules
+                    are redundant together).
+
+                    Attributes added in the attribute enrichment step above are
+                    available at this point.
+                    ]]
+                    attributes = {
+                        role = {"pas:Recto", "pas:Verso"},
+                        contentType =  {"pas:StillImage"},
+                    },
+                },
+                -- "add" adds each of the listed relationships to each of the
+                -- resources matching "source" conditions, pointing to all the
+                -- resources matching "target" conditions for each source.
+                add = { "hasFile" },
+            },
+
+            target = {
+                match = {
+                    -- Path matching is done via regex here too, with the
+                    -- addition of the `{{src_path}}` variable that gets
+                    -- expanded to the source path before parsing the regex.
+                    path = {"{{src_path}}/[^/]+$"},
+                    fs_type = "file",
+                },
+            },
+        },
+    }
+
+