Thanks! getDataItem() seems to have done the trick. And I believe the Semantic Internal Objects code on SVN now works with with SMW 1.6.
[Forwarding to the list as this might be of general interest]There are basically two cases:
On 07/06/11 04:24, Yaron Koren wrote:
I'm modifying Semantic Internal Objects to work with SMW 1.6. SIO
currently has some code that creates an object of type SMWDataValue, and
calls getDBkeys() on it. That is now deprecated - instead one is
supposed to call SMWCompatibilityHelpers::getDBkeysFromDataItem(). That
function, though, takes in an object of type SMWDataItem, not
SMWDataValue. I don't know how to generate an object of type SMWDataItem
- I couldn't find a constructor function for it. I have a property name
and a value - how do I create one using those?
(1) You have user input data and want a data item.
(2) You have exact, normalized, internal data and want a data item.
In case (1), you should create an SMWDataValue as before. The data value classes are the place where all the parsing and cleaning of user data happens. You can call getDataItem() to get the dataitem (as usual, you may want to check isvalid() to see if the input could be parsed at all).
In case (2), you simply call the constructor of the SMWDataItem that you want to create, using the right parameters. This should always be done if a fixed data item is required in the code (e.g. to represent a fixed special property that is created from its key).
Dataitems should be viewed as simple data structures: they don't do anything intelligent other than possibly some basic sanity checks in the constructor. In most cases, you should no longer need to access the elements of the array that was returned by getDBkeys(): the same information is represented in a more direct way by the data item. The DBkeys-based methods are only useful if your code generally uses such arrays internally. Otherwise, the arrays should be replaced by data item objects, and it might not be necessary to ever convert these to arrays at all.