|
@@ -1,7 +1,13 @@
|
|
local io = io
|
|
local io = io
|
|
|
|
|
|
local csv = require "csv"
|
|
local csv = require "csv"
|
|
|
|
+local uuid = require "uuid"
|
|
|
|
|
|
|
|
+-- Random number generator for uuid()
|
|
|
|
+local posix_uuid = pcall(function()
|
|
|
|
+ uuid.set_rng(uuid.rng.urandom())
|
|
|
|
+end)
|
|
|
|
+if not posix_uuid then rng = uuid.set_rng(uuid.rng.win_ffi()) end
|
|
|
|
|
|
local M = {} -- Submission module
|
|
local M = {} -- Submission module
|
|
|
|
|
|
@@ -27,7 +33,7 @@ local function escape_pattern(s)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
-M.deposit = function(path)
|
|
|
|
|
|
+M.generate_sip = function(path)
|
|
local sub_data = assert(csv.open(path))
|
|
local sub_data = assert(csv.open(path))
|
|
local md = {}
|
|
local md = {}
|
|
local prev_ref, prev_k
|
|
local prev_ref, prev_k
|
|
@@ -74,16 +80,20 @@ M.deposit = function(path)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
- md[ref] = md[ref] or {path = ref, _sort = i}
|
|
|
|
|
|
+ md[ref] = md[ref] or {id = uuid(), path = ref, _sort = i}
|
|
md[ref][k] = md[ref][k] or {}
|
|
md[ref][k] = md[ref][k] or {}
|
|
- table.insert(md[ref][k], v)
|
|
|
|
|
|
+ if k == "type" then
|
|
|
|
+ md[ref][k] = v
|
|
|
|
+ else
|
|
|
|
+ table.insert(md[ref][k], v)
|
|
|
|
+ end
|
|
|
|
|
|
::continue::
|
|
::continue::
|
|
i = i + 1
|
|
i = i + 1
|
|
end
|
|
end
|
|
|
|
|
|
-- Move md to an ordered list.
|
|
-- Move md to an ordered list.
|
|
- mdlist = {}
|
|
|
|
|
|
+ mdlist = {root_path = path:match("(.*/)")}
|
|
for _, v in pairs(md) do table.insert(mdlist, v) end
|
|
for _, v in pairs(md) do table.insert(mdlist, v) end
|
|
table.sort(mdlist, function (a, b) return (a._sort < b._sort) end)
|
|
table.sort(mdlist, function (a, b) return (a._sort < b._sort) end)
|
|
|
|
|
|
@@ -108,4 +118,12 @@ M.deposit = function(path)
|
|
return mdlist
|
|
return mdlist
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+
|
|
|
|
+M.deposit = function(sip)
|
|
|
|
+ for i, rsrc in ipairs(sip) do
|
|
|
|
+ print(("Processing resource #%d of %d"):format(i, #sip))
|
|
|
|
+ abs_path = sip.root_path
|
|
|
|
+ end
|
|
|
|
+end
|
|
|
|
+
|
|
return M
|
|
return M
|