|
@@ -79,6 +79,11 @@ end
|
|
|
|
|
|
|
|
|
local function generate_sip(ll_path)
|
|
|
+ if not path.isfile(ll_path) then error(ll_path .. " is not a file.", 2) end
|
|
|
+
|
|
|
+ -- Submission ID sticks to all the resources.
|
|
|
+ local sub_id = idgen()
|
|
|
+
|
|
|
local sip = {root_path = path.dirname(ll_path)}
|
|
|
path_to_uri = {}
|
|
|
|
|
@@ -107,16 +112,18 @@ local function generate_sip(ll_path)
|
|
|
:format(i, row_n))
|
|
|
prev_path = row.source_path
|
|
|
-- New row.
|
|
|
- sip[i] = {}
|
|
|
+ sip[i] = {
|
|
|
+ -- Normalize provided ID or generate random ID if not provided.
|
|
|
+ id = "par:" .. (row.id or idgen()),
|
|
|
+ sub_id = sub_id,
|
|
|
+ }
|
|
|
for k, v in pairs(row) do
|
|
|
- if not v then goto cont1 end -- skip empty strings.
|
|
|
+ if not v or k == "id" then goto cont1 end -- skip empty strings.
|
|
|
if pkar.config.md.single_values[k] then sip[i][k] = v
|
|
|
-- Multi-values are ordered in the SIP for further processing.
|
|
|
else sip[i][k] = {v} end
|
|
|
::cont1::
|
|
|
end
|
|
|
- -- Normalize provided ID or generate random ID if not provided.
|
|
|
- sip[i].id = "par:" .. ((sip[i].id or {})[0] or idgen())
|
|
|
-- Add to path to URI map for later referencing.
|
|
|
path_to_uri[row.source_path] = sip[i].id
|
|
|
else
|
|
@@ -148,7 +155,7 @@ local function generate_sip(ll_path)
|
|
|
-- Infer structure from paths and row ordering.
|
|
|
for i, v in ipairs(sip) do
|
|
|
local rmod = model.types[v.content_type]
|
|
|
- dbg.assert(v.source_path)
|
|
|
+ --dbg.assert(v.source_path)
|
|
|
local fpath = path.join(sip.root_path, v.source_path)
|
|
|
--dbg.assert(rmod)
|
|
|
v.has_member = v.has_member or {}
|
|
@@ -159,6 +166,7 @@ local function generate_sip(ll_path)
|
|
|
table.insert(sip, {
|
|
|
content_type = rmod.default_fmodel or "file",
|
|
|
id = file_id,
|
|
|
+ sub_id = sub_id,
|
|
|
label = path.basename(v.source_path),
|
|
|
source_path = v.source_path,
|
|
|
})
|