function getSearchResultAsRecordSet( $queryResult ) { $o = OmegaWikiAttributes::getInstance(); global $definedMeaningReferenceType, $wgDefinedMeaning; $dbr = wfGetDB( DB_SLAVE ); $spellingAttribute = new Attribute( "found-word", "Found word", "short-text" ); $languageAttribute = new Attribute( "language", "Language", "language" ); $expressionStructure = new Structure( $spellingAttribute, $languageAttribute ); $expressionAttribute = new Attribute( "expression", "Expression", $expressionStructure ); $definedMeaningAttribute = new Attribute( $wgDefinedMeaning, "Defined meaning", $definedMeaningReferenceType ); $definitionAttribute = new Attribute( "definition", "Definition", "definition" ); $meaningStructure = new Structure( $definedMeaningAttribute, $definitionAttribute ); $meaningAttribute = new Attribute( "meaning", "Meaning", $meaningStructure ); $recordSet = new ArrayRecordSet( new Structure( $o->definedMeaningId, $expressionAttribute, $meaningAttribute ), new Structure( $o->definedMeaningId ) ); while ( $row = $dbr->fetchObject( $queryResult ) ) { $expressionRecord = new ArrayRecord( $expressionStructure ); $expressionRecord->setAttributeValue( $spellingAttribute, $row->spelling ); $expressionRecord->setAttributeValue( $languageAttribute, $row->language_id ); $meaningRecord = new ArrayRecord( $meaningStructure ); $meaningRecord->setAttributeValue( $definedMeaningAttribute, getDefinedMeaningReferenceRecord( $row->defined_meaning_id ) ); $meaningRecord->setAttributeValue( $definitionAttribute, getDefinedMeaningDefinition( $row->defined_meaning_id ) ); $recordSet->addRecord( array( $row->defined_meaning_id, $expressionRecord, $meaningRecord ) ); } $expressionEditor = new RecordTableCellEditor( $expressionAttribute ); $expressionEditor->addEditor( new SpellingEditor( $spellingAttribute, new SimplePermissionController( false ), false ) ); $expressionEditor->addEditor( new LanguageEditor( $languageAttribute, new SimplePermissionController( false ), false ) ); $meaningEditor = new RecordTableCellEditor( $meaningAttribute ); $meaningEditor->addEditor( new DefinedMeaningReferenceEditor( $definedMeaningAttribute, new SimplePermissionController( false ), false ) ); $meaningEditor->addEditor( new TextEditor( $definitionAttribute, new SimplePermissionController( false ), false, true, 75 ) ); $editor = createTableViewer( null ); $editor->addEditor( $expressionEditor ); $editor->addEditor( $meaningEditor ); return array( $recordSet, $editor ); }
private function getDefinedMeaningAsRecordSet( $queryResult ) { global $wgDefinedMeaning ; $o = OmegaWikiAttributes::getInstance(); $dbr = wfGetDB( DB_SLAVE ); $spellingAttribute = new Attribute( "spelling", wfMsg( 'ow_Spelling' ), "short-text" ); $languageAttribute = new Attribute( "language", wfMsg( 'ow_Language' ), "language" ); $expressionStructure = new Structure( $wgDefinedMeaning, $spellingAttribute, $languageAttribute ); $definedMeaningAttribute = new Attribute( null, wfMsg( 'ow_DefinedMeaning' ), $expressionStructure ); $definitionAttribute = new Attribute( "definition", wfMsg( 'ow_Definition' ), "definition" ); $recordSet = new ArrayRecordSet( new Structure( $o->id, $definedMeaningAttribute, $definitionAttribute ), new Structure( $o->id ) ); while ( $row = $dbr->fetchObject( $queryResult ) ) { $definedMeaningRecord = new ArrayRecord( $expressionStructure ); $definedMeaningRecord->setAttributeValue( $spellingAttribute, $row->spelling ); $definedMeaningRecord->setAttributeValue( $languageAttribute, $row->language_id ); $recordSet->addRecord( array( $row->defined_meaning_id, $definedMeaningRecord, getDefinedMeaningDefinition( $row->defined_meaning_id ) ) ); } $expressionEditor = new RecordTableCellEditor( $definedMeaningAttribute ); $expressionEditor->addEditor( createShortTextViewer( $spellingAttribute ) ); $expressionEditor->addEditor( createLanguageViewer( $languageAttribute ) ); $editor = createSuggestionsTableViewer( null ); $editor->addEditor( $expressionEditor ); $editor->addEditor( new TextEditor( $definitionAttribute, new SimplePermissionController( false ), false, true, 75 ) ); return array( $recordSet, $editor ); }
function queryRecordSet( $recordSetStructureId, QueryTransactionInformation $transactionInformation, Attribute $keyAttribute, TableColumnsToAttributesMapping $tableColumnsToAttributeMapping, Table $table, array $restrictions, array $orderBy = array(), $count = - 1, $offset = 0 ) { $dbr = wfGetDB( DB_SLAVE ); $selectFields = $tableColumnsToAttributeMapping->getSelectColumns(); $attributes = $tableColumnsToAttributeMapping->getAttributes(); if ( $table->isVersioned ) { $allAttributes = array_merge( $attributes, $transactionInformation->versioningAttributes() ); } else { $allAttributes = $attributes; } $query = getTransactedSQL( $transactionInformation, $selectFields, $table, $restrictions, $orderBy, $count, $offset ); $queryResult = $dbr->query( $query ); if ( !is_null( $recordSetStructureId ) ) { $structure = new Structure( $recordSetStructureId, $allAttributes ); } else { $structure = new Structure( $allAttributes ); } $recordSet = new ArrayRecordSet( $structure, new Structure( $keyAttribute ) ); while ( $row = $dbr->fetchRow( $queryResult ) ) { $record = new ArrayRecord( $structure ); $columnIndex = 0; for ( $i = 0; $i < $tableColumnsToAttributeMapping->getCount(); $i++ ) { $mapping = $tableColumnsToAttributeMapping->getMapping( $i ); $attribute = $mapping->getAttribute(); $tableColumns = $mapping->getTableColumns(); if ( count( $tableColumns ) == 1 ) { $value = $row[$columnIndex]; } else { $value = getRecordFromRow( $row, $columnIndex, $attribute->type ); } $record->setAttributeValue( $attribute, $value ); $columnIndex += count( $tableColumns ); } $transactionInformation->setVersioningAttributes( $record, $row ); $recordSet->add( $record ); } return $recordSet; }
function getExternalIdentifiersSearchResultAsRecordSet($queryResult) { $dbr = wfGetDB(DB_SLAVE); $externalIdentifierMatchStructure = new Structure($this->externalIdentifierAttribute, $this->collectionAttribute, $this->collectionMemberAttribute); $recordSet = new ArrayRecordSet($externalIdentifierMatchStructure, new Structure($this->externalIdentifierAttribute)); while ($row = $dbr->fetchObject($queryResult)) { $record = new ArrayRecord($this->externalIdentifierMatchStructure); $record->setAttributeValue($this->externalIdentifierAttribute, $row->external_identifier); $record->setAttributeValue($this->collectionAttribute, $row->collection_mid); $record->setAttributeValue($this->collectionMemberAttribute, $row->member_mid); $recordSet->add($record); } expandDefinedMeaningReferencesInRecordSet($recordSet, array($this->collectionAttribute, $this->collectionMemberAttribute)); return $recordSet; }
function project( Record $record, Structure $structure ) { $result = new ArrayRecord( $structure ); foreach ( $structure->getAttributes() as $attribute ) { $type = $attribute->type; $value = $record->getAttributeValue( $attribute ); if ( $type instanceof Structure ) $result->setAttributeValue( $attribute, project( $record, $type->getStructure() ) ); else $result->setAttributeValue( $attribute, $value ); } return $result; }
function simpleRecord( $structure, $values ) { $attributes = $structure->getAttributes(); $result = new ArrayRecord( $structure ); for ( $i = 0; $i < count( $attributes ); $i++ ) $result->setAttributeValue( $attributes[$i], $values[$i] ); return $result; }
function filterObjectAttributesRecord( Record $sourceRecord, array &$attributeIds ) { $o = OmegaWikiAttributes::getInstance(); $result = new ArrayRecord( $sourceRecord->getStructure() ); $result->objectId = $sourceRecord->objectId; $result->setAttributeValue( $o->relations, filterAttributeValues( $sourceRecord->relations, $o->relationType, $attributeIds ) ); $result->setAttributeValue( $o->textAttributeValues, filterAttributeValues( $sourceRecord->textAttributeValues, $o->textAttribute, $attributeIds ) ); $result->setAttributeValue( $o->translatedTextAttributeValues, filterAttributeValues( $sourceRecord->translatedTextAttributeValues, $o->translatedTextAttribute, $attributeIds ) ); $result->setAttributeValue( $o->linkAttributeValues, filterAttributeValues( $sourceRecord->linkAttributeValues, $o->linkAttribute, $attributeIds ) ); $result->setAttributeValue( $o->optionAttributeValues, filterAttributeValues( $sourceRecord->optionAttributeValues, $o->optionAttribute, $attributeIds ) ); return $result; }
public function convert( $record ) { $result = new ArrayRecord( $this->structure ); $result->setAttributeValue( $this->attribute, convertToHTML( $record->getAttributeValue( $this->attribute ), $this->attribute->type ) ); return $result; }
public function getUpdateValue( IdStack $idPath ) { $result = new ArrayRecord( $this->getUpdateStructure() ); foreach ( $this->getEditors() as $editor ) if ( $attribute = $editor->getUpdateAttribute() ) { $idPath->pushAttribute( $attribute ); $result->setAttributeValue( $attribute, $editor->getUpdateValue( $idPath ) ); $idPath->popAttribute(); } return $result; }