<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AFinalContent_-_ASSET_-_LUA</id>
	<title>ICT:FinalContent - ASSET - LUA - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AFinalContent_-_ASSET_-_LUA"/>
	<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:FinalContent_-_ASSET_-_LUA&amp;action=history"/>
	<updated>2026-07-23T01:59:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://mwiki.costasano.club/index.php?title=ICT:FinalContent_-_ASSET_-_LUA&amp;diff=692&amp;oldid=prev</id>
		<title>Mngr: Created page with &quot;&lt;pre&gt; -- Module:DigitalAssetID local p = {}  local cargo = mw.ext.cargo  -- Helper: zero-pad sequence number local function pad(num)     return string.format(&quot;%04d&quot;, tonumber(num)) end  -- Main function: compute identifier function p.generate(frame)     local args = frame.args     local chapterPage = args.chapter_id     local placePage = args.place_id     local orgPage = args.organisation_id      -- 1. Enforce exclusivity     if (placePage ~= &quot;&quot; and orgPage ~= &quot;&quot;) then...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:FinalContent_-_ASSET_-_LUA&amp;diff=692&amp;oldid=prev"/>
		<updated>2026-02-13T21:26:52Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;pre&amp;gt; -- Module:DigitalAssetID local p = {}  local cargo = mw.ext.cargo  -- Helper: zero-pad sequence number local function pad(num)     return string.format(&amp;quot;%04d&amp;quot;, tonumber(num)) end  -- Main function: compute identifier function p.generate(frame)     local args = frame.args     local chapterPage = args.chapter_id     local placePage = args.place_id     local orgPage = args.organisation_id      -- 1. Enforce exclusivity     if (placePage ~= &amp;quot;&amp;quot; and orgPage ~= &amp;quot;&amp;quot;) then...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
-- Module:DigitalAssetID&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local cargo = mw.ext.cargo&lt;br /&gt;
&lt;br /&gt;
-- Helper: zero-pad sequence number&lt;br /&gt;
local function pad(num)&lt;br /&gt;
    return string.format(&amp;quot;%04d&amp;quot;, tonumber(num))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Main function: compute identifier&lt;br /&gt;
function p.generate(frame)&lt;br /&gt;
    local args = frame.args&lt;br /&gt;
    local chapterPage = args.chapter_id&lt;br /&gt;
    local placePage = args.place_id&lt;br /&gt;
    local orgPage = args.organisation_id&lt;br /&gt;
&lt;br /&gt;
    -- 1. Enforce exclusivity&lt;br /&gt;
    if (placePage ~= &amp;quot;&amp;quot; and orgPage ~= &amp;quot;&amp;quot;) then&lt;br /&gt;
        return mw.text.jsonEncode({&lt;br /&gt;
            error = &amp;quot;Select either a Place OR an Organisation, not both.&amp;quot;&lt;br /&gt;
        })&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if (placePage == &amp;quot;&amp;quot; and orgPage == &amp;quot;&amp;quot;) then&lt;br /&gt;
        return mw.text.jsonEncode({&lt;br /&gt;
            error = &amp;quot;You must select a Place OR an Organisation.&amp;quot;&lt;br /&gt;
        })&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- 2. Fetch Chapter code&lt;br /&gt;
    local chapterRes = cargo.query(&lt;br /&gt;
        &amp;quot;ResearchChapters&amp;quot;,&lt;br /&gt;
        &amp;quot;code&amp;quot;,&lt;br /&gt;
        { where = string.format(&amp;quot;_pageName=&amp;#039;%s&amp;#039;&amp;quot;, chapterPage) }&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    if not chapterRes[1] then&lt;br /&gt;
        return mw.text.jsonEncode({ error = &amp;quot;Invalid chapter selected.&amp;quot; })&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local chapterCode = chapterRes[1].code&lt;br /&gt;
&lt;br /&gt;
    -- 3. Fetch context code (Place or Organisation)&lt;br /&gt;
    local contextCode = nil&lt;br /&gt;
    local contextTable = nil&lt;br /&gt;
    local contextPage = nil&lt;br /&gt;
&lt;br /&gt;
    if placePage ~= &amp;quot;&amp;quot; then&lt;br /&gt;
        contextTable = &amp;quot;Places&amp;quot;&lt;br /&gt;
        contextPage = placePage&lt;br /&gt;
    else&lt;br /&gt;
        contextTable = &amp;quot;Organisations&amp;quot;&lt;br /&gt;
        contextPage = orgPage&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local ctxRes = cargo.query(&lt;br /&gt;
        contextTable,&lt;br /&gt;
        &amp;quot;code&amp;quot;,&lt;br /&gt;
        { where = string.format(&amp;quot;_pageName=&amp;#039;%s&amp;#039;&amp;quot;, contextPage) }&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    if not ctxRes[1] then&lt;br /&gt;
        return mw.text.jsonEncode({ error = &amp;quot;Invalid context selected.&amp;quot; })&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    contextCode = ctxRes[1].code&lt;br /&gt;
&lt;br /&gt;
    -- 4. Determine next sequence number&lt;br /&gt;
    local existing = cargo.query(&lt;br /&gt;
        &amp;quot;DigitalAssets&amp;quot;,&lt;br /&gt;
        &amp;quot;sequence_number&amp;quot;,&lt;br /&gt;
        {&lt;br /&gt;
            where = string.format(&lt;br /&gt;
                &amp;quot;chapter_id=&amp;#039;%s&amp;#039; AND (place_id=&amp;#039;%s&amp;#039; OR organisation_id=&amp;#039;%s&amp;#039;)&amp;quot;,&lt;br /&gt;
                chapterPage, placePage, orgPage&lt;br /&gt;
            ),&lt;br /&gt;
            orderBy = &amp;quot;sequence_number DESC&amp;quot;,&lt;br /&gt;
            limit = 1&lt;br /&gt;
        }&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    local nextSeq = 1&lt;br /&gt;
    if existing[1] and existing[1].sequence_number then&lt;br /&gt;
        nextSeq = tonumber(existing[1].sequence_number) + 1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- 5. Format identifier&lt;br /&gt;
    local identifier = string.format(&lt;br /&gt;
        &amp;quot;%s-%s-%s&amp;quot;,&lt;br /&gt;
        chapterCode,&lt;br /&gt;
        contextCode,&lt;br /&gt;
        pad(nextSeq)&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    -- 6. Return result&lt;br /&gt;
    return mw.text.jsonEncode({&lt;br /&gt;
        identifier = identifier,&lt;br /&gt;
        sequence_number = nextSeq&lt;br /&gt;
    })&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mngr</name></author>
	</entry>
</feed>