Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -106,20 +106,20 @@ |
107 | 107 | $t->expression = new Attribute("expression", wfMsgSc("Spelling"), "spelling"); |
108 | 108 | else { |
109 | 109 | $t->expressionStructure = new Structure("expression", $t->language, $t->spelling); |
110 | | - $t->expression = new Attribute(null, wfMsgSc("Expression"), $t->expressionStructure); |
| 110 | + $t->expression = new Attribute("expression", wfMsgSc("Expression"), $t->expressionStructure); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $t->definedMeaningId = new Attribute("defined-meaning-id", "Defined meaning identifier", "defined-meaning-id"); |
114 | 114 | $t->definedMeaningDefiningExpression = new Attribute("defined-meaning-defining-expression", "Defined meaning defining expression", "short-text"); |
115 | 115 | $t->definedMeaningCompleteDefiningExpressionStructure = |
116 | | - new Structure("defined-meaning-full-defining-expression", |
| 116 | + new Structure("defined-meaning-complete-defining-expression", |
117 | 117 | $t->definedMeaningDefiningExpression, |
118 | 118 | $t->expressionId, |
119 | 119 | $t->language |
120 | 120 | ); |
121 | 121 | #try this |
122 | 122 | $t->definedMeaningCompleteDefiningExpressionStructure->setStructureType("expression"); |
123 | | - $t->definedMeaningCompleteDefiningExpression=new Attribute(null, "Defining expression", $t->definedMeaningCompleteDefiningExpressionStructure); |
| 123 | + $t->definedMeaningCompleteDefiningExpression = new Attribute(null, "Defining expression", $t->definedMeaningCompleteDefiningExpressionStructure); |
124 | 124 | global |
125 | 125 | $definedMeaningReferenceType; |
126 | 126 | |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | $wgRelationsAttributeId, $wgIncomingRelationsAttributeId ; |
162 | 162 | |
163 | 163 | $t->relationStructure = new Structure("relations", $t->relationId, $t->relationType, $t->otherDefinedMeaning, $t->objectAttributes); |
164 | | - $t->relations = new Attribute(null, wfMsgSc("Relations"), $t->relationStructure); |
| 164 | + $t->relations = new Attribute("relations", wfMsgSc("Relations"), $t->relationStructure); |
165 | 165 | $t->reciprocalRelations = new Attribute("reciprocal-relations", wfMsgSc("IncomingRelations"), $t->relationStructure); |
166 | 166 | $t->translatedTextId = new Attribute("translated-text-id", "Translated text ID", "integer"); |
167 | 167 | $t->translatedTextStructure = new Structure("translated-text", $t->language, $t->text); |
— | — | @@ -178,7 +178,6 @@ |
179 | 179 | $wgAlternativeDefinitionsAttributeId; |
180 | 180 | |
181 | 181 | $t->alternativeDefinitionsStructure = new Structure("alternative-definitions", $t->definitionId, $t->alternativeDefinition, $t->source); |
182 | | - |
183 | 182 | $t->alternativeDefinitions = new Attribute(null, wfMsgSc("AlternativeDefinitions"), $t->alternativeDefinitionsStructure); |
184 | 183 | |
185 | 184 | global |
— | — | @@ -201,7 +200,7 @@ |
202 | 201 | if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes()) |
203 | 202 | $t->translatedTextValue = new Attribute("translated-text-value", wfMsgSc("TranslatedTextAttributeValue"), "text"); |
204 | 203 | else |
205 | | - $t->translatedTextValue = new Attribute("translated-text", wfMsgSc("TranslatedTextAttributeValue"), $t->translatedTextStructure); |
| 204 | + $t->translatedTextValue = new Attribute("translated-text-value", wfMsgSc("TranslatedTextAttributeValue"), $t->translatedTextStructure); |
206 | 205 | |
207 | 206 | $t->translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$t->translatedTextAttributeId, $t->attributeObjectId, $t->translatedTextAttribute, $t->translatedTextValueId, $t->translatedTextValue, $t->objectAttributes); |
208 | 207 | $t->translatedTextAttributeValues = new Attribute(null, wfMsgSc("TranslatedTextAttributeValues"), $t->translatedTextAttributeValuesStructure); |
— | — | @@ -220,20 +219,20 @@ |
221 | 220 | $t->linkAttribute = new Attribute("link-attribute", wfMsgSc("LinkAttribute"), $t->definedMeaningReferenceStructure); |
222 | 221 | $t->linkAttributeValuesStructure = new Structure("link-attribute-values", $t->linkAttributeId, $t->linkAttributeObject, $t->linkAttribute, $t->link, $t->objectAttributes); |
223 | 222 | $t->linkAttributeValues = new Attribute(null, wfMsgSc("LinkAttributeValues"), $t->linkAttributeValuesStructure); |
224 | | - $t->optionAttributeId = new Attribute('option-attribute-id', 'Attribute identifier', 'object-id'); |
225 | | - $t->optionAttributeObject = new Attribute('option-attribute-object-id', 'Attribute object', 'object-id'); |
226 | | - $t->optionAttribute = new Attribute('option-attribute', wfMsgSc("OptionAttribute"), $definedMeaningReferenceType); |
227 | | - $t->optionAttributeOption = new Attribute('option-attribute-option', wfMsgSc("OptionAttributeOption"), $definedMeaningReferenceType); |
228 | | - $t->optionAttributeValuesStructure = new Structure('option-attribute-values', $t->optionAttributeId, $t->optionAttribute, $t->optionAttributeObject, $t->optionAttributeOption, $t->objectAttributes); |
| 223 | + $t->optionAttributeId = new Attribute("option-attribute-id", "Attribute identifier", "object-id"); |
| 224 | + $t->optionAttributeObject = new Attribute("option-attribute-object-id", "Attribute object", "object-id"); |
| 225 | + $t->optionAttribute = new Attribute("option-attribute", wfMsgSc("OptionAttribute"), $definedMeaningReferenceType); |
| 226 | + $t->optionAttributeOption = new Attribute("option-attribute-option", wfMsgSc("OptionAttributeOption"), $definedMeaningReferenceType); |
| 227 | + $t->optionAttributeValuesStructure = new Structure("option-attribute-values", $t->optionAttributeId, $t->optionAttribute, $t->optionAttributeObject, $t->optionAttributeOption, $t->objectAttributes); |
229 | 228 | $t->optionAttributeValues = new Attribute(null, wfMsgSc("OptionAttributeValues"), $t->optionAttributeValuesStructure); |
230 | | - $t->optionAttributeOptionId = new Attribute('option-attribute-option-id', 'Option identifier', 'object-id'); |
231 | | - $t->optionAttributeOptionsStructure = new Structure('option-attribute-options', $t->optionAttributeOptionId, $t->optionAttribute, $t->optionAttributeOption, $t->language); |
| 229 | + $t->optionAttributeOptionId = new Attribute("option-attribute-option-id", "Option identifier", "object-id"); |
| 230 | + $t->optionAttributeOptionsStructure = new Structure("option-attribute-options", $t->optionAttributeOptionId, $t->optionAttribute, $t->optionAttributeOption, $t->language); |
232 | 231 | $t->optionAttributeOptions = new Attribute(null, wfMsgSc("OptionAttributeOptions"), $t->optionAttributeOptionsStructure); |
233 | 232 | |
234 | 233 | if ($viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes()) |
235 | 234 | $t->translatedText = new Attribute("translated-text", wfMsgSc("Text"), "text"); |
236 | 235 | else |
237 | | - $t->translatedText = new Attribute(null, wfMsgSc("TranslatedText"), $t->translatedTextStructure); |
| 236 | + $t->translatedText = new Attribute("translated-text", wfMsgSc("TranslatedText"), $t->translatedTextStructure); |
238 | 237 | |
239 | 238 | $t->definition = new Attribute(null, wfMsgSc("Definition"), new Structure("definition", $t->translatedText, $t->objectAttributes)); |
240 | 239 | |
— | — | @@ -250,6 +249,7 @@ |
251 | 250 | $t->definedMeaning = new Attribute(null, wfMsgSc("DefinedMeaning"), |
252 | 251 | new Structure( |
253 | 252 | "defined-meaning", |
| 253 | + $t->definedMeaningCompleteDefiningExpression, |
254 | 254 | $t->definition, |
255 | 255 | $t->classAttributes, |
256 | 256 | $t->alternativeDefinitions, |
— | — | @@ -258,11 +258,12 @@ |
259 | 259 | $t->reciprocalRelations, |
260 | 260 | $t->classMembership, |
261 | 261 | $t->collectionMembership, |
262 | | - $t->definedMeaningAttributes) |
| 262 | + $t->definedMeaningAttributes |
| 263 | + ) |
263 | 264 | ); |
264 | 265 | |
265 | | - $t->expressionMeaningStructure = new Structure("expression-exact-meanings", $t->definedMeaningId, $t->text, $t->definedMeaning); |
266 | | - $t->expressionExactMeanings = new Attribute(null, wfMsgSc("ExactMeanings"), $t->expressionMeaningStructure); |
| 266 | + $t->expressionMeaningStructure = new Structure($t->definedMeaningId, $t->text, $t->definedMeaning); |
| 267 | + $t->expressionExactMeanings = new Attribute("expression-exact-meanings", wfMsgSc("ExactMeanings"), $t->expressionMeaningStructure); |
267 | 268 | $t->expressionApproximateMeanings = new Attribute("expression-approximate-meanings", wfMsgSc("ApproximateMeanings"), $t->expressionMeaningStructure); |
268 | 269 | # bug found here also: $t->expressionAoproximateMeaning_S_ |
269 | 270 | $t->expressionMeaningsStructure = new Structure("expression-meanings", $t->expressionExactMeanings, $t->expressionApproximateMeanings); |
— | — | @@ -270,22 +271,27 @@ |
271 | 272 | $t->expressionsStructure = new Structure("expressions", $t->expressionId, $t->expression, $t->expressionMeanings); |
272 | 273 | $t->expressions = new Attribute(null, wfMsgSc("Expressions"), $t->expressionsStructure); |
273 | 274 | $t->objectId = new Attribute("object-id", "Object identifier", "object-id"); |
274 | | - $t->objectAttributesStructure = new Structure("object-attributes", $t->objectId, $t->textAttributeValues, $t->translatedTextAttributeValues, $t->optionAttributeValues); |
| 275 | + $t->objectAttributesStructure = new Structure("object-attributes", $t->objectId, $t->textAttributeValues, $t->translatedTextAttributeValues, $t->linkAttributeValues, $t->optionAttributeValues); |
275 | 276 | $t->objectAttributes->setAttributeType($t->objectAttributesStructure); |
276 | 277 | $t->definedMeaningAttributes->setAttributeType($t->objectAttributesStructure); |
277 | 278 | |
278 | | - $t->annotatedAttributes = array( |
| 279 | + $annotatedAttributes = array( |
| 280 | + $t->definedMeaning, |
279 | 281 | $t->definition, |
280 | 282 | $t->synonymsAndTranslations, |
281 | 283 | $t->relations, |
282 | | - $t->reciprocalRelations |
| 284 | + $t->reciprocalRelations, |
| 285 | + $t->textAttributeValues, |
| 286 | + $t->linkAttributeValues, |
| 287 | + $t->translatedTextAttributeValues, |
| 288 | + $t->optionAttributeValues |
283 | 289 | ); |
284 | 290 | |
285 | 291 | foreach ($viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter) { |
286 | 292 | $attribute = $propertyToColumnFilter->getAttribute(); |
287 | 293 | $attribute->setAttributeType($t->objectAttributesStructure); |
288 | 294 | |
289 | | - foreach ($t->annotatedAttributes as $annotatedAttribute) |
| 295 | + foreach ($annotatedAttributes as $annotatedAttribute) |
290 | 296 | $annotatedAttribute->type->addAttribute($attribute); |
291 | 297 | } |
292 | 298 | $t->in_setup=False; |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -1289,13 +1289,11 @@ |
1290 | 1290 | public function add(IdStack $idPath) { |
1291 | 1291 | if ($this->isAddField) { |
1292 | 1292 | |
1293 | | - $o=OmegaWikiAttributes::getInstance(); |
1294 | | - |
1295 | | - $syntransId = $idPath->getKeyStack()->peek(0)->syntransId; |
| 1293 | + $objectId = $this->objectIdFetcher->fetch($idPath->getKeyStack()); |
1296 | 1294 | $parameters = array( |
1297 | 1295 | 'attributesLevel' => $this->attributesLevelName, |
1298 | | - 'attributesObjectId' => $this->objectIdFetcher->fetch($idPath->getKeyStack()), |
1299 | | - 'onUpdate' => 'updateSelectOptions(\'' . $this->addId($idPath->getId()) . '-option\',' . $syntransId |
| 1296 | + 'attributesObjectId' => $objectId, |
| 1297 | + 'onUpdate' => 'updateSelectOptions(\'' . $this->addId($idPath->getId()) . '-option\',' . $objectId |
1300 | 1298 | ); |
1301 | 1299 | return getSuggest($this->addId($idPath->getId()), $this->suggestType(), $parameters); |
1302 | 1300 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/Attribute.php |
— | — | @@ -42,16 +42,15 @@ |
43 | 43 | } |
44 | 44 | |
45 | 45 | class Structure { |
46 | | - |
47 | | - private $structure; |
| 46 | + private $attributes; |
48 | 47 | private $type; |
49 | 48 | |
50 | 49 | public function getAttributes() { |
51 | | - return $this->structure; |
| 50 | + return $this->attributes; |
52 | 51 | } |
53 | 52 | |
54 | | - public function addAttribute($attribute) { |
55 | | - $this->structure[]=$attribute; |
| 53 | + public function addAttribute(Attribute $attribute) { |
| 54 | + $this->attributes[] = $attribute; |
56 | 55 | } |
57 | 56 | |
58 | 57 | public function getStructureType() { |
— | — | @@ -59,7 +58,7 @@ |
60 | 59 | } |
61 | 60 | |
62 | 61 | public function setStructureType($type) { |
63 | | - $this->type=$type; |
| 62 | + $this->type = $type; |
64 | 63 | } |
65 | 64 | |
66 | 65 | |
— | — | @@ -78,22 +77,22 @@ |
79 | 78 | |
80 | 79 | # We're trying to be clever. |
81 | 80 | $args=func_get_args(); |
82 | | - $this->structure=null; |
| 81 | + $this->attributes=null; |
83 | 82 | |
84 | 83 | if($args[0] instanceof Attribute) { |
85 | | - $this->structure=$args; |
| 84 | + $this->attributes=$args; |
86 | 85 | } elseif(is_array($args[0])) { |
87 | | - $this->structure=$args[0]; |
| 86 | + $this->attributes=$args[0]; |
88 | 87 | } |
89 | 88 | |
90 | | - if(is_array($this->structure)) { |
| 89 | + if(is_array($this->attributes)) { |
91 | 90 | # We don't know what to call an unnamed |
92 | 91 | # structure with multiple attributes. |
93 | | - if(sizeof($this->structure)>1) { |
| 92 | + if(sizeof($this->attributes) > 1) { |
94 | 93 | $this->type='anonymous-structure'; |
95 | 94 | # Meh, just one Attribute. Let's eat it. |
96 | | - } elseif(sizeof($this->structure)==1) { |
97 | | - $this->type=$this->structure[0]->id; |
| 95 | + } elseif(sizeof($this->attributes)==1) { |
| 96 | + $this->type=$this->attributes[0]->id; |
98 | 97 | } else { |
99 | 98 | $this->type='empty-structure'; |
100 | 99 | } |
— | — | @@ -102,16 +101,48 @@ |
103 | 102 | } elseif(is_string($args[0]) && !empty($args[0])) { |
104 | 103 | $this->type=$args[0]; |
105 | 104 | if(is_array($args[1])) { |
106 | | - $this->structure=$args[1]; |
| 105 | + $this->attributes = $args[1]; |
107 | 106 | } else { |
108 | 107 | array_shift($args); |
109 | | - $this->structure=$args; |
| 108 | + $this->attributes = $args; |
110 | 109 | } |
111 | 110 | } else { |
112 | 111 | # WTF? |
113 | 112 | throw new Exception("Invalid structure constructor: ".print_r($args,true)); |
114 | 113 | } |
115 | 114 | } |
| 115 | + |
| 116 | + public function supportsAttributeId($attributeId) { |
| 117 | +// $result = false; |
| 118 | +// $i = 0; |
| 119 | +// |
| 120 | +// while (!$result && $i < count($this->attributes)) { |
| 121 | +// $result = $this->attributes[$i]->id == $attributeId; |
| 122 | +// $i++; |
| 123 | +// } |
| 124 | +// |
| 125 | +// return $result; |
| 126 | + return true; |
| 127 | + } |
| 128 | + |
| 129 | + public function supportsAttribute(Attribute $attribute) { |
| 130 | + return $this->supportsAttributeId($attribute->id); |
| 131 | + } |
| 132 | + |
| 133 | + public function __tostring() { |
| 134 | + $result = "{"; |
| 135 | + |
| 136 | + if (count($this->attributes) > 0) { |
| 137 | + $result .= $this->attributes[0]->id; |
| 138 | + |
| 139 | + for ($i = 1; $i < count($this->attributes); $i++) |
| 140 | + $result .= ", " . $this->attributes[$i]->id; |
| 141 | + } |
| 142 | + |
| 143 | + $result .= "}"; |
| 144 | + |
| 145 | + return $result; |
| 146 | + } |
116 | 147 | } |
117 | 148 | |
118 | 149 | |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -523,7 +523,7 @@ |
524 | 524 | $o=OmegaWikiAttributes::getInstance(); |
525 | 525 | |
526 | 526 | $definitionId = getDefinedMeaningDefinitionId($definedMeaningId); |
527 | | - $record = new ArrayRecord(new Structure($o->definition)); |
| 527 | + $record = new ArrayRecord($o->definition->type); |
528 | 528 | $record->translatedText = getTranslatedContentValue($definitionId, $viewInformation); |
529 | 529 | |
530 | 530 | $objectAttributesRecord = getObjectAttributesRecord($definitionId, $viewInformation, $o->objectAttributes->id); |
— | — | @@ -553,13 +553,12 @@ |
554 | 554 | } |
555 | 555 | |
556 | 556 | function getObjectAttributesRecord($objectId, ViewInformation $viewInformation, $structuralOverride = null) { |
557 | | - |
558 | 557 | $o=OmegaWikiAttributes::getInstance(); |
559 | 558 | |
560 | 559 | if ($structuralOverride) |
561 | | - $record = new ArrayRecord(new Structure($structuralOverride, $o->definedMeaningAttributes)); |
| 560 | + $record = new ArrayRecord(new Structure($structuralOverride, $o->definedMeaningAttributes->type->getAttributes())); |
562 | 561 | else |
563 | | - $record = new ArrayRecord(new Structure($o->definedMeaningAttributes)); |
| 562 | + $record = new ArrayRecord($o->definedMeaningAttributes->type); |
564 | 563 | |
565 | 564 | $record->objectId = $objectId; |
566 | 565 | $record->textAttributeValues = getTextAttributesValuesRecordSet(array($objectId), $viewInformation); |
— | — | @@ -571,9 +570,6 @@ |
572 | 571 | } |
573 | 572 | |
574 | 573 | function filterAttributeValues(RecordSet $sourceRecordSet, Attribute $attributeAttribute, array &$attributeIds) { |
575 | | - |
576 | | - $o=OmegaWikiAttributes::getInstance(); |
577 | | - |
578 | 574 | $result = new ArrayRecordSet($sourceRecordSet->getStructure(), $sourceRecordSet->getKey()); |
579 | 575 | $i = 0; |
580 | 576 | |
— | — | @@ -744,6 +740,9 @@ |
745 | 741 | |
746 | 742 | $recordSetStructure = $recordSet->getStructure(); |
747 | 743 | $recordSetStructure->addAttribute($attributeToExpand); |
| 744 | + |
| 745 | + foreach ($viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter) |
| 746 | + $recordSetStructure->addAttribute($propertyToColumnFilter->getAttribute()); |
748 | 747 | |
749 | 748 | $objectAttributesRecordStructure = $attributeToExpand->type; |
750 | 749 | $objectIds = getUniqueIdsInRecordSet($recordSet, array($objectIdAttribute)); |
— | — | @@ -825,7 +824,7 @@ |
826 | 825 | $optionAttributeValuesRecordSet = $emptyOptionAttributesRecordSet; |
827 | 826 | |
828 | 827 | $objectAttributesRecord = new ArrayRecord($objectAttributesRecordStructure); |
829 | | - $objectAttributesRecord->setAttributeValue($objectIdAttribute, $objectId); |
| 828 | + $objectAttributesRecord->objectId = $objectId; |
830 | 829 | $objectAttributesRecord->textAttributeValues = $textAttributeValuesRecordSet; |
831 | 830 | $objectAttributesRecord->translatedTextAttributeValues = $translatedTextAttributeValuesRecordSet; |
832 | 831 | $objectAttributesRecord->linkAttributeValues = $linkAttributeValuesRecordSet; |
— | — | @@ -963,7 +962,9 @@ |
964 | 963 | array("member_mid=$definedMeaningId") |
965 | 964 | ); |
966 | 965 | |
967 | | - $recordSet->getStructure()->addAttribute($o->collectionMeaning); |
| 966 | + $structure = $recordSet->getStructure(); |
| 967 | + $structure->addAttribute($o->collectionMeaning); |
| 968 | + $structure->addAttribute($o->gotoSource); |
968 | 969 | |
969 | 970 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
970 | 971 | $record = $recordSet->getRecord($i); |
— | — | @@ -1115,6 +1116,9 @@ |
1116 | 1117 | global |
1117 | 1118 | $optionAttributeOptionsTable, $classAttributesTable; |
1118 | 1119 | |
| 1120 | + $recordSet->getStructure()->addAttribute($o->optionAttributeOption); |
| 1121 | + $recordSet->getStructure()->addAttribute($o->optionAttribute); |
| 1122 | + |
1119 | 1123 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
1120 | 1124 | $record = $recordSet->getRecord($i); |
1121 | 1125 | |
— | — | @@ -1171,10 +1175,6 @@ |
1172 | 1176 | } |
1173 | 1177 | |
1174 | 1178 | function getDefiningExpressionRecord($definedMeaningId) { |
1175 | | - |
1176 | | - |
1177 | | - $o=OmegaWikiAttributes::getInstance(); |
1178 | | - |
1179 | 1179 | $o=OmegaWikiAttributes::getInstance(); |
1180 | 1180 | |
1181 | 1181 | $definingExpression=definingExpressionRow($definedMeaningId); |
— | — | @@ -1183,5 +1183,4 @@ |
1184 | 1184 | $definingExpressionRecord->definedMeaningDefiningExpression = $definingExpression[1]; |
1185 | 1185 | $definingExpressionRecord->language = $definingExpression[2]; |
1186 | 1186 | return $definingExpressionRecord; |
1187 | | - |
1188 | 1187 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -25,9 +25,19 @@ |
26 | 26 | return $this->structure; |
27 | 27 | } |
28 | 28 | |
| 29 | + protected function getAttributeValueForId($attributeId) { |
| 30 | + if ($this->structure->supportsAttributeId($attributeId)) { |
| 31 | + if (isset($this->values[$attributeId])) |
| 32 | + return $this->values[$attributeId]; |
| 33 | + else |
| 34 | + return null; |
| 35 | + } |
| 36 | + else |
| 37 | + throw new Exception("Structure does not support attribute!\n Structure: " . $this->structure . "\n Attribute: " . $attributeId); |
| 38 | + } |
| 39 | + |
29 | 40 | public function getAttributeValue($attribute) { |
30 | | - #FIXME: check if valid |
31 | | - return @$this->values[$attribute->id]; |
| 41 | + return $this->getAttributeValueForId($attribute->id); |
32 | 42 | } |
33 | 43 | |
34 | 44 | /** |
— | — | @@ -64,9 +74,15 @@ |
65 | 75 | return $result; |
66 | 76 | } |
67 | 77 | |
| 78 | + public function setAttributeValueForId($attributeId, $value) { |
| 79 | + if ($this->structure->supportsAttributeId($attributeId)) |
| 80 | + $this->values[$attributeId] = $value; |
| 81 | + else |
| 82 | + throw new Exception("Structure does not support attribute!\n Structure: " . $this->structure. "\n Attribute: " . $attributeId); |
| 83 | + } |
| 84 | + |
68 | 85 | public function setAttributeValue(Attribute $attribute, $value) { |
69 | | - #FIXME: check if valid |
70 | | - @$this->values[$attribute->id] = $value; |
| 86 | + $this->setAttributeValueForId($attribute->id, $value); |
71 | 87 | } |
72 | 88 | |
73 | 89 | /** |
Index: trunk/extensions/Wikidata/OmegaWiki/Fetcher.php |
— | — | @@ -14,7 +14,10 @@ |
15 | 15 | $this->attribute = $attribute; |
16 | 16 | } |
17 | 17 | public function fetch($keyPath) { |
18 | | - return $keyPath->peek($this->attributeLevel)->getAttributeValue($this->attribute); |
| 18 | + if ($keyPath->peek($this->attributeLevel)->getStructure()->supportsAttribute($this->attribute)) |
| 19 | + return $keyPath->peek($this->attributeLevel)->getAttributeValue($this->attribute); |
| 20 | + else |
| 21 | + return null; # FIXME: Should not happen, check should leave when the reason of the attribute not being support by the record is determined |
19 | 22 | } |
20 | 23 | } |
21 | 24 | |