Updated mediawiki/extensions
Project: mediawiki/extensions/SemanticMediaWiki  7c5d09297153e2a368ba7314c6abb4aa5bfd9692
null
Merge "smw.dataItem.factory() to enable dataItem type hinting during parseJSON()"

Enables type hinting during JSON parsing on the following objects:
+ '_wpg' -> smw.dataItem.wikiPage
+ '_uri' -> smw.dataItem.uri
+ '_dat' -> smw.dataItem.time

+ smw.dataItem.property

JSON.parse let’s you add [r1] a function call while parsing and making it
possible for each key/value to be transformed into an appropriate
typed object.

While the SMWDISerializer does not directly enable type hinting
of its serialized objects (it does by having an reference
object “printrequests” which assigns each “Property” a “typeid”,
for example “_wpg” as SMWDIWikiPage representation).

The smw.dataItem.factory() will map those result objects that were
serialized through the SMWDISerializer and use the “printrequests” type
hinting as reference map in order to assign each of them a
smw.dataItem object.

Dataitems are now assigned to a smw.dataitem.property which
enables to assign multi values to a single property.

Subject (if exists is of type smw.dataItem.wikiPage otherwise a simple object)
|--> property -> smw.dataItem.property
|--> smw.dataItem.wikiPage
|--> ...
|--> property -> smw.dataItem.property
|--> smw.dataItem.uri
|--> ...
|--> property -> smw.dataItem.property
|--> smw.dataItem.time
|--> ...

While smw.dataItem.factory() is a public method it is mostly used as
indirect methods during smw.Api.parse() or smw.Api.fetch().

var smwApi = new smw.Api();
smwApi.parse( data ) returns typed objects
smwApi.fetch( query ) returns typed objects

var smwQuery = new smw.Api.query( printouts, parameters, conditions );
queryString = smwQuery.toString()

++ ext.smw.dataItem.test 29 tests of 29 passed
++ ext.smw.Api.test 7 tests of 7 passed
++ ext.smw.Api.query 7 tests of 7 passed
++ ext.smw.dataItem.property 4 tests of 4 passed

Change-Id: Ia50a05d77195e94ff17290955ccedf26028f3873