10
10
* @constructor
11
11
* @since 1.0
12
12
*
13
- * @param {wikibase.datamodel.TermSet |null } [labels]
14
- * @param {wikibase.datamodel.TermSet |null } [descriptions]
15
- * @param {wikibase.datamodel.MultiTermSet |null } [aliases]
13
+ * @param {wikibase.datamodel.TermMap |null } [labels]
14
+ * @param {wikibase.datamodel.TermMap |null } [descriptions]
15
+ * @param {wikibase.datamodel.MultiTermMap |null } [aliases]
16
16
*/
17
17
var SELF
18
18
= wb . datamodel . Fingerprint
19
19
= function WbDataModelFingerprint ( labels , descriptions , aliases ) {
20
- labels = labels || new wb . datamodel . TermSet ( ) ;
21
- descriptions = descriptions || new wb . datamodel . TermSet ( ) ;
22
- aliases = aliases || new wb . datamodel . MultiTermSet ( ) ;
20
+ labels = labels || new wb . datamodel . TermMap ( ) ;
21
+ descriptions = descriptions || new wb . datamodel . TermMap ( ) ;
22
+ aliases = aliases || new wb . datamodel . MultiTermMap ( ) ;
23
23
24
24
if (
25
- ! ( labels instanceof wb . datamodel . TermSet )
26
- || ! ( descriptions instanceof wb . datamodel . TermSet )
27
- || ! ( aliases instanceof wb . datamodel . MultiTermSet )
25
+ ! ( labels instanceof wb . datamodel . TermMap )
26
+ || ! ( descriptions instanceof wb . datamodel . TermMap )
27
+ || ! ( aliases instanceof wb . datamodel . MultiTermMap )
28
28
) {
29
29
throw new Error ( 'Required parameter(s) not specified or not defined properly' ) ;
30
30
}
@@ -36,22 +36,22 @@ var SELF
36
36
37
37
$ . extend ( SELF . prototype , {
38
38
/**
39
- * @type {wikibase.datamodel.TermSet }
39
+ * @type {wikibase.datamodel.TermMap }
40
40
*/
41
41
_labels : null ,
42
42
43
43
/**
44
- * @type {wikibase.datamodel.TermSet }
44
+ * @type {wikibase.datamodel.TermMap }
45
45
*/
46
46
_descriptions : null ,
47
47
48
48
/**
49
- * @type {wikibase.datamodel.MultiTermSet }
49
+ * @type {wikibase.datamodel.MultiTermMap }
50
50
*/
51
51
_aliases : null ,
52
52
53
53
/**
54
- * @return {wikibase.datamodel.TermSet }
54
+ * @return {wikibase.datamodel.TermMap }
55
55
*/
56
56
getLabels : function ( ) {
57
57
return this . _labels ;
@@ -66,11 +66,12 @@ $.extend( SELF.prototype, {
66
66
} ,
67
67
68
68
/**
69
+ * @param {string } languageCode
69
70
* @param {wikibase.datamodel.Term } label
70
71
* @return {boolean }
71
72
*/
72
- hasLabel : function ( label ) {
73
- return this . _labels . hasItem ( label ) ;
73
+ hasLabel : function ( languageCode , label ) {
74
+ return this . _labels . hasItem ( languageCode , label ) ;
74
75
} ,
75
76
76
77
/**
@@ -82,17 +83,19 @@ $.extend( SELF.prototype, {
82
83
} ,
83
84
84
85
/**
86
+ * @param {string } languageCode
85
87
* @param {wikibase.datamodel.Term } term
86
88
*/
87
- setLabel : function ( term ) {
88
- this . _labels . setItem ( term ) ;
89
+ setLabel : function ( languageCode , term ) {
90
+ this . _labels . setItem ( languageCode , term ) ;
89
91
} ,
90
92
91
93
/**
94
+ * @param {string } languageCode
92
95
* @param {wikibase.datamodel.Term } label
93
96
*/
94
- removeLabel : function ( label ) {
95
- this . _labels . removeItem ( label ) ;
97
+ removeLabel : function ( languageCode , label ) {
98
+ this . _labels . removeItem ( languageCode , label ) ;
96
99
} ,
97
100
98
101
/**
@@ -103,7 +106,7 @@ $.extend( SELF.prototype, {
103
106
} ,
104
107
105
108
/**
106
- * @return {wikibase.datamodel.TermSet }
109
+ * @return {wikibase.datamodel.TermMap }
107
110
*/
108
111
getDescriptions : function ( ) {
109
112
return this . _descriptions ;
@@ -118,11 +121,12 @@ $.extend( SELF.prototype, {
118
121
} ,
119
122
120
123
/**
124
+ * @param {string } languageCode
121
125
* @param {wikibase.datamodel.Term } description
122
126
* @return {boolean }
123
127
*/
124
- hasDescription : function ( description ) {
125
- return this . _descriptions . hasItem ( description ) ;
128
+ hasDescription : function ( languageCode , description ) {
129
+ return this . _descriptions . hasItem ( languageCode , description ) ;
126
130
} ,
127
131
128
132
/**
@@ -134,17 +138,19 @@ $.extend( SELF.prototype, {
134
138
} ,
135
139
136
140
/**
141
+ * @param {string } languageCode
137
142
* @param {wikibase.datamodel.Term } term
138
143
*/
139
- setDescription : function ( term ) {
140
- this . _descriptions . setItem ( term ) ;
144
+ setDescription : function ( languageCode , term ) {
145
+ this . _descriptions . setItem ( languageCode , term ) ;
141
146
} ,
142
147
143
148
/**
149
+ * @param {string } languageCode
144
150
* @param {wikibase.datamodel.Term } description
145
151
*/
146
- removeDescription : function ( description ) {
147
- this . _descriptions . removeItem ( description ) ;
152
+ removeDescription : function ( languageCode , description ) {
153
+ this . _descriptions . removeItem ( languageCode , description ) ;
148
154
} ,
149
155
150
156
/**
@@ -155,7 +161,7 @@ $.extend( SELF.prototype, {
155
161
} ,
156
162
157
163
/**
158
- * @return {wikibase.datamodel.MultiTermSet }
164
+ * @return {wikibase.datamodel.MultiTermMap }
159
165
*/
160
166
getAliases : function ( ) {
161
167
return this . _aliases ;
@@ -170,11 +176,12 @@ $.extend( SELF.prototype, {
170
176
} ,
171
177
172
178
/**
179
+ * @param {string } languageCode
173
180
* @param {wikibase.datamodel.MultiTerm } aliases
174
181
* @return {boolean }
175
182
*/
176
- hasAliases : function ( aliases ) {
177
- return this . _aliases . hasItem ( aliases ) ;
183
+ hasAliases : function ( languageCode , aliases ) {
184
+ return this . _aliases . hasItem ( languageCode , aliases ) ;
178
185
} ,
179
186
180
187
/**
@@ -186,24 +193,35 @@ $.extend( SELF.prototype, {
186
193
} ,
187
194
188
195
/**
189
- * @param wikibase.datamodel.MultiTerm|wikibase.datamodel.MultiTermSet} aliases
196
+ * @param {string } [languageCode]
197
+ * @param {wikibase.datamodel.MultiTerm|wikibase.datamodel.MultiTermMap } aliases
190
198
*/
191
- setAliases : function ( aliases ) {
199
+ setAliases : function ( languageCode , aliases ) {
200
+ if ( typeof languageCode !== 'string' ) {
201
+ aliases = languageCode ;
202
+ languageCode = undefined ;
203
+ }
204
+
192
205
if ( aliases instanceof wb . datamodel . MultiTerm ) {
193
- this . _aliases . setItem ( aliases ) ;
194
- } else if ( aliases instanceof wb . datamodel . MultiTermSet ) {
206
+ if ( ! languageCode ) {
207
+ throw new Error ( 'Language code the wb.datamodel.MultiTerm object should be set '
208
+ + 'for needs to be specified' ) ;
209
+ }
210
+ this . _aliases . setItem ( languageCode , aliases ) ;
211
+ } else if ( aliases instanceof wb . datamodel . MultiTermMap ) {
195
212
this . _aliases = aliases ;
196
213
} else {
197
214
throw new Error ( 'Aliases need to be specified as wb.datamodel.MultiTerm or '
198
- + 'wb.datamodel.MultiTermSet instance' ) ;
215
+ + 'wb.datamodel.MultiTermMap instance' ) ;
199
216
}
200
217
} ,
201
218
202
219
/**
220
+ * @param {string } languageCode
203
221
* @param {wikibase.datamodel.MultiTerm } aliases
204
222
*/
205
- removeAliases : function ( aliases ) {
206
- this . _aliases . removeItem ( aliases ) ;
223
+ removeAliases : function ( languageCode , aliases ) {
224
+ this . _aliases . removeItem ( languageCode , aliases ) ;
207
225
} ,
208
226
209
227
/**
0 commit comments