Skip to content

Commit eb0b13f

Browse files
tarrowjakobw
authored andcommitted
Introduce FingerprintableEntity in a backwards compatible way
Summary: Not all entities must have fingerprints e.g. Lexemes. This commit starts the process of being able to remove fingerprints from Entity Bug: T197085
1 parent 93229f5 commit eb0b13f

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ the corresponding serializer, and send back to the API.
1717

1818
## Release notes
1919

20+
### 4.1.0 (2018-06-25)
21+
22+
* Added new FingerprintableEntity class
23+
* Make Item and Property inherit from it
24+
2025
### 4.0.0 (2017-10-09)
2126

2227
* Made the library a pure JavaScript library.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "wikibase-data-model",
33
"description": "JavaScript implementation of the basic Wikibase DataModel entity types and components they are made of",
4-
"version": "4.0.0",
4+
"version": "4.1.0",
55
"directories": {
66
"lib": "src",
77
"test": "tests"

src/FingerprintableEntity.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
( function( wb, $ ) {
2+
'use strict';
3+
4+
var PARENT = wb.datamodel.Entity;
5+
6+
/**
7+
* Abstract FingerprintableEntity class featuring an id and a fingerprint.
8+
* @class wikibase.datamodel.FingerprintableEntity
9+
* @abstract
10+
* @since 4.1.0
11+
* @license GPL-2.0+
12+
* @author T. Arrow < thomas.arrow_ext@wikimedia.de >
13+
*
14+
* @constructor
15+
*
16+
* @throws {Error} when trying to instantiate since FingerprintableEntity is abstract.
17+
*/
18+
19+
var SELF = wb.datamodel.FingerprintableEntity = util.inherit(
20+
'WbDataModelFingerprintableEntity',
21+
PARENT,
22+
{
23+
/**
24+
* @property {wikibase.datamodel.Fingerprint}
25+
* @private
26+
*/
27+
_fingerprint: null,
28+
29+
/**
30+
* @return {wikibase.datamodel.Fingerprint}
31+
*/
32+
getFingerprint: function() {
33+
return this._fingerprint;
34+
},
35+
36+
/**
37+
* @param {wikibase.datamodel.Fingerprint} fingerprint
38+
*/
39+
setFingerprint: function( fingerprint ) {
40+
this._fingerprint = fingerprint;
41+
}
42+
}
43+
);
44+
45+
}( wikibase, jQuery ) );

src/Item.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
( function( wb, util ) {
22
'use strict';
33

4-
var PARENT = wb.datamodel.Entity;
4+
var PARENT = wb.datamodel.FingerprintableEntity;
55

66
/**
77
* Entity derivative featuring statements and site links.
88
* @class wikibase.datamodel.Item
9-
* @extends wikibase.datamodel.Entity
9+
* @extends wikibase.datamodel.FingerprintableEntity
1010
* @since 1.0
1111
* @license GPL-2.0+
1212
* @author H. Snater < mediawiki@snater.com >

src/Property.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
( function( wb, util ) {
22
'use strict';
33

4-
var PARENT = wb.datamodel.Entity;
4+
var PARENT = wb.datamodel.FingerprintableEntity;
55

66
/**
77
* Entity derivative featuring a data type and statements.
88
* @class wikibase.datamodel.Property
9-
* @extends wikibase.datamodel.Entity
9+
* @extends wikibase.datamodel.FingerprintableEntity
1010
* @since 1.0
1111
* @license GPL-2.0+
1212
* @author H. Snater < mediawiki@snater.com >

0 commit comments

Comments
 (0)