ソースを参照

WIP structural bricks: add ordered prop values to SIP.

scossu 2 週間 前
コミット
eabab4f811

+ 1 - 0
.gitignore

@@ -40,6 +40,7 @@ luac.out
 *.hex
 
 # Local
+.~lock.*
 vgcore*
 data/ores/*
 data/dres/*

+ 3 - 3
README.md

@@ -207,7 +207,7 @@ components, even if not entirely developed or only usable in a specific
 development environment, to demonstrate the overall workflows and
 functionality.
 
-The second step is to prduce a minimum viable product, which is fully
+The second step is to produce a minimum viable product, which is fully
 functional and available for use by the intended audience.
 
 #### Prototype
@@ -219,8 +219,8 @@ functional and available for use by the intended audience.
 - ⚒ Submission module
   - ✓ SIP building
   - ✓ Metadata from LL
-  - ✓ Structure inference
-  - ⚒ Collections
+  - ⚒ Brick structures
+  - ⚒ Structure inference
 - ✓ HTML generator
   - ✓ Index
   - ✓ Resource

+ 3 - 4
config/model/submission/postcard.lua

@@ -33,7 +33,7 @@ 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"} },
+        add = { contentType = {still_image = true} },
     },
 
     -- Rule #2: assign the "recto" tag to folders with specific names.
@@ -142,6 +142,5 @@ attributes = {
                 },
             },
         },
-    }
-
-
+    },
+}

+ 9 - 2
config/model/typedef/brick.lua

@@ -17,7 +17,7 @@ In a more complex hierarchy, any given Part may have both "first" and
 
 return {
     uri = "pas:Brick",
-    label = "Brick",
+    label = "Structural brick",
 
     broader = "anything",
 
@@ -32,6 +32,13 @@ return {
             label = "Next sibling",
             type = "resource",
             max_cardinality = 1,
-        }
+        },
+        href = {
+            uri = "pas:ref",
+            label = "Reference",
+            description = "The actual resource the brick refers to.",
+            type = "resource",
+            max_cardinality = 1,
+        },
     }
 }

+ 0 - 9
config/model/typedef/collection.lua

@@ -3,15 +3,6 @@ return {
     label = "Collection",
 
     broader = "brick",
-
-    properties = {
-        first = {
-            range = {collection = true, artifact = true},
-        },
-        next = {
-            range = {collection = true, artifact = true},
-        }
-    }
 }
 
 

+ 0 - 9
config/model/typedef/part.lua

@@ -3,14 +3,5 @@ return {
     label = "Part",
 
     broader = "brick",
-
-    properties = {
-        first = {
-            range = {part = true, file = true},
-        },
-        next = {
-            range = {part = true},
-        }
-    }
 }
 

+ 17 - 0
config/model/typedef/proxy.lua

@@ -0,0 +1,17 @@
+return {
+    uri = "pas:Proxy",
+    label = "Proxy",
+
+    broader = "brick",
+
+    properties = {
+        href = {
+            label = "Reference",
+            uri = "pas:href",
+            type = "resource",
+            max_cardinality = 1,
+        },
+    },
+}
+
+

+ 4 - 3
src/submission.lua

@@ -76,7 +76,8 @@ M.generate_sip = function(path)
             for k, v in pairs(row) do
                 if v == "" then goto cont1 end  -- skip empty strings.
                 if pkar.config.md.single_values[k] then sip[i][k] = v
-                else sip[i][k] = {[v] = true} end  -- Multi-values are a set.
+                -- Multi-values are ordered in the SIP for further processing.
+                else sip[i][k] = {v} end
                 ::cont1::
             end
 
@@ -107,7 +108,7 @@ M.generate_sip = function(path)
                     else
                         logger:debug("Value: ", v)
                         logger:debug("Inserting at row ", i - 1)
-                        sip[i][k][v] = true
+                        table.insert(sip[i][k], v)
                     end
                     ::cont2::
                 end
@@ -176,7 +177,7 @@ M.rsrc_to_graph = function(rsrc)
         -- Force all fields to be multi-valued.
         if type(v) ~= "table" then v = {[v] = true} end
         local o
-        for vv in pairs(v) do
+        for i, vv in ipairs(v) do
             if k == "content_type" then
                 vv = rmod.uri
             end

+ 1 - 2
src/validator.lua

@@ -17,8 +17,7 @@ local M = {}
 
 M.validate = function(gr, s)
     _, ctype = next(gr:attr(s, pkar.CONTENT_TYPE_P))
-    local rmod = model.from_type_uri(ctype)
-    dbg.assert(rmod)
+    local rmod = model.from_uri(ctype)
     if not rmod then error("No type definition for " .. ctype.data) end
 
     local report = {

+ 0 - 0
test/sample_submission/demo01/coll2/.keep


+ 18 - 15
test/sample_submission/demo01/pkar_submission.csv

@@ -1,15 +1,18 @@
-"source_path","ext_id","content_type","label","alt_label","description","location","date"
-"demo_collection",,"collection","My Demo Collection","My Beautiful  Collection","Some random stuff from my hard drive.",,2025-07-28
-,,,,"My Aunt's Beautiful Collection","Old B/W photos.",,
-,,,,,"More description to demonstrate how multi-valued fields are filled.",,
-,,,,,"""id"" fields have been left blank to let the system auto-generate them.",,
-"demo_collection/demo_postcard",,"postcard","Example Postcard","This is an alternative label","Note that recto and verso representations have been named front and back, to emphasize that the ordering is not alphabetical.",,2025-06-10
-"demo_collection/demo_postcard/front",,"part","Recto",,"An idle, windy day in Capo Falcone, Sardinia","Capo Falcone (SS) Italy",2004-04-12
-,,,,,,"https://www.openstreetmap.org/#map=18/40.9696884/8.2020324",
-"demo_collection/demo_postcard/front/54321.jpg",,"still_image_file",,,,,
-"demo_collection/demo_postcard/back",,"part","Verso",,"Wandering around somewhere in Tirana, 2006.","Tirana, Albania",2006-05-05
-,,,,,,"https://geohack.toolforge.org/geohack.php?params=41.32888888888889_N_19.817777777777778_E_globe:earth&language=en",
-"demo_collection/demo_postcard/back/567890.jpg",,"still_image_file",,,,,
-"demo_collection/single_image",,"still_image","Preparing kebab at Aqil's during curfew.",,"Nothing much to do under curfew but cooking, eating, singing, dancing, playing cards, smoking water pipe, and occasionally playing soccer in the street when the Merkava didn't get in the way.","Nablus, Palestine",2002-08-16
-,,,,,,"https://www.openstreetmap.org/#map=19/32.221597/35.260929",
-"demo_collection/single_image/0685_04.jpg",,"still_image_file",,,,,
+"source_path","id","ext_id","content_type","label","alt_label","description","location","date","has_member","pref_rep"
+"demo_collection",,"coll0001","collection","My Demo Collection","My Beautiful  Collection","Some random stuff from my hard drive.",,2025-07-28,,"demo_collection/single_image/0685_04.jpg"
+,,,,,"My Aunt's Beautiful Collection","Old B/W photos.",,,,
+,,,,,,"More description to demonstrate how multi-valued fields are filled.",,,,
+,,,,,,"""id"" fields have been left blank to let the system auto-generate them.",,,,
+"demo_collection/demo_postcard",,"art0001","postcard","Example Postcard","This is an alternative label","Note that recto and verso representations have been named front and back, to emphasize that the ordering is not alphabetical.",,2025-06-10,,
+,,,,,,,,,,
+"demo_collection/demo_postcard/front",,,"brick","Recto",,"A windy spring day in Capo Falcone, Sardinia","Capo Falcone (SS) Italy",2004-04-12,,
+,,,,,,,"https://www.openstreetmap.org/#map=18/40.9696884/8.2020324",,,
+"demo_collection/demo_postcard/front/54321.jpg",,"file0001","still_image_file",,,,,,,
+"demo_collection/demo_postcard/back",,,"brick","Verso",,"Wandering around somewhere in Tirana, 2006.","Tirana, Albania",2006-05-05,,
+,,,,,,,"https://www.openstreetmap.org/relation/1250106",,,
+"demo_collection/demo_postcard/back/567890.jpg",,"file0002","still_image_file",,,,,,,
+"demo_collection/single_image",,"art0002","still_image","Preparing kebab at Aqil's during curfew.",,"Nothing much to do under curfew but cooking, eating, singing, dancing, playing cards, smoking water pipe, and occasionally playing soccer in the street when the Merkava didn't get in the way.","Nablus, Palestine",2002-08-16,,
+,,,,,,,"https://www.openstreetmap.org/#map=19/32.221597/35.260929",,,
+"demo_collection/single_image/0685_04.jpg",,"file0003","still_image_file",,,,,,,
+"coll2",,"coll0002","collection","Second collection",,"Collection made by reusing files from another collection.",,,"demo_collection/single_image/0685_04.jpg","demo_collection/single_image/0685_04.jpg"
+,,,,,,,,,"demo_collection/demo_postcard/front/54321.jpg",