Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php |
— | — | @@ -46,14 +46,13 @@ |
47 | 47 | class Table { |
48 | 48 | public $identifier; |
49 | 49 | public $isVersioned; |
50 | | - public $keyFields; |
| 50 | + public $keyColumns; |
51 | 51 | public $columns; |
52 | 52 | |
53 | | - public function __construct($identifier, $isVersioned, $keyFields) { |
| 53 | + public function __construct($identifier, $isVersioned) { |
54 | 54 | # Without dataset prefix! |
55 | 55 | $this->identifier = $identifier; |
56 | 56 | $this->isVersioned = $isVersioned; |
57 | | - $this->keyFields = $keyFields; |
58 | 57 | $this->columns = array(); |
59 | 58 | } |
60 | 59 | |
— | — | @@ -68,14 +67,18 @@ |
69 | 68 | |
70 | 69 | return $result; |
71 | 70 | } |
| 71 | + |
| 72 | + protected function setKeyColumns(array $keyColumns) { |
| 73 | + $this->keyColumns = $keyColumns; |
| 74 | + } |
72 | 75 | } |
73 | 76 | |
74 | 77 | class VersionedTable extends Table { |
75 | 78 | public $addTransactionId; |
76 | 79 | public $removeTransactionId; |
77 | 80 | |
78 | | - public function __construct($identifier, $keyFields) { |
79 | | - parent::__construct($identifier, true, $keyFields); |
| 81 | + public function __construct($identifier) { |
| 82 | + parent::__construct($identifier, true); |
80 | 83 | |
81 | 84 | $this->addTransactionId = $this->createColumn("add_transaction_id"); |
82 | 85 | $this->removeTransactionId = $this->createColumn("remove_transaction_id"); |
— | — | @@ -87,10 +90,12 @@ |
88 | 91 | public $definedMeaningId; |
89 | 92 | |
90 | 93 | public function __construct($identifier) { |
91 | | - parent::__construct($identifier, false, array("name")); |
| 94 | + parent::__construct($identifier, false); |
92 | 95 | |
93 | 96 | $this->name = $this->createColumn("name"); |
94 | 97 | $this->definedMeaningId = $this->createColumn("defined_meaning_id"); |
| 98 | + |
| 99 | + $this->setKeyColumns(array($this->name)); |
95 | 100 | } |
96 | 101 | } |
97 | 102 | |
— | — | @@ -102,13 +107,15 @@ |
103 | 108 | public $comment; |
104 | 109 | |
105 | 110 | public function __construct($identifier) { |
106 | | - parent::__construct($identifier, false, array("transaction_id")); |
| 111 | + parent::__construct($identifier, false); |
107 | 112 | |
108 | 113 | $this->transactionId = $this->createColumn("transaction_id"); |
109 | 114 | $this->userId = $this->createColumn("user_id"); |
110 | 115 | $this->userIp = $this->createColumn("user_ip"); |
111 | 116 | $this->timestamp = $this->createColumn("timestamp"); |
112 | 117 | $this->comment = $this->createColumn("comment"); |
| 118 | + |
| 119 | + $this->setKeyColumns(array($this->transactionId)); |
113 | 120 | } |
114 | 121 | } |
115 | 122 | |
— | — | @@ -118,11 +125,13 @@ |
119 | 126 | public $meaningTextTcid; |
120 | 127 | |
121 | 128 | public function __construct($identifier) { |
122 | | - parent::__construct($identifier, array("defined_meaning_id")); |
| 129 | + parent::__construct($identifier); |
123 | 130 | |
124 | 131 | $this->definedMeaningId = $this->createColumn("defined_meaning_id"); |
125 | 132 | $this->expressionId = $this->createColumn("expression_id"); |
126 | 133 | $this->meaningTextTcid = $this->createColumn("meaning_text_tcid"); |
| 134 | + |
| 135 | + $this->setKeyColumns(array($this->definedMeaningId)); |
127 | 136 | } |
128 | 137 | } |
129 | 138 | |
— | — | @@ -132,11 +141,13 @@ |
133 | 142 | public $sourceId; |
134 | 143 | |
135 | 144 | public function __construct($identifier) { |
136 | | - parent::__construct($identifier, array("meaning_mid", "meaning_text_tcid")); |
| 145 | + parent::__construct($identifier); |
137 | 146 | |
138 | 147 | $this->meaningMid = $this->createColumn("meaning_mid"); |
139 | 148 | $this->meaningTextTcid = $this->createColumn("meaning_text_tcid"); |
140 | 149 | $this->sourceId = $this->createColumn("source_id"); |
| 150 | + |
| 151 | + $this->setKeyColumns(array($this->meaningMid, $this->meaningTextTcid)); |
141 | 152 | } |
142 | 153 | } |
143 | 154 | |
— | — | @@ -147,12 +158,14 @@ |
148 | 159 | public $languageId; |
149 | 160 | |
150 | 161 | public function __construct($name) { |
151 | | - parent::__construct($name, array("expression_id")); |
| 162 | + parent::__construct($name); |
152 | 163 | |
153 | 164 | $this->expressionId = $this->createColumn("expression_id"); |
154 | 165 | $this->spelling = $this->createColumn("spelling"); |
155 | 166 | $this->hyphenation = $this->createColumn("hyphenation"); |
156 | 167 | $this->languageId = $this->createColumn("language_id"); |
| 168 | + |
| 169 | + $this->setKeyColumns(array($this->expressionId)); |
157 | 170 | } |
158 | 171 | } |
159 | 172 | |
— | — | @@ -164,13 +177,15 @@ |
165 | 178 | public $attributeType; |
166 | 179 | |
167 | 180 | public function __construct($name) { |
168 | | - parent::__construct($name, array("object_id")); |
| 181 | + parent::__construct($name); |
169 | 182 | |
170 | 183 | $this->objectId = $this->createColumn("object_id"); |
171 | 184 | $this->classMid = $this->createColumn("class_mid"); |
172 | 185 | $this->levelMid = $this->createColumn("level_mid"); |
173 | 186 | $this->attributeMid = $this->createColumn("attribute_mid"); |
174 | | - $this->attributeType = $this->createColumn("attribute_type"); |
| 187 | + $this->attributeType = $this->createColumn("attribute_type"); |
| 188 | + |
| 189 | + $this->setKeyColumns(array($this->objectId)); |
175 | 190 | } |
176 | 191 | } |
177 | 192 | |
— | — | @@ -180,11 +195,13 @@ |
181 | 196 | public $classMemberMid; |
182 | 197 | |
183 | 198 | public function __construct($name) { |
184 | | - parent::__construct($name, array("class_membership_id")); |
| 199 | + parent::__construct($name); |
185 | 200 | |
186 | 201 | $this->classMembershipId = $this->createColumn("class_membership_id"); |
187 | 202 | $this->classMid = $this->createColumn("class_mid"); |
188 | 203 | $this->classMemberMid = $this->createColumn("class_member_mid"); |
| 204 | + |
| 205 | + $this->setKeyColumns(array($this->classMembershipId)); |
189 | 206 | } |
190 | 207 | } |
191 | 208 | |
— | — | @@ -195,12 +212,14 @@ |
196 | 213 | public $applicableLanguageId; |
197 | 214 | |
198 | 215 | public function __construct($name) { |
199 | | - parent::__construct($name, array('collection_id', 'member_mid')); |
| 216 | + parent::__construct($name); |
200 | 217 | |
201 | 218 | $this->collectionId = $this->createColumn("collection_id"); |
202 | 219 | $this->memberMid = $this->createColumn("member_mid"); |
203 | 220 | $this->internalMemberId = $this->createColumn("internal_member_id"); |
204 | 221 | $this->applicableLanguageId = $this->createColumn("applicable_language_id"); |
| 222 | + |
| 223 | + $this->setKeyColumns(array($this->collectionId, $this->memberMid)); |
205 | 224 | } |
206 | 225 | } |
207 | 226 | |
— | — | @@ -211,12 +230,14 @@ |
212 | 231 | public $relationTypeMid; |
213 | 232 | |
214 | 233 | public function __construct($name) { |
215 | | - parent::__construct($name, array("relation_id")); |
| 234 | + parent::__construct($name); |
216 | 235 | |
217 | 236 | $this->relationId = $this->createColumn("relation_id"); |
218 | 237 | $this->meaning1Mid = $this->createColumn("meaning1_mid"); |
219 | 238 | $this->meaning2Mid = $this->createColumn("meaning2_mid"); |
220 | 239 | $this->relationTypeMid = $this->createColumn("relationtype_mid"); |
| 240 | + |
| 241 | + $this->setKeyColumns(array($this->relationId)); |
221 | 242 | } |
222 | 243 | } |
223 | 244 | |
— | — | @@ -228,13 +249,15 @@ |
229 | 250 | public $identicalMeaning; |
230 | 251 | |
231 | 252 | public function __construct($name) { |
232 | | - parent::__construct($name, array("syntrans_sid")); |
| 253 | + parent::__construct($name); |
233 | 254 | |
234 | 255 | $this->syntransSid = $this->createColumn("syntrans_sid"); |
235 | 256 | $this->definedMeaningId = $this->createColumn("defined_meaning_id"); |
236 | 257 | $this->expressionId = $this->createColumn("expression_id"); |
237 | 258 | $this->firstUse = $this->createColumn("firstuse"); |
238 | 259 | $this->identicalMeaning = $this->createColumn("identical_meaning"); |
| 260 | + |
| 261 | + $this->setKeyColumns(array($this->syntransSid)); |
239 | 262 | } |
240 | 263 | } |
241 | 264 | |
— | — | @@ -245,12 +268,14 @@ |
246 | 269 | public $text; |
247 | 270 | |
248 | 271 | public function __construct($name) { |
249 | | - parent::__construct($name, array("value_id")); |
| 272 | + parent::__construct($name); |
250 | 273 | |
251 | 274 | $this->valueId = $this->createColumn("value_id"); |
252 | 275 | $this->objectId = $this->createColumn("object_id"); |
253 | 276 | $this->attributeMid = $this->createColumn("attribute_mid"); |
254 | 277 | $this->text = $this->createColumn("text"); |
| 278 | + |
| 279 | + $this->setKeyColumns(array($this->valueId)); |
255 | 280 | } |
256 | 281 | } |
257 | 282 | |
— | — | @@ -261,12 +286,14 @@ |
262 | 287 | public $valueTcid; |
263 | 288 | |
264 | 289 | public function __construct($name) { |
265 | | - parent::__construct($name, array("value_id")); |
| 290 | + parent::__construct($name); |
266 | 291 | |
267 | 292 | $this->valueId = $this->createColumn("value_id"); |
268 | 293 | $this->objectId = $this->createColumn("object_id"); |
269 | 294 | $this->attributeMid = $this->createColumn("attribute_mid"); |
270 | 295 | $this->valueTcid = $this->createColumn("value_tcid"); |
| 296 | + |
| 297 | + $this->setKeyColumns(array($this->valueId)); |
271 | 298 | } |
272 | 299 | } |
273 | 300 | |
— | — | @@ -278,13 +305,15 @@ |
279 | 306 | public $originalLanguageId; |
280 | 307 | |
281 | 308 | public function __construct($name) { |
282 | | - parent::__construct($name, array("translated_content_id", "language_id")); |
| 309 | + parent::__construct($name); |
283 | 310 | |
284 | 311 | $this->translatedContentId = $this->createColumn("translated_content_id"); |
285 | 312 | $this->languageId = $this->createColumn("language_id"); |
286 | 313 | $this->shortTextId = $this->createColumn("shorttext_id"); |
287 | 314 | $this->textId = $this->createColumn("text_id"); |
288 | 315 | $this->originalLanguageId = $this->createColumn("original_language_id"); |
| 316 | + |
| 317 | + $this->setKeyColumns(array($this->translatedContentId, $this->languageId)); |
289 | 318 | } |
290 | 319 | } |
291 | 320 | |
— | — | @@ -295,12 +324,14 @@ |
296 | 325 | public $languageId; |
297 | 326 | |
298 | 327 | public function __construct($name) { |
299 | | - parent::__construct($name, array("attribute_id", "option_mid")); |
| 328 | + parent::__construct($name); |
300 | 329 | |
301 | 330 | $this->optionId = $this->createColumn("option_id"); |
302 | 331 | $this->attributeId = $this->createColumn("attribute_id"); |
303 | 332 | $this->optionMid = $this->createColumn("option_mid"); |
304 | 333 | $this->languageId = $this->createColumn("language_id"); |
| 334 | + |
| 335 | + $this->setKeyColumns(array($this->attributeId, $this->optionMid)); // TODO: is this the correct key? |
305 | 336 | } |
306 | 337 | } |
307 | 338 | |
— | — | @@ -310,11 +341,13 @@ |
311 | 342 | public $optionId; |
312 | 343 | |
313 | 344 | public function __construct($name) { |
314 | | - parent::__construct($name, array("value_id")); |
| 345 | + parent::__construct($name); |
315 | 346 | |
316 | 347 | $this->valueId = $this->createColumn("value_id"); |
317 | 348 | $this->objectId = $this->createColumn("object_id"); |
318 | 349 | $this->optionId = $this->createColumn("option_id"); |
| 350 | + |
| 351 | + $this->setKeyColumns(array($this->valueId)); |
319 | 352 | } |
320 | 353 | } |
321 | 354 | |
— | — | @@ -326,13 +359,15 @@ |
327 | 360 | public $label; |
328 | 361 | |
329 | 362 | public function __construct($name) { |
330 | | - parent::__construct($name, array("value_id")); |
| 363 | + parent::__construct($name); |
331 | 364 | |
332 | 365 | $this->valueId = $this->createColumn("value_id"); |
333 | 366 | $this->objectId = $this->createColumn("object_id"); |
334 | 367 | $this->attributeMid = $this->createColumn("attribute_mid"); |
335 | 368 | $this->url = $this->createColumn("url"); |
336 | 369 | $this->label = $this->createColumn("label"); |
| 370 | + |
| 371 | + $this->setKeyColumns(array($this->valueId)); |
337 | 372 | } |
338 | 373 | } |
339 | 374 | |