Module:PublicationShowAbstract

From MaRDI portal
Revision as of 14:04, 8 April 2025 by Tconrad (talk | contribs)

Documentation for this module may be created at Module:PublicationShowAbstract/doc

-- Required module containing helper methods
local helper = require('Module:HelperMethods')

-- Required modules for SPARQL queries and HTML table generation
local sparql = require('SPARQL')
local mwHtml = require('mw.html')

local p = {}

function p.queryAbstractDB(QID)
	local abstract = ""

	mw.log("QID:") 
	mw.log(QID) 

	if not QID or QID == '' then
		return abstract
	end	
	
	local safeID = tostring(QID):gsub("^Q", "")

	mw.log(safeID) 

    local row = mw.ext.externaldata.getDbData {
	    db = "AbstractDB",
	    parameters = safeID
	}
	
	mw.log( row )
                
	if row then
		abstract = row.abstract
	end

    return abstract
end


function p.getAbstractForPaperQID(frame)
	
    -- Retrieve target1 from frame arguments or return error message if not set
	local target1 = frame.args[1]
    if not target1 or target1 == '' then
        return "No records found"
    end    
    
    mw.log("target1")
    mw.log(target1)

	local abstract = p.queryAbstractDB(target1)
	
	-- mw.log(abstract) 
	
    return abstract
end

return p