472
edits
mNo edit summary |
(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 361: | Line 362: | ||
:attr( 'class', 'info_box' ) | :attr( 'class', 'info_box' ) | ||
:tag( 'tr' ) | :tag( 'tr' ) | ||
:tag( ' | :tag( 'th' ) | ||
:attr( 'class', ' | :attr( 'class', 'heading' ) | ||
:attr( 'colspan', '2' ) | :attr( 'colspan', '2' ) | ||
:wikitext( schema_label ) | :wikitext( schema_label ) | ||
Line 515: | 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 580: | 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_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_data[k] = {schema_type=schema_type, schema_data=schema_property, property=property_name, value=v} | ||
end | end | ||
end | end | ||
Line 647: | Line 649: | ||
if (jsondata[p.keys.name] ~= nil) then properties['Display title of'] = jsondata[p.keys.name] | if (jsondata[p.keys.name] ~= nil) then properties['Display title of'] = jsondata[p.keys.name] | ||
elseif (jsondata[p.keys.label] ~= nil and jsondata[p.keys.label][1] ~= nil) then properties['Display title of'] = p.splitString(jsondata[p.keys.label][1], '@')[1] | elseif (jsondata[p.keys.label] ~= nil and jsondata[p.keys.label][1] ~= nil) then properties['Display title of'] = p.splitString(jsondata[p.keys.label][1], '@')[1] | ||
else properties['Display title of'] = p.defaultArg(parent_schema_property.schema_data['title'], "") end | else properties['Display title of'] = p.defaultArg(parent_schema_property.schema_data['title'], "") end | ||
if (p.tableLength(properties) > 0) then | if (p.tableLength(properties) > 0) then |
edits