Module:SoftwareLicenseList: Difference between revisions

From MaRDI portal
No edit summary
No edit summary
 
Line 18: Line 18:
     end     
     end     
      
      
jsonResults = helper.getValuesForProperty( target1, "P163" )
    local fakeFrame = { args = {[1] = target1, [2] = "P163" } }
jsonResults = helper.getValuesForProperty( fakeFrame )


if not jsonResults then
if not jsonResults then

Latest revision as of 15:11, 15 April 2025

Documentation for this module may be created at Module:SoftwareLicenseList/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')

-- Main table to hold all functions
local p = {}

-- Function to build the list
function p.buildLicenseList(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    
    
    local fakeFrame = { args = {[1] = target1, [2] = "P163" } }
	jsonResults = helper.getValuesForProperty( fakeFrame )

	if not jsonResults then
        return "Could not fetch data."
	end
	
	if helper.countElementsInBindings(jsonResults.results.bindings) == 0 then
        return "No records found."
	end

	local licenseList = helper.convertJsonToCommaSeparatedList(jsonResults)
	
	-- mw.log(licenseList) 
	
    return licenseList
end

-- Return the created html table
return p