Changes

From BrineRIS Dataspace
484 bytes added ,  08:48, 15 June 2023
Update package: OSW Core
Line 258: Line 258:  
--jsonschema = p.defaultArg(jsonschema, {})
 
--jsonschema = p.defaultArg(jsonschema, {})
 
--jsondata = p.defaultArg(jsondata, {})
 
--jsondata = p.defaultArg(jsondata, {})
if (categories == nil) then categories = jsondata[p.keys.category] end
+
--if (categories == nil) then categories = jsondata[p.keys.category] end -- let function param overwrite json property
 +
if (not p.nilOrEmpty(jsondata[p.keys.category])) then categories = jsondata[p.keys.category] end -- let json property overwrite function param
 
 
 
local schema_res = p.walkJsonSchema({jsonschema=jsonschema, categories=categories, mode=mode, recursive=recursive, debug=debug})
 
local schema_res = p.walkJsonSchema({jsonschema=jsonschema, categories=categories, mode=mode, recursive=recursive, debug=debug})
Line 298: Line 299:  
--mw.log("JSONDATA RENDER")
 
--mw.log("JSONDATA RENDER")
 
--mw.logObject(jsondata)
 
--mw.logObject(jsondata)
      +
local max_index = p.tableLength(schema_res.visited)
 
for i, category in ipairs(schema_res.visited) do
 
for i, category in ipairs(schema_res.visited) do
 +
if (mode == p.mode.footer) then category = schema_res.visited[max_index - i +1] end --reverse order for footer templates
 
local jsonschema = schema_res.jsonschemas[category]
 
local jsonschema = schema_res.jsonschemas[category]
 
local template = schema_res.templates[category]
 
local template = schema_res.templates[category]
Line 360: Line 362:  
:attr( 'class', 'info_box' )
 
:attr( 'class', 'info_box' )
 
:tag( 'tr' )
 
:tag( 'tr' )
:tag( 'td' )
+
:tag( 'th' )
:attr( 'class', 'subheading' )
+
:attr( 'class', 'heading' )
 
:attr( 'colspan', '2' )
 
:attr( 'colspan', '2' )
 
:wikitext( schema_label )
 
:wikitext( schema_label )
Line 514: Line 516:     
--maps jsondata values to semantic properties by using the @context attribute within the schema
 
--maps jsondata values to semantic properties by using the @context attribute within the schema
--test: mw.logObject(p.getSemanticProperties({jsonschema={["@context"]={test="Property:TestProperty", myObjectProperty={["@id"]= "Property:MyObjectProperty", ["@type"]= "@id"}}}, jsondata={test="TestValue", myObjectProperty="123"}, debug=true}))
+
--test: mw.logObject(p.getSemanticProperties({jsonschema={["@context"]={test="Property:schema:TestProperty", myObjectProperty={["@id"]= "Property:MyObjectProperty", ["@type"]= "@id"}}}, jsondata={test="TestValue", myObjectProperty="123"}, debug=true}))
 
--test: mw.logObject(p.getSemanticProperties({jsonschema={["@context"]={"some uri",{test="Property:TestProperty", myObjectProperty={["@id"]= "Property:MyObjectProperty", ["@type"]= "@id"}}}}, jsondata={test="TestValue", myObjectProperty="123"}, debug=true}))
 
--test: mw.logObject(p.getSemanticProperties({jsonschema={["@context"]={"some uri",{test="Property:TestProperty", myObjectProperty={["@id"]= "Property:MyObjectProperty", ["@type"]= "@id"}}}}, jsondata={test="TestValue", myObjectProperty="123"}, debug=true}))
 
--[[
 
--[[
Line 579: Line 581:  
if property_definition[1] == p.keys.property_ns_prefix then
 
if property_definition[1] == p.keys.property_ns_prefix then
 
mapping_found = true
 
mapping_found = true
table.insert(property_names, property_definition[2])
+
property_name = string.gsub(e, p.keys.property_ns_prefix .. ":", "") -- also allow prefix properties like: Property:schema:url
 +
table.insert(property_names, property_name)
 
local schema_property = p.defaultArg(schema_properties[k], {})
 
local schema_property = p.defaultArg(schema_properties[k], {})
 
local schema_type = p.defaultArg(schema_property.type, nil) --todo: also load smw property type on demand
 
local schema_type = p.defaultArg(schema_property.type, nil) --todo: also load smw property type on demand
property_data[k] = {schema_type=schema_type, schema_data=schema_property, property=property_definition[2], value=v}
+
property_data[k] = {schema_type=schema_type, schema_data=schema_property, property=property_name, value=v}
 
end
 
end
 
end
 
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.