Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General update #16

Merged
merged 74 commits into from Oct 29, 2014
Merged

General update #16

merged 74 commits into from Oct 29, 2014

Conversation

snaterlicious
Copy link
Contributor

Updated component in compliance with DataModel 1.0 aiming at being able to properly manage Fingerprint, Item and Property objects in front-end code. Functionality supposed to be obsolete (e.g. toJSON(), newFromJSON()) is removed in favour of using the wikibase.serialization component (see wmde/WikibaseSerializationJavaScript#6 for corresponding changes to that component).
The changes are supposed to add completeness to the component being able to properly model the UI using objects provided by the component. Inspired by the back-end implementation of the data model, there are, however, a few differences. Most obvious is the more intuitive and consistent naming of constructors ending with _Set, _List and *Group. The concept of groups is not a dedicated part of the back-end data model and is, instead, applied and resolved during serialization/deserialization. However, since grouping is an essential logical concept, it should be an integral part of the JS data model.

@JeroenDeDauw
Copy link
Contributor

Did only a rough review, though this looks like it's going in the right direction and does not contain any serious issues design wise

@snaterlicious snaterlicious force-pushed the fingerprint branch 2 times, most recently from 7cb4aca to ac83724 Compare September 23, 2014 15:41
@adrianheine
Copy link
Contributor

What did you use as reference when implementing this? Some documentation, spec, code?

*/
var SELF = wb.datamodel.Statement = util.inherit( 'WbStatement', PARENT, constructor, {
var SELF = wb.datamodel.Statement = function WbDataModelStatement( claim, references, rank ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering. The constructor in WikibaseDataModel is missing the third rank parameter. Should we add it there?

@adrianheine
Copy link
Contributor

The following fails:

deserializer.deserialize( {
  type: 'item',
  id: 'Q1',
  labels: {
    "be-tarask":{"language":"be-tarask","value":"a"},
    "be-x-old":{"language":"be-tarask","value":"b"}
  }
} );

Error message is There may only be one item per item key. See https://bugzilla.wikimedia.org/show_bug.cgi?id=72183 for the same issue in the PHP DM.

@adrianheine
Copy link
Contributor

EntityId needs to be able to parse the legacy format with numeric-id, since it is still used for snak values.

@adrianheine
Copy link
Contributor

We could also work around this in wikibase.git instead of here.

@adrianheine
Copy link
Contributor

@snaterlicious
Copy link
Contributor Author

I could imagine us running into trouble if we try to work around that in Wikibase.git. Especially, since I do not see a chance of the issue being resolved in the near future. Although I do not like the idea at all either, still, it might be the cleanest solution to (re-)implement a LegacyEntityId and the corresponding Serializer/Deserializer in the JS serialization pull request. If there are no objections, I will amend the pull request.

@adrianheine
Copy link
Contributor

Works for me, too.

@adrianheine
Copy link
Contributor

I think the LegacyEntityId has to be used for wikibase-entityid datavalues.


for( var i = 0; i < this._items.length; i++ ) {
var propertyId = this._items[i].getMainSnak().getPropertyId();
if( $.inArray( propertyId, propertyIds ) === -1 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An inArray check in a loop is not so nice perfomance-wise. Could be refactored using a map instead. But not a reason to not merge this patch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just use jQuery.map and jQuery.unique. Probably faster.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to actually get data on that. I remember seeing some website where you could easily compare such things - can't find it now though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can write our own test on http://jsperf.com/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jQuery.unique works on DOM elements only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. _.uniq would work, but we don't have underscore.

@thiemowmde
Copy link
Contributor

+1. I'm fine with merging this as it is. There are some nested loops I don't like for performance reasons. But these can be easily refactored in later patches.

adrianheine added a commit that referenced this pull request Oct 29, 2014
@adrianheine adrianheine merged commit 7cab070 into master Oct 29, 2014
@adrianheine adrianheine deleted the fingerprint branch October 29, 2014 15:18
wmfgerrit pushed a commit to wikimedia/mediawiki-extensions-Wikibase that referenced this pull request Nov 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants