Index: trunk/extensions/Wikidata/WiktionaryZ/Expression.php |
— | — | @@ -236,6 +236,14 @@ |
237 | 237 | " AND remove_transaction_id IS NULL"); |
238 | 238 | } |
239 | 239 | |
| 240 | +function addClassAttribute($definedMeaningId, $attibuteMeaningId) { |
| 241 | +//TODO: addClassAttribute |
| 242 | +} |
| 243 | + |
| 244 | +function removeClassAttributeWithId($classAttributeId) { |
| 245 | +//TODO: removeClassAttributeWithId |
| 246 | +} |
| 247 | + |
240 | 248 | function getClassMembershipId($classMemberId, $classId) { |
241 | 249 | $dbr =& wfGetDB(DB_SLAVE); |
242 | 250 | $queryResult = $dbr->query("SELECT class_membership_id FROM uw_class_membership " . |
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZAttributes.php |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | |
131 | 131 | $translatedTextAttribute = new Attribute("translated-text", "Translated text", new RecordSetType($translatedTextStructure)); |
132 | 132 | $definitionAttribute = new Attribute("definition", "Definition", new RecordType(new Structure($translatedTextAttribute, $objectAttributesAttribute))); |
133 | | -$definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", new RecordType(new Structure($definitionAttribute, $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, $relationsAttribute, $classMembershipAttribute, $collectionMembershipAttribute, $objectAttributesAttribute))); |
| 133 | +$definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", new RecordType(new Structure($definitionAttribute, $classAttributesAttribute, $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, $relationsAttribute, $classMembershipAttribute, $collectionMembershipAttribute, $objectAttributesAttribute))); |
134 | 134 | |
135 | 135 | global |
136 | 136 | $expressionsAttribute, $expressionMeaningStructure, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute; |
— | — | @@ -153,4 +153,17 @@ |
154 | 154 | $objectAttributesStructure = new Structure($objectIdAttribute, $textAttributeValuesAttribute, $translatedTextAttributeValuesAttribute); |
155 | 155 | $objectAttributesAttribute = new Attribute("object-attributes", "Annotation", new RecordType($objectAttributesStructure)); |
156 | 156 | |
| 157 | +global |
| 158 | + $classAttributesStructure, |
| 159 | + $classAttributesAttribute, |
| 160 | +// $classAttributeClassAttribute, |
| 161 | + $classAttributeIdAttribute, $classAttributeAttributeAttribute; |
| 162 | + |
| 163 | +$classAttributeIdAttribute = new Attribute("class-attribute-id", "Class attribute identifier", "object-id"); |
| 164 | +//$classAttributeClassAttribute = new Attribute("class-attribute-class", "Class", "defined-meaning-id"); |
| 165 | +$classAttributeAttributeAttribute = new Attribute("class-attribute-attribute", "Attribute", new RecordType($definedMeaningReferenceStructure)); |
| 166 | + |
| 167 | +$classAttributesStructure = new Structure($classAttributeIdAttribute, $classAttributeAttributeAttribute); |
| 168 | +$classAttributesAttribute = new Attribute("class-attributes", "Class attributes", new RecordSetType($classAttributesStructure)); |
| 169 | + |
157 | 170 | ?> |
Index: trunk/extensions/Wikidata/WiktionaryZ/Controller.php |
— | — | @@ -178,6 +178,30 @@ |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
| 182 | +class ClassAttributesController implements Controller { |
| 183 | + public function add($keyPath, $record) { |
| 184 | + global |
| 185 | + $definedMeaningIdAttribute, $classAttributeAttributeAttribute; |
| 186 | + |
| 187 | + $definedMeaningId = $keyPath->peek(0)->getAttributeValue($definedMeaningIdAttribute); |
| 188 | + $attibuteMeaningId = $record->getAttributeValue($classAttributeAttributeAttribute); |
| 189 | + |
| 190 | + if ($attibuteMeaningId != 0) |
| 191 | + addClassAttribute($definedMeaningId, $attibuteMeaningId); |
| 192 | + } |
| 193 | + |
| 194 | + public function remove($keyPath) { |
| 195 | + global |
| 196 | + $classAttributeIdAttribute; |
| 197 | + |
| 198 | + $classAttributeId = $keyPath->peek(0)->getAttributeValue($classAttributeIdAttribute); |
| 199 | + removeClassAttributeWithId($classAttributeId); |
| 200 | + } |
| 201 | + |
| 202 | + public function update($keyPath, $record) { |
| 203 | + } |
| 204 | +} |
| 205 | + |
182 | 206 | class DefinedMeaningRelationController implements Controller { |
183 | 207 | public function add($keyPath, $record) { |
184 | 208 | global |
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php |
— | — | @@ -107,6 +107,16 @@ |
108 | 108 | return $editor; |
109 | 109 | } |
110 | 110 | |
| 111 | +function getClassAttributesEditor($showRecordLifeSpan) { |
| 112 | + global |
| 113 | + $classAttributesAttribute, $classAttributeAttributeAttribute; |
| 114 | + |
| 115 | + $tableEditor = new RecordSetTableEditor($classAttributesAttribute, new SimplePermissionController(true), true, true, false, new ClassAttributesController()); |
| 116 | + $tableEditor->addEditor(new DefinedMeaningReferenceEditor($classAttributeAttributeAttribute, new SimplePermissionController(false), true)); |
| 117 | + addTableLifeSpanEditor($tableEditor, $showRecordLifeSpan); |
| 118 | + return $tableEditor; |
| 119 | +} |
| 120 | + |
111 | 121 | function getSynonymsAndTranslationsEditor($showRecordLifeSpan) { |
112 | 122 | global |
113 | 123 | $synonymsAndTranslationsAttribute, $identicalMeaningAttribute, $expressionIdAttribute, |
— | — | @@ -247,7 +257,8 @@ |
248 | 258 | global |
249 | 259 | $definitionAttribute, $definedMeaningAttribute, $definedMeaningObjectAttributesEditor; |
250 | 260 | |
251 | | - $definitionEditor = getDefinitionEditor($definitionAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan); |
| 261 | + $definitionEditor = getDefinitionEditor($definitionAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan); |
| 262 | + $classAttributesEditor = getClassAttributesEditor($showRecordLifeSpan); |
252 | 263 | $synonymsAndTranslationsEditor = getSynonymsAndTranslationsEditor($showRecordLifeSpan); |
253 | 264 | $relationsEditor = getDefinedMeaningRelationsEditor($showRecordLifeSpan); |
254 | 265 | $reciprocalRelationsEditor = getDefinedMeaningReciprocalRelationsEditor($showRecordLifeSpan); |
— | — | @@ -256,6 +267,7 @@ |
257 | 268 | |
258 | 269 | $definedMeaningEditor = new RecordUnorderedListEditor($definedMeaningAttribute, 4); |
259 | 270 | $definedMeaningEditor->addEditor($definitionEditor); |
| 271 | + $definedMeaningEditor->addEditor($classAttributesEditor); |
260 | 272 | $definedMeaningEditor->addEditor(getAlternativeDefinitionsEditor($showRecordLifeSpan)); |
261 | 273 | $definedMeaningEditor->addEditor($synonymsAndTranslationsEditor); |
262 | 274 | $definedMeaningEditor->addEditor($relationsEditor); |
Index: trunk/extensions/Wikidata/WiktionaryZ/WikiDataTables.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | global |
15 | 15 | $tables, $meaningRelationsTable, $classMembershipsTable, $collectionMembershipsTable, $syntransTable, |
16 | 16 | $translatedContentTable, $alternativeDefinitionsTable, $translatedContentAttributeValuesTable, $transactionsTable, |
17 | | - $textAttributeValuesTable; |
| 17 | + $textAttributeValuesTable, $classAttributesTable; |
18 | 18 | |
19 | 19 | $transactionsTable = new Table('transactions', false); |
20 | 20 | $meaningRelationsTable = new Table('uw_meaning_relations', true); |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | $syntransTable = new Table('uw_syntrans', true); |
24 | 24 | $translatedContentTable = new Table('translated_content', true); |
25 | 25 | $alternativeDefinitionsTable = new Table('uw_alt_meaningtexts', true); |
| 26 | +$classAttributesTable = new Table('uw_class_attributes', true); |
26 | 27 | |
27 | 28 | $translatedContentAttributeValuesTable = new Table('uw_translated_content_attribute_values', true); |
28 | 29 | $textAttributeValuesTable = new Table('uw_text_attribute_values', true); |
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZRecordSets.php |
— | — | @@ -405,12 +405,14 @@ |
406 | 406 | |
407 | 407 | function getDefinedMeaningRecord($definedMeaningId, $queryTransactionInformation) { |
408 | 408 | global |
409 | | - $definedMeaningAttribute, $definitionAttribute, $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, |
| 409 | + $definedMeaningAttribute, $definitionAttribute, $classAttributesAttribute, |
| 410 | + $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, |
410 | 411 | $relationsAttribute, $reciprocalRelationsAttribute, |
411 | 412 | $classMembershipAttribute, $collectionMembershipAttribute, $objectAttributesAttribute; |
412 | 413 | |
413 | 414 | $record = new ArrayRecord($definedMeaningAttribute->type->getStructure()); |
414 | 415 | $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $queryTransactionInformation)); |
| 416 | + $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation)); |
415 | 417 | $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $queryTransactionInformation)); |
416 | 418 | $record->setAttributeValue($synonymsAndTranslationsAttribute, getSynonymAndTranslationRecordSet($definedMeaningId, $queryTransactionInformation)); |
417 | 419 | $record->setAttributeValue($relationsAttribute, getDefinedMeaningRelationsRecordSet($definedMeaningId, $queryTransactionInformation)); |
— | — | @@ -422,6 +424,25 @@ |
423 | 425 | return $record; |
424 | 426 | } |
425 | 427 | |
| 428 | +function getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation) { |
| 429 | + global |
| 430 | + $classAttributesTable, $classAttributeIdAttribute, $classAttributeAttributeAttribute; |
| 431 | + |
| 432 | + $recordSet = queryRecordSet( |
| 433 | + $queryTransactionInformation, |
| 434 | + $classAttributeIdAttribute, |
| 435 | + array( |
| 436 | + 'object_id' => $classAttributeIdAttribute, |
| 437 | + 'attribute_mid' => $classAttributeAttributeAttribute |
| 438 | + ), |
| 439 | + $classAttributesTable, |
| 440 | + array("class_mid=$definedMeaningId") |
| 441 | + ); |
| 442 | + |
| 443 | + expandDefinedMeaningReferencesInRecordSet($recordSet, array($classAttributeAttributeAttribute)); |
| 444 | + return $recordSet; |
| 445 | +} |
| 446 | + |
426 | 447 | function getAlternativeDefinitionsRecordSet($definedMeaningId, $queryTransactionInformation) { |
427 | 448 | global |
428 | 449 | $alternativeDefinitionsTable, $definitionIdAttribute, $alternativeDefinitionAttribute, $sourceAttribute; |
Index: trunk/extensions/Wikidata/Database scripts/Incremental/21 - Add class attributes.sql |
— | — | @@ -0,0 +1,14 @@ |
| 2 | +--
|
| 3 | +--Add class attributes table to store which attributes can be added to object's that belong to a class
|
| 4 | +--
|
| 5 | +
|
| 6 | +CREATE TABLE `uw_class_attributes` (
|
| 7 | + `object_id` INT NOT NULL ,
|
| 8 | + `class_mid` INT NOT NULL DEFAULT '0',
|
| 9 | + `attribute_mid` INT NOT NULL DEFAULT '0',
|
| 10 | + `add_transaction_id` INT NOT NULL ,
|
| 11 | + `remove_transaction_id` INT NULL
|
| 12 | +);
|
| 13 | +
|
| 14 | +INSERT INTO `script_log` (`time`, `script_name`)
|
| 15 | + VALUES (NOW(), '21 - Add class attributes.sql'); |
\ No newline at end of file |